Wow. Clearly the OP does not understand indentation.
If you indent the_ship (line 13), you are trying to assign an instance of the class before it's even defined.
Furthermore, indenting those last 12 lines is just silly. Now why would you want to do that?
I'm assuming you're just copying someone else's code and trying to modify it? Or following some advanced game making tutorial? These are the problems that stem from being unable to code in a language you want to use for more advanced purposes...
Edit:
I don't like where this thread's heading, so I'll just give you the code how it should look (
assuming your lines are merely incorrectly placed ... the rest is up to you):
import math, random
class Ship(Collider):
"""The player's ship."""
image = games.load_image("ship.bmp")
sound = games.load_sound("thrust.wav")
ROTATION_STEP = 3
VELOCITY_STEP = .03
def update(self):
"""Rotates based on keys pressed."""
if games.keyboard.is_pressed(games.K_LEFT):
self.angle -= Ship.ROTATION_STEP
if games.keyboard.is_pressed(games.K_RIGHT):
self.angle += Ship.ROTATION_STEP
super(Ship, self).die()
# apply thrust based on up arrow key
if games.keyboard.is_pressed(games.K_UP):
Ship.sound.play()
# change velocity based on ship's angle
angle = self.angle * math.pi / 180 #convert to radian
self.dx += Ship.VELOCITY_STEP * math.sin(angle)
self.dy += Ship.VELOCITY_STEP * -math.cos(angle)
the_ship = Ship(image = Ship.image,
x = games.screen.width/2,
y = games.screen.height/2)
games.screen.add(the_ship)