How do I move the player based on dice roll?

  • I'm working on a "simple" single player game for a class at school, and I've kind of written myself into a corner. I can't figure out how to do the actual movement on the board. So here's a quick setup of what I've got so far:

    Player chooses which of the 5 characters they want to be. A semi-transparent version of that character shows up on its starting square on the board. Player rolls the dice. If the player chooses to be Wind Mage or Knight, they add 2 to each roll; Wizard or Firemancer adds 3; Death adds 4.

    So say the player chose to be a Wizard. They won't see anything at first because the player sprite is merged with that square on the board. Player rolls a 3. With the "add-on," that means player gets to move 6 spaces. So then I would need the semi-transparent version of the wizard to appear 6 spaces ahead (in this example, the 3 under the Firemancer). Each time the player rolls, they need to move on the squares in that same path. This will change based on other rules of the game which I believe I can implement on my own.

    Can anyone help me out?

    I'm attaching a picture of the board and the events I have currently.

    Thank you!

  • FYI I have the pink boxes behind everything because I thought I might could set the sprite's location to those object boxes as the player moved, but I would I have to do that for every single movement/number of spaces

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The spaces on the board should have a variable to mark its position on the board, so 1, 2, 3, 4 in order etc. The player also has a position which is a global var. I see you have the power as gv and also dice roll. So if player position is 1 to start. You do a roll and get 3, the power is 2. The move amount should be diceroll+power each time. To move you set player position to position+(diceroll+power) so now player position would be 1+(3+2)=6, so player position is 6. To then move the player you can have an event that always sets the player location to the tile where player position var = board space var. The only tricky thing is then if it cycles round so when you hit the maximum space on the board, it needs to do a calculation to bring it round to start from 1.

  • Thanks, plinkie !

    I'll give that a shot and see what I can come up with. I appreciate it!

  • Plinkie beat me, but here's the basics. For a circular board, give each square a sequence ID (start at 0), and use the Modulo (%) operator to deal with the wrap-around. My sample has a die of 4, and 10 squares (event 5).

    blackhornettechnologies.com/Construct3Stuff/Samples/LesleyBeth_CircularBoard.zip

  • blackhornet THANK YOU so much! This is super helpful!

  • So I am still not able to get the player to become visible or move around the board. What am I missing??

    EDIT Never mind! I needed to make my selection sprite, player sprite, and my "square" sprite global. Now it works!

    Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)