Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: parserp on October 29, 2011, 02:03:37 pm

Title: Collisions...again
Post by: parserp 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
Title: Re: Collisions...again
Post by: epic7 on October 29, 2011, 05:00:23 pm
I didn't know you could even do collisions without x,y coords...
Title: Re: Collisions...again
Post by: Builderboy 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
Title: Re: Collisions...again
Post by: parserp on October 29, 2011, 07:26:59 pm
Yes: it is for my game: http://ourl.ca/13637
I think that should do it...
Title: Re: Collisions...again
Post by: Builderboy on October 29, 2011, 07:50:33 pm
But non moving objects never move, why would they need to collide with anything?
Title: Re: Collisions...again
Post by: Darl181 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?
Title: Re: Collisions...again
Post by: parserp 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. :(
Title: Re: Collisions...again
Post by: Builderboy 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 :)
Title: Re: Collisions...again
Post by: ztrumpet 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)."
Title: Re: Collisions...again
Post by: parserp on October 30, 2011, 10:49:30 pm
oh wow, that helps A LOT. thanks guys!!!! ;D