Random spawning on a grid - Help!

So I am trying to get multiple actors to spawn randomly on a grid of pre-determined points and I'm not sure where to even start with this one.

Any help would be appreciated here, and thanks in advance!

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi @gama3 This would be relatively straightforward using a table. Are you used to using tables yet?

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • DevirosDeviros Member, PRO Posts: 87

    @gama3 - I completely agree with @gyroscope - that's the perfect way to do that.

    Here, i've attached a project i threw together real quick for you that demonstrates how to execute it - for a 5x5 grid.

    This is not a SMART project, mind you - you would be best served to also have a table that keeps track of which grid locations are already filled, but this should get you started at least!

    Happy to help if you have any questions =D

  • gama3gama3 Member Posts: 29

    I am currently away from my computer, so I can't try anything yet, but thank you for your responses.

    I am not familiar with tables in Gamesalad @gyroscope.

  • DevirosDeviros Member, PRO Posts: 87

    @gama3 - have a look at the simple project i attached when you get a chance, and see if that helps you at all. I kept it as simple as i could!

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    I have a complete video series on tables on my guru site. Click the link in my signature.

  • elektroformelektroform Member Posts: 7

    @gama3,

    I wrote some logics in: http://forums.gamesalad.com/discussion/90339/randomize-falling-blocks#latest

    maybe that could be helpful.
    take care.
    J

  • gama3gama3 Member Posts: 29

    Thanks for all the help guys, I will check out all the links and tips you guys have sent me.

    @Deviros I downloaded your game file and am looking at the rule in the actor "spawner"
    Could you explain what the change attributes are doing in conjunction with the table you made when the spawner is pressed?

  • DevirosDeviros Member, PRO Posts: 87
    edited December 2015

    Sure.

    The spawner actor stores all the pertinent information for the soon-to-be-spawned object.

    INT_X_Pos_1 and INT_X_Pos_2 represent row and column locations in the table - I apologize for that not being more clear - that's my fault.

    Think of it this way: X_Pos_1 is X_Col and X_Pos_2 is X_Row

    So - they are randomly (using rand) getting a row and column number based on the total number of each available:

    X_Col = random(1,tableColCount( game.TBL_Grid_Locations ))

    And then the new X and Y positions are determined from those values:

    (spawned Object X_Position) = tableCellValue( game.TBL_Grid_Locations , self.INT_X_Pos_2 , self.INT_X_Pos_1 )

    In the new nomencalature, that's:

    (spawned Object X_Position) = tableCellValue( game.TBL_Grid_Locations , self.INT_X_Row, self.INT_X_Col )

    Does that make sense?

  • gama3gama3 Member Posts: 29
    edited December 2015

    So, why does the grid location table have three columns if we are only using x and y coordinates? I'm not totally sure what each column is representing.

    Edit: I think I'm understanding whats going on in your project a little bit now... I'm going to play around with it and see if I can get this to work from scratch now. Thanks for the help everyone, and I will come back here if I have an further questions!

    @Lost_Oasis_Games I really enjoy your youtube videos, they seem like they will be very helpful in the future!

Sign In or Register to comment.