Python Beginners – Space Defender

                                       ImageToday in the Python group we looked at how a few simple changes can change the look and feel of a game. Our space Defender game uses code recycled from last weeks Bunnies And Badgers game combined with a few new sprites to make a completely new game. We also looked at how to use Geometry when moving sprites around the screen.

movex=math.cos(angle_z)*10

movey=math.sin(angle_z)*10

xpos+=movex

ypos-=movey

The above code calculates how many pixels the x and y coordinates of our sprite needs to be changed for it to move 10 pixels in the direction of angle_z. You can learn more about Sin and Cos here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s