Game maker studio 2 click to move
I’ll start by creating an object called oBoard. I’ve imported sprites for 3 example pieces: circle, square, and triangle. Now let’s start making the actual project. This way a team will be able to move one piece each turn. If it is, it will delete the piece at its original location, and move it to the new cell.Īfter that, the other team will be given their turn, and state will be reset to 0. When the state is 1 and the player clicks on a cell, it will check whether that cell is empty. If it does, it will store that cell’s info (location, piece type) to some variables, and set the state to 1. When the player clicks on any piece, it will check whether that piece belongs to that team. In our project, there will be two states: 0 and 1. When a side is moving a piece, this variable will keep track of where that action has progressed. There will be another variable called state. When it is a team’s turn, they will be able to move one of their pieces to some other cell. A variable called turn will store whose turn it is (0 or 1). But if there is a piece at a cell, it will hold an array with the two aforementioned elements.īoth sides will take turns moving their pieces. So, if a cell in that grid is empty, its value will be 0. The arrays will contain only two elements: the first one will store the piece type (from the enum), and the second element will contain the team that piece belongs to (0 or 1).
![game maker studio 2 click to move game maker studio 2 click to move](https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/gettyimages-801931944-1633528330.jpg)
That grid, in each cell, will contain an array. Then we’ll create a DS grid for the main board. x, y is the cell position to access, //where 0, 0 would be the top-left cell //Readingįirst we’ll set up the pieces inside an enum. If you want to access or set a value in the grid, you can do it like you would with a 2D array, but using the # accessor: //Writing Each cell can hold a value.Ī grid can be created using ds_grid_create(w, h), where w and h are the width & height of the grid.Īll cells in a new grid hold 0. The board will contain different pieces, with each piece belonging to either team, like Chess.ĭS Grids are 2D data structures that contain a certain number of cells, which are determined by the width & height of the grid. In this project, there will be two teams.
![game maker studio 2 click to move game maker studio 2 click to move](https://www.dummies.com/wp-content/uploads/438670.image0.jpg)
GAME MAKER STUDIO 2 CLICK TO MOVE FREE
Here is one I made, which is free to look at on GitHub: Using this method, you can even build a Chess game. This is what we’ll create in this tutorial:
GAME MAKER STUDIO 2 CLICK TO MOVE HOW TO
Hey there! In this tutorial, you’ll learn how to create a turn-based board game using DS grids.