Is this possible with Gamesalad?
Hi,
If I had an image that I placed in the game area of GameSalad, could I randomly generate objects to appear on that picture?
I wanted to randomly generate objects in each level in that picture.
Thanks
Best Answers
-
natzuur Posts: 304
And i'm guessing you don't want repeats or overlaps? I would do a table system with the positions written into cells.
So column 1-10 would be sets and under each column the rows would be the positions you decide. Lets call the table Gamedata.
so column 1 could be position 1,3,2,5,6,7,4,8,10,9
and column 2 could be position 1,9,8,7,6,5,4,3,2,10
etc, etc.When a scene starts, do:
change attribute Game.PosColumn to a random (1,10).
And then assign each spawn actor some rows to reference, so Spawn A is always using row 1/2 (x,y).
So on Spawn A:
constrain Self position X to tablcellvalue(GameData,1,Game.poscolumn) constrain Self position Y to tablcellvalue(GameData,2,Game.poscolumn)
OR on Spawn B:
constrain Self position X to tablcellvalue(GameData,3,Game.poscolumn) constrain Self position Y to tablcellvalue(GameData,4,Game.poscolumn)
Now to prevent repeats you could do a second change on scene end
This one is
change attribute Game.LastCol to Game.PosColumn
And then a couple rules
When Game.PosColumn = Game.LastCol And Game.PosColumn =/= 10 Change Attribute Game.PosColumn to Game.LastCol+1 When Game.PosColumn = Game.LastCol And Game.PosColumn = 10 Change Attribute Game.PosColumn to Game.LastCol-1
at the start.
Answers
Thanks! @Socks
Any ideas on how to accomplish this?
Place a background image into your scene, then spawn actors over that image.
Ah, you gotta admire @Socks' sayin' it like it is!!
@allc1865 I guess patience is needed to answer obvious and basic stuff sometimes - your answer is right there in the Spawn behaviour - in it, is included Layer Order, where you can choose in front of actor, in back of actor, front of layer or back of layer.
Also your heading to your thread - "Is this possible with Gamesalad?" is devoid of information to let anyone know what your question is. Surely with 508 posts under your belt, you've read a few other posts were people have been asked to make their titles more meaningful...you should do the same in future, to help you, and to help the helpers.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
I like to see meaningful questions as every bit as important as meaningful answers
I could be wrong, but he doesn't mention layers anywhere in his post ? Maybe you read the "I wanted to randomly generate objects in each level in that picture" as meaning he wanted to place objects in different layers (you might, of course, be right), but I read 'levels' as 'game levels', as in "you've completed level 4, now progress to level 5!" . . . level 4 has 9 objects, if you spot them all or shoot them all or collect them all, you progress to level 5 where another 7 objects are added . . . . .
But ultimately these kinds questions are so vague as to invite guesswork.
Yes, but as you know, one of the options in Layer Order refers to placement of the spawned image in front of actor. Which is what @alc1865 was asking...
I guess my way of thinking isn't the same wavelength as yours sometimes, @Socks
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Hi @socks, @gyroscope -
Thanks for the replies. I thought I had explained it fairly well - sorry about that!
I guess what I pretty much wanted to have happen was, on certain locations of the image, spawn an object, then once you've completed that level, on the next level have those same objects randomly spawned again in certain locations of the image.
I could create this effect by using the spawn actor and using it's X & Y positions to position the objects where I want them, but, on the next level to have them randomly placed in certain locations...I'm not sure how to do.
Thanks for your help!
Like I say I wasn't sure he was wanting to place actors on different layers, guessing that he wanted some kind of layer control from the word 'on' is a guess too far for me
It wasn't impatient, I was simply giving what I thought was the best answer, if someone asks a vague question I think it's best to give a simple answer and not read too much into the question, not to attempt to interpret it too much !
The phrase 'randomly spawned in certain locations' is a little too vague for me, could mean quite a few different things.
Don't know what that means either, I don't think I'm being much help in this thread, lol I'll leave it to others who might be better in tune with the way you explain things.
So when you say random, do you really mean totally random? Or like spot 1,2,3,4,5 where any of the spawns can land on the pre-determined position?
@natzuur, yes!
@natzuur, I mean like what you said, "spot 1,2,3,4,5 where any of the spawns can land on the pre-determined position" - but those spawns shuffle with each level on where they're placed.
For example, there's, say, 10 positions these spawns can be in.
Level 1
spawn A was in position 1
spawn B was in positon 2
spawn C was in position 5
Level 2
spawn A is now in position 3
spawn B is now in position 1
spawn C is now in position 6
@natzuur, hi thank you for the rules!
Where do you get game.PosColumn and game.LastCol? Is that an attribute I have to create?
@natzuur, what I've done is added where I wanted my spawn points to be in my table.
So for spawn A, i've set the coordinates on where I want it spawn (there are three spawn points) and did the same for spawn B, both on the same table.
In spawn A i said:
constrain Self position X to tablcellvalue(GameData,1,Game.poscolumn)
constrain Self position Y to tablcellvalue(GameData,2,Game.poscolumn)
in spawn B I said:
constrain Self position X to tablcellvalue(GameData,4,Game.poscolumn)
constrain Self position Y to tablcellvalue(GameData,5,Game.poscolumn)
spawn B isn't even moving so I'm sure I did something wrong, I'm just not sure what
Nevermind, thanks! Got it to work!
Thanks for your help & the rules!