Detecting actors which are next to one another... like Candy Crush/Bejeweled?

TomCoffeeTomCoffee Member, PRO Posts: 175
Hi...

I've been thinking about this for a while and haven't come up with a great method... Is there a way you can think of to have one actor know if there is another actor next to it? Or touching on a certain side?

I've looked at templates, poked around the forum and run Google searches galore... what am I missing? I think the key is the process would have to run (or the actor would have to sense it) without a user's touch being involved.

Any ideas?

Comments

  • SolarPepperStudiosSolarPepperStudios Member Posts: 754
    @TomCoffee I'm with ya on this. :) I need the same thing, only I'm going to use it to make my level infinite. (When the actor gets near the end of the scene it adds to the length.)
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    I think someone here has done a bejeweled style game using tables, anyone else remember that?
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    @TomCoffee -- In other implemetations its all done with arrays. In GameSalad, it would be done with tables. You need to make a table and check each cell against its neighbors. The stuff on the screen would be a representation of the status of each cell in the table.
  • ElfizmElfizm Member Posts: 489
    So for example each actor is given a own unique ID. Using tables that information is stored. It also has two other attributes, col and row. This tells it where it is on the game and where it is on the table.

    Now, if table value is 1, it means it's a yellow actor, 2 is green ect (or what type an actor is, you choose what you want those values to equal)

    On each actor have an Detector attribute, integer in which that number can be changed depending on what actor your looking for.

    To find one next to the one you touched, (or an event or continuous you just get rid of the of touch is pressed)

    When touch is pressed, (if your doing it)
    Another rule added with "any of these happen then"

    If self.detector is equal to Tablevalue(table1,self.row+1,self.col)
    Or
    Tablevalue(table1,self.row-1,self.col)
    Or
    Tablevalue(table1,self.row,self.col+1)
    Or
    Tablevalue(table1.self.row,self.col-1)


    Then do event you want to happen.

    Self.detector is used to get the value needed to check. If you want to know if a value 1 (could mean a yellow actor) is near change it to 1. It will then, when press check if there is one next to.

    If you only want one direction, get rid of some of the tablevalue rules as needed.

    Hope this helps a bit if not too confusing

    Elfizm
  • TomCoffeeTomCoffee Member, PRO Posts: 175
    Cool, thanks! I was thinking about the table method but figured the actions of detecting values and then "deleting" them and making all the values drop down one or two levels (like candy crush) would be nightmarish...

    And.. I still think it might be.. heh.

    Hmm. There's no way for an actor to tell which direction it's being touched (collided) on by another actor, is there?
  • ElfizmElfizm Member Posts: 489
    To tell you know, there is a free demo of actors falling down that I worked with and added the above to make a clone version if a similar game. It is possible.

    To collide,
    You can say this, if it's your main actor that is colliding, when collide with another object, change the positions of that actor to game.attributes.

    Then if self.cloakroom minus game.otherxposition is less then 0

    Then direction is going to be right.

    If it's more then 0 it's going to be left.

    Same principle applies for Y axis.

    Is that what you mean, having a main actor?
Sign In or Register to comment.