grid movement

Blitz3D Forums/Blitz3D Beginners Area/grid movement

Jsoren(Posted 2006) [#1]
hi, i am making a 3D stratagy/RPG game, and i want to have the movment so u walk using preset squares (a grid i guess), and everything is positioned on this grid. almost exactly like the movement system from 'final fansaty tactics advanced' for game boy advance, if anyone if farmilliar with that game...

if u can help thx!

JS


Boiled Sweets(Posted 2006) [#2]
If you are having trouble getting this basic bit working dare I say attempting a 3d strategy/rpg game is perhaps a too big a project for you (at the moment)

I really don't mean to be negative, I just want to offer some friendly constructive thoughts. Judging by the number of posts you have made I'm guessing you are fairly new to Blitz. Perhaps a smaller less ambitious project would get you up to speed first...

On the other hand GO FOR IT! I just hope you realise the work required to finish that type of game. I seriously hope you have designed it first and I don't just mean the design of the characters, I mean the design of the 'engine' etc.


Jsoren(Posted 2006) [#3]
thanks, a stratgy/rpg probly is too big for me to tackle, but what the heck, i like to try anyway. i have only been programming in basic for a year, and its my very first attempt at any programming languige so far... i have done a futuristic flight game, a map editor, a game that really has no description, and a few others. and i have a rpg engine almost done, but i never did anything with this kind of movement...

and yeah, i do use the forums alot, i think posting and getting help from more experianced programmers is preferable to spending weeks trying to figure out somthing by yourself.

ty, please post if u can help

JS


Jsoren(Posted 2006) [#4]
i could still use help on this if anyone has sugjestions...should i create the grid using an array? with each grid square as a type? im not really sure where to start here... sry, for all the questions, but plz help if u can :)

JS


Matty(Posted 2006) [#5]
Hi Jsoren,

if you want to use a grid style movement system there are many ways of doing this.

What I think is possibly the simplest is the following:

Often in my games when I have a creature/entity that needs to walk/move from one point to another I store the following variables:

x,y,z - global coordinates of current position

tx,ty,tx - global coordinates of target position

Then simply point the creature/entity at the target position, which in your case would be the centre of the next grid square to move to.

Then proceed to move the creature/entity to the tx,ty,tz coordinates at its usual movement speed.

The final step is to ensure that it ends its movement on the target coordinates. This may be done in a number of ways. The simplest is to simply 'accept' the movement as being complete once the distance to the target position is within a specified tolerance. A more complex method is to reduce the creature's/entity's movement speed such that as it gets closer to the target position it slows down until it stops.

Using an array for the grid is handy if you want to store say the object handle of the creature/entity in the appropriate slot in the array to designate it as 'filled' and 0 otherwise.

Hopefully that gives you some ideas.


Jsoren(Posted 2006) [#6]
unfourtunatly this is a little too simple for what i am doing. i need each grid square to hold the information: is a player occupying this square, if so, does that player block u from moving there or allow u to attack him, is there a obsticle on this qsuare, is it interactable, does this square do anything special (teleport, etc...). this is why i think using types might be best, just no sure how. i also need to light up certain squares on command, so i meght need to use sprites to i guess

JS


Stevie G(Posted 2006) [#7]
Use and array of types ... a very basic example

Type Tile
 field ID
 field Otherstuff
 field etc
end type

const GridSize = 50
const Layers = 3

Dim Grid.Tile( GridSize-1, GridSize-1, Layers )

Restore GridData
for x = 0 to GridSize-1
  for y = 0 to GridSize - 1
       Grid( x, y,0 ) = new Tile
       Read Grid( x, y,0 )\ID 
       Read Grid( x, y,0 )\OtherStuff   
       Read Grid( x, y,0 )\etc
  next
next

.GridData
data .........



To be honest if you're stuck at this part I'd suggest something more simple.

Stevie


Jsoren(Posted 2006) [#8]
thanks, just what im looking for!
@stevie G: agreed, but im still goin ahed with this, im very stubborn...

ty,
JS


YellBellzDotCom(Posted 2006) [#9]
Ok, thats one cool little routine there. Thanks for that.