Hi guys,
I am trying to create one small board game. Size of the board is 6 rows and 8 columns (think of a chess board ). Its a two player turn based game. The objective of game is simple where player have to fill the board with his coins. Player who is having more coins on board wins the game.
Here comes the rules and this is where i am stuck.
Player can fill upto 4 blocks in a row or column. (no diagonal selection is allowed)
Selection should be continues. (Player cant choose blocks scattered around the board. So its like vertical or horizontal blocks line)
Player will keep getting points for each block filled.
Player will lose points if he fills the last empty block (this can be anywhere in the row or column) of the row or the column.
Game will continue until all the blocks are filled.
My question is how to approach this game to get started with coding. Here are the problems i am facing.
I am able to select upto 4 (or whatever is the max limit) but i am not able to disable diagonal selection.
How can i pass information to code that how many empty blocks are still there in rows and columns. So game on that basis i can add or subtract players pointsâŠ
I hope i am clear enough on what i want to know.
Any help or guidance on the same will be very helpful to me.
Maybe make your board up where each block, section on the board is a trigger, cube collider. Each collider is assigned a value A1, A2âŠ, B1, B2⊠And so on.
When a block is taken, it knows this by the coin triggering it. The block tells the board manager, boardMng, tht it has been taken. The board manager sees column A and row 1 is now taken. Now, it is the responsibility of the manager to check what other blocks are taken. You could do this by knowing ABCD, BCDE, CDEF⊠Or if 1,1,1,1, or 2,2,2,2⊠And so on. Since there is no diagonal, it should be easy.
One other thing i was thinking of creating int variables (size of row or column) for each row and column.
When player will fill any of the block it will get subtracted from the variable, with this i can get info on how many empty blocks are there on the board.
I might be wrong or i am thinking very long wayâŠ
Thanks for the quick replay, help from you guys will always keep me going.
Thanks a lot for all the kind support. I was just going through all the docs which talk about â2D arrayâ. Just came back here to found this linkâŠ
Many many thanksâŠ
Well, using booleans eliminates the need for any type of collision, so I donât know why you dismissed that as not being better. Or I didnât understand what you are asking?
Well,
I would think you place a collider, into a section, that would trigger the bool. How else can you place an object I to some position and have some manager realise it is there?
So, would you shoot a ray from each section. Then place a block on section. If block is let go, it is assumed to be dropped into place, turn off ray, register this section taken?
Well, if you have the size of each square on the grid, and you have the postion of the object you can work out which position in the array the piece is moving to using basic math to translate itâs world position into array indices.
I donât like to use a collision system if I can somehow manage without it. This is how I would do it:
Select an object
Set calculateGridCellIndices to true
Inside Update
if calculateGridCellIndices
colIndex = player.position.y / gridSquareSize
rowIndex = player.position.x / gridSquareSize
End Update
If object unselected
truncate last calculated colIndex and rowIndex to closest integer
check array position colIndex,rowIndex
if bAlreadyTaken is false
Set position of object to be here
bAlreadyTaken is true
calculateGridCellIndices = false
I was practicing to work with â2d arrayâ and now i can play with them a little.
I can feed and read values in it (manual or with for loop ). but i am still not able to find a way to implement this into my game logic.
For e.g : Now i am looking at this array as its filled with bool values (is it empty ?) but how to toggle this values while interacting with game objects? What kind of logic should i apply to solve this? Please help me on this.
@Mister-E2 , Yes i have read through all and unfortunately i got stuck at the very beginning of it. I am not a programmer but i am learning how to code.
I have just completed some basic tutorials and i took this as an assignment for myself and i really wanted to finish it.
I know, i cant ask you guys to do spoon feeding but if i get little guidance on it, then i can finish this assignment faster.