jumpers are now random. ball now goes toward the last person who won and the direction is random
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/09/13 16:20:58 by tomoron #+# #+# #
|
# Created: 2024/09/13 16:20:58 by tomoron #+# #+# #
|
||||||
# Updated: 2024/09/25 16:32:24 by tomoron ### ########.fr #
|
# Updated: 2024/09/25 17:08:55 by tomoron ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -37,14 +37,14 @@ class Game:
|
|||||||
{ "type":2, "pos": {"x": -1, "y": 0, "z": 1}, "isUp": True}
|
{ "type":2, "pos": {"x": -1, "y": 0, "z": 1}, "isUp": True}
|
||||||
]
|
]
|
||||||
jumpersPos = [
|
jumpersPos = [
|
||||||
# { "type":1, "pos":{"x": -1.5, "y": 0.2, "z":mapLength/4}, "isUp": False },
|
{ "type":1, "pos":{"x": -1.5, "y": 0.2, "z":mapLength/4}, "isUp": False },
|
||||||
# { "type":1, "pos":{"x": -1.5, "y": 3.2, "z": mapLength / 4}, "isUp": True },
|
{ "type":1, "pos":{"x": -1.5, "y": 3.2, "z": mapLength / 4}, "isUp": True },
|
||||||
{ "type":1, "pos":{"x": 1.5, "y": 0.2, "z": mapLength / 4}, "isUp": False },
|
{ "type":1, "pos":{"x": 1.5, "y": 0.2, "z": mapLength / 4}, "isUp": False },
|
||||||
# { "type":1, "pos":{"x": 1.5, "y": 3.2, "z": mapLength / 4}, "isUp": True },
|
{ "type":1, "pos":{"x": 1.5, "y": 3.2, "z": mapLength / 4}, "isUp": True },
|
||||||
# { "type":1, "pos":{"x": -1.5, "y": 0.2, "z": -mapLength / 4}, "isUp": False },
|
{ "type":1, "pos":{"x": -1.5, "y": 0.2, "z": -mapLength / 4}, "isUp": False },
|
||||||
# { "type":1, "pos":{"x": -1.5, "y": 3.2, "z": -mapLength / 4}, "isUp": True },
|
{ "type":1, "pos":{"x": -1.5, "y": 3.2, "z": -mapLength / 4}, "isUp": True },
|
||||||
# { "type":1, "pos":{"x": 1.5, "y": 0.2, "z": -mapLength / 4}, "isUp": False },
|
{ "type":1, "pos":{"x": 1.5, "y": 0.2, "z": -mapLength / 4}, "isUp": False },
|
||||||
# { "type":1, "pos":{"x": 1.5, "y": 3.2, "z": -mapLength / 4}, "isUp": True }
|
{ "type":1, "pos":{"x": 1.5, "y": 3.2, "z": -mapLength / 4}, "isUp": True }
|
||||||
]
|
]
|
||||||
skins = [
|
skins = [
|
||||||
{id: 0, 'color': 0xff53aa, 'texture': None},
|
{id: 0, 'color': 0xff53aa, 'texture': None},
|
||||||
@ -74,6 +74,7 @@ class Game:
|
|||||||
self.ballVel = (self.speed, 0)
|
self.ballVel = (self.speed, 0)
|
||||||
self.score = [0, 0]
|
self.score = [0, 0]
|
||||||
self.obstacles = []
|
self.obstacles = []
|
||||||
|
self.lastWin = 2
|
||||||
|
|
||||||
if(withBot):
|
if(withBot):
|
||||||
self.join(socket)
|
self.join(socket)
|
||||||
@ -101,7 +102,7 @@ class Game:
|
|||||||
self.obstacles.append(x)
|
self.obstacles.append(x)
|
||||||
i = 0
|
i = 0
|
||||||
while(i < len(Game.jumpersPos)):
|
while(i < len(Game.jumpersPos)):
|
||||||
if(random.randint(1, 100) < 101):
|
if(random.randint(1, 100) < 50):
|
||||||
self.obstacles.append(Game.jumpersPos[i])
|
self.obstacles.append(Game.jumpersPos[i])
|
||||||
i+=1
|
i+=1
|
||||||
i+=1
|
i+=1
|
||||||
@ -305,6 +306,7 @@ class Game:
|
|||||||
velZ = -velZ
|
velZ = -velZ
|
||||||
else:
|
else:
|
||||||
print("distance :", playerDistance)
|
print("distance :", playerDistance)
|
||||||
|
self.lastWin = 1 if newBallPos[1] < 0 else 2
|
||||||
await self.scoreGoal(1 if newBallPos[1] < 0 else 2)
|
await self.scoreGoal(1 if newBallPos[1] < 0 else 2)
|
||||||
return;
|
return;
|
||||||
elif(newBallPos[0] <= Game.limits["left"] or newBallPos[0] >= Game.limits["right"]):
|
elif(newBallPos[0] <= Game.limits["left"] or newBallPos[0] >= Game.limits["right"]):
|
||||||
@ -316,11 +318,15 @@ class Game:
|
|||||||
self.sendNewBallInfo()
|
self.sendNewBallInfo()
|
||||||
|
|
||||||
def prepareGame(self, stop = False):
|
def prepareGame(self, stop = False):
|
||||||
self.ballPos = {"pos":(0, 6), "up": False}
|
self.ballPos = {"pos":(0, 0), "up": False}
|
||||||
if(stop):
|
if(stop):
|
||||||
self.ballVel = (0, 0)
|
self.ballVel = (0, 0)
|
||||||
else:
|
else:
|
||||||
self.ballVel = (0.50, -1)
|
velX = self.speed * (random.randint(-50, 50) / 100)
|
||||||
|
velZ = self.speed - abs(velX)
|
||||||
|
if(self.lastWin == 2):
|
||||||
|
velZ = -velZ
|
||||||
|
self.ballVel = (velX, velZ)
|
||||||
self.sendNewBallInfo()
|
self.sendNewBallInfo()
|
||||||
self.lastUpdate = time.time()
|
self.lastUpdate = time.time()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user