Unit 3: Animations and Games, Lesson 20: Defender Game

Hi all,

I’m looking for some help on with this student’s game. They’ve made a game that rotates their tanks, and they want them to move in the direction that they rotate in. Is there anyway to get the .rotation property. As in the X and Y coordinates, to make the tank move to where it’s pointing?

Help! https://studio.code.org/projects/gamelab/BNUfuMbwerBFIkcGmfVGCHe9QEsPQQsQ8lLiImvUoHw/edit

Hi Michelle,

The student is in the right track. They will need to use the setSpeedAndDirection() block to make this work. I’ve shown an example here: https://studio.code.org/projects/gamelab/oVSfd400GQ8WILhvW1I0QRFxlPOTret06niw9w-89TM

Note that sprites are expected to move to the right, so for the sprite to move in the right direction, the student will need to rotate the animation so that the tank is facing to the right. Once that is done, they can use the sprite rotation property to orient the sprite how they want. I didn’t rotate the animation, but you can probably see what I mean from how the tank moves to the side.