Skip to content

Commit fa962a3

Browse files
Boilerplate code
1 parent c5dc50b commit fa962a3

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

scripts/main.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import pygame
2+
import sys
3+
pygame.init()
4+
5+
6+
class Game:
7+
def __init__(self, size):
8+
self.width = size[0]
9+
self.height = size[1]
10+
self.win = pygame.display.set_mode(size)
11+
pygame.display.set_caption("Racing Game")
12+
self.background = (0, 0, 0)
13+
14+
def input(self, keys):
15+
pass
16+
17+
def logic(self, delta):
18+
print(delta)
19+
20+
def render(self, window):
21+
window.fill(self.background)
22+
23+
pygame.draw.rect(window, (255, 255, 255), (100, 100, 50, 50))
24+
25+
pygame.display.update()
26+
27+
28+
def main():
29+
g = Game((800, 600))
30+
clock = pygame.time.Clock()
31+
fps = 60
32+
33+
while True:
34+
clock.tick(fps)
35+
36+
for event in pygame.event.get():
37+
if event.type == pygame.QUIT:
38+
return
39+
40+
g.input(pygame.key.get_pressed())
41+
g.logic(clock.get_time() / 1000)
42+
g.render(g.win)
43+
44+
45+
if __name__ == "__main__":
46+
main()
47+
sys.exit()

0 commit comments

Comments
 (0)