-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpygame_template.py
More file actions
44 lines (32 loc) · 918 Bytes
/
pygame_template.py
File metadata and controls
44 lines (32 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import pygame
import random
from settings import *
# Game Loop
running = True
while running:
'''
Loop Logic:
- Sets the tick rate at which the loop runs
- Look for events (such as movement, attack, closing the game, etc)
- Update the game logic
- Draw everything
- Double buffer
'''
# keep this running at the FPS defined above.
clock.tick(FPS)
# Process input (events)
for event in pygame.event.get():
# check for closing the window
if event.type == pygame.QUIT:
running = False
# Update
# Draw / Render
screen.fill(BLACK)
#####################
# Double buffering, this is a performance trick.
# This always needs to happens after everything that we need to draw!
#####################
pygame.display.flip()
print(int(clock.get_fps()))
# Closing everything.
pygame.quit()