-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleveleditor.py
More file actions
118 lines (81 loc) · 2.66 KB
/
Copy pathleveleditor.py
File metadata and controls
118 lines (81 loc) · 2.66 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from re import template
import sys
import json
import pygame
from pygame.locals import *
import bombjack
pygame.init()
fps = 60
fpsClock = pygame.time.Clock()
width = bombjack.sWidth
height = bombjack.sHeight
screen = pygame.display.set_mode((width, height))
background = bombjack.sprites.background_spr1
bombLocs = []
bombs = []
walkerLocs = []
walkers = []
platLocs = []
plats = []
tempPlat = []
level = {}
platPoint = 0
# Game loop.
while True:
screen.fill((0, 0, 0))
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
"""
if event.type == pygame.MOUSEBUTTONDOWN:
pos = pygame.mouse.get_pos()
bombLocs.append(list((list(pos)[0] - 32/2, list(pos)[1] - 32/2)))
bombs.append(bombjack.Bomb(list(pos)[0] - 32/2, list(pos)[1] - 32/2))
print(bombLocs)
"""
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
level["bombs"] = bombLocs
level["platforms"] = platLocs
level["walkers"] = walkerLocs
with open("level.json", "w") as outfile:
json.dump(level, outfile, indent=4)
if event.key == pygame.K_b:
pos = pygame.mouse.get_pos()
bombLocs.append(list((list(pos)[0] - 32/2, list(pos)[1] - 32/2)))
bombs.append(bombjack.Bomb(list(pos)[0] - 32/2, list(pos)[1] - 32/2))
if event.key == pygame.K_w:
pos = pygame.mouse.get_pos()
walkerLocs.append(list((list(pos)[0] - 32/2, list(pos)[1] - 32/2)))
walkers.append(bombjack.Walker(list(pos)[0] - 32/2, list(pos)[1] - 32/2, 0, 1))
print(walkers)
if event.key == pygame.K_p:
pos = pygame.mouse.get_pos()
if platPoint == 0:
tempPlat.append(pos[0])
tempPlat.append(pos[1])
platPoint = 1
else:
tempPlat.append(pos[0])
tempPlat.append(pos[1])
platLocs.append(tempPlat)
platPoint = 0
plats.append(bombjack.Platform(tempPlat[0], tempPlat[1], tempPlat[2], tempPlat[3]))
tempPlat = []
if event.type == QUIT:
pygame.quit()
sys.exit()
# Update.
# Draw.
screen.blit(background, (0, bombjack.settings.GAME_CEILING))
for bomb in bombs:
bomb.draw(screen)
for plat in plats:
plat.draw(screen)
for walker in walkers:
walker.draw(screen)
pygame.draw.rect(screen, (255, 255, 0), pygame.Rect(0, 60, 880, 15))
pygame.draw.rect(screen, (255, 255, 0), pygame.Rect(0, height - 60 - 20, 800, 15))
pygame.display.flip()
fpsClock.tick(fps)