Author Topic: Collisions...again  (Read 4287 times)

0 Members and 1 Guest are viewing this topic.

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Collisions...again
« on: October 29, 2011, 02:03:37 pm »
So, for my game swords, I am having trouble with collisions with things like speed up/downs, keys, and other non-moving objects.  D:
Should I use a X,Y coordinate to do this, or some other method? And how would I go about doing that?
And what collision checks should I use for moving objects? (enemies). any help would be great.  ;D

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Collisions...again
« Reply #1 on: October 29, 2011, 05:00:23 pm »
I didn't know you could even do collisions without x,y coords...

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Collisions...again
« Reply #2 on: October 29, 2011, 05:55:00 pm »
I'm a bit confused by your question, you are having trouble with collisions for non moving objects? O.o

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: Collisions...again
« Reply #3 on: October 29, 2011, 07:26:59 pm »
Yes: it is for my game: http://ourl.ca/13637
I think that should do it...

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Collisions...again
« Reply #4 on: October 29, 2011, 07:50:33 pm »
But non moving objects never move, why would they need to collide with anything?

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Collisions...again
« Reply #5 on: October 29, 2011, 08:00:28 pm »
Perhaps the player can collide with a stationary object, such as a wall?

There are multiple methods, which depend on how you store the level.  Is it a buffer you pixel-test, or is it a tilemap that's stored somewhere?
Vy'o'us pleorsdti thl'e gjaemue

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: Collisions...again
« Reply #6 on: October 29, 2011, 09:53:16 pm »
oh wait, never mind, I've got the collisions with non moving objects... duh I am stupid :P
ok, so if I have an enemy at coods. ({L1+1},50) and the player is at (X,Y), for some reason it doesn't work if I do:
Code: [Select]
:{L1+1}->R
:If ((R-1)<(X)<(R+9)) and (42<Y<58)
:.do collision stuff
:End
but it does the collision stuff even if there's not a collision. :(

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Collisions...again
« Reply #7 on: October 30, 2011, 12:43:15 am »
Ah, you are falling into a common trap by assuming Axe does calculations in the normal order, where in fact it does them left to right.  The expression 42<Y<58 will *not* return true if Y is between 42 and 58 because 42<Y is evaluated first to either 1 or 0, and then that value is tested against 58.  As you can see, this expression will always return true!  Adding in some parenthesis will definitely help here :)

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Collisions...again
« Reply #8 on: October 30, 2011, 01:10:40 am »
Adding in some parenthesis will definitely help here :)
He has parenthesis. ;)

Axe uses left to right order of operations.  Make sure you're using your parenthesis correctly.
Instead of "(R-1)<(X)<(R+9)," try "R-1<X and (R+9>X)."

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: Collisions...again
« Reply #9 on: October 30, 2011, 10:49:30 pm »
oh wow, that helps A LOT. thanks guys!!!! ;D