Ayuda por favor, estoy haciendo un juego de quoridor pero no sé como hacer para validar el movimiento de los peones | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Ayuda por favor, estoy haciendo un juego de quoridor pero no sé como hacer para validar el movimiento de los peones

Help please, I'm playing a quoridor game but I don't know how to validate the movement of the pawns I must do the pawn movement restrictions in java, which are, the pawns should move to one square, either sideways or up or down and not move diagonally, if you can help me I will be very grateful Debo hacer las restricciones de movimiento del peón en java, que son, los peones se deben mover de a una casilla, ya sea a los lados o arriba o abajo y no moverse en diagonal, si me pueden ayudar estaré muy agradecido

22nd May 2020, 7:38 PM
Juan pablo Peña
Juan pablo Peña - avatar
9 Answers
+ 1
the code is in java language, I have programmed it in the eclipse ide
22nd May 2020, 11:02 PM
Juan pablo Peña
Juan pablo Peña - avatar
0
In order to figure out the logic we need the code. Could you please post a link to it?
22nd May 2020, 10:46 PM
George Ryan
George Ryan - avatar
0
Juan pablo Peña Yes, I need to see the code.
22nd May 2020, 11:02 PM
George Ryan
George Ryan - avatar
0
Or at least can you explain how exactly the piece moving works. Is it grid based? Or what
22nd May 2020, 11:03 PM
George Ryan
George Ryan - avatar
0
yes, the game is a board a board that is made up of ascii codes, the pawn can move sideways, up and down but I don't know how to validate the movements, el usuario ingresa el movimiento por coordenadas X y Y, el tablero es de 9x9
22nd May 2020, 11:08 PM
Juan pablo Peña
Juan pablo Peña - avatar
0
Are the pieces objects? If so one way to fix this is adding a position attribute to each piece, so when you move it, before the move is rendered test if it is valid.
22nd May 2020, 11:10 PM
George Ryan
George Ryan - avatar
0
The pieces of the game are * and +, then the player gives the coordinates and the tile moves to where it asks
22nd May 2020, 11:14 PM
Juan pablo Peña
Juan pablo Peña - avatar
0
Then it just seems like simple if/else logic.
22nd May 2020, 11:15 PM
George Ryan
George Ryan - avatar
0
but I don't know how to do it bro, if you can help me I will be very grateful
22nd May 2020, 11:16 PM
Juan pablo Peña
Juan pablo Peña - avatar