Randomizing background/foreground. I am super lost...

davesubaru

  • Posts: 79
So the game I am making has only one main level. Every time a player starts, I want the background to randomize so the experience is better.

I also have want to randomize a foreground but match with a specific background.

Example: I have 5 backgrounds and 5 foregrounds.

Let's say background randomization works:
If background 1 shows up, I want foreground 1 to show up, Not foreground 2-5.
If background 4 shows up, I want foreground 4 to show up, Not 1-3, and 5.

ggiersdorf

  • Posts: 52
What you need to do in that case is make an actor from the background and create 4 other animations (each a different background).   Create an attribute say "Background" and assign a random number between 1-5 to it in the actor events.

Than do an IF "background"=1 create actor at x=y
You will also need the Change an animation code to whatever you named each animation to..


Unless someone has a better idea.. Thats what I had to do for my game as well.


squeeb

  • Posts: 1617
Here is how i do it,  i used scenes with different background and foregrounds though... random scene is set by
... create number, set number random 1-however many you need... if number = 1 load background and foreground (scene1) if number = 2 load scene 2..ect
ps. i was testing out 2 and 3.. should say random 1-3... also this is a button on main menu.. so when it is clicked this happens... i have the random number set 1-3 in the scene behaviors when scene is created

davesubaru

  • Posts: 79
Here is how i do it,  i used scenes with different background and foregrounds though... random scene is set by
... create number, set number random 1-however many you need... if number = 1 load background and foreground (scene1) if number = 2 load scene 2..ect
ps. i was testing out 2 and 3.. should say random 1-3... also this is a button on main menu.. so when it is clicked this happens... i have the random number set 1-3 in the scene behaviors when scene is created

Yeah I understand multiple scene randomization. But I am stuck on randomizing background + foreground on one main level.

What you need to do in that case is make an actor from the background and create 4 other animations (each a different background).   Create an attribute say "Background" and assign a random number between 1-5 to it in the actor events.

Than do an IF "background"=1 create actor at x=y
You will also need the Change an animation code to whatever you named each animation to..


Unless someone has a better idea.. Thats what I had to do for my game as well.



I've been messing around for quite a while and cannot figure out how you would do it. If it's not much trouble, could you post text or screenshot of how it is done? Thank you in advance.

ggiersdorf

  • Posts: 52
sure here is an old example I used. You dont need the timer or the spawn command but this is an example of how to setup an easy random actor..


davesubaru

  • Posts: 79
sure here is an old example I used. You dont need the timer or the spawn command but this is an example of how to setup an easy random actor..



Finally got it to work. Thank you kind sir! I got the background (actor) to match the foreground (actor) that is needed :). But I had to make separate layers for each foreground (actor) and set the attribute.

But is there an easier way to do this? I want to reduce lag / file size of course.
I didn't want to use the create box for the foreground since I can only choose
front, middle, and back which limits to 3 layers. I need more than that.

« Last Edit: March 19, 2014, 08:40:32 pm by davesubaru »