-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
75 lines (65 loc) · 1.92 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
import pygame
import sys
from Functions import text_to_screen
from Tile_List import Big_Ass_List
from Classes import *
from interaction import interaction
from random import randint
pygame.init()
pygame.mixer.init()
pygame.font.init()
SCREENWIDTH = 380
SCREENHEIGHT = 900
screen = pygame.display.set_mode((SCREENWIDTH, SCREENHEIGHT), 0, 32)
Invalids = Big_Ass_List
for y in range(0, screen.get_height(),10):
for x in range(0, screen.get_width(), 10):
if Tile.total_tiles in Invalids:
Tile(x, y, 'solid')
else:
Tile(x, y, 'empty')
clock = pygame.time.Clock()
fps = 1
first_apple = Tile.random_tile(958, 1588, Invalids)
head = Head(180, 400)
target = Apple(first_apple.x, first_apple.y)
#pygame.mixer.music.load("Music/BloodyTears.ogg")
#pygame.mixer.music.play(-1)
background = pygame.image.load("Images/Nokia_Phone.png")
while True:
#Processes
interaction(screen, head)
#Processes
#Logic
head.motion()
Tile.Occupied = []
Tile.Occupied_Numbers = []
for segment in Body.List:
for tile in Tile.List:
if tile.x == segment.x and tile.y == segment.y:
Tile.Occupied.append(tile)
Tile.Occupied_Numbers.append(tile.number)
elif tile.number in Invalids:
continue
else:
tile.Type = 'empty'
tile.walkable = True
for tile in Tile.Occupied:
tile.Type = 'full'
tile.walkable = False
if target.x == head.x and target.y == head.y:
Apple.List = []
create_apple = Tile.random_tile(958, 1588, Invalids)
Body(0,0)
target = Apple(create_apple.x, create_apple.y)
fps += 1
#Logic
#Draw
screen.blit(background, (0,0))
pygame.draw.rect(screen, (0,0,0), (68, 248, 233, 173), 2)
Body.draw(screen)
Head.draw(screen)
Apple.draw(screen)
pygame.display.flip()
#Draw
clock.tick(fps)