How to randomly change position using tables
hello gurus,
im struggling with this issue:
i have a scene and outside the scene i have 1 actor 6 times so basically the same actor with 6 different pics which are my buttons.
i need to make them appear randomly on the scene at 6 specific positions when the game starts, so i created a table with 2 columns x,y(real attributes) and wrote the 6 different positions ex: x:80- y:100. Then at each actor i used the Interpolate behavior with:
self.Position.X --> tableCellValue( game.Tb Button Position ,1, game.spawn point ) 1 corresponds to x position of the table
self.Position.Y -->tableCellValue( game.Tb Button Position ,2, game.spawn point ) 2 corresponds to Y position of the table
My problem is now that the actors appear on the scene randomly but ALL in the SAME position.
Any suggestions in order to make them take different positions from the table?? I need to create another table with the ids of those positions??
Any help will be VERY appreciated!!!
im struggling with this issue:
i have a scene and outside the scene i have 1 actor 6 times so basically the same actor with 6 different pics which are my buttons.
i need to make them appear randomly on the scene at 6 specific positions when the game starts, so i created a table with 2 columns x,y(real attributes) and wrote the 6 different positions ex: x:80- y:100. Then at each actor i used the Interpolate behavior with:
self.Position.X --> tableCellValue( game.Tb Button Position ,1, game.spawn point ) 1 corresponds to x position of the table
self.Position.Y -->tableCellValue( game.Tb Button Position ,2, game.spawn point ) 2 corresponds to Y position of the table
My problem is now that the actors appear on the scene randomly but ALL in the SAME position.
Any suggestions in order to make them take different positions from the table?? I need to create another table with the ids of those positions??
Any help will be VERY appreciated!!!
Comments
I would create a Game attribute RandomRow and in your game have a Scene controller that sets Game.RandomRow to random(1,10) ...
I would then create 2 tables one for X values one for Y. Each with 6 columns and 10 rows (10 more or less this is up to you).
In each row enter your six X values (and Y in other table). Do the same for each row and mix them up so it could be Row1 400,390,32,86,222,316 Row2 180,310 .... etc
then your X statement would be: self.Position.X --> tableCellValue( game.TableX ,self.WhatNumberamI, game.Game.RandomRow) do the same for Y
I think that should give you great randomness without two of the same positions being chosen (which could happen if you were using random in other ways.
thanks a lot i ll try your suggestion .... and i ll post the result
thanks again!
well, this suggustiond did the trick almost....
the actor(1 but 6 times so 6 actors) did get different positin with tableX and tableY but many times the actor(1 but 6 times so 6 actors) may have the same position....
how can i assure that the actor(1 but 6 times so 6 actors) dont have the same position ?
thanks again ...
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS