diff --git a/levels.py b/levels.py index d36a15e..77cfc73 100644 --- a/levels.py +++ b/levels.py @@ -6,6 +6,12 @@ zombie_dx, zombie_dy = 1, 1 zombie_x, zombie_y = 645, 214 zombie_timer = 0 holding_milk = False +zombie_hp = 20 +milkactive = False +enemy_zombies = [ + {"x": 200, "y": 200, "hp": 20, "dead": False, "dx": 1, "dy": 1, "timer": 0}, + {"x": 400, "y": 300, "hp": 20, "dead": False, "dx": -1, "dy": 1, "timer": 0}, +] def level1(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, mouse, click, big_text, level, tick): # the function for our first level, ignore the unused variables here, you can use them when you edit it screen.blit(load_sprite(sheet, 0, 0, 48, 36, screen_width, screen_height), (0, 0)) # this renders a button I made in the sprites.png, its purely for visual purposes so it doesnt matter where you click rn @@ -197,7 +203,7 @@ def level4(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, level = 4.5 return level def level5(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, mouse, click, big_text, level, tick, smalltext): # function for level 5 - global zombie_x, zombie_y, zombie_timer, zombie_dx, zombie_dy + global zombie_x, zombie_y, zombie_timer, zombie_dx, zombie_dy, zombie_hp, milkactive, milk_pos_x, milk_pos_y, holding_milk screen.blit(load_sprite(sheet, 49, 46, 48, 36, screen_width, screen_height), (0, 0)) zombie_timer += 1 if zombie_timer > 60: # change direction every ~1 sec @@ -208,4 +214,63 @@ def level5(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, zombie_y += zombie_dy zombie_x = max(0, min(zombie_x, screen_width - 96)) zombie_y = max(0, min(zombie_y, screen_height - 96)) - screen.blit(load_sprite(sheet, 27, 82, 7, 12, 56, 96), (zombie_x, zombie_y)) # ZOMBIE \ No newline at end of file + if tick <= 200: + dialog = smalltext.render("click enemies to damage them", True, (255, 255, 255)) + screen.blit(dialog, (50, 50)) + elif 800 >= tick >= 200: + dialog = smalltext.render("drag milk to dead enemies to", True, (255, 255, 255)) + dialog2 = smalltext.render("make them your own minions", True, (255, 255, 255)) + screen.blit(dialog, (50, 50)) + screen.blit(dialog2, (50, 75)) + zombie_hp_box_red = pygame.surface.Surface((60, 10), pygame.SRCALPHA) + zombie_hp_box_red.fill((255,0,0)) + screen.blit(zombie_hp_box_red, (zombie_x, zombie_y-20)) + if zombie_hp > 0: # AVOIDING ERRORS AT ALL COSTS + zombie_hp_box_green = pygame.surface.Surface((zombie_hp*3, 10), pygame.SRCALPHA) + zombie_hp_box_green.fill((0,255,0)) + screen.blit(zombie_hp_box_green, (zombie_x, zombie_y-20)) + if random.randint(tick-300, tick+300) == tick and not milkactive: + milk_pos_x, milk_pos_y = random.randint(0, screen_width), random.randint(0, screen_height) + milkactive = True + + for ez in enemy_zombies: + if not ez["dead"]: + ez["timer"] += 1 + if ez["timer"] > 60: + ez["dx"] = random.choice([-2, -1, 1, 2]) + ez["dy"] = random.choice([-2, -1, 1, 2]) + ez["timer"] = 0 + ez["x"] += ez["dx"] + ez["y"] += ez["dy"] + ez["x"] = max(0, min(ez["x"], screen_width - 96)) + ez["y"] = max(0, min(ez["y"], screen_height - 96)) + if ez["hp"] <= 0: + ez["dead"] = True + screen.blit(load_sprite(sheet, 46, 82, 7, 12, 56, 96), (ez["x"], ez["y"])) # enemy zombie + zombie1 + else: + screen.blit(load_sprite(sheet, 34, 82, 12, 12, 96, 96), (ez["x"], ez["y"])) # dead sprite + # milk revive check + if milkactive and not holding_milk and not click: + milk_rect = pygame.Rect(milk_pos_x - 20, milk_pos_y - 50, 49, 74) + dead_rect = pygame.Rect(ez["x"], ez["y"], 96, 96) + if milk_rect.colliderect(dead_rect): + ez["dead"] = False + ez["hp"] = 20 + milkactive = False + + screen.blit(load_sprite(sheet, 27, 82, 7, 12, 56, 96), (zombie_x, zombie_y)) # ZOMBIE + + if milkactive: + milk_collision = pygame.Rect(milk_pos_x - 20, milk_pos_y - 50, 49, 74) + msx, msy = pygame.mouse.get_pos() + if milk_collision.collidepoint(mouse.get_pos()): + if click: + holding_milk = True + if not click: + holding_milk = False + if holding_milk: + milk_pos_x, milk_pos_y = msx, msy + screen.blit(load_sprite(sheet, 20, 82, 7, 12, 49, 74), (milk_pos_x - 20, milk_pos_y - 50)) # MILK CARTON + + return level \ No newline at end of file diff --git a/main.py b/main.py index ebfbcef..279a7f6 100644 --- a/main.py +++ b/main.py @@ -30,7 +30,7 @@ def main(fps=window_fps): # the main function if event.key == pygame.K_ESCAPE: # what happens when you press escape running = False # poof if event.key == pygame.K_k: - level = 2.5 + level = 4.5 if event.type == pygame.MOUSEBUTTONDOWN: # what happens when you press down a mouse button click = True # sets the click variable to True so level function in levels.py can see print(pygame.mouse.get_pos()) # prints out where the mouse is during the click for debugging purposes diff --git a/sprites.png b/sprites.png index 8057517..e1ace43 100644 Binary files a/sprites.png and b/sprites.png differ diff --git a/sprites.pxo b/sprites.pxo index 4824ff4..a61c2c6 100644 Binary files a/sprites.pxo and b/sprites.pxo differ