How to Make an RPG Overworld
An RPG overworld is the map or background of an RPG project. It can often scroll with the main character's movement to allow the viewer to travel among a rather large world. Other objects such as enemies in the world need to therefore have positions relative to the scroll of the background. The player's perspective is looking down at the character, rather than the player looking at the character from the side. Шаблон:Note
Main Idea
In the RPG, the player figuratively moves but remains with a static x and y position. The world that is visually behind the character moves opposite the character due to the limitations of the stage's size compared to the world's.
Main Character Movement
Assuming scrolling is utilized for the gameplay, the following script can be placed in the main character sprite to scroll the background:
when gf clicked //or during a moment movement is proper go to x: (0) y: (0) //centers the character forever if <key [right arrow v] pressed?> then change [scroll x v] by (-1) //to "move" right, scroll the background left end if <key [left arrow v] pressed?> then change [scroll x v] by (1) end if <key [up arrow v] pressed?> then change [scroll y v] by (1) end if <key [down arrow v] pressed?> then change [scroll y v] by (-1) end
Making Boundaries
Boundaries set limits on how far the world can be scrolled. The player sprite, who controls all scrolling, can have a modified script shown below to set boundaries of the world:
when gf clicked //or during a moment movement is proper go to x: (0) y: (0) //centers the character forever if <<key [right arrow v] pressed?> and <(scroll x) > (-960)>> then //-960 is the boundary change [scroll x v] by (-1) //to "move" right, scroll the background left end if <<key [left arrow v] pressed?> and <(scroll x) < (960)>> then change [scroll x v] by (1) end if <<key [up arrow v] pressed?> and <(scroll y) < (720)>> then change [scroll y v] by (1) end if <<key [down arrow v] pressed?> and <(scroll y) > (-720)>> then change [scroll y v] by (-1) end
Enemy Movement
Enemies in an RPG often move to bring more excitement and challenge to the game. An enemy who remains still may not be as difficult to defeat as one who moves. Enemies must scroll with the over world because only the main character remains in a static position. When the world scrolls due to the player's movement, the enemy has to scroll with the background to justify the movement properly. The first step is to create the enemy sprites, which can be drawn in the paint editor or imported. Enemies may have movement that differs from one another. To generate random movement in the over world, the following script can be used or relate to one's needs:
when I start as a clone //assuming there are multiple enemies go to x: (pick random (-220) to (220)) y: (pick random (-160) to (160)) //generates near the player set [off x v] to ((x position) - (scroll x)) //justifies x position with the background set [off y v] to ((y position) - (scroll y)) //justifies y position forever go to x: ((scroll x) + (off x)) y: ((scroll y) + (off y)) if <([y position v] of [character v]) < (y position)> then //if character below enemy change [off y v] by (-2) //moves down end if <([y position v] of [character v]) > (y position)> then //if character above enemy change [off y v] by (2) //moves up end if <([x position v] of [character v]) < (x position)> then //if character left of enemy change [off x v] by (-2) //moves left end if <([x position v] of [character v]) > (x position)> then //if character right of enemy change [off x v] by (2) //moves right end
Create a variable named "battle". When the battle starts, this will keep the battle from repeating over and over again. Lastly, use these scripts:
when flag clicked forever if <<touching [enemy v]?> and <not <(battle) = (1)>>> then broadcast [battle v] //Make this the broadcast that starts the battle sequence. set [battle v] to (1) end end