-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
105 lines (69 loc) · 2.11 KB
/
Copy pathmain.py
File metadata and controls
105 lines (69 loc) · 2.11 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import pygame
game_is_running = False
class Game:
def __init__(self):
self.width = 1920
self.heigth = 1020
self.window = pygame.display.set_mode((self.width, self.heigth))
pygame.display.set_caption("Snake Game")
def initialized_window(self):
try:
pygame.init()
print("Pygame has started. Enjoy this AI Model")
self.window()
except:
pygame.error("The Initialized_window does not work!")
def setup(self):
pass
def process_input(self):
#inherited class will execute the code of this function
pass
def update(self):
#inherited class will execute the code of this function
pass
def render(self):
pygame.display.flip()
pass
def destroy_window(self):
pygame.display.quit()
pygame.quit()
quit()
class Snake(Game):
def __init__(self, x, y, height, width, color):
self.rect = pygame.Rect(x, y, width, height)
self.color = color
def setup_snake(self):
super().setup()
pass
def render_snake(self):
pygame.draw.rect(Game.window, self.color, self.rect)
super().render()
def expand_snake(self):
pass
pass
class Apple(Game):
def __init__(self, x, y, height, width, color):
self.rect = pygame.Rect(x, y, width, height)
self.color = color
def setup_apple(self):
super().setup()
pass
def render_apple(self):
pygame.draw.rect(Game.window, self.color, self.rect)
super().render()
def change_position(self):
pass
pass
game = Game()
snake = Snake(500, 500, 50, 50, (0, 0, 255))
apple = Apple(1000, 1000, 20, 30, (100, 50, 200))
def main():
game_is_running = game.initialized_window()
game.setup()
while game_is_running:
game.process_input()
game.update()
game.render()
game.destroy_window()
if __name__ == "__main__":
main()