Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: willrandship on January 11, 2011, 06:40:39 pm

Title: What is wrong with this code? :(
Post by: willrandship on January 11, 2011, 06:40:39 pm
http://pastebin.com/pR57e81a (http://pastebin.com/pR57e81a)

This is giving me a headache. It's supposed to give me walls being drawn, getting progressively farther away, being detected off a pic, but It's not showing anything, probably due to a mistake in the formula that I can't find.  :mad: :banghead:

Anyone have any helpful ideas/suggestions? even a completely new formula, I just want it to work.
Title: Re: What is wrong with this code? :(
Post by: Michael_Lee on January 11, 2011, 06:54:01 pm
I think the main part of your problem is that in this line of code:
Code: [Select]
If {PY*96+PX+(A*96)+GDB1+F}=1
I think you're trying to check bit by bit for the location of a wall, but when you access data using curly braces, it returns the value of the byte.

Also, try closing your parenthesis - leaving them open in Axe can cause issues.

Also, I didn't know that you could use variables created using more then one letter.  Does that really work?
Title: Re: What is wrong with this code? :(
Post by: willrandship on January 11, 2011, 06:55:56 pm
In axe it does I think (hope), unless the Pic1xX thing only applies to other variables. maybe that's the issue. I actually changed that = to a >= so it would work that way. I'll try changing it to just X and Y.
Title: Re: What is wrong with this code? :(
Post by: Deep Toaster on January 11, 2011, 06:59:47 pm
What's PY and PX? If you're trying to do P*Y and P*X, remember that Axe doesn't support implicit multiplication.
Title: Re: What is wrong with this code? :(
Post by: willrandship on January 11, 2011, 07:40:49 pm
No, I was doing PY as one var and PX as one var. They are the player's coordinates on the pic var.
Title: Re: What is wrong with this code? :(
Post by: FinaleTI on January 11, 2011, 07:58:48 pm
Try Y instead of PY and X instead of PX. I don't think Axe supports multiple letter variables like it does with static pointers.
Title: Re: What is wrong with this code? :(
Post by: Quigibo on January 11, 2011, 08:00:16 pm
That only works for static pointers becasue those don't take up any memory.  I only have a limited number of variables because I want to leave users with enough free ram to play around with.  If you need more variables, you can always use these ram locations manually: {L1+10}r for instance will act exactly the same as a regular variable (make that 10 any constant you want as long as it fits in ram)
Title: Re: What is wrong with this code? :(
Post by: willrandship on January 11, 2011, 08:36:09 pm
Yeah, I tried with X and Y, no change at all. I also made sure that it was detecting something at one point, by forcing the If function.
Title: Re: What is wrong with this code? :(
Post by: Deep Toaster on January 11, 2011, 09:36:34 pm
Are you sure you  changed all the PXs and PYs to Xs and Ys?

Also,

Code: (Axe) [Select]
If {Y*96+X+(A*96)+GDB1+F}=1

would be a lot more optimized as

Code: (Axe) [Select]
!If {Y+A*96+X+F+GDB1}-1

Taking out those parentheses in particular helps a lot :)
Title: Re: What is wrong with this code? :(
Post by: willrandship on January 12, 2011, 09:30:50 am
Umm, those two lines don't do the same thing.

Y+A*96 != Y*96+A*96

I tried it in my calc, no change :( The paste has the old, my calc has yours DT

And yes, I got all the PX's and PYs, they're only referenced in the one line anyways :P

By the way, an updated paste http://pastebin.com/TGSqGSJ8 (http://pastebin.com/TGSqGSJ8)
Title: Re: What is wrong with this code? :(
Post by: Deep Toaster on January 12, 2011, 11:43:38 am
Umm, those two lines don't do the same thing.

Y+A*96 != Y*96+A*96

It's the same because there's no order of operations in Axe, remember. It goes strictly from left to right.
Title: Re: What is wrong with this code? :(
Post by: calcdude84se on January 12, 2011, 01:15:58 pm
Deep Thought is right AFAICT.
"Y+A*96" evaluates as "(Y+A)*96", which is the same as "Y*96+(A*96)"
Title: Re: What is wrong with this code? :(
Post by: Munchor on January 12, 2011, 01:22:27 pm
XCB doesn't multiply X by C by B?

Shocking news!: That's why many of the games I attempted never worked and kept giving me errors... I never thought it was this part of the code because I assumed it was OK.
Title: Re: What is wrong with this code? :(
Post by: calcdude84se on January 12, 2011, 01:24:52 pm
Indeed, Axe doesn't have implicit multiplication. In fact, if you have, say, "ABC" in your code, it will evaluate just like C alone would, but more slowly. (Since it loads A, then B, and finally C) ;)
Title: Re: What is wrong with this code? :(
Post by: Munchor on January 12, 2011, 01:25:32 pm
Indeed, Axe doesn't have implicit multiplication. In fact, if you have, say, "ABC" in your code, it will evaluate just like C alone would, but more slowly. (Since it loads A, then B, and finally C) ;)

I thought it loaded A. This is where the NSpire Basic wins: multiple character variables.
Title: Re: What is wrong with this code? :(
Post by: willrandship on January 12, 2011, 11:28:16 pm
The 86 had it first, and its basic is faster :P

86 Basic you could load any 8 letter var (excluding commands) as any var type.
Title: Re: What is wrong with this code? :(
Post by: Deep Toaster on January 12, 2011, 11:33:48 pm
Indeed, Axe doesn't have implicit multiplication. In fact, if you have, say, "ABC" in your code, it will evaluate just like C alone would, but more slowly. (Since it loads A, then B, and finally C) ;)

I thought it loaded A. This is where the NSpire Basic wins: multiple character variables.

Nope, Axe does exactly what you type: It does the first operation (which just loads A), then the second (loading B), then the third.
Title: Re: What is wrong with this code? :(
Post by: DJ Omnimaga on January 13, 2011, 12:25:12 am
The 86 had it first, and its basic is faster :P

86 Basic you could load any 8 letter var (excluding commands) as any var type.
Really? I thought Nspire Math BASIC was quite fast and only the display stuff were slow? That said, 86 BASIC was slower (http://www.youtube.com/watch?v=L6w6KnnyhdI) than on the 82, 83, 83+ and 85, though.
Title: Re: What is wrong with this code? :(
Post by: willrandship on January 13, 2011, 09:23:42 am
Well, true but at least it still had all the functions, like getkey, circle and output :P

But anyways, perhaps someone else could write me a function that does the following for my code.....

For walls ranging from left to right 12 sprites (F) and 4 sprites deep(A)

If Your position + the wall's position relative to you is on (in GDB1)
Draw a column That is at the correct F location, and that is A*8 pixels away from the top and bottom of the screen, using the picvar + the depth (for offset to other pics in mem, Pic1+A*16 or similar)
End
End
End
Dispgraph :P

That's what my code is supposed to do.
Title: Re: What is wrong with this code? :(
Post by: willrandship on January 13, 2011, 11:12:00 pm
Aww, no one wants to make one for me?  :'(