-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
59 lines (41 loc) · 1.39 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
import pygame
import os
# GAME WINDOW
WIDTH, HEIGHT = 1300,700
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("JNP")
# COLORS
BLUE = (0,0,255)
RED = (255,0,0)
#PLAYER INFO
PLAYER_WIDTH, PLAYER_HEIGHT = 60, 80
LEFT_PLAYER_IMAGE = pygame.image.load(
os.path.join('Assets', 'impossible-triangle.png'))
LEFT_PLAYER = pygame.transform.rotate(pygame.transform.scale(
LEFT_PLAYER_IMAGE, (PLAYER_WIDTH, PLAYER_HEIGHT)), 270)
def draw_window(left_player):
WIN.blit(LEFT_PLAYER, (left_player.x, left_player.y))
pygame.display.update()
def handle_input(keys_pressed, left_player):
if keys_pressed[pygame.K_a]: # LEFT
rotated_image = pygame.transform.rotate(LEFT_PLAYER, -10)
new_rect = rotated_image.get_rect(center = LEFT_PLAYER.get_rect(topleft = LEFT).center)
WIN.blit(rotated_image, new_rect)
if keys_pressed[pygame.K_d]: # RIGHT
pass
def main():
left_player = pygame.Rect(100, 320, PLAYER_WIDTH, PLAYER_WIDTH)
clock = pygame.time.Clock()
run = True
while run:
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.quit()
keys_pressed = pygame.key.get_pressed()
handle_input(keys_pressed, left_player)
draw_window(left_player)
main()
if __name__ == "__main__":
main()