Now the second part of my tutorial, a short one :
How to move the members of your team and how to limit them. You know that each member has a limit of displacement; for example this one (the 'X') has a limit of three :
3 3 2 3 3 2 1 2 3 3 2 1 X 1 2 3 3 2 1 2 3 3 2 3 3And the formula to show the moving limit is the following :
FOR i = -limit TO limit nbcase = ABS(limit - ABS(i)) * 2 + 1 'this gives us the number of reachable places per row FOR j = 1 TO nbcase LOCATE (1 - nbcase) / 2 + j - 1 + xposition, i + yposition: COLOR 18: PRINT CHR$(219) NEXT j, i COLOR 7 LOCATE xposition, yposition : PRINT "X"You must specify the limit, the xposition and yposition before starting, or build a SUB with limit, xpos and ypos as the arguments. This example in SCREEN 0 shows : the character ('X') and his moving ability (in blinking green).
But that's not all : we must include a moving and limited character.
There are two ways of doing it :
1. The 'classic' method (in Shining Force) : you can move the character only on the blinking piece of ground.
2. The 'modern' method (in Vandal Heart) : you move a cursor all over the map, seeing the properties then you choose (on the blinking area) the place where you want your character to go.
There are pros and cons in the programming of the two ways :
1.First method :
|PROS||You move the character, there's no use of programming an A.I|
|CONS||You have to program a limit of movement
You can't see ennemy's tile status directly
|PROS||You don't have to set a limit of movement
You can view ALL tiles status and all the ground
|CONS||Must program a (little) A.I to move the character where you want to
You can't undo a movement
Now choose the method you want to use: there are tips below to program the two methods and when I will come back from my holidays I will release a demo of the two methods.
Tips for the first method : Create a clone array of the ground then add 1000 on all the tiles reachables by the character then just make a test /*/IF tilevalue>1000 THEN move ELSE stop moving.\*\ To draw the tiles with a value increased by 1000 make this test : /*/IF tilevalue>1000 then draw tile for value tilevalue-1000 \*\(if you have more than 1000 tiles drawed for your game, increase the value by 10000 or higher).
Tips for the second method : Let a free moving cursor then make a test /*/IF cursor is on a blinking tile AND enter key is pressed THEN move the character ELSE beep or PRINT "Unreachable".\*\ A.I to move the character :
(verticalposition of the cursor - verticalposition of the character) = vertical moving (horizontalposition of the cursor - horizontalposition of the character) = horizontal movingNow with that values you just have to move verticaly then horizontaly. But the simpliest way is to show directly the character at the place you choosed it to go (but it's not very pretty).