There are certainly other approaches to this problem but I hope this one is enough to get you started on tackling the issue. So in conclusion, this approach simplifies stating which moves are valid for the knight, but adds in some trickiness about transforming between the absolute and relative grid so you can compare the players absolute grid mouse clicks with the relative grid moveset of the knight. The valid positions could most concisely be stated as (+/-1, +/-2) and (+/-2, +/-1) Since there are only 8 valid moves maximum for a knight, the simplest approach is likely to hard code these valid relative moves, then check the players attempted move against the list of valid relative positions representing knight's possible moves. In the example image's grid this is the move that ends up on (3,0), but in our imaginary relative grid this would end up at (1, 2). Lets consider the movement where the knight heads north and then east. Using these relative positions can make it a lot simpler to determine which knight moves are valid. However, what code can I use to make the objects move along a grid, for instance like a chess board (or the game Civilization if you. I know for this I can use the following code: movetowardspoint (objplayer.x,objplayer.y,speed). To tie this in with the example image, if we drew these relative grid labels on the example image, the knight's position would be labeled (0,0), and the grid would range through (+/-2, +/-2). mail indir apk gamemaker studio 2 apk iq broker apk picture this apk full. I want to move certain objects towards my player object. If your knight is at a position, lets say (x,y) on the chess board/grid, lets also imagine a second version of this grid that is relative to the knights position. There are quite a few approaches you could take to validating this kind of movement, so you should choose whatever is cohesive with the style of your movement validation so far, but I'll suggest a simple approach and perhaps you and other answerers can build on it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |