generated from dvorakmortonxd/pygame-template
finished it up to work for pygbag with asyncio :3
This commit is contained in:
parent
008b4811a0
commit
1ccdfc6ee8
2 changed files with 6 additions and 6 deletions
|
|
@ -9,8 +9,8 @@ holding_milk = False
|
|||
zombie_hp = 20
|
||||
milkactive = False
|
||||
enemy_zombies = [
|
||||
{"x": 200, "y": 200, "hp": 20, "dead": False, "dx": 1, "dy": 1, "timer": 0, "coll": pygame.Rect(200, 200, 56, 96), "friendly": False},
|
||||
{"x": 400, "y": 300, "hp": 20, "dead": False, "dx": -1, "dy": 1, "timer": 0, "coll": pygame.Rect(400, 300, 56, 96), "friendly": False},
|
||||
{"x": 200, "y": 200, "hp": 20, "dead": False, "dx": 1, "dy": 1, "timer": 0, "coll": None, "friendly": False},
|
||||
{"x": 400, "y": 300, "hp": 20, "dead": False, "dx": -1, "dy": 1, "timer": 0, "coll": None, "friendly": 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
|
||||
|
|
|
|||
8
main.py
8
main.py
|
|
@ -1,9 +1,10 @@
|
|||
#!/usr/bin/env python3
|
||||
import pygame, levels # Imports the pygame library and our own levels.py we made for the code to be more readable, obviously
|
||||
import asyncio
|
||||
|
||||
window_fps = 60 # the frames per second, this decides how fast the main loop runs per second
|
||||
|
||||
def main(fps=window_fps): # the main function
|
||||
async def main(fps=window_fps): # the main function
|
||||
pygame.init() # initalizes pygame
|
||||
screen_width = 768 # the screen width
|
||||
screen_height = 576 # the screen height
|
||||
|
|
@ -29,8 +30,6 @@ 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 = 6
|
||||
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
|
||||
|
|
@ -68,7 +67,8 @@ def main(fps=window_fps): # the main function
|
|||
if level != 6:
|
||||
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
|
||||
await asyncio.sleep(0)
|
||||
clock.tick(fps) # this makes sure the game loop runs at the fps we set it to before
|
||||
pygame.quit() #this quits our game when the game loop somehow ends, for example by pressing escape or the X button on the window
|
||||
if __name__ == "__main__": # this just makes sure that this only runs when you launch it and not when you import it as a module like we imported levels.py at the top
|
||||
main() # this actually runs our stuff
|
||||
asyncio.run(main()) # this actually runs our stuff
|
||||
Loading…
Add table
Add a link
Reference in a new issue