init (Bugg fix mouse increased the speed of the evolutions)
This commit is contained in:
parent
877b0ff9a6
commit
e5e441622b
|
@ -3,6 +3,7 @@ class GeneralConfig:
|
||||||
height = 1000
|
height = 1000
|
||||||
fps = 150
|
fps = 150
|
||||||
window_caption = "GOL"
|
window_caption = "GOL"
|
||||||
|
evolve_speed= 360# ziemlich slow das updated abhänig davon wie viele mill sec das game seit dem eltzten mal gelaufen ist im schnit sind das so 60
|
||||||
|
|
||||||
class Colors:
|
class Colors:
|
||||||
ORANGE = (255, 140, 0)
|
ORANGE = (255, 140, 0)
|
||||||
|
|
|
@ -53,7 +53,7 @@ class Rules:
|
||||||
start = time.time()
|
start = time.time()
|
||||||
field_new = Field()
|
field_new = Field()
|
||||||
end = time.time()
|
end = time.time()
|
||||||
print(end - start)
|
#print(end - start)
|
||||||
|
|
||||||
index_x = 0
|
index_x = 0
|
||||||
index_y = 0
|
index_y = 0
|
||||||
|
|
|
@ -23,7 +23,6 @@ class GameState:
|
||||||
self.update_field_events.append(event)
|
self.update_field_events.append(event)
|
||||||
if event.type == pygame.KEYDOWN:
|
if event.type == pygame.KEYDOWN:
|
||||||
if event.key == pygame.K_SPACE:
|
if event.key == pygame.K_SPACE:
|
||||||
self.update_field_events.append(event)
|
|
||||||
self.pause_for_input = not self.pause_for_input
|
self.pause_for_input = not self.pause_for_input
|
||||||
|
|
||||||
def update_field_with_input(self, event):
|
def update_field_with_input(self, event):
|
||||||
|
@ -51,23 +50,24 @@ def run_game():
|
||||||
time_elapsed_since_last_action = 0
|
time_elapsed_since_last_action = 0
|
||||||
while game_state.run:
|
while game_state.run:
|
||||||
game_state.event_handler()
|
game_state.event_handler()
|
||||||
print(len(game_state.update_field_events))
|
|
||||||
|
|
||||||
for event in game_state.update_field_events:
|
for event in game_state.update_field_events:
|
||||||
game_state.update_field_with_input(event)
|
game_state.update_field_with_input(event)
|
||||||
game_state.update_field_events.remove(event)
|
game_state.update_field_events.remove(event)
|
||||||
|
|
||||||
print("running")
|
|
||||||
clock.tick(GeneralConfig.fps)
|
clock.tick(GeneralConfig.fps)
|
||||||
time_elapsed_since_last_action += clock.tick()
|
time_elapsed_since_last_action += clock.get_time()
|
||||||
|
|
||||||
if game_state.pause_for_input:
|
if game_state.pause_for_input:
|
||||||
|
|
||||||
if time_elapsed_since_last_action > 1:
|
if time_elapsed_since_last_action > 100:
|
||||||
start = ti.time()
|
|
||||||
|
#start = ti.time()
|
||||||
game_state.evolve()
|
game_state.evolve()
|
||||||
end = ti.time()
|
#end = ti.time()
|
||||||
print(end - start)
|
#print(end - start)
|
||||||
time_elapsed_since_last_action = 0 # reset it to 0 so you can count again
|
time_elapsed_since_last_action = 0 # reset it to 0 so you can count again
|
||||||
|
|
||||||
game_state.redraw_field(window)
|
game_state.redraw_field(window)
|
||||||
|
|
Loading…
Reference in a new issue