I don't know if what I programmed worth anything, I've never programmed something like that, I just need to handle a player movement on a map, I thought a tile map will work, but I don't know anymore.
Description of logic of end result
I have a board game I want to program, the map has 3 levels.
Each level is a square (outer square, inner, and middle square).
On a player move phase (I have phases and turns implemented).
He rolls a dice (random func from 1 to 6 implemented).
And he can move forward or backwards how much he rolled (let's say he rolled 3).
End description of logic of end result
Below here is what I tried to do.
I can get the player map pos, the map is a 2d array (like a tilemap), I've also created a "location" array to represent each location. (bellow is an example not actual code).
var map = [ [0,1,3,5] ,[11,31,4,5,] ,[12,31,4,5,] ]; var locations = []; locations[0]={name:"trailer park",desc:"bla",pos_on_map:[0,0]}; locations[1]={name:"mall",desc:"bla",pos_on_map:[1,0]}; Say I created a move method on the game handle object how do I let the player select to move 3 squares backwards or forward(he can select to move 1 or 2 if he wants). and what if it means going from 0 to 11 or 12 or from 11 to 3.
How do I loop through such options? It's from one array "row" to another on the 2d array.
Now I have:
if(game_manger.turn_phase >2){game_manger.manu="game_manu"} //loop trogh all input options output var loop_tims = game_manger.move_amount; var c_player = game_manger_p.current_player(); var p_loc = c_player.loc; var c_p_level = c_player.map_level; var board_len = my_map[c_p_level].length ; for(var i =0; i < loop_tims;i++) { if(i < board_len)//only existing locations { var loc = i+1 + p_loc;//map location num jout(loc+")locatio name"); } } It's not very well implemented... not even the map data part, I don't think a 2d array like this will work I need something to separate it to levels but still let me output it like a tile map.
Also there is no info anywhere on the web about how to program a board game or a turn based game.