@@ -44,7 +44,7 @@ player = void
4444camera = void
4545world = void
4646tileSheet = void
47- bgSheet = void
47+ bgFarSheet = void
4848playerSheet = void
4949enemySheet = void
5050coinSprite = void
@@ -121,7 +121,7 @@ function loadLevel(n)
121121 exitX = lvl .exitX (n )
122122 exitY = lvl .exitY (n )
123123 player = Player (spawnX , spawnY , 0 , 0 , false , 1 , 0 )
124- camera = mp .camera (320 , 180 )
124+ camera = mp .camera (480 , 270 )
125125 camera .worldWidth = w * 32
126126 camera .worldHeight = h * 32
127127
@@ -153,10 +153,10 @@ function resetLevel()
153153end function
154154
155155function initialize (game )
156- global tileSheet , bgSheet , playerSheet , enemySheet , coinSprite , exitSprite , cloudSprite , flowerSprite , sparkSprite , campfireSprite
156+ global tileSheet , bgFarSheet , playerSheet , enemySheet , coinSprite , exitSprite , cloudSprite , flowerSprite , sparkSprite , campfireSprite
157157 game .assets = gen .registry ()
158158 tileSheet = gen .sheet_tiles ()
159- bgSheet = gen .sheet_backgrounds ()
159+ bgFarSheet = gen .sheet_bg_far ()
160160 playerSheet = gen .sheet_player ()
161161 enemySheet = gen .sheet_enemy ()
162162 coinSprite = tileSheet .getFrame (1 )
@@ -406,8 +406,36 @@ function update(game, dt)
406406 end if
407407end function
408408
409+ function drawBgLayer (canvas , sheet , divisor , y )
410+ frame = sheet .getFrame (levelIndex )
411+ shift = (camera .x / divisor ) % 512
412+ x = 0 - shift
413+ while x < 480
414+ canvas .drawSpriteEx (frame , x , y , false , false , 8 , mp .rgba (255 , 255 , 255 , 255 ))
415+ x = x + 512
416+ end while
417+ end function
418+
419+ function drawTreeBand (canvas , divisor , baseY , color , trunkColor , step , maxHeight )
420+ shift = (camera .x / divisor ) % (step * 8 )
421+ x = 0 - shift
422+ i = 0
423+ while x < 500
424+ h = 18 + ((i % 5 ) * (maxHeight / 5 ))
425+ canvas .fillRect (x + 3 , baseY - h , 4 , h , trunkColor )
426+ canvas .fillRect (x , baseY - h - 8 , 16 , h + 10 , color )
427+ canvas .fillRect (x + 5 , baseY - h - 15 , 6 , 10 , color )
428+ x = x + step
429+ i = i + 1
430+ end while
431+ end function
432+
409433function drawParallax (canvas )
410- canvas .drawSpriteEx (bgSheet .getFrame (levelIndex ), 0 , 0 , false , false , 8 , mp .rgba (255 , 255 , 255 , 255 ))
434+ canvas .clear (mp .rgb (140 , 211 , 218 ))
435+ drawBgLayer (canvas , bgFarSheet , 16 , 0 )
436+ drawTreeBand (canvas , 10 , 214 , mp .rgba (67 , 91 , 58 , 190 ), mp .rgba (43 , 58 , 40 , 210 ), 26 , 20 )
437+ drawTreeBand (canvas , 5 , 238 , mp .rgba (42 , 67 , 45 , 210 ), mp .rgba (30 , 45 , 32 , 230 ), 22 , 32 )
438+ canvas .fillRect (0 , 242 , 480 , 28 , mp .rgba (39 , 57 , 39 , 165 ))
411439end function
412440
413441function drawParticles (canvas )
@@ -422,19 +450,19 @@ function drawParticles(canvas)
422450end function
423451
424452function drawHud (canvas )
425- canvas .fillRect (0 , 0 , 320 , 18 , mp .rgba (20 , 28 , 34 , 170 ))
453+ canvas .fillRect (0 , 0 , 480 , 18 , mp .rgba (20 , 28 , 34 , 170 ))
426454 mp .drawText (canvas , "LEVEL " + (levelIndex + 1 ), 7 , 6 , 1 , mp .rgb (255 , 255 , 255 ))
427- mp .drawText (canvas , "COINS " + coinsTaken + "/" + coinCount , 91 , 6 , 1 , mp .rgb (255 , 220 , 80 ))
428- mp .drawText (canvas , "HP " + lives , 188 , 6 , 1 , mp .rgb (255 , 110 , 120 ))
429- canvas .fillRect (244 , 6 , 66 , 5 , mp .rgb (38 , 62 , 44 ))
430- canvas .fillRect (244 , 6 , (coinsTaken * 66 ) / coinCount , 5 , mp .rgb (116 , 220 , 98 ))
455+ mp .drawText (canvas , "COINS " + coinsTaken + "/" + coinCount , 150 , 6 , 1 , mp .rgb (255 , 220 , 80 ))
456+ mp .drawText (canvas , "HP " + lives , 306 , 6 , 1 , mp .rgb (255 , 110 , 120 ))
457+ canvas .fillRect (390 , 6 , 78 , 5 , mp .rgb (38 , 62 , 44 ))
458+ canvas .fillRect (390 , 6 , (coinsTaken * 78 ) / coinCount , 5 , mp .rgb (116 , 220 , 98 ))
431459end function
432460
433461function drawLevelIntro (canvas )
434462 if levelIntro < = 0 then return end if
435- canvas .fillRect (0 , 58 , 320 , 48 , mp .rgba (0 , 0 , 0 , 150 ))
436- mp .drawTextCentered (canvas , "LEVEL " + (levelIndex + 1 ), 67 , 2 , mp .rgb (255 , 255 , 255 ))
437- mp .drawTextCentered (canvas , "COLLECT ALL COINS" , 91 , 1 , mp .rgb (255 , 220 , 80 ))
463+ canvas .fillRect (0 , 96 , 480 , 48 , mp .rgba (0 , 0 , 0 , 150 ))
464+ mp .drawTextCentered (canvas , "LEVEL " + (levelIndex + 1 ), 105 , 2 , mp .rgb (255 , 255 , 255 ))
465+ mp .drawTextCentered (canvas , "COLLECT ALL COINS" , 129 , 1 , mp .rgb (255 , 220 , 80 ))
438466end function
439467
440468function drawPlay (game , canvas )
@@ -447,12 +475,12 @@ function drawPlay(game, canvas)
447475 mp .drawSpriteWorldEx (canvas , camera , tileSheet .getFrame (exitFrame ), exitX , exitY , false , false , 2 , mp .rgba (255 , 255 , 255 , 255 ))
448476 if coinsTaken < coinCount then
449477 sx = exitX - camera .x
450- if sx > - 48 and sx < 320 then
478+ if sx > - 48 and sx < 480 then
451479 mp .drawText (canvas , "LOCKED" , sx - 4 , exitY - camera .y - 10 , 1 , mp .rgb (255 , 220 , 80 ))
452480 end if
453481 end if
454482
455- for d = 0 to 10
483+ for d = 0 to 18
456484 dx = 120 + (d * 146 )
457485 mp .drawSpriteWorld (canvas , camera , tileSheet .getFrame (5 ), dx , 194 )
458486 end for
@@ -507,30 +535,33 @@ function drawPlay(game, canvas)
507535 drawHud (canvas )
508536 drawLevelIntro (canvas )
509537 if hitFlash > 0 then
510- canvas .fillRect (0 , 0 , 320 , 180 , mp .rgba (255 , 255 , 255 , 35 ))
538+ canvas .fillRect (0 , 0 , 480 , 270 , mp .rgba (255 , 255 , 255 , 35 ))
511539 end if
512540end function
513541
514542function drawMenuScreen (game , canvas , title , subtitle , color )
515543 menuPulse = pulse2 (game , 18 )
516544 glow = pulse2 (game , 18 )
517- canvas .drawSpriteEx (bgSheet .getFrame (0 ), 0 , 0 , false , false , 8 , mp .rgba (255 , 255 , 255 , 255 ))
518- canvas .fillRect (0 , 122 , 320 , 58 , mp .rgba (24 , 42 , 30 , 120 ))
519- canvas .fillRect (44 , 27 , 232 , 76 , mp .rgba (0 , 0 , 0 , 175 ))
520- canvas .drawRect (44 , 27 , 232 , 76 , color )
545+ canvas .clear (mp .rgb (140 , 211 , 218 ))
546+ canvas .drawSpriteEx (bgFarSheet .getFrame (0 ), 0 , 0 , false , false , 8 , mp .rgba (255 , 255 , 255 , 255 ))
547+ drawTreeBand (canvas , 10 , 214 , mp .rgba (67 , 91 , 58 , 190 ), mp .rgba (43 , 58 , 40 , 210 ), 26 , 20 )
548+ drawTreeBand (canvas , 5 , 238 , mp .rgba (42 , 67 , 45 , 210 ), mp .rgba (30 , 45 , 32 , 230 ), 22 , 32 )
549+ canvas .fillRect (0 , 196 , 480 , 74 , mp .rgba (24 , 42 , 30 , 120 ))
550+ canvas .fillRect (124 , 56 , 232 , 76 , mp .rgba (0 , 0 , 0 , 175 ))
551+ canvas .drawRect (124 , 56 , 232 , 76 , color )
521552 if glow == 1 then
522- canvas .drawRect (46 , 29 , 228 , 72 , mp .rgba (255 , 255 , 255 , 90 ))
553+ canvas .drawRect (126 , 58 , 228 , 72 , mp .rgba (255 , 255 , 255 , 90 ))
523554 end if
524- mp .drawTextCentered (canvas , title , 44 , 3 , color )
525- canvas .fillRect (83 , 82 , 154 , 12 , mp .rgb (255 , 255 , 255 ))
526- mp .drawTextCentered (canvas , subtitle , 84 , 1 , mp .rgb (30 , 42 , 60 ))
527- canvas .drawSprite (tileSheet .getFrame (0 ), 32 , 120 )
528- canvas .drawSprite (tileSheet .getFrame (0 ), 64 , 120 )
529- canvas .drawSprite (tileSheet .getFrame (0 ), 224 , 120 )
530- canvas .drawSprite (tileSheet .getFrame (0 ), 256 , 120 )
531- canvas .drawSprite (playerSheet .getFrame (0 ), 96 , 104 )
532- canvas .drawSprite (enemySheet .getFrame (menuPulse ), 205 , 112 )
533- canvas .drawSprite (tileSheet .getFrame (1 + menuPulse ), 149 , 118 )
555+ mp .drawTextCentered (canvas , title , 73 , 3 , color )
556+ canvas .fillRect (163 , 111 , 154 , 12 , mp .rgb (255 , 255 , 255 ))
557+ mp .drawTextCentered (canvas , subtitle , 113 , 1 , mp .rgb (30 , 42 , 60 ))
558+ canvas .drawSprite (tileSheet .getFrame (0 ), 152 , 196 )
559+ canvas .drawSprite (tileSheet .getFrame (0 ), 184 , 196 )
560+ canvas .drawSprite (tileSheet .getFrame (0 ), 296 , 196 )
561+ canvas .drawSprite (tileSheet .getFrame (0 ), 328 , 196 )
562+ canvas .drawSprite (playerSheet .getFrame (0 ), 216 , 180 )
563+ canvas .drawSprite (enemySheet .getFrame (menuPulse ), 285 , 188 )
564+ canvas .drawSprite (tileSheet .getFrame (1 + menuPulse ), 237 , 194 )
534565end function
535566
536567function render (game , canvas )
@@ -553,6 +584,6 @@ function render(game, canvas)
553584end function
554585
555586function main (args )
556- cfg = mp .createConfig ("MiniPixels Skyline Run" , 320 , 180 , 4 )
587+ cfg = mp .createConfig ("MiniPixels Skyline Run" , 480 , 270 , 3 )
557588 return mp .run (cfg , initialize , update , render , void )
558589end function
0 commit comments