Skip to content

Commit 3e4ec0b

Browse files
Switch to overlap flag to win
1 parent 11e2558 commit 3e4ec0b

7 files changed

Lines changed: 65 additions & 18 deletions

File tree

.github/makecode/blocks.png

-1.72 KB
Loading

.github/makecode/blocksdiff.png

-41.6 KB
Loading

main.blocks

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

main.ts

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ function create_status_bar (sprite: Sprite, tilemap_length: number) {
6464
} else {
6565
sprite_progress_bar.setLabel("" + percent_traveled + "%", 15)
6666
}
67-
if (percent_traveled == 100) {
68-
win()
69-
}
7067
pause(100)
7168
}
7269
})
@@ -77,8 +74,15 @@ function game_over (win2: boolean) {
7774
high_scores[selected_level - 1] = info.score()
7875
}
7976
blockSettings.writeNumberArray("high_scores", high_scores)
80-
game.over(win2)
77+
timer.after(2000, function () {
78+
game.over(win2)
79+
})
8180
}
81+
scene.onOverlapTile(SpriteKind.Player, assets.tile`flag_bottom`, function (sprite, location) {
82+
if (!(won)) {
83+
win()
84+
}
85+
})
8286
scene.onOverlapTile(SpriteKind.Player, assets.tile`auto_jump`, function (sprite, location) {
8387
timer.throttle("auto_jump", 100, function () {
8488
jump(sprite_player, gravity, constants_tiles_high_jump)
@@ -97,6 +101,11 @@ function prepare_level () {
97101
tiles.coverAllTiles(assets.tile`from`, assets.tile`blank`)
98102
tiles.coverAllTiles(assets.tile`to0`, assets.tile`blank`)
99103
}
104+
scene.onOverlapTile(SpriteKind.Player, assets.tile`flag_top`, function (sprite, location) {
105+
if (!(won)) {
106+
win()
107+
}
108+
})
100109
scene.onOverlapTile(SpriteKind.Player, assets.tile`from`, function (sprite, location) {
101110
tiles.placeOnRandomTile(sprite_player, assets.tile`to0`)
102111
tiles.placeOnRandomTile(sprite_player_cam, assets.tile`to0`)
@@ -187,9 +196,7 @@ function wait_for_select () {
187196
}
188197
sprites.onDestroyed(SpriteKind.Player, function (sprite) {
189198
sprite_player_cam.setVelocity(0, 0)
190-
timer.after(2000, function () {
191-
game_over(false)
192-
})
199+
game_over(false)
193200
})
194201
blockMenu.onMenuOptionSelected(function (option, index) {
195202
selected = true
@@ -225,15 +232,27 @@ let constants_levels = 4
225232
jumps = 0
226233
won = false
227234
in_game = false
228-
pause(500)
229-
if (controller.B.isPressed()) {
230-
scene.setBackgroundColor(13)
231-
pause(100)
232-
if (game.ask("Reset high scores?")) {
233-
blockSettings.remove("high_scores")
234-
blockSettings.remove("high-score")
235-
game.showLongText("Successfully reset high scores!", DialogLayout.Bottom)
235+
while (game.runtime() < 500) {
236+
if (controller.B.isPressed()) {
237+
color.setPalette(
238+
color.Black
239+
)
240+
scene.setBackgroundColor(13)
241+
pause(100)
242+
fade(false, 2000, true)
243+
if (game.ask("Reset high scores?")) {
244+
blockSettings.remove("high_scores")
245+
blockSettings.remove("high-score")
246+
game.showLongText("Successfully reset high scores!", DialogLayout.Bottom)
247+
fade(true, 2000, true)
248+
break;
249+
}
250+
fade(true, 2000, true)
236251
}
252+
if (controller.A.isPressed()) {
253+
break;
254+
}
255+
pause(100)
237256
}
238257
if (!(blockSettings.exists("high_scores"))) {
239258
high_scores = []
@@ -248,7 +267,7 @@ sprite_player.say("Dash!")
248267
if (true) {
249268
menu = []
250269
for (let index = 0; index <= constants_levels - 1; index++) {
251-
menu.push("" + (index + 1) + " (" + spriteutils.roundWithPrecision(high_scores[index] / constants_length * 100, 2) + "%" + ")")
270+
menu.push("" + (index + 1) + " (" + spriteutils.roundWithPrecision(high_scores[index] / constants_length * 100, 2) + "%)" + "")
252271
}
253272
selected_level = select_level()
254273
pause(1000)

pxt.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "Dash! v1.2.3",
2+
"name": "Dash! v1.3.0",
33
"version": "1.2.3",
44
"description": "",
55
"dependencies": {

tilemap.g.jres

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6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DAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
307+
"tileset": [
308+
"myTiles.transparency16"
309+
],
310+
"displayName": "level19"
311+
},
303312
"*": {
304313
"mimeType": "image/x-mkcd-f4",
305314
"dataEncoding": "base64",

tilemap.g.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,25 @@ namespace myTiles {
371371
222222222222..22..22..22..22..2222222....................................................................22.................................222222222222222222222222222222.......................22.....
372372
222222222222...................2....2......................................................................................................2222222222222222222222222222222..............................
373373
`, [myTiles.transparency8,myTiles.tile1,myTiles.tile8,myTiles.tile13,myTiles.tile2,myTiles.tile3,myTiles.tile7,myTiles.tile6,myTiles.tile14,myTiles.tile4,myTiles.tile5], TileScale.Eight);
374+
case "level19":
375+
case "level19":return tiles.createTilemap(hex`1000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000`, img`
376+
. . . . . . . . . . . . . . . .
377+
. . . . . . . . . . . . . . . .
378+
. . . . . . . . . . . . . . . .
379+
. . . . . . . . . . . . . . . .
380+
. . . . . . . . . . . . . . . .
381+
. . . . . . . . . . . . . . . .
382+
. . . . . . . . . . . . . . . .
383+
. . . . . . . . . . . . . . . .
384+
. . . . . . . . . . . . . . . .
385+
. . . . . . . . . . . . . . . .
386+
. . . . . . . . . . . . . . . .
387+
. . . . . . . . . . . . . . . .
388+
. . . . . . . . . . . . . . . .
389+
. . . . . . . . . . . . . . . .
390+
. . . . . . . . . . . . . . . .
391+
. . . . . . . . . . . . . . . .
392+
`, [myTiles.transparency16], TileScale.Sixteen);
374393
}
375394
return null;
376395
})

0 commit comments

Comments
 (0)