-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_COPY_AND_RENAME.py
70 lines (53 loc) · 1.77 KB
/
main_COPY_AND_RENAME.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
import sys
import os
import pygame
"""
SETUP section - preparing everything before the main loop runs
"""
pygame.init()
# Global constants
SCREEN_WIDTH = 1000
SCREEN_HEIGHT = 800
FRAME_RATE = 60
# Useful colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
# Creating the screen and the clock
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
screen.set_alpha(0) # Make alpha bits transparent
clock = pygame.time.Clock()
while True:
"""
EVENTS section - how the code reacts when users do things
"""
for event in pygame.event.get():
if event.type == pygame.QUIT: # When user clicks the 'x' on the window, close our game
pygame.quit()
sys.exit()
# Keyboard events
keys_pressed = pygame.key.get_pressed()
if keys_pressed[pygame.K_UP]:
pass # Replace this line
if keys_pressed[pygame.K_LEFT]:
pass # Replace this line
if keys_pressed[pygame.K_RIGHT]:
pass # Replace this line
if keys_pressed[pygame.K_DOWN]:
pass # Replace this line
# Mouse events
mouse_pos = pygame.mouse.get_pos() # Get position of mouse as a tuple representing the
# (x, y) coordinate
mouse_buttons = pygame.mouse.get_pressed()
if mouse_buttons[0]: # If left mouse pressed
pass # Replace this line
if mouse_buttons[2]: # If right mouse pressed
pass # Replace this line
"""
UPDATE section - manipulate everything on the screen
"""
"""
DRAW section - make everything show up on screen
"""
screen.fill(BLACK) # Fill the screen with one colour
pygame.display.flip() # Pygame uses a double-buffer, without this we see half-completed frames
clock.tick(FRAME_RATE) # Pause the clock to always maintain FRAME_RATE frames per second