This site requires JavaScript, please enable it in your browser!
Greenfoot back
DAustin15
DAustin15 wrote ...

2012/5/23

Anybody know the code to theses certain circumstances?

DAustin15 DAustin15

2012/5/23

#
this is in reply to my other post but i was wondering what would the code be in this scenario. the object moves certain x and y coordinates. when it moves one time it checks to see if its at a certain x and y and if it's not there it keeps moving on how many times the dice tells it to. when it hits that certain x and y it rotates 90 degrees and restarts the loop and keeps moving a certain number of x and y coordinates until it hits another edge that has a certain coordinate. So far we have the game programmed so it rolls two dice, and we have code so that greenfoot is able to get the value of the two dice which we add together. We want to program the game to get the value of the dice rolled and follow the set circumstances above.
danpost danpost

2012/5/23

#
Check out one of my Snake Demo scenarios. It has code for 4-way movement (up, down, left, and right). The only difference being that the Snake is user-controlled (by the arrow keys), and your scenario will just increment the direction value (direction = (direction + 1) % 4; when it reaches the edges). Get all individual parts of the game working first, then work on combining them into a complete game.
You need to login to post a reply.