-
Notifications
You must be signed in to change notification settings - Fork 0
/
pygame.py
91 lines (55 loc) · 1.9 KB
/
pygame.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
#pygame
import pygame
#import random
## x = pygame.init()
# print(x)
pygame.init()
#RGB 256; 256^3 combs; screen pixels
white = (255,255,255)
black = (0,0,0)
red = (255,0,0)
Blu = (0,0,100)
gameDisplay = pygame.display.set_mode((800,600))
pygame.display.set_caption('ANN')
# pygame.display.flip()
# pygame.display.update()
gameExit = False
lead_x = 300
lead_y = 300
lead_x_change = 0
font = pygame.font.SysFont(None, 25)
#def message_scrn(msg,color):
#screen_text = font.render(msg, True, color)
#randApple = random.randrange(0, display_width)
#event handling and logic-based
#using while game loop - skeleton B
#
while not gameExit:
#event handling loop
for event in pygame.event.get():
#print(event)
if event.type == pygame.QUIT:
gameExit = True
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
lead_x -= 10
if event.key == pygame.K_RIGHT:
lead_x += 10
if event.key == pygame.K_DOWN:
lead_y += 10
if event.key == pygame.K_UP:
lead_y -= 10
#if event.type == pygame.MOUSEBUTTONUP:
#if event.key == pygame.
if lead_x > 800 or lead_x < 0 or lead_y > 600 or lead_y < 0:
pygame.draw.rect(gameDisplay, white, [700,10,10,10])
if lead_x >= 200 and lead_x <= 250 and lead_y >= 200 and lead_y <=250:
pygame.draw.rect(gameDisplay, white, [700,10,10,10])
gameDisplay.fill(Blu)
pygame.draw.rect(gameDisplay, red, [lead_x,lead_y,10,50])
pygame.draw.rect(gameDisplay, white, [lead_x,lead_y,10,10])
gameDisplay.fill(red, rect=[200,200,50,50])
#minusHealth = gameDisplay.fill(white, rect=[700,10,10,10])
pygame.display.update()
pygame.quit()
quit()