1

Hi!
Can someone help me out on a track that I can walk to the right to the left, so I can make a bonus, but I think it will appear in different parts of the track every 20 seconds?

Thumbs up

2

Hello,
can you please specify a bit what exactly you mean? I understand it as you have a track on whych you want bonus to appear every 20 seconds in different place, am I right?
Greetings

Rastislav

Thumbs up

3

Yes.

Thumbs up

4

Hi,
well, there are few ways to do it. If you have simple sidescroller track with no z axis, it can be done like this:

//main.bgt
timer bonustimer;
int track_length=100, bonus=track_length+20; //we do not want to make bonus spawn on the position of the player, so we move it behind track
...
void game_loop()
{
//this method is called in while cycle, managing the game universe
if (bonustimer.elapsed>=20000) {
bonus=random(0, track_length-1); //placing bonus to the random direction, -1 is here because of possible array system, you can customize it for your programming style
//here you can place a code to update bonus sound position
bonustimer.restart(); //restart timer, if not used, bonus spawns every while cycle period, what we do not need.
}
}

That's simplest possible solution I think. If you want to make spawn more bonuses than one, use array for them and do like in this code, in that case you can easyly controll how many bonuses are on the track, combined with soundpool it gives you a nice ability to controll bonus system.
If your game have also z axis, or in hardest case also y axis (three dimensional surface), you need to also controll platforms location, so you don't spawn bonus to the air, that would be annoing for player. If this is your case, more detayls about used map system are needed, there are more principles how to do maps.

Hope this helps.
Best regards

Rastislav

Thumbs up

5

thanks! And the right one to walk to the right and the left to play in, or when I pick up what it sounds to be. Because you want to add bonuses that give the player power - I could already create a command to enter a box and increase your strength.

Thumbs up