howdy folks,
im just nearing actually the end of doing a complete remake of my game FRONG. originally it was made in UNITY, but have decided now since im sticking to HAXE/OPENFL, to update the games ive made previous. this being the first.
but FRONG is a 4 player breakout/pong mash-up, so has 4 different scores, but im just having a small bit o’ trouble doing the scores for each individual, plus the ball movement is fun, since its actually not predictable, but would like to make it more fluid and life like per-se
the trouble is actually matching the 4 scores first. so say if the 2nd player gets scored past, id like a point to go to the other 3.
i have tried something like this: but does run up with errors. obviously, i kind of knew it would. but just looking for a way for it to apply to others.
if (ball.y < 5 || ball.y > 795) ballMovement.y *= -1;
if (ball.x > 795) winGame(Human01 || Human03 || Human04);
if (ball.x < 5) winGame(Human02 || Human03 || Human04);
if (ball.y > 795) winGame(Human03 || Human01 || Human02);
if (ball.y < 5) winGame(Human03 || Human01 || Human04);
}
private function winGame(player:Player):Void {
if (player == Human01) {
scorePlayer01++;
} else if (player == Human02) {
scorePlayer02++;
} else if (player == Human03) {
scorePlayer03++;
} else if (player == Human04) {
scorePlayer04++;
}
setGameState(Paused);
}
and lastly. the ball movement is a bit erratic when bouncing off of all paddles, it doesnt have as natural bounce. it could go 1 way or the other. could you show me how to fix this. can see the problem, but cant work out the solution
private function bounceBall():Void {
var direction:Int = (ballMovement.x > 0)?(-1):(1);
var randomAngle:Float = (Math.random() * Math.PI / 3) - 45;
ballMovement.x = direction * Math.cos(randomAngle) * ballSpeed;
ballMovement.y = direction * Math.sin(randomAngle) * ballSpeed;
}
i will be sharing the entire code base once finished. plus will be putting it online for everyone to play as well. maybe on itch.io
plus will actually do the breakout part as well, and add proper 4 player mode too it. its currently just single player
this original tutorial was from the haxecoder one which teaches you pong. but i have then taken it further to completely remake my FRONG project
this is the original inception of it [you do need unity player for it to work. though once this is done,you wont ;)]. enjoy