Enable food spawning and ensure selected objects remain valid during ticks
All checks were successful
Build Simulation and Test / Run All Tests (push) Successful in 40s
All checks were successful
Build Simulation and Test / Run All Tests (push) Successful in 40s
This commit is contained in:
parent
5eb2079da1
commit
9e3c34fd3e
7
main.py
7
main.py
@ -26,7 +26,7 @@ GRID_HEIGHT = 15 # Number of cells vertically
|
|||||||
CELL_SIZE = 20 # Size of each cell in pixels
|
CELL_SIZE = 20 # Size of each cell in pixels
|
||||||
|
|
||||||
DEFAULT_TPS = 20 # Number of ticks per second for the simulation
|
DEFAULT_TPS = 20 # Number of ticks per second for the simulation
|
||||||
FOOD_SPAWNING = False
|
FOOD_SPAWNING = True
|
||||||
|
|
||||||
|
|
||||||
def draw_grid(screen, camera, showing_grid=True):
|
def draw_grid(screen, camera, showing_grid=True):
|
||||||
@ -239,6 +239,11 @@ def main():
|
|||||||
if food < 10 and FOOD_SPAWNING == True:
|
if food < 10 and FOOD_SPAWNING == True:
|
||||||
world.add_object(FoodObject(Position(random.randint(-200, 200), random.randint(-200, 200))))
|
world.add_object(FoodObject(Position(random.randint(-200, 200), random.randint(-200, 200))))
|
||||||
|
|
||||||
|
# ensure selected objects are still valid or have not changed position, if so, reselect them
|
||||||
|
selected_objects = [
|
||||||
|
obj for obj in selected_objects if obj in world.get_objects()
|
||||||
|
]
|
||||||
|
|
||||||
print("Tick logic executed")
|
print("Tick logic executed")
|
||||||
world.tick_all()
|
world.tick_all()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user