Constrain to circle DEMO

firemaplegamesfiremaplegames Member Posts: 3,211
edited November -1 in Working with GS (Mac)
Hey All,

Here is a demo showing how to constrain the dragging region of an actor to a circular area:

http://gamesalad.com/game/play/71909

This could be used in a variety of ways - limiting the possible distance an actor can move in a turn, limiting the power of a slingshot or projectile, etc., etc...

Feel free to use this in any way you want!

Joe
Fire Maple Games

Comments

  • synthesissynthesis Member Posts: 1,693
    What is your primary behavior controller in that? A magnitude rule set?

    Good demo.
  • LordTarantorLordTarantor Member, PRO Posts: 890
    Hey FMG I want it to tell you last weekend my family and I were going to the movies and we trade it for a tournament night at home playing Danger Cats.
    It all happens because I was searching the forum and I read a post about how good it was. I download the lite and 5 minutes later I was buying the complete one. like in level 10 I stop to make me a cup of coffee, my wife grabs the iphone and start playing, then she did not want to stop. In my house we have an iphone and two ipods I put the game in the 3 devices because my 3 kids wanted to play it to. We were five and there were only 3 devices so we divided the time so everybody played for 10 minutes and pass it, 10 minutes and pass it and so on. Of course that was after everybody got to level 10 because that was the level I was. We spent four hours playing it. It was so funny, I got Silver, almost got gold but went over by 38 seconds...
    Any way, just wanted to share that with you,
    Super nice game...
    Ps- Next weekend will have Stunt Squirrels tournament...
  • firemaplegamesfiremaplegames Member Posts: 3,211
    @synthesis: yes, magnitude combined with sine and cosine to set the position.

    @LordTarantor: Thanks so much! That's so awesome! I'm so glad you guys enjoyed the game! I plan on making the sequel when I finally finish the current game I am working on.

    BTW, You can also play both games for free on www.gamesalad.com in the games section:

    Danger Cats!: http://gamesalad.com/game/play/30122

    Stunt Squirrels!: http://gamesalad.com/game/play/34565
  • A3MGA3MG Member Posts: 152
    Nice work Joe, you certainly have the math stuff down.
  • netdzynrnetdzynr Member Posts: 296
    This is nice, FMG.

    By any chance do you have a GS formula for determining if a point is within a polygonal region? I've been trying to get the following working in GS and have only gotten mixed results. Trying to rewrite it in GS has been a major headache -- I'm wondering if you might have already done something similar. Thanks in advance for any suggestions.

    int pnpoly(int npol, float *xp, float *yp, float x, float y)
    {
    int i, j, c = 0;
    for (i = 0, j = npol-1; i < npol; j = i++) {
    if ((((yp[i] <= y) && (y < yp[j])) ||
    ((yp[j] <= y) && (y < yp[i]))) &&
    (x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i]))
    c = !c;
    }
    return c;
    }
  • firemaplegamesfiremaplegames Member Posts: 3,211
    @netdznr: I'll see what I can come up with...
  • netdzynrnetdzynr Member Posts: 296
    Thanks FMG. I have the above working in Revolution, so I know conceptually it *can* work. But I must not be translating it properly to GS... :-/
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Hey netdzynr,

    I got it working and made a demo here:

    http://gamesalad.com/game/play/71942

    It is definitely a bit tedious to set up the rules, but it is certainly doable. I made a triangle to start with, but a polygon with any amount of sides is possible.
  • netdzynrnetdzynr Member Posts: 296
    Thanks FMG -- I had a feeling this would be up your alley. Looks like you grouped the X and Y checks separately? At any rate, thank you so much. I found another formula for point checking within triangular regions that I got working in GS and I'm sorry I didn't use this one to keep things simpler. Oh well.

    Can I offer you anything in exchange for your efforts? I would offer some design/graphics work but I believe you already do this kind of stuff. Still, I would happy to do something in trade.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    @netdzynr: Yes, I nested the X check inside the Y check - because if it doesn't pass the Y check, there's no need to check the X. I also split the Y checks in half and put one in the otherwise section. Just so the engine doesn't test things needlessly. In theory it should give the engine a weensy performance improvement. Who knows.

    And you don't owe me anything. I'm glad to help. Plus it gives my brain a little workout which I appreciate. My new game has a ton of art and animation assets and I feel like I've been working in an art assembly line for the past coupe of weeks!
  • Mcreator83Mcreator83 Member Posts: 120
    hi there

    i tried to replicate the demo in my game but i can only get it to move once and then cant move it any more. everything is the same as the demo yet i can't make it work. is there something hidden that i might have missed?

    thanks
  • Rob2Rob2 Member Posts: 2,402
    The boolean switch in otherwise of 'Set Dragging' maybe?
  • Mcreator83Mcreator83 Member Posts: 120
    i tried that, even created a scene to try it out on its own still no luck.. hmm
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Mcreator83 said:
    i tried that, even created a scene to try it out on its own still no luck.. hmm

    Check the otherwise section of every single rule in the demo. I'm willing to bet you have a hiding rule or behavior somewhere. They can be hard to find. It would be best if you have the project merger to merger the demo into your project. it will save so many hours of back and forth recreating every single attribute and rule.
Sign In or Register to comment.