-
Notifications
You must be signed in to change notification settings - Fork 0
/
RedneckDeerHunting.py
executable file
·62 lines (51 loc) · 1.94 KB
/
RedneckDeerHunting.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pygame
import time
import sys
from model.Game import *
from model.MainMenu import *
from model.ScoreScreen import *
FRAMERATE = 30
class RedneckDearHunting:
def __init__(self, resolution=(800, 600), fullscreen=False):
pygame.init()
pygame.mixer.init(frequency=22050)
self.resolution = resolution
self.fullscreen = fullscreen
if fullscreen:
self.screen = pygame.display.set_mode(resolution, pygame.FULLSCREEN)
else:
self.screen = pygame.display.set_mode(resolution)
pygame.display.set_caption('Redneck Dear Hunting')
pygame.display.set_icon(pygame.image.load('images/Mooses/idle_left.png'))
self.main_menu = MainMenu(self, resolution)
self.game = Game(self, resolution)
#self.score_screen = ScoreScreen(self, resolution, self.game)
self.views = {
'main_menu': self.main_menu,
'game': self.game,
#'score_screen': self.score_screen
}
self.current_view = 'main_menu'
def change_view(self, view_name):
if self.views[view_name]:
self.current_view = view_name
def loop(self, framerate):
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.KEYDOWN:
self.views[self.current_view].key_press(event.key)
if event.type == pygame.KEYUP:
self.views[self.current_view].key_release(event.key)
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
sys.exit()
if self.current_view == 'game':
self.game.update(framerate)
self.views[self.current_view].draw(self.screen)
if __name__ == "__main__":
redneck = RedneckDearHunting(fullscreen=False)
while 1:
time.sleep(FRAMERATE/1000.0)
redneck.loop(FRAMERATE)
pygame.display.flip()