jump game

Hi guys! I would like to randomize the images from my platforms, every time I start the game again, the platform randomize the image. Does anyone know how to do this?

only the images, I do not want to change their position :smiley:

Thanks a lot,
Sinha. :blush:

The simplest way to do this is probably to put all the different images into your platform object as separate animations and then randomly pick an animation in the"At the beginning of the scene" event by using the random function with the animation setting action.

Do =Random(5) to the number of current animation of Platform

If you had six different platform images, that would randomly set every platform to one of those six images, but do you actually want to have all the platforms set to the same randomly chosen image? If so, use two actions and add a scene variable to record which image/animation will be used:

Do =Random(5) to the scene variable pickplatform
Do =Variable(pickplatform)to the number of current animation of Platform

If you have multiple platform types as different objects then just add extra animation changing actions:

Do =Random(5) to the scene variable pickplatform
Do =Variable(pickplatform)to the number of current animation of Platform
Do =Variable(pickplatform)to the number of current animation of Platform2
Do =Variable(pickplatform)to the number of current animation of Platform3

Or create a group with all the platform objects in it e.g. allplats and reference that:

Do =Random(5) to the scene variable pickplatform
Do =Variable(pickplatform)to the number of current animation of allplats

Oh! Thanks, i will try.

So… i have another question about the camera,
how to use the camera with limits? I have no idea how to use the expressions to do this…

Note that the code explained above must be run separately for each platform, otherwise a random animation will be selected but every platform will use the same random value :slight_smile:

You’ll need a for-each loop event:

[code]Conditions: At the beginning of the scene
Actions: No actions

    // Sub-event
    For each Platform:

            // Sub-sub-event
            Conditions: No conditions
            Actions: Do = Random(3) to the animation of Platform[/code]

(Assuming there’re 4 animations).

For the limits, they are global values, for example is the left limit is 0 the camera won’t be able to move to the left passing the 0, which is the scene origin point in X (where the black rectangle starts). The same for the other values, explained with images here: [url]Besoin d'une équipe pour votre projet de jeu?]

Thank you very much! is working perfectly! Thanks! <3

Guys, I need your help on my platforms animations.
In the game the character jumps all the time, he is never stopped, so i was trying to make every time he touches the platform, the platform make an animation and then stop, but it did not work …
So… I would like to do this:
When the character is on the platform, the platform makes an animation that stops when it is completed.

I thought that, but when I tried it, the single action “Do =Random(5) to the number of current animation of Platform” picks a different random number for each instance, even without a for-each loop.

These screenshots are from two different previews:
randplat1.png

randplat2.png

Any idea?

Make sure the animation set NOT to loop.
In order to change and play the animation only once when the player colliding with the platform for the first time, try checking the animation number.

Something like this.

Condition

Player is in collision with the Platform Player is on Floor (I would think the platform is a floor object too) X position of Player is > Platform.X() (in case platform is not a floor) Animation of Platform is != 1 [/b]

Action

Do = 1 to Animation of Platform Play animation of Platform (in case it is not playing)

If you want the animation to play each time player touch the platform also if jumping, use Trigger Once instead of Animation check

Condition

Player is in collision with the Platform Player is on Floor (I would think the platform is a floor object too) X position of Player is > Platform.X() (in case platform is not a floor) Trigger Once [/b]

Action

Play Animation of Platform

Something along these lines.

i tested this, but the animation play just one time, and when the player touch again the platform, the animation not working,
so i thought: maybe it’s because the animation end in the last frame, so i added a new action:

Modify the current frame of animation do = 0 to frame of platform

And now its working perfectly!

Thanks a lot!

Mmmh, I see, the generated code is clean and use random per-instance, cool :slight_smile:
It even reads object properties per-instance, I think it didn’t work this way before, when was it updated? :stuck_out_tongue:

I just tried it on the last version of GD4 and it does the same thing there too, so it’s not a new thing in 5.

Haha, maybe it was updated years ago! (I’m using it from 2010 and never checked it again)… or it always worked and I did some mistakes back then :neutral_face: