Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

understanding the code a little #19

Open
AlenToma opened this issue Nov 10, 2022 · 1 comment
Open

understanding the code a little #19

AlenToma opened this issue Nov 10, 2022 · 1 comment

Comments

@AlenToma
Copy link

Hi, I am looking at your code and trying to understand how and where you convert the mp3 file to a readable notes and convert them to balls

could you please try and explain this.

I Opened an issue on stackoverflow about this, it would be great help if you could have a little time to explain this.

@pspeter
Copy link
Owner

pspeter commented Nov 11, 2022

Hey Alen!
We would have loved to do something like that back when we created this, but to be honest, it would've been way to complex for this project. We hacked this game together for a university project, and only had like four days of time. The balls are just generated randomly, with no real correlation to the music. You can find the spawn logic here:

private void spawnBalls() {
float randFloat = _rand.nextFloat();
final int ballY = BALL_INITIAL_Y;
int ballX = _gameWidth / 3 / 2;
spawnBall(_ballsLeft, randFloat, ballX, ballY);
randFloat = _rand.nextFloat();
ballX = _gameWidth / 2;
spawnBall(_ballsMiddle, randFloat, ballX, ballY);
randFloat = _rand.nextFloat();
ballX = _gameWidth - _gameWidth / 3 / 2;
spawnBall(_ballsRight, randFloat, ballX, ballY);
}
private void spawnBall(List<Ball> balls, float randFloat, int ballX, int ballY) {
if (randFloat < _spawnChance_normal) {
balls.add(0, new Ball(ballX, ballY, Ball.BallType.Normal));
} else if (randFloat < _spawnChance_oneup) {
balls.add(0, new Ball(ballX, ballY, Ball.BallType.OneUp));
} else if (randFloat < _spawnChance_multiplier) {
balls.add(0, new Ball(ballX, ballY, Ball.BallType.Multiplier));
} else if (randFloat < _spawnChance_speeder) {
balls.add(0, new Ball(ballX, ballY, Ball.BallType.Speeder));
} else if (randFloat < _spawnChance_bomb) {
balls.add(0, new Ball(ballX, ballY, Ball.BallType.Bomb));
} else if (randFloat < _spawnChance_skull) {
balls.add(0, new Ball(ballX, ballY, Ball.BallType.Skull));
}
}

If you have any other questions I'm happy to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants