Esempio n. 1
0

def fire():
    ship.fireBullet()


def quit():
    turtle.goto(0, screenMaxY - 100)
    turtle.color('green')
    turtle.write("Thanks for playing!", font=("Arial", 30), align="center")
    sleep(1)
    exit()


turtle.hideturtle()

screen.tracer(0);

screen.onkey(turnLeft, 'Left')
screen.onkey(turnRight, 'Right')
screen.onkey(go, 'Up')
screen.onkey(fire, 'x')
screen.onkey(quit, 'q')
screen.listen()

play()

screen.mainloop()

print("Done")
Esempio n. 2
0

def fire():
    ship.fireBullet()


def quit():
    turtle.goto(0, screenMaxY - 100)
    turtle.color("green")
    turtle.write("Thanks for playing!", font=("Arial", 30), align="center")
    sleep(1)
    exit()


turtle.hideturtle()

screen.tracer(0)

screen.onkey(turnLeft, "Left")
screen.onkey(turnRight, "Right")
screen.onkey(go, "Up")
screen.onkey(fire, "x")
screen.onkey(quit, "q")
screen.listen()

play()

screen.mainloop()

print("Done")
Esempio n. 3
0

#Lager lamper
a = Lampe()
b = Lampe()

# Lager skilpadder
a.lag_skilpadde()
b.lag_skilpadde()

a.turtle.forward(100)
b.turtle.backward(100)

#Skru på B


def ff_pa_aav(tut, paa_av):
	def factory_slaa():
		def slaa():
			tut.slaa_ + 'paa_av'+ ()
		return slaa_ + 'paa_av'
	

s.onkey(ff_pa_aav(a, 'paa'), 'a')
s.onkey(ff_pa_aav(a, 'av'), 'z')

s.onkey(ff_pa_aav(b, 'paa'), 's')
s.onkey(ff_pa_aav(b, 'av'), 'x')
s.listen()

s.mainloop()
    draw_triangle(d * 2)

    jack.right(90)
    jack.forward(d * 2 - d / 3)
    jack.left(90)
    draw_triangle(d * 3)


def go_forward():
    jack.forward(10)


def go_backward():
    jack.backward(10)


def go_left():
    jack.left(90)


def go_right():
    jack.right(90)

screen.onkey(draw_pine_tree, "p")
screen.onkey(go_forward, "Up")
screen.onkey(go_backward, "Down")
screen.onkey(go_left, "Left")
screen.onkey(go_right, "Right")

screen.listen()
screen.mainloop()
Esempio n. 5
0
from food import Food
from scoreboard import Scoreboard
import time

screen = Screen()
screen.setup(width=600, height=600)
screen.bgcolor("black")
screen.title("Snake Game")
screen.tracer(0)

snake = Snake()
food = Food()
scoreboard = Scoreboard()

screen.listen()
screen.onkey(snake.up, "Up")
screen.onkey(snake.down, "Down")
screen.onkey(snake.left, "Left")
screen.onkey(snake.right, "Right")

game_on = True

while game_on:
    screen.update()
    time.sleep(0.1)

    snake.move()

    # Detect food collision
    if snake.segments[0].distance(food) < 15:
        food.refresh()
Esempio n. 6
0
from ball import Ball
from paddle import Paddle
from scoreboard import Scoreboard

screen = Screen()
screen.setup(width=800, height=600)
screen.bgcolor("black")
screen.title("Pong")
screen.tracer(0)

r_paddle = Paddle((350, 0))
l_paddle = Paddle((-350, 0))

screen.listen()
screen.onkey(r_paddle.go_up, "Up")
screen.onkey(r_paddle.go_down, "Down")
screen.onkey(l_paddle.go_up, "w")
screen.onkey(l_paddle.go_down, "s")

ball = Ball()
scoreboard = Scoreboard()

game_is_on = True
while game_is_on:
    time.sleep(ball.move_speed)
    screen.update()
    ball.move()
    # Detecting the collision with the wall
    if ball.ycor() > 280 or ball.ycor() < -280:
        ball.bounce_y()