Configure steps per simulation update function call via SimStepsPerUpdate

This commit is contained in:
ChaoticByte 2025-08-21 18:26:29 +02:00
parent 1ab0b43946
commit 958e97de0c
No known key found for this signature in database
2 changed files with 5 additions and 3 deletions

View file

@ -49,7 +49,7 @@ func main() {
ebiten.MaximizeWindow()
ebiten.SetTPS(MaxTps)
app := &Application{
simulation: *simulation.NewSimulation(CanvasWidth, CanvasHeight),
simulation: *simulation.NewSimulation(CanvasWidth, CanvasHeight, SimStepsPerUpdate),
}
InitGrid(app.simulation.Grid)
err := ebiten.RunGame(app)

View file

@ -5,11 +5,12 @@ import (
)
type Simulation struct {
StepsPerUpdate int
Grid *XelGrid
}
func (sim *Simulation) Update() {
for range 10 {
for range sim.StepsPerUpdate {
// get all available xels with energy != 0
available_positions := []Vector2{}
for i, xel := range sim.Grid.Xels {
@ -25,8 +26,9 @@ func (sim *Simulation) Update() {
}
}
func NewSimulation(width int, height int) *Simulation {
func NewSimulation(width int, height int, stepsPerUpdate int) *Simulation {
return &Simulation{
Grid: NewXelGrid(width, height),
StepsPerUpdate: stepsPerUpdate,
}
}