|
-
Oct 12th, 2000, 04:50 AM
#1
Thread Starter
Addicted Member
Heres what I found to be the easiest way to program a movement system.
Create 2 arrays, one is your map, the other is your Character.
Dim CharacterArray(5)
Dim MapArray(10,10,1) ' this will allow for a set of squares, 10 by 10.
Then you need to setup the map array, you need to draw the 10 by 10 grid on paper, and draw your map on it using 1 square as a location. Then make a note on each square what exits are available, using N for north, S for south and so on. Then match up the grid locations, (i.e. 2(across),5(down)) and do...
MapArray(2,5,0) = "NS" ' this tells the program that the user can move North, and South
MapArray(2,5,1) = "An empty Street" ' This is the description of the location.
Then the character array contains this data.
CharacterArray(0) = "Allanon" ' There name
CharacterArray(1) = 0 ' There Across position in relation to the maparray
CharacterArray(2) = 0 ' There Down position in relation to the maparray
Then When a character requests to move, all you need do is this code...
If moverequest = "N" and instr(maparray(characterarray(1),characterarray(2),0),"N") Then
CharacterArray(2) = CharacterArray(2) + 1
End If
TO move south, just subtract 1 from that, and user characterarray(1) for moving east and west.
Then all you need to do it print out the description..
User.Screen.Caption = maparray(characterarray(1),characterarray(2),1)
You can expand on this lots, adding up and down, is very easy, and both the character array, and the map array can have any amount of extra data added to them.
Tony@Work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|