-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
106 lines (81 loc) · 3.01 KB
/
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
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
106
"""
This is the start of a racing game!
TODO:
- Multiplayer
- Road
- KENT 'TURTLE' NEX
- Last Updated - March 4nd, 2015
"""
##############################
# IMPORTS #
##############################
import pygame
import keyboard_mouse_Class
import global_Module
import menu_Class
import car_Class
import wall
from pygame.locals import *
##############################
# GLOBALS #
##############################
#Globals
INT_SIZE = INT_WIDTH, INT_HEIGHT = global_Module.screen_size # This is the size of the screen
FPS = 180 # FPS
##############################
# FUNCTIONS #
##############################
##############################
# MAIN #
##############################
# This is the main function of the program
def main():
##############################
# M VARIABLES #
##############################
# Color
colors = global_Module.colors # Gets the colors from the globals
game_loop = True # Used to stop the game when you want it over
menu_dict = {'Start' : (INT_WIDTH / 2, (INT_HEIGHT / 6) * 3),
'Multi-player' : (INT_WIDTH / 2, (INT_HEIGHT / 6) * 4),
'Quit' : (INT_WIDTH / 2 , (INT_HEIGHT / 6) * 5)}
##############################
# M INIT #
##############################
pygame.init() # inits
fps_clock = pygame.time.Clock() # sets the framerate clock
win_screen_obj = pygame.display.set_mode(INT_SIZE) # sets the display
pygame.display.set_caption('Racing Game') # sets the caption for the display
userKeyboard = keyboard_mouse_Class.Keyboard() # All keyboard and mouse are handled by this
main_menu = menu_Class.Menu(win_screen_obj, fps_clock, menu_dict, "ULTIMATE RACING BUTLER SIMULATOR 2015")
player_sprite_group = pygame.sprite.Group()
player_car = car_Class.Car()
player_sprite_group.add(player_car)
wall_sprite_group = pygame.sprite.Group()
##############################
# M MENU CLASS #
##############################
#main_menu.main()
##############################
# M MAIN LOOP #
##############################
while game_loop: # Game loop
# Fetch info
keys = userKeyboard.update() # Fetches keyboard and mouse inputs
if keys['K']:
rand_wall = wall.wall()
wall_sprite_group.add(rand_wall)
keys['K'] = False
# Updates
win_screen_obj.fill(colors['white']) # sets the screen color to white
player_sprite_group.draw(win_screen_obj)
player_sprite_group.update(keys, win_screen_obj)
wall_sprite_group.draw(win_screen_obj)
fps_clock.tick(FPS) # This sets the block at the fps
pygame.display.update() # This updates the screen
##############################
# START #
##############################
# if the program is launched by itself then it runs main
if __name__ == '__main__':
main()