tayustayus / violin-plot

A python program done to analyze data by plotting graphs.
0 stars 0 forks source link

Ping Pong Game #1

Open tayustayus opened 5 years ago

tayustayus commented 5 years ago

Hello,

I was working on this ping pong game but got stucked along the line.

The paddle were not to drag lines having drop a line of code paddle_a.penup() #and paddle_b.penup()/

Kindly assist.

Eyitayo

ping pong game

import turtle

setup screen

wn = turtle.Screen() wn.title("Ping pong game") wn.setup(width=800, height=600) wn.bgcolor('black') wn.tracer(0) # the tracer updates the screen per time

set up paddle a

paddle_a = turtle.Turtle() paddle_a.speed(0) paddle_a.color("white") paddle_a.shape("square") paddle_a.shapesize(stretch_wid=5, stretch_len=1) paddle_a.goto(-350, 0) paddle_a.penup()

set paddle b

paddle_b = turtle.Turtle() paddle_b.speed(0) paddle_b.color("white") paddle_b.shape("square") paddle_b.shapesize(stretch_wid=5, stretch_len=1) paddle_b.goto(350, 0) paddle_b.penup()

ball = turtle.Turtle() ball.speed(0) ball.color("white") ball.shape("circle") ball.goto(0, 0) ball.penup()

functon

def paddle_a_up(): y = paddle_a.ycor() y += 20 paddle_a.sety(y)

def paddle_a_down(): y = paddle_a.ycor() y -= 20 paddle_a.sety(y)

def paddle_b_up(): y = paddle_b.ycor() y += 20 paddle_b.sety(y)

def paddle_b_down(): y = paddle_b.ycor() y -= 20 paddle_b.sety(y)

main game loop

setkeyboard bindings

wn.listen() wn.onkeypress(paddle_a_up, "w") wn.onkeypress(paddle_a_down, "s") wn.onkeypress(paddle_b_up, "p") wn.onkeypress(paddle_b_down, "l")

while True: wn.update()

tayustayus commented 5 years ago

Hello, I was working on this ping pong game but got stucked along the line. The paddle were not to drag lines having drop a line of code paddle_a.penup() #and paddle_b.penup()/ Kindly assist. Eyitayo