39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
from gamegrid import *
|
|
from cell import Cell
|
|
from cgol import CGOL
|
|
|
|
game_list = []
|
|
|
|
def gather_life():
|
|
global game_list, game
|
|
game_list = []
|
|
for y in range(0, 20, 1):
|
|
game_list.append([])
|
|
for x in range(0, 20, 1):
|
|
cell = getOneActorAt(Location(x, y), Cell)
|
|
if cell != None:
|
|
print("Lebendig auf X:" + str(x) + " Y:" + str(y))
|
|
game_list[y].append(1)
|
|
else:
|
|
game_list[y].append(0)
|
|
print(str(game_list))
|
|
refresh()
|
|
game.game_list = game_list
|
|
|
|
def pressCallback(e):
|
|
location = toLocationInGrid(e.getX(), e.getY())
|
|
cell = getOneActorAt(location, Cell)
|
|
if cell == None:
|
|
addActor(Cell(), location)
|
|
else:
|
|
removeActor(cell)
|
|
refresh()
|
|
gather_life()
|
|
|
|
# Initialize the CGOL class with the game_list as an argument.
|
|
game = CGOL(game_list)
|
|
|
|
makeGameGrid(20, 20, 30, Color.yellow, "/home/prenski/Informatik/Informatik 12/12b/vitus/OOP-Spiel/Bilder/sand.png", mousePressed=pressCallback)
|
|
setTitle("Conways Game of Life")
|
|
show()
|