This commit is contained in:
tafit0902 2024-04-13 23:49:04 +02:00
parent 9ca821bab8
commit eb5556e514
2 changed files with 10 additions and 6 deletions

View File

@ -55,8 +55,8 @@ class Pole:
def check_collision(self,mouse_x,mouse_y):
mouse_x=math.floor(mouse_x/dCon.CUBE_SIZE)
mouse_y=math.floor(mouse_y/dCon.CUBE_SIZE)
if(mouse_x<20):
if(mouse_y<12):
if(mouse_x<dCon.NUM_X):
if(mouse_y<dCon.NUM_Y):
collided=self.get_slot_from_cord((mouse_x,mouse_y))
return collided.print_status()
return ""

View File

@ -181,19 +181,23 @@ class Tractor:
self.do_move_if_valid(pole,(0,0))
def initial_move(self,pole):
for y in range (0,12):
for y in range (0,dCon.NUM_Y):
if(y%2==0):
for x in range(0,20):
for x in range(0,dCon.NUM_X):
self.snake_move(pole,x,y)
else:
for x in range(20,0,-1):
for x in range(dCon.NUM_X,-1,-1):
self.snake_move(pole,x,y)
def snake_move(self,pole,x,y):
next_slot_coordinates=(x,y)
if(self.do_move_if_valid(pole,next_slot_coordinates)):
self.slot_hydrate_dict[(x,y)]= pole.get_slot_from_cord((x,y)).get_hydrate_stats() #Budowanie slownika slotow z poziomem nawodnienia dla traktorka
if pole.get_slot_from_cord((x,y)).get_hydrate_stats() < 60:
hydrateIndex = 0
else:
hydrateIndex = 1
self.slot_hydrate_dict[(x,y)]= hydrateIndex #Budowanie slownika slotow z poziomem nawodnienia dla traktorka
self.clock.tick(10)
for event in pygame.event.get():
if event.type == pygame.QUIT: