Beispiel #1
0
def interval():
    global score
    if not game_over:
        bottom_pipe = codesters.Rectangle(250, 0, 100, 400, "grey")
        bottom_pipe.set_x_speed(-pipe_speed)
        bottom_pipe.set_gravity_off()
        pipe_height = random.randint(-100, 100)
        bottom_pipe.set_top(pipe_height)
        pipe_list.append(bottom_pipe)

        top_pipe = codesters.Rectangle(250, 0, 100, 400, "grey")
        top_pipe.set_gravity_off()
        top_pipe.set_x_speed(-pipe_speed)
        top_pipe.set_bottom(pipe_height + pipe_gap)
        pipe_list.append(top_pipe)

        score += 1
        score_display.set_text("Flappy Points: " + str(score))
 def end_level(self):
     self.clean_up()
     if self.score >= self.num_goal:
         end_text = codesters.Text('You Win!')
         self.sprites.append(end_text)
         next_button = codesters.Rectangle(0, -80, 100, 50, 'green')
         next_button.event_click(self.next_level)
         self.sprites.append(next_button)
         button_text = codesters.Text('Continue', 0, -80)
         button_text.set_color('#ffffff')
         self.sprites.append(button_text)
     else:
         end_text = codesters.Text('Close! Try again.')
         self.sprites.append(end_text)
         next_button = codesters.Rectangle(0, -80, 100, 50, 'green')
         next_button.event_click(self.restart_level)
         self.sprites.append(next_button)
         button_text = codesters.Text('Restart', 0, -80)
         button_text.set_color('#ffffff')
         self.sprites.append(button_text)
    def display_start_button(self):
        start_square = codesters.Rectangle(0, -80, 100, 50, 'green')
        start_square.event_click(self.start_level)
        self.sprites.append(start_square)

        button_text = codesters.Text('Start', 0, -80)
        button_text.set_color('#ffffff')
        self.sprites.append(button_text)

        goal_text = codesters.Text('Goal: ' + str(self.num_goal) + ' points')
        goal_text.set_color('#ffffff')
        self.sprites.append(goal_text)
Beispiel #4
0
    ball.set_gravity_on()
    start_txt.hide()
    win_text.hide()


stage.event_key("space", space_bar)

player1 = codesters.Sprite("hedgehog", -210, -225)
player1.set_size(.6)

player2 = codesters.Sprite("kitten", 210, -225)
player2.set_size(.5)
player2.flip_right_left()
barrier = codesters.Line(0, 250, 0, -250, "gray")
barrier.set_gravity_off()
net = codesters.Rectangle(0, -210, 20, 80, "darkgray")
net.set_gravity_off()
player1_area = codesters.Rectangle(-130, -250, 235, 10, "purple")
player1_area.set_gravity_off()
player2_area = codesters.Rectangle(130, -250, 235, 10, "blue")
player2_area.set_gravity_off()


def w_key():
    player1.move_up(30)
    # add other actions...


stage.event_key("w", w_key)

import codesters

stage = codesters.Environment()

sky = codesters.Rectangle(0, 0, 510, 510, 'lightblue')
sky.set_gravity_off()
sky.cannot_collide()

floor = codesters.Rectangle(0, -250, 500, 20, 'grey')
floor.set_gravity_off()
floor.cannot_collide()

back = codesters.Sprite('backboard', 200, -160)
back.set_gravity_off()
back.set_size(0.5)
back.cannot_collide()

hoop = codesters.Sprite('hoop', 170, -150)
hoop.set_gravity_off()
hoop.cannot_collide()
hoop.set_size(0.5)
hoop.is_goal()

ball = codesters.Sprite('basketball')
ball.set_size(0.4)
stage.set_gravity(10)

score = 0
t = codesters.Text('0', 200, 200)

Beispiel #6
0
## FROGGER BY SHIRLEY
## LOCATED HERE: https://www.codesters.com/preview/86a38f1a916adbfd928e4b4d54c758e2782f115a/

import codesters
stage = codesters.Environment()

start_ground = codesters.Rectangle(0, -240, 500, 25, "darkgreen")

mid_ground = codesters.Rectangle(0, 0, 500, 25, "darkgreen")

end_ground = codesters.Rectangle(0, 240, 500, 25, "darkgreen")

global frogger  # GLOBALS
frogger = codesters.Sprite("", 0, -250)
frogger.set_size(0.5)
print frogger.modes

# barrier = codesters.Line(-220, 248, -220, -248, "black")
# barrier2 = codesters.Line(220, 248, 220, -248, "black")

for counter in range(-200, 0, 50):
    road = codesters.Rectangle(0, counter, 500, 20, "gray")
    road.set_opacity(.2)  # IS OPACITY STILL NOT WORKING?

for counter in range(50, 250, 50):
    pond = codesters.Rectangle(0, counter, 500, 20, "blue")
    pond.set_opacity(.2)  # IS OPACITY STILL NOT WORKING?

global make_lilypad

Beispiel #7
0
    elif stage.click_x() < 250 - block_width:
        is_drawing = sprite.get_pen_down()
        if is_drawing:
            sprite.pen_up()
        if not is_drawing:
            sprite.pen_down()
stage.event_click(click)

def mouse_move():
    x = stage.mouse_x()
    y = stage.mouse_y()
    sprite.set_position(x, y)
    # add other actions...
stage.event_mouse_move(mouse_move)

finish_bg = codesters.Rectangle(-150, -225, 100, 30, None, "black")
finish_btn = codesters.Text("Done drawing?", -150, -225)
finish_btn.set_size(.7)

def click_finish():
    sprite.pen_up()
    print("done")
    announcer.say("Time to guess!")
    stage.wait(1)
    guess = " "
    while guess != word:
        stage.wait(1)
        guess = announcer.ask("What is the word?")
        if guess != word:
            announcer.say("Sorry, that's wrong!")
        else:
Beispiel #8
0
# Score setup
score = 0
score_display = codesters.Text("Flappy Points: ", 0, 200, "white")

game_over = False
pipe_list = []


def space():
    sprite.jump(flappiness)
    # add other actions...


stage.event_space_key(space)

floor = codesters.Rectangle(0, -240, 500, 20, "black")
floor.set_gravity_off()


def interval():
    global score
    if not game_over:
        bottom_pipe = codesters.Rectangle(250, 0, 100, 400, "grey")
        bottom_pipe.set_x_speed(-pipe_speed)
        bottom_pipe.set_gravity_off()
        pipe_height = random.randint(-100, 100)
        bottom_pipe.set_top(pipe_height)
        pipe_list.append(bottom_pipe)

        top_pipe = codesters.Rectangle(250, 0, 100, 400, "grey")
        top_pipe.set_gravity_off()
Beispiel #9
0
import codesters
stage = codesters.Environment()

sky = codesters.Rectangle(0, 0, 510, 510, 'skyblue')
sky.collision_off()
sky.gravity_off()

ground = codesters.Rectangle(0, -250, 510, 20, 'green')
ground.collision_off()
ground.gravity_off()

flowers = []
for i in range(10):
    x = i * 230 - 200
    flower = codesters.Sprite('flowers', x, -240)
    flower.collision_off()
    flower.gravity_off()
    flowers.append(flower)

# Make a character, we'll use a fox
global fox
fox = codesters.Sprite('fox', -200, 0)

# Add some gravity so our fox doesn't float away
stage.set_gravity(15)
stage.set_bounce(0.3)


# Let's make the fox jump if you push the space bar
def space_key():
    fox.jump(20)