Configure steps per simulation update function call via SimStepsPerUpdate
This commit is contained in:
parent
1ab0b43946
commit
958e97de0c
2 changed files with 5 additions and 3 deletions
2
main.go
2
main.go
|
@ -49,7 +49,7 @@ func main() {
|
||||||
ebiten.MaximizeWindow()
|
ebiten.MaximizeWindow()
|
||||||
ebiten.SetTPS(MaxTps)
|
ebiten.SetTPS(MaxTps)
|
||||||
app := &Application{
|
app := &Application{
|
||||||
simulation: *simulation.NewSimulation(CanvasWidth, CanvasHeight),
|
simulation: *simulation.NewSimulation(CanvasWidth, CanvasHeight, SimStepsPerUpdate),
|
||||||
}
|
}
|
||||||
InitGrid(app.simulation.Grid)
|
InitGrid(app.simulation.Grid)
|
||||||
err := ebiten.RunGame(app)
|
err := ebiten.RunGame(app)
|
||||||
|
|
|
@ -5,11 +5,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Simulation struct {
|
type Simulation struct {
|
||||||
|
StepsPerUpdate int
|
||||||
Grid *XelGrid
|
Grid *XelGrid
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sim *Simulation) Update() {
|
func (sim *Simulation) Update() {
|
||||||
for range 10 {
|
for range sim.StepsPerUpdate {
|
||||||
// get all available xels with energy != 0
|
// get all available xels with energy != 0
|
||||||
available_positions := []Vector2{}
|
available_positions := []Vector2{}
|
||||||
for i, xel := range sim.Grid.Xels {
|
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{
|
return &Simulation{
|
||||||
Grid: NewXelGrid(width, height),
|
Grid: NewXelGrid(width, height),
|
||||||
|
StepsPerUpdate: stepsPerUpdate,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue