diff --git a/levels.py b/levels.py index 2d5b0fd..b9a0621 100644 --- a/levels.py +++ b/levels.py @@ -1,6 +1,9 @@ import pygame 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 +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 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 mainmenu_text = big_text.render("Revival Inc.", True, (0, 0, 0)) @@ -32,7 +35,6 @@ def level2(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, 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 screen.blit(load_sprite(sheet, 20, 82, 7, 12, 49,74), (274, 342)) # MILK CARTON - print(tick) dialog_square = pygame.surface.Surface((700, 68), pygame.SRCALPHA) dialog_square.fill((0, 0, 0)) if 60 <= tick <= 400: @@ -91,6 +93,32 @@ def level2(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, 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 >= 2201: - level = 3 - return level # returns the current level set \ No newline at end of file + elif 2201 <= tick <= 2500: + if tick < 2326: + dialog = smalltext.render("try dragging the milk to him", True, (0+(tick-2201)*2, 0+(tick-2201)*2, 0+(tick-2201)*2)) + else: + dialog = smalltext.render("try dragging the milk to him", 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 >= 2501: + level = 2.5 + return level # returns the current level set +def level3(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, mouse, click, big_text, level, tick, smalltext): # function for level 2 + global milk_pos_x, milk_pos_y, holding_milk + 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 + 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 + print(milk_collision) + dialog_square = pygame.surface.Surface((700, 68), pygame.SRCALPHA) + dialog_square.fill((0, 0, 0)) + return level \ No newline at end of file diff --git a/main.py b/main.py index 725ab16..cd05efe 100644 --- a/main.py +++ b/main.py @@ -29,6 +29,8 @@ def main(fps=window_fps): # the main function if event.type == pygame.KEYDOWN: # what happens when you press down a key if event.key == pygame.K_ESCAPE: # what happens when you press escape running = False # poof + if event.key == pygame.K_k: + level = 2.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 @@ -45,6 +47,12 @@ def main(fps=window_fps): # the main function elif level == 2: # what happens when the level variable is equal to 2 ofc tick += 1 level = levels.level2(screen, sheet, screen_width, screen_height, lastclickpos, basicfont, pygame.mouse, click, bigtext, level, tick, smalltext) # runs the level2 function from levels.py + elif level == 2.5: + tick = 0 + 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 + 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