Role-playing games, sometimes abbreviated as RPG, are single or multiple playable characters who are guided on a quest through a world full of enemies. They usually are played from a top-down perspective. This tutorial will show how to make a role-playing game with top-down scrolling.
Movement
Movement is one of the most basic scripts in a role-playing game. This script will control the player with the arrow keys, and stop when the player hits a black wall.
Basic Movement
This is the more basic method of movement that can be used.
When gf clicked go to x: (0) y: (0) forever if <key (up arrow v) pressed?> then change y by (7) if <touching color [#000000]?> then change y by (-7) end end if <key (down arrow v) pressed?> then change y by (-7) if <touching color [#000000]?> then change y by (7) end end if <key (left arrow v) pressed?> then change x by (-7) if <touching color [#000000]?> then change x by (7) end end if <key (right arrow v) pressed?> then change x by (7) if <touching color [#000000]?> then change x by (-7) end end
Note: | Using this method of detection, good timing will allow somebody to "clip" into the wall, and move around freely by pressing the arrow opposite the direction they want to go. Also, using this method the only way to get to places beyond the view of the window is using a new background in which the background changes when the sprite reaches the edge and it teleports the sprite to the other edge. |
Scrolling Movement
This is a more advanced method of movement in which the player stays centered, but the background moves, giving an impression of the player moving.
In order to make scrolling movement, some sprites and variables are needed:
- Character sprite
- Background sprite (one costume for each full screen of background)
- Set the backdrop to the color that blocks motion
- Private variable for the background sprite: CloneID
- ScrollX variable