-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
40 lines (29 loc) · 811 Bytes
/
main.py
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
import pygame
import sys
from src.screen import Screen
# Constants
FPS = 60
def main():
# Objects
pygame.init()
screen = Screen()
# Variables
clock = pygame.time.Clock()
previous_time = pygame.time.get_ticks()
# Main Loop
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
# Set Delta Time
present_time = pygame.time.get_ticks()
delta_time = (present_time - previous_time) / 1000
previous_time = present_time
# Update and Render the Screen
screen.update(delta_time)
screen.render()
# Get constant FPS
clock.tick(FPS)
if __name__ == "__main__":
main()