NaaLaa
Scrolling - Printable Version

+- NaaLaa (https://www.naalaa.com/forum)
+-- Forum: NaaLaa (https://www.naalaa.com/forum/forum-1.html)
+--- Forum: NaaLaa 7 Questions (https://www.naalaa.com/forum/forum-3.html)
+--- Thread: Scrolling (/thread-135.html)



Scrolling - johnno56 - 05-15-2024

If one were to say, create a side scrolling Mario-type game that has a level much wider than the desktop, would there be such an example or tutorial on how to use the tilemap library to control the camera and scrolling? Just in case one were to consider such a project...

All I have is the Tilemap Editor PDF file as reference... No rush...


RE: Scrolling - 1micha.elok - 05-15-2024

(05-15-2024, 07:37 AM)johnno56 Wrote: If one were to say, create a side scrolling Mario-type game that has a level much wider than the desktop, would there be such an example or tutorial on how to use the tilemap library to control the camera and scrolling? Just in case one were to consider such a project...

All I have is the Tilemap Editor PDF file as reference... No rush...

Herewith a simplified code if maps larger than the view
camera control :  TM_CenterCamera(player.x + player.w/2, player.y + player.h)

Code:
...

'-----------
' MAIN LOOP
'-----------

while not keydown(KEY_ESCAPE, true)
   
    ' Control : LEFT, RIGHT to move horizontally
    if keydown(KEY_LEFT)                                player.dx = -1
    if keydown(KEY_RIGHT)                               player.dx = 1
    if not keydown(KEY_LEFT) and not keydown(KEY_RIGHT) player.dx = 0

    TM_MoveSprite(player, player.dx, player.dy)
    TM_CenterCamera(player.x + player.w/2, player.y + player.h)
   
    ...
wend



RE: Scrolling - Marcus - 05-15-2024

Here's an example using graphics from Super Mario Bro's 2. If something is unclear, just ask Smile


RE: Scrolling - johnno56 - 05-15-2024

Excellent! As we say here in Australia, "Your blood is worth bottling". (https://www.usingenglish.com/reference/idioms/blood+is+worth+bottling.html)