Here on the newbie forums, I sort of think newbies should help newbies as a way to learn, so while Im by no stretch of the imagination an expert (quite to the contrary), I have found that by helping other people I learn a lot on my own. So here goes
By RPG movement Im assuming your talking about something along the lines of Zelda (like a top down view in a 2d enviroment?).
I started working on something similiar and while I don't think this is THE way to do it, i think its a good start.
rem This is the basic setup, I will assume everyone is familiar with these
Sync On
Sync Rate 60
Set Display Mode 800, 600, 32
Autocam off
Hide mouse
Color Backdrop rgb(0,0,0)
rem load the image we are going to use for movement. no animation here, just a static image (we can work that out later)
load image "ship.bmp",1,1
Ok so now we have set up the coade with an image being loaded into memory. I think (not 100% sure here) that we need to create some variables for keeping track of the angle.
angle#=0
x#=100.0
Y#=100.0
This is the next line. I saw this used in a couple of examples. The Angle#=0 basicaly sets the starting position for what will be our sprite in the main loop. So Angle 0 should mean pointing North effectivly or up if you will.
Then we set X and Y at 100.0, This will set the starting position for the sprite that again we will load in the main loop.
Next we need to load the spite into position. The rest of the code should be within our loop so we have to add a DO at the start here.
Do
sprite 1, x#,Y#,1:offset sprite 1, sprite width(1)/2, sprite height(1)/2
rotate sprite 1, angle#
So the command is Sprite, the number 1 is a reference to the sprite, so this is sprite 1 we are loading. Then we set the position (X and Y) using our variables instead of a fixed number since will be changing these when we start moving. finally the number 1 after the position is the reference to the image which is image 1.
The next thing is the rotation of the sprite. We want to tell the program that it should rotate the sprite on a 360 degree angle using our angle variable as a starting point.
The command is rotate sprite and a reference to the sprite number. Then the angle which we are going to use our variable for (angle#).
Now I think we need to set up the movement with the left and right keys so that the sprite can rotate.
if leftkey()
angle#=wrapvalue(angle#-4.0)
else
if rightkey()
angle#=wrapvalue(angle#+4.0)
endif
Endif
The trick here is the "wrapvalue" command. We tell the program if you press the Leftkey then change the value of angle# to angle#+ new angle. So in this example I use 4.0 which just means it will add 4.0 to the 360 angle per click of the key. The higher this number the faster it will rotate. The same for the right key. Since there are two ifs we have to have 2 endifs. (Im not sure why that is since its a single if command with an Else if in it but thats how it works (tested it)
finally we add the sync command and close the loop so
The complete code should look like this.
Sync On
Sync Rate 60
Set Display Mode 800, 600, 32
Autocam off
Hide mouse
Color Backdrop rgb(0,0,0)
load image "ship.bmp",1,1
angle#=0
x#=100.0
Y#=100.0
do
sprite 1, x#,Y#,1
rotate sprite 1, angle#
if leftkey()
angle#=wrapvalue(angle#-4.0)
else
if rightkey()
angle#=wrapvalue(angle#+4.0)
endif
Endif
sync
loop
I don't think we are done here.. the effect is a bit wierd as the sprite doesn't rotate around a center point. I will try to find out why it does that.
Newbie Alert