I have a student who wants to move players on a game board. What condition and action would you create to make this happen?
I have a student who wants to move players on a game board. What condition and action would you create to make this happen?
Are they actually wanting to create a board game or just a fake movement on a board?
Because setting up a path movement with nodes is a good way of doing a fake board movement.
It really depends, any info you can provide would be great
Jason
One wanted to try and create a chess game. But I'm not sure I know the difference between creating a board game where the pieces are able to be moved by a player or creating a fake movement on the board?
Is the fake movement one in which the piece moves by itself?
He wants the movement of the chess piece to be up to the players. So would you have to create a path on every square on the chess board?
There are a couple of ways to do it, but from the top of my head... yes you could create a movement path. But thats alot of precise work. For example the Pawns, you could create one, do all the movements for one square, and two square movements, then clone it to do all the others, and then clone again and replace the black pawn with a white pawn. So though its some work, there are ways to cut it down.
Another way would be too do it all in the event editor. Using an array perhaps.
As long as you know the distance between each square, and can compare an array or global value to see if there is a chess item already on the board (so it doesnt move through it).
Its not straight forward, but possible.
Hope something there helps
Jason
You could put grids all over the board (use active objects but make them invisible) then make it so when you click on a piece a
White square appears around the piece taking up the number of grids it can move. Then do something like:
+Mouse is over "movement Square"
+User clicks on "grid"
Then position "game Piece" at 0,0 of "grid".
Or something like that.
It would only work for a game like Checkers, because Chess is a bit more complex.
If I had to do this then the easiest way would be to use an array, and the pathfinding object combined with EasyGrid (or just a little math).
Basically the concept is the game board forms a grid. Every square is a cell.
Let's assume that each cell is 32x32 pixels. If I had a 5x5 grid then that gives a total size of 160x160 pixels.
Let's say I was at the top corner of the grid and I want to move to the middle of the grid:
The start (marked with an S) is at 0,0 on the grid or 0,0 when converted to screen coordinates (0x32,0x32 although you may want to add an origin which would make it OriginX+0x32,OriginY+0x32).Code:[S][ ][ ][ ][ ] [ ][ ][ ][ ][ ] [ ][ ][F][ ][ ] [ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ]
F would be at 2,2 (because it is 0 based) and so that position would be 2*32,2*32 or OriginX+2*32,OriginY+2*32.
Ok so now we can position our objects. We find that to move from S to F we need to move through the cell marked with an M.
That is where the pathfinding object comes in. Using the pathfinding object you can calculate the shortest path between S and FCode:[S][ ][ ][ ][ ] [ ][M][ ][ ][ ] [ ][ ][F][ ][ ] [ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ].
Once you have pieces on the board then they become obstacles.
Imagine I had a piece at the spot where M is:
Then to get from S to F I need a new path which are shown now by numbers:Code:[S][ ][ ][ ][ ] [ ][P][ ][ ][ ] [ ][ ][F][ ][ ] [ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ]
Now the hard part in all of this is restricting that path and implementing all sorts of rules (like movement ranges, ect).Code:[S][1][1][ ][ ] [2][P][1][ ][ ] [2][2][F][ ][ ] [ ][ ][ ][ ][ ] [ ][ ][ ][ ][ ]
Good luck.
EDIT: Just realized that TGF 2 wouldn't have the pathfinding object... That is a shame.
Here is an EXE realization of what I am talking about: Board Test
Left click to calculate a path, right click to place a stone, press C to clear all of the stones.