diff --git a/levels.py b/levels.py index b9a0621..7e960f6 100644 --- a/levels.py +++ b/levels.py @@ -1,7 +1,10 @@ -import pygame +import pygame, random from render import load_sprite # this makes it so our function for rendering sprites from sprites.png is available in here milk_pos_x, milk_pos_y = 274, 342 +zombie_dx, zombie_dy = 1, 1 +zombie_x, zombie_y = 645, 214 +zombie_timer = 0 holding_milk = False 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 @@ -109,6 +112,7 @@ def level3(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, milk_collision = pygame.Rect(milk_pos_x-20, milk_pos_y-50, 49, 74) screen.blit(load_sprite(sheet, 0, 46, 48, 36, screen_width, screen_height), (0, 0)) screen.blit(load_sprite(sheet, 8, 82, 12, 12, 96, 96), (645, 214)) # ZOMBIE + zombie_collision = pygame.Rect(645,214,96,96) msx, msy = pygame.mouse.get_pos() if milk_collision.collidepoint(mouse.get_pos()): if click: @@ -117,8 +121,79 @@ def level3(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, holding_milk = False if holding_milk: milk_pos_x, milk_pos_y = msx, msy + if zombie_collision.collidepoint(milk_pos_x, milk_pos_y): + level = 4 screen.blit(load_sprite(sheet, 20, 82, 7, 12, 49, 74), (milk_pos_x-20, milk_pos_y-50)) # MILK CARTON - print(milk_collision) dialog_square = pygame.surface.Surface((700, 68), pygame.SRCALPHA) dialog_square.fill((0, 0, 0)) + return level +def level4(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, mouse, click, big_text, level, tick, smalltext): # function for level 2 + global zombie_x, zombie_y, zombie_timer, zombie_dx, zombie_dy + milk_collision = pygame.Rect(milk_pos_x-20, milk_pos_y-50, 49, 74) + screen.blit(load_sprite(sheet, 0, 46, 48, 36, screen_width, screen_height), (0, 0)) + zombie_timer += 1 + if zombie_timer > 60: # change direction every ~1 sec + zombie_dx = random.choice([-2, -1, 1, 2]) + zombie_dy = random.choice([-2, -1, 1, 2]) + zombie_timer = 0 + zombie_x += zombie_dx + 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 + dialog_square = pygame.surface.Surface((700, 68), pygame.SRCALPHA) + dialog_square.fill((0, 0, 0)) + + # dialogs here + + if 60 <= tick <= 270: + if tick < 186: + dialog = basicfont.render("see????", True, (0+tick*2-120, 0+tick*2-120, 0+tick*2-120)) + else: + dialog = basicfont.render("see????", True, (255, 255, 255)) + dialog_square.blit(load_sprite(sheet, 0, 82, 8, 8, 48, 48), (15, 10)) + dialog_square.blit(dialog, (78, 15)) + screen.blit(dialog_square, (34, 500)) + elif 271 <= tick <= 500: + if tick < 390: + dialog = smalltext.render("the milk brought him back!", True, (0+(tick-271)*2, 0+(tick-271)*2, 0+(tick-271)*2)) + else: + dialog = smalltext.render("the milk brought him back!", True, (255, 255, 255)) + dialog_square.blit(load_sprite(sheet, 0, 82, 8, 8, 48, 48), (15, 10)) + dialog_square.blit(dialog, (78, 15)) + screen.blit(dialog_square, (34, 500)) + elif 501 <= tick <= 750: + if tick < 626: + dialog = smalltext.render("I mean sure hes a little dumb", True, (0+(tick-501)*2, 0+(tick-501)*2, 0+(tick-501)*2)) + else: + dialog = smalltext.render("I mean sure hes a little dumb", True, (255, 255, 255)) + dialog_square.blit(load_sprite(sheet, 0, 82, 8, 8, 48, 48), (15, 10)) + dialog_square.blit(dialog, (78, 15)) + screen.blit(dialog_square, (34, 500)) + elif 751 <= tick <= 1000: + if tick < 876: + dialog = smalltext.render("but hes ressurected!!!", True, (0+(tick-751)*2, 0+(tick-751)*2, 0+(tick-751)*2)) + else: + dialog = smalltext.render("but hes ressurected!!!", True, (255, 255, 255)) + dialog_square.blit(load_sprite(sheet, 0, 82, 8, 8, 48, 48), (15, 10)) + dialog_square.blit(dialog, (78, 15)) + screen.blit(dialog_square, (34, 500)) + elif 1001 <= tick <= 1250: + if tick < 1126: + dialog = smalltext.render("now you know the basics", True, (0+(tick-1001)*2, 0+(tick-1001)*2, 0+(tick-1001)*2)) + else: + dialog = smalltext.render("now you know the basics", True, (255, 255, 255)) + dialog_square.blit(load_sprite(sheet, 0, 82, 8, 8, 48, 48), (15, 10)) + dialog_square.blit(dialog, (78, 15)) + screen.blit(dialog_square, (34, 500)) + elif 1251 <= tick <= 1500: + if tick < 1376: + dialog = smalltext.render("so go on!", True, (0+(tick-1251)*2, 0+(tick-1251)*2, 0+(tick-1251)*2)) + else: + dialog = smalltext.render("so go on!", True, (255, 255, 255)) + dialog_square.blit(load_sprite(sheet, 0, 82, 8, 8, 48, 48), (15, 10)) + dialog_square.blit(dialog, (78, 15)) + screen.blit(dialog_square, (34, 500)) + elif tick > 1500: + level = 5 return level \ No newline at end of file diff --git a/main.py b/main.py index cd05efe..15cf0b5 100644 --- a/main.py +++ b/main.py @@ -52,7 +52,9 @@ def main(fps=window_fps): # the main function level = 3 elif level == 3: level = levels.level3(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, pygame.mouse, click, bigtext, level, tick, smalltext) # runs the level2 function from levels.py - + elif level == 4: + tick += 1 + level = levels.level4(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, pygame.mouse, click, bigtext, level, tick, smalltext) # runs the level2 function from levels.py fps_text = smalltext.render(str(int(clock.get_fps())), True, (0, 255, 0)) # defines a thing that renders your fps in the top left corner screen.blit(fps_text, (5, 5)) # this actually renders "ftp_text" on the screen at the position (5, 5) which is the top left corner pygame.display.flip() # this updates the display so it displays all the new stuff we added diff --git a/sprites.png b/sprites.png index 1d89cfd..6f57033 100644 Binary files a/sprites.png and b/sprites.png differ diff --git a/sprites.pxo b/sprites.pxo index 9ca390b..1766186 100644 Binary files a/sprites.pxo and b/sprites.pxo differ