86 lines
3.8 KiB
Python
86 lines
3.8 KiB
Python
|
import random
|
||
|
import time
|
||
|
global HASHGAME
|
||
|
global HASHBASE
|
||
|
global SOUND
|
||
|
global currentspeed
|
||
|
global debounce
|
||
|
global speedincrease
|
||
|
ball = HASHGAME.getobjbySID("jYFrLyJBVMJgBfPPalVcUImJLUbVmiNmtzHoZdGLPaTQvAVMAlSVMOlUtrWiFtSybxtdXrxqqiVSGMOFPBwltyqmpwEIFxwrnErQuLVnMCWtMHKqpzGohWKeylyVWlApeCtDKTuVwzqbYNleAtjYjVPqmXONSxPabToIiKzUVgmdJPgvERSVAkjqtHzbBPpTGdCvhzqbPUrILjSroXLJdtjXeNyAsGIxSTVITUawNpwhFsGwCXVphjHtzereFBd")
|
||
|
upperobj1 = HASHGAME.getobjbySID("OspxVXZmVoEVdlfswQNBRXEXAPrErOJXZRWfIQEmGziyXbzQXFmVgWJNLIzvgAjkQrZydGYkDFBVhrbciwOqzlFJWSOeAwcqmitVxfeUPuUIQralBzAfXeaVZzpUwhsWBKXPlhALyeByTaWcsDUITulskyqxcrYiLNNQGaEZJxyIAaxqnIMoktHvIkTmfGzXXeYAIkjyKEWjhkJzxxmMWJjCpPQkBJBLagKYTWDPUxXRxahljZCUpnVmqnOOUGQ")
|
||
|
lowerobj1 = HASHGAME.getobjbySID("lQwOxmoKQUhilJgPARdJEcJLwOgnHnyJDxiFBgBSNmQXWHzeDvgGUaTvnkIGlCHJkvOHOAQklmCfftvXmkBMbopIZJMLSdcYOuvFWPyaNVZqZRMNJKNyaPLAwHoFLtjQWSAJfZoZqbQknmwhOoMIZpaumDRYFSNzqTvOzklUlAbcLDMRialZTlAFQLLHxECQhxwwkTDinnkIExaOWMUzlrrNdGwNHTLGxcBvJkUWbZYkRGNwwoPMIykQIcwgybj")
|
||
|
upperobj2 = HASHGAME.getobjbySID("hwDoZwmJeGaHQZecyjBRNWcTJXyFbQexBygreLGQdikUVUldcHyLJChjClstfKWUfkmDVyuBLvWypGifxRsobJSEWkqySvkthlpaNuBgNsEHjBULHILeNythkyTyHRWODZfZYCWWFsQQssKjwQhvcnheiNogPtsNVmSXcRmHnSiklHAtFwdWUDgsguLuBExbMBxMSyVzKuzqeciQRxVpBooptDHBvjfEaBcZOrJMhnIhOovsJhcEJVVRAfrVEYl")
|
||
|
lowerobj2 = HASHGAME.getobjbySID("HbxiUvAmmJdipAAYBaQbwvxOhKQrlCMuOSikBrvCpeRxUBjzDDCxUGWYzlxJqtJtoCNhSKOREArHZwqobbdPjySAcvXJhBSKKZqZqspVggwXywXhRkhZGenYOiheNkFpMBpYOWODCMjifuRJIjYfNFFODKScnoxleYiMbtVkuCkGhWhLUffepdmZKaVxbtvLdOTyIamHTKYlwPrtenszbwzTohjELaiYGtFhSgZAShNqXRSvUwZQKJHMzDCIxaH")
|
||
|
hitsound = SOUND(HASHGAME.sounds["ponghit"])
|
||
|
wonsound = SOUND(HASHGAME.sounds["won"])
|
||
|
lowerbound = 0
|
||
|
upperbound = 9
|
||
|
player1border = 0
|
||
|
player2border = 19
|
||
|
speedincrease = 0.1
|
||
|
debounce = False
|
||
|
currentspeed = speedincrease
|
||
|
def init():
|
||
|
global currentspeed
|
||
|
currentspeed = speedincrease
|
||
|
ball.velocity = HASHBASE.vector2(0.1, random.uniform(-0.5, 0.5))
|
||
|
ball.position = HASHBASE.vector2(9, 4)
|
||
|
|
||
|
def handleplayerhit():
|
||
|
global currentspeed
|
||
|
global debounce
|
||
|
hitsound.stop()
|
||
|
hitsound.play()
|
||
|
if debounce == True: return
|
||
|
debounce = True
|
||
|
if currentspeed > 0:
|
||
|
ball.position.x = player2border-1
|
||
|
ball.velocity.x = -currentspeed
|
||
|
ball.velocity.y = random.uniform(-0.5, 0.5)
|
||
|
currentspeed = -currentspeed
|
||
|
#ball.position.x = player2border-1
|
||
|
else:
|
||
|
ball.position.x = player1border+1
|
||
|
ball.velocity.x = -currentspeed
|
||
|
ball.velocity.y = random.uniform(-0.5, 0.5)
|
||
|
currentspeed = -currentspeed
|
||
|
#ball.position.x = player1border+1
|
||
|
speedincreasefunc()
|
||
|
debounce = False
|
||
|
|
||
|
def speedincreasefunc():
|
||
|
global currentspeed
|
||
|
if currentspeed > 0:
|
||
|
ball.velocity.x = currentspeed+speedincrease
|
||
|
currentspeed += speedincrease
|
||
|
else:
|
||
|
ball.velocity.x = currentspeed-speedincrease
|
||
|
currentspeed -= speedincrease
|
||
|
|
||
|
#ball._touching.attach(handleplayerhit)
|
||
|
init()
|
||
|
|
||
|
while True:
|
||
|
if ball.position.y > upperbound:
|
||
|
hitsound.stop()
|
||
|
hitsound.play()
|
||
|
ball.velocity.y = -ball.velocity.y
|
||
|
ball.position.y = upperbound-1
|
||
|
speedincreasefunc()
|
||
|
if ball.position.y < lowerbound:
|
||
|
hitsound.stop()
|
||
|
hitsound.play()
|
||
|
ball.velocity.y = -ball.velocity.y
|
||
|
ball.position.y = lowerbound+1
|
||
|
speedincreasefunc()
|
||
|
if ball.position.x > player2border or ball.position.x < player1border:
|
||
|
if not HASHGAME.between(upperobj1.position.y, lowerobj1.position.y, ball.position.y) and not HASHGAME.between(upperobj2.position.y, lowerobj2.position.y, ball.position.y):
|
||
|
wonsound.stop()
|
||
|
wonsound.play()
|
||
|
ball.position = HASHBASE.vector2(99, 99)
|
||
|
ball.velocity = HASHBASE.vector2()
|
||
|
time.sleep(3)
|
||
|
init()
|
||
|
else:
|
||
|
handleplayerhit()
|
||
|
time.sleep(0.5)
|