rotating, destroying actor

skippertechskippertech Member Posts: 67
edited August 2012 in Working with GS (Mac)
Hey guys, i am making a puzzle game, where I have an actor rotating. When the actor rotates, if a certain side of it (mqrked by color) lands next to another. It destroys the actor. Is this possuble to do? It has to be a certain side, lining up with the correct color of another actor... how can this be done?

Comments

  • skippertechskippertech Member Posts: 67
    So if the blue side of the actor lines up with the other blueside..the actor gets destryoed. To clarify
  • skippertechskippertech Member Posts: 67
    Bump
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    One way would be to not think about the color of the sides at all. Instead, think of comparing the rotation of the colliding actors.

    Say for example, that all actors have blue on the right border. If the actor is rotated to 0 then the blue side is on the right. If the actor is rotated to 90 then the blue side is facing up. If the actor is rotated to 180 then the blue side is facing left. And if the actor is rotated to 270 then the blue side is facing down.

    When two actors collide, you would check to see if their angles of rotation are opposite. If they are opposite, then you know that the same side is touching.

    (That make sense in my head! Does it work in practice!?!)
  • skippertechskippertech Member Posts: 67
    One way would be to not think about the color of the sides at all. Instead, think of comparing the rotation of the colliding actors.

    Say for example, that all actors have blue on the right border. If the actor is rotated to 0 then the blue side is on the right. If the actor is rotated to 90 then the blue side is facing up. If the actor is rotated to 180 then the blue side is facing left. And if the actor is rotated to 270 then the blue side is facing down.

    When two actors collide, you would check to see if their angles of rotation are opposite. If they are opposite, then you know that the same side is touching.

    (That make sense in my head! Does it work in practice!?!)
    Definetly making sense, but wouldnt work with my game.there are many shapes, and not all would start with the same exact position. On one blue could be down, and the one next to it the nlue could be on its right side. Until it is rotated and the blue matches the blue. Make sense? there would be a lot of shapes and to get them to matche spme rotate more than the others. Is this possible? It dosent matter if its doffocult
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited August 2012
    Sorry it won't work for you.

    The only other way I can think of is to constrain colored actors to the sides of the shapes -- so that you could check to if certain colored actors are colliding.

    Hmmm..... by "many shapes" do you mean different kinds of shapes? Or do you mean that there are many actors -- each with the same basic shape and color scheme, but with different starting rotations and positions? What does "many shapes" mean?
  • skippertechskippertech Member Posts: 67
    Many shapes, all the same shape tho.. like lets say a triangle.. with a red, blue and green side. Rotates and matches with another triangle with the same color scheme. And their blue side both line up.

    I was just paranoid spmeone would take my idea so i said as little as possible about my game xD

    Constraing actors could work, only could i have them rotate in groups or if one rptates do i have to set it so they all rotate. Because i am going to have a lot of shapes, that would be a pain.

    My idea is to have the triangle actor, then on each of the three edges put a small transparent actor along the side. So when that actor lines up with the one its identical to it destroys the actor..the question is can i get all the other transparent actors to stay and rotate with the triangle actor?


    Thanks. Youve been a so helpful

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    OK -- I understand a little better. It sounds like all the shapes are instances of the same actor prototype. (They are all instances of the same triangle actor.) If that's the case, then my first suggestion still goes.

    In my head it goes something like this -- if two actors collide, subtract the rotation of one actor from the rotation of the other actor. If the answer = 180 then they are opposite (and therefore the same colored sides are touching).
  • skippertechskippertech Member Posts: 67
    that sounds okay. but how was my first idea...


    My idea is to have the triangle actor, then on each of the three edges put a small transparent actor along the side. So when that actor lines up with the one its identical to it destroys the actor..the question is can i get all the other transparent actors to stay and rotate with the triangle actor?
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Your first idea is technically do-able. However, constraining at least three actors to a central actor can really start sucking up the processing power. And the frame rate starts to go south pretty quickly. Just 10 puzzle pieces would really translate into 40 actors and 60 constrain behaviors. The FPS will drop to 20 (or lower) on older devices. (Anything under 30 FPS is fairly noticeable.)

    On the other hand a simple subtraction upon collision is almost effortless for GameSalad.
  • skippertechskippertech Member Posts: 67
    ah I see what you mean, but each piece will be positioned differently through out the screen, so some will have to rotate more to collide with the correct color then others. Get what I mean?

    on a side note, what is constraining an actor?
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    By constraining actors, I meant using a constrain behavior to constantly update an actor's X coordinate, Y coordinate, and rotation -- to another actor's x, y and rotation. It will constantly do it just fast as the processor will go.

    In addition, each constrain behavior would need to do some trig calculations.
  • skippertechskippertech Member Posts: 67
    ah I see what you mean, but each piecemeal will be positioned differently through out the screen, so some will have to rotate more to collide with the correct color then others. Get what I mean?

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Yes, each actor will be positioned in its own place in the scene. All scenes are built this way.

    Do you mean that each actor might be rotated differently? That is also true of any scene.

    And yes, some actors might need to rotate more that others actors.

    Puzzle pieces are supposed to move to different locations and rotate into different orientations. Some will be further away than others. Also, some will need to rotate more than others. This is what makes them puzzle pieces.
  • skippertechskippertech Member Posts: 67
    Yeah thats what i mean, some will be rotated more than others to line up.. make sense? One may have to rptate completly around and anpther may only have to move slightly. How could i acomplish that? Because once they rotate, (they get rotated by the player) they should line up with the same color from another piece. Which then the two actors would destroy. What i need tp aconplish is when blue from one piece collides with another blueside. It destroys.. regardless of hpw each of the twp rptate..rotate haha make sense?
  • skippertechskippertech Member Posts: 67
    Yeah thats what i mean, some will be rotated more than others to line up.. make sense? One may have to rptate completly around and anpther may only have to move slightly. How could i acomplish that? Because once they rotate, (they get rotated by the player) they should line up with the same color from another piece. Which then the two actors would destroy. What i need tp aconplish is when blue from one piece collides with another blueside. It destroys.. regardless of hpw each of the twp rptate..rotate haha make sense?
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Here is a thread with a download from tshirtbooth. He is an expert on this kind of thing. I'd suggest studying the demo thoroughly. It will teach you how to move and rotate your puzzle pieces.

    http://forums.gamesalad.com/discussion/38050/how-to-move-from-center-and-rotate-from-the-sides-with-touch-anyone-have-this-template
Sign In or Register to comment.