Skip to content

Commit 5847385

Browse files
committed
Update pxt.json, main.blocks, main.ts, main.py, images.g.jres, images.g.ts
1 parent b1fec6f commit 5847385

File tree

8 files changed

+344
-179
lines changed

8 files changed

+344
-179
lines changed

.github/makecode/blocks.png

268 KB
Loading

.github/makecode/blocksdiff.png

106 KB
Loading

images.g.jres

Lines changed: 9 additions & 2 deletions
Large diffs are not rendered by default.

images.g.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,30 @@ e e e e b b b b b b e e
12481248
................................................................................
12491249
................................................................................
12501250
`;
1251-
case "image17":return img`
1251+
case "image21":
1252+
case "image22":return img`
1253+
. . . . . . . . . . . . . . . .
1254+
. . . . . . . . . . . . . . . .
1255+
. . . . . . . . . . . . . . . .
1256+
. . . . . . . 4 4 . . . . . . .
1257+
. . . . . . 4 4 4 4 . . . . . .
1258+
. . . . . 4 4 5 5 4 4 . . . . .
1259+
. . . . 4 4 5 5 5 5 4 4 . . . .
1260+
. . . . 4 5 5 5 5 5 5 5 4 . . .
1261+
. . . 4 4 5 5 5 5 5 5 5 4 . . .
1262+
. . . 4 4 5 5 5 5 5 5 5 4 . . .
1263+
. . . . 4 5 5 5 5 5 5 4 4 . . .
1264+
. . . . 4 4 4 5 5 5 5 4 . . . .
1265+
. . . . . . 4 4 4 4 4 . . . . .
1266+
. . . . . . . . . . . . . . . .
1267+
. . . . . . . . . . . . . . . .
1268+
. . . . . . . . . . . . . . . .
1269+
`;
1270+
case "image22":return img`
1271+
a e 3 . a 7 e
1272+
a 7 e 2 2 . .
1273+
`;
1274+
case "image23":return img`
12521275
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
12531276
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
12541277
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
@@ -1370,7 +1393,7 @@ e e e e b b b b b b e e
13701393
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
13711394
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
13721395
`;
1373-
case "image21":return img`
1396+
case "image17":return img`
13741397
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
13751398
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
13761399
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
@@ -1492,7 +1515,11 @@ e e e e b b b b b b e e
14921515
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
14931516
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
14941517
`;
1495-
case "image22":return img`
1518+
case "image24":return img`
1519+
a e 3 . a 7 e
1520+
a 7 e 2 2 . .
1521+
`;
1522+
case "image25":return img`
14961523
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
14971524
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
14981525
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999

main.blocks

Lines changed: 6 additions & 3 deletions
Large diffs are not rendered by default.

main.py

Lines changed: 71 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1+
@namespace
2+
class SpriteKind:
3+
FireKind = SpriteKind.create()
4+
StoneKind = SpriteKind.create()
5+
16
def on_up_pressed():
27
global cnt
38
if hacker.vy == 0:
4-
hacker.vy = -120
9+
hacker.vy = -135
510
cnt = 1
611
elif cnt == 1:
7-
hacker.vy = -120
12+
hacker.vy = -135
813
cnt += 2
9-
if hacker.vx < 0:
14+
if hacker.vx > 0:
1015
animation.run_image_animation(hacker,
1116
assets.animation("""
1217
left jump animation
1318
"""),
14-
300,
19+
200,
1520
False)
1621
else:
1722
animation.run_image_animation(hacker,
1823
assets.animation("""
1924
right jump animation
2025
"""),
21-
300,
26+
200,
2227
False)
2328
controller.up.on_event(ControllerButtonEvent.PRESSED, on_up_pressed)
2429

@@ -28,16 +33,45 @@ def on_left_pressed():
2833
"""))
2934
controller.left.on_event(ControllerButtonEvent.PRESSED, on_left_pressed)
3035

36+
def on_on_zero(status):
37+
info.change_life_by(-1)
38+
healthbar.value = 100
39+
statusbars.on_zero(StatusBarKind.health, on_on_zero)
40+
3141
def on_right_pressed():
3242
hacker.set_image(assets.image("""
3343
Temporary asset2
3444
"""))
3545
controller.right.on_event(ControllerButtonEvent.PRESSED, on_right_pressed)
3646

47+
def on_life_zero():
48+
game.over(False, effects.melt)
49+
info.on_life_zero(on_life_zero)
50+
51+
def on_hit_wall(sprite, location):
52+
fireball.destroy(effects.ashes, 100)
53+
stone.destroy(effects.disintegrate, 500)
54+
scene.on_hit_wall(SpriteKind.projectile, on_hit_wall)
55+
56+
def on_on_overlap(sprite: Sprite, otherSprite: Sprite):
57+
if otherSprite == fireball:
58+
healthbar.value += -0.2
59+
else:
60+
healthbar.value += -0.1
61+
curScore = 0
62+
diff = 0
3763
projectile: Sprite = None
38-
stone: Sprite = None
64+
fireball: Sprite = None
3965
cnt = 0
4066
hacker: Sprite = None
67+
stone: Sprite = None
68+
healthbar: StatusBarSprite = None
69+
sprites.on_overlap(SpriteKind.player, SpriteKind.projectile, on_on_overlap)
70+
sprites.on_overlap(SpriteKind.player, SpriteKind.projectile, on_on_overlap)
71+
sprites.on_overlap(SpriteKind.player, SpriteKind.projectile, on_on_overlap)
72+
def on_on_overlap2(sprite: any, stone: any):
73+
healthbar.value += -0.1
74+
sprites.on_overlap(SpriteKind.player, SpriteKind.projectile, on_on_overlap)
4175
scene.set_background_image(img("""
4276
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
4377
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
@@ -166,28 +200,33 @@ def on_right_pressed():
166200
SpriteKind.player)
167201
hacker.set_position(40, 90)
168202
controller.move_sprite(hacker, 80, 0)
169-
hacker.ay = 120
203+
info.set_life(3)
204+
info.set_score(1000)
205+
hacker.ay = 200
170206
tiles.set_tilemap(tilemap("""
171207
level1
172208
"""))
173209
scene.camera_follow_sprite(hacker)
210+
healthbar = statusbars.create(25, 4, StatusBarKind.health)
211+
healthbar.set_position(14, 15)
212+
healthbar.max = 100
174213
# else:
175214
# hacker.ay = 0
176215
# hacker.vy = 0
177216

178217
def on_on_update():
179218
if hacker.y < 50:
180-
hacker.vy = 10
181-
hacker.ay = 120
219+
hacker.vy = 50
220+
hacker.ay = 200
182221
elif hacker.y <= 90:
183-
hacker.ay = 120
222+
hacker.ay = 200
184223
game.on_update(on_on_update)
185224

186225
def on_update_interval():
187226
global stone
188227
stone = sprites.create_projectile_from_side(assets.image("""
189-
cactus_img
190-
"""), 0, 55)
228+
stone_img
229+
"""), 0, 45)
191230
stone.x = hacker.x + 5
192231
game.on_update_interval(5000, on_update_interval)
193232

@@ -197,4 +236,23 @@ def on_update_interval2():
197236
smartCloud
198237
"""), -19, 0)
199238
projectile.y = 50
200-
game.on_update_interval(5000, on_update_interval2)
239+
game.on_update_interval(2000, on_update_interval2)
240+
241+
def on_update_interval3():
242+
global diff, curScore
243+
diff = 2 * game.runtime() / 2500
244+
curScore = info.score() - diff
245+
curScore = max(curScore, 0)
246+
info.set_score(curScore)
247+
game.on_update_interval(3000, on_update_interval3)
248+
249+
def on_update_interval4():
250+
global fireball
251+
fireball = sprites.create_projectile_from_side(img("""
252+
a e 3 . a 7 e
253+
a 7 e 2 2 . .
254+
"""),
255+
-35,
256+
55)
257+
fireball.x = hacker.x + 30
258+
game.on_update_interval(8000, on_update_interval4)

0 commit comments

Comments
 (0)