stage.set_background("space")
ufo = codesters.Sprite("ufo",200 ,170)
ufo.set_size(.5)
alien = codesters.Sprite("alien2", 120, 200)
alien.set_size(.5)
def up_key():
alien.move_up(20)
stage.event_key("up", up_key)
def down_key():
alien.move_down(20)
stage.event_key("down", down_key)
def left_key():
alien.move_left(20)
stage.event_key("left", left_key)
def right_key():
alien.move_right(20)
stage.event_key("right", right_key)
obstacle1 = codesters.Sprite("meteor1",-200, 50)
obstacle1.set_size(.5)
obstacle1.set_x_speed(5)
obstacle2 = codesters.Sprite("meteor2",200, -170)
obstacle2.set_size(.5)
obstacle2.set_x_speed(4)
obstacle3 = codesters.Sprite("meteor2", 0, -170)
obstacle3.set_size(.5)
obstacle3.set_x_speed(7)
obstacle4 = codesters.Sprite("meteor1", 10, 50)
obstacle4.set_size(.5)
obstacle4.set_x_speed(8)
def collision(alien, hit_sprite):
alien.go_to(120,200)
alien.event_collision(collision)
finish = codesters.Rectangle(0, -220, 500, 10, "green")
def collision(alien, finish):
alien.go_to(120, 200)
my_var = finish.get_color()
if my_var == "green":
ufo.say("Good Job!!!")
alien.event_collision(collision)
-
Run Code
-
-
Stop Running Code
-
Show Chart
-
Show Console
-
Codesters How To (opens in a new tab)