spawner update
This commit is contained in:
+4
-3
@@ -167,16 +167,17 @@ class UI:
|
|||||||
|
|
||||||
class Spawner:
|
class Spawner:
|
||||||
active = True # Whether the spawner is active
|
active = True # Whether the spawner is active
|
||||||
frequency = 500 # Number of ticks between spawns
|
delay = 500 # Number of ticks between spawns
|
||||||
tick_counter = 0 # Counter for ticks
|
tick_counter = 0 # Counter for ticks
|
||||||
|
|
||||||
def __init__(self, barrier_image_path):
|
def __init__(self, barrier_image_path, delay):
|
||||||
self.barrier_image_path = barrier_image_path # Path to the barrier image
|
self.barrier_image_path = barrier_image_path # Path to the barrier image
|
||||||
|
self.delay = delay
|
||||||
|
|
||||||
def handle(self):
|
def handle(self):
|
||||||
if self.active:
|
if self.active:
|
||||||
self.tick_counter += 1 # Increment tick counter
|
self.tick_counter += 1 # Increment tick counter
|
||||||
if self.tick_counter >= self.frequency: # Check if it's time to spawn
|
if self.tick_counter >= self.delay: # Check if it's time to spawn
|
||||||
self.spawn()
|
self.spawn()
|
||||||
self.tick_counter = 0 # Reset tick counter
|
self.tick_counter = 0 # Reset tick counter
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import sys
|
|||||||
from gameobjects import *
|
from gameobjects import *
|
||||||
from genetic_alg import GeneticAlgorithm
|
from genetic_alg import GeneticAlgorithm
|
||||||
|
|
||||||
POPULATION_SIZE = 50
|
POPULATION_SIZE = 20
|
||||||
MUTATION_RATE = 0.5
|
MUTATION_RATE = 0.5
|
||||||
POPULATION_BEST = 0.2
|
POPULATION_BEST = 0.2
|
||||||
FRAME_RATE = 160 #TODO: FIX THE INCORRECT FRAME RATE CORRELATION
|
FRAME_RATE = 160 #TODO: FIX THE INCORRECT FRAME RATE CORRELATION
|
||||||
@@ -32,7 +32,7 @@ def init_game():
|
|||||||
grass = Background("images/Grass.jpg", 0, 0)
|
grass = Background("images/Grass.jpg", 0, 0)
|
||||||
grass.set_size(WIDTH, HEIGHT)
|
grass.set_size(WIDTH, HEIGHT)
|
||||||
|
|
||||||
BARRIER_SPEED = 1
|
BARRIER_SPEED = 15
|
||||||
|
|
||||||
gameobjects = []
|
gameobjects = []
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ def init_game():
|
|||||||
horse.set_vspeed(0)
|
horse.set_vspeed(0)
|
||||||
horse.frame_counter = 0
|
horse.frame_counter = 0
|
||||||
horse.fitness = 0
|
horse.fitness = 0
|
||||||
spawner = Spawner("images/Barrier.png")
|
spawner = Spawner("images/Barrier.png", 125)
|
||||||
new_barrier = spawner.spawn()
|
new_barrier = spawner.spawn()
|
||||||
barriers.append(new_barrier)
|
barriers.append(new_barrier)
|
||||||
gameobjects.extend(horses)
|
gameobjects.extend(horses)
|
||||||
|
|||||||
Reference in New Issue
Block a user