@@ -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+ } )
8286scene . 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+ } )
100109scene . 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}
188197sprites . 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} )
194201blockMenu . onMenuOptionSelected ( function ( option , index ) {
195202 selected = true
@@ -225,15 +232,27 @@ let constants_levels = 4
225232jumps = 0
226233won = false
227234in_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}
238257if ( ! ( blockSettings . exists ( "high_scores" ) ) ) {
239258 high_scores = [ ]
@@ -248,7 +267,7 @@ sprite_player.say("Dash!")
248267if ( 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 )
0 commit comments