Skip to content

Commit 333f035

Browse files
Change to percents
1 parent 0b3dc08 commit 333f035

5 files changed

Lines changed: 13 additions & 5 deletions

File tree

.github/makecode/blocks.png

8.7 KB
Loading

.github/makecode/blocksdiff.png

-11.8 KB
Loading

main.blocks

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

main.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ let percent_traveled = 0
185185
let sprite_progress_bar: StatusBarSprite = null
186186
let sprite_player_cam: Sprite = null
187187
let selected_level = 0
188+
let percent = 0
188189
let menu: string[] = []
189190
let sprite_player: Sprite = null
190191
let high_scores: number[] = []
@@ -199,6 +200,7 @@ constants_gravity = 300
199200
constants_tiles_high_jump = 3
200201
constants_max_jumps = 2
201202
constants_length = 1600
203+
let constants_levels = 3
202204
jumps = 0
203205
won = false
204206
in_game = false
@@ -213,15 +215,20 @@ if (controller.B.isPressed()) {
213215
}
214216
}
215217
if (!(blockSettings.exists("high_scores"))) {
216-
blockSettings.writeNumberArray("high_scores", [0, 0, 0])
218+
high_scores = []
219+
for (let index = 0; index < constants_levels; index++) {
220+
high_scores.push(0)
221+
}
222+
blockSettings.writeNumberArray("high_scores", high_scores)
217223
}
218224
high_scores = blockSettings.readNumberArray("high_scores")
219225
make_player()
220226
sprite_player.say("Dash!")
221227
if (true) {
222228
menu = []
223-
for (let index = 0; index <= 2; index++) {
224-
menu.push("" + (index + 1) + " (" + high_scores[index] + "/" + constants_length + ")")
229+
for (let index = 0; index <= constants_levels - 1; index++) {
230+
percent = spriteutils.roundWithPrecision(high_scores[index] / constants_length * 100, 2)
231+
menu.push("" + (index + 1) + " (" + percent + "%" + ")")
225232
}
226233
selected_level = select_level()
227234
pause(1000)

pxt.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"Color Fading": "github:jwunderl/pxt-color#v0.2.0",
1212
"pxt-status-bar": "github:jwunderl/pxt-status-bar#v0.4.0",
1313
"block-menu": "github:riknoll/arcade-custom-menu#v0.0.1",
14-
"settings-blocks": "github:microsoft/pxt-settings-blocks#v1.0.0"
14+
"settings-blocks": "github:microsoft/pxt-settings-blocks#v1.0.0",
15+
"arcade-sprite-util": "github:jwunderl/arcade-sprite-util#v0.1.0"
1516
},
1617
"files": [
1718
"main.blocks",

0 commit comments

Comments
 (0)