-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
75 lines (56 loc) · 1.98 KB
/
index.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
"""The main python file for the mario game"""
from __future__ import absolute_import
import sys
import pygame
# Import custom classes and files
import constants
from level_creator import level_creator
from player import player
from control_player import control_player
from collision_detection import collision_detection
def main():
"""The main function for the program"""
# Initialize pygame
pygame.init()
pygame.display.set_caption(constants.Game.TITLE)
screen = pygame.display.set_mode(constants.Game.GAME_SIZE)
# Define all the classes
_clock = pygame.time.Clock()
# Temporary way to define all the levels
# TODO: Clean up the levels
levels = (
constants.Levels.LEVEL_ONE,
constants.Levels.LEVEL_TWO,
constants.Levels.LEVEL_THREE
)
# Define variables to be used
running = True
# Main while loop that only stops when the game is exited
while running:
# Initialize the timer and repaint the background
_clock.tick(constants.Game.FRAME_RATE)
screen.fill(constants.Colors.CYAN)
# Loop through events and see if the window should be closed
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_w and pygame.key.get_mods() & pygame.KMOD_CTRL:
running = False
# Draw the level (the bricks)
screen = level_creator.draw_level(screen, levels[0])
# Draw enemies
# Control player
control_player.move_player()
# Control camera
# Collision detection
collision_detection.detect_collisions()
# Action listener
# Draw player
player.set_player_position(control_player.get_player_position())
screen = player.draw_player(screen)
# Repaint the screen
pygame.display.flip()
sys.exit() # Quit
if __name__ == '__main__':
main()