Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: yunhua98 on June 07, 2010, 04:01:56 pm
-
OK, Thanks.
Read Topic for Question^^
Here's the code:
:.Keep in mind I'm skipping a lot of the code
:Repeat K=15 or (L=0
:.(X,Y) is your coordinates and (P,Q) is the bomb's
:If (X-P<16 or (P-X<16)) and (Y=Q
:If (Y-Q<16 or (Q-Y<16)) and (P=X
:0->L
:End:End
:End
For some reason I won't die unless I'm right on top of the bomb when it explodes.
Oh, and i used quote instead of code so the < are underlined.
EDIT: ugh, I was stupid, put Y-Q=0 and P-X=0 instead of Y=Q and P=X, optimized now.
-
You should be fine by asking help, as long as you agree that if you use too much code by other people, it migth affect your originality score
-
I'm a bit confused by what kind of hit detection you're looking for. Do you want it to check to see if the bomb is within 16 pixels horizontally and vertically of the character? Like a square around the character with side length 32?
Or does the fact that this question is more than a week old mean that you already solved the problem, I'm just wondering why nobody ever posted a solution or you never posted to say that you fixed it yourself.
-
It appears to have been solved by himself. I think that might have been the day where there were like 45 active topics so we could easily miss topics. In fact, this weekend I'll probably do like last weekend again to check stuff I might have missed. I am still not used to the high board activity XD
EDIT: Also I think that member is not going to be very active until July 5th, from what I could read in another post somewhere.
-
:If (X-P<16 or (P-X<16)) and (Y=Q
:If (Y-Q<16 or (Q-Y<16)) and (P=X
:0->L
:End:End
Disclaimer: I am not yet a Axe Parser programmer. I will try to not just give away code, instead give you some pointers to fix the problem.
Check if you need " and " logic. It may be the reason why you only loose when you are in the place of the bomb.
I think you don't need signed comparison in "X-P<16 or (P-X<16)" and "Y-Q<16 or (Q-Y<16)" like you are doing.
But if Axe Parser has abs() you can do like in BASIC: abs(X-P)<16. Dunno if it would be optimized but is probably easier for TI-BASIC coders read.
-
yeah, I solved it myself, I did something stupid with the logic so instead of two separated If statements I did a nested one.
-
using and/or with Axe as well as </>/<</>> can be a major pain, for the later especially when you deal with negative values. In some cases, you need a lot of parhentesises or you need to separate if statements. Glad you got it fixed, though. Builderboy and SirCmpwn gave me hints on collision detection a few days ago and one day I tried them again, and it took me several hours to get an half-decent engine (which I'm still not 100% satisfied about)