Skip to content

Commit

Permalink
background music added updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Super-JoConnell committed Aug 17, 2021
1 parent e7024a8 commit 41fcadf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
28 changes: 16 additions & 12 deletions Game Of Pong.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Joconnells Game Of Pong
# Its a work in progress ok
# dont judge

from playsound import playsound
import turtle
import winsound

Expand All @@ -20,6 +20,8 @@

FPS = 30 # constant: refresh about 30 times per second
TIMER_VALUE = 1000//FPS # the timer value in milliseconds for timer events
music = "SFX/background.wav" # music sound file
sfx = "SFX/pop.wav" # sfx location

# Variable

Expand Down Expand Up @@ -103,7 +105,7 @@ def esc_shutdown():

# Main Game Physics for laggy Ball
def move_ball():
global score_1, score_a, should_draw, t, xx, yy, xr, yr # to bring in variables and or constants and edit them in a function box
global score_1, score_a, should_draw, xx, yy, xr, yr # to bring in variables and or constants and edit them in a function box

# Move the ball

Expand All @@ -118,12 +120,12 @@ def move_ball():
if yy > 290:
yy = 290
yr = yr * -1
winsound.PlaySound("SFX/pop.wav", winsound.SND_ASYNC)
playsound(sfx, block=False)

elif yy < -290:
yy = -290
yr = yr * -1
winsound.PlaySound("SFX/pop.wav", winsound.SND_ASYNC)
playsound(sfx, block=False)

if xx > 390:
xx = 0
Expand All @@ -146,33 +148,33 @@ def move_ball():
if xx > 340 and xx < 350 and yy < paddle_r.ycor() +40 and yy > paddle_r.ycor() -40: #collision for side part of paddle
xx = 340
xr = xr * -1
winsound.PlaySound("SFX/pop.wav", winsound.SND_ASYNC)
playsound(sfx, block=False)

elif xx < -340 and xx > -350 and yy < paddle_l.ycor() +40 and yy > paddle_l.ycor() -40: #collision for side part of paddle
xx = -340
xr = xr *-1
winsound.PlaySound("SFX/pop.wav", winsound.SND_ASYNC)
playsound(sfx, block=False)

elif xx > 341 and xx < 360 and yy < paddle_r.ycor() +50 and yy > paddle_r.ycor(): # collision for top of paddle
yy = (paddle_r.ycor() +50)
yr = yr * -1
winsound.PlaySound("SFX/pop.wav", winsound.SND_ASYNC)
playsound(sfx, block=False)

elif xx > 341 and xx < 360 and yy > paddle_r.ycor() -50 and yy < paddle_r.ycor(): # collision for bottom of paddle
yy = (paddle_r.ycor() -50)
yr = yr * -1
winsound.PlaySound("SFX/pop.wav", winsound.SND_ASYNC)
playsound(sfx, block=False)

elif xx < -341 and xx > -360 and yy > paddle_l.ycor() -50 and yy < paddle_l.ycor(): # collision for bottom of paddle
yy = (paddle_l.ycor() -50)
yr = yr * -1
winsound.PlaySound("SFX/pop.wav", winsound.SND_ASYNC)

playsound(sfx, block=False)

elif xx < -341 and xx > -360 and yy < paddle_l.ycor() +50 and yy > paddle_l.ycor(): # collision for top of paddle
yy = (paddle_l.ycor() +50)
yr = yr * -1
winsound.PlaySound("SFX/pop.wav", winsound.SND_ASYNC)
playsound(sfx, block=False)
#winsound.PlaySound("SFX/pop.wav", winsound.SND_ASYNC)

if xx != bxx and yy != byy: # to confirm changes to cordinates position to tell python to draw ball
should_draw = True
Expand All @@ -194,6 +196,8 @@ def draw_ball(): #draws ball


wn.ontimer(move_ball, TIMER_VALUE)
#playsound(music, block=False)
winsound.PlaySound(music, winsound.SND_ASYNC + winsound.SND_LOOP)

while True: # loops forever
draw_ball()
Expand Down
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# Retarded-Pong
A Retarded Version of Pong Coded in Python
# Retarded-Pong
A Retarded Version of Pong Coded in Python using turtle module (not pygame)

Music Produced by Myself as well I'm not great at it just threw something together quickly

w, s, up and down control the paddles 

i created this as part of my learning towards python
next game will be pygame orientated 

dependencies: playsound

to install playsound:

pip install playsound

or

pip3 install playsound

0 comments on commit 41fcadf

Please sign in to comment.