Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: parserp on October 13, 2011, 06:54:44 pm

Title: Jumping
Post by: parserp on October 13, 2011, 06:54:44 pm
I am looking for a tutorial on jumping, but one for a COMPLETE beginner.
I haven't been able to understand any so far.  :-\
If you could explain it or recommend a tutorial that would be great.  ;D

[random question]
I have been noticing that in advanced programs in axe, (such as the demo rpg) in the beginning the sprites are declared and then it just has something like this:
Code: [Select]
:[FF36C78465378FC
1636374858CCFCF3
352CFFFC3T5376CD
3]
:
but it doesn't store it or anything.
what is the use of this?
[/random question]
Title: Re: Jumping
Post by: ztrumpet on October 13, 2011, 06:57:34 pm
I know this is written for TI Basic, but it is still very applicable to Axe code.  I highly recommend it.
http://www.omnimaga.org/index.php?action=articles;sa=view;article=37
Title: Re: Jumping
Post by: parserp on October 13, 2011, 06:58:56 pm
/me reads the tutorial...
thanx ztrupet :D
Title: Re: Jumping
Post by: Deep Toaster on October 13, 2011, 07:09:33 pm
[random question]
I have been noticing that in advanced programs in axe, (such as the demo rpg) in the beginning the sprites are declared and then it just has something like this:
Code: [Select]
:[FF36C78465378FC
1636374858CCFCF3
352CFFFC3T5376CD
3]
but it doesn't store it or anything.
what is the use of this?
[/random question]
All static variables are stored one after another in memory, so if you do something like
Quote from: Axe
[00]→GDB1
[FF]
then {GDB1+1} will be EFF.
Title: Re: Jumping
Post by: parserp on October 13, 2011, 07:12:02 pm
[random question]
I have been noticing that in advanced programs in axe, (such as the demo rpg) in the beginning the sprites are declared and then it just has something like this:
Code: [Select]
:[FF36C78465378FC
1636374858CCFCF3
352CFFFC3T5376CD
3]
but it doesn't store it or anything.
what is the use of this?
[/random question]
All static variables are stored one after another in memory, so if you do something like
Quote from: Axe
[00]→GDB1
[FF]
then {Str0+1} will be EFF.
ooh I think i get it now... XD
Title: Re: Jumping
Post by: ztrumpet on October 13, 2011, 07:19:12 pm
All static variables are stored one after another in memory, so if you do something like
Quote from: Axe
[00]→GDB1
[FF]
then {Str0+1} will be EFF.
For the record, Deep made a typo here.  It should read:
...
Quote from: Axe
[00]→GDB1
[FF]
then {GDB1+1} will be EFF.
Title: Re: Jumping
Post by: Deep Toaster on October 13, 2011, 07:21:48 pm
That, and the colors are wrong. Fixed.
Title: Re: Jumping
Post by: parserp on October 20, 2011, 12:11:40 am
Ok, so I have another question...
So, this was my first attempt at using pointers in axe.
I've got the Idea, but not completely, so I don't know what I did wrong with this program.
It's for a game I'm making called swords, and all that I need to do is have the enemies walk across the screen and back.
Source and Executable are included...
and screenie!!!
EDIT: I'll just put the source here:
Code: [Select]
:.ENEMY
:.enemy
:[3C4289819F423C14]->Pic1
:.X position of enemies in L1
:For(A,1,5)
:(A*9)->{L1+A}
:End
:.which direction each enemy is going
:For(A,6,10)
:1->{L1+A}
:End
:Repeat getKey(15)
:ClrDraw
:Line(0,63,95,63)
:Line(0,0,95,0)
:Line(95,0,95,63)
:Line 0,0,0,63)
:.draw guys
:For(E,1,5)
:Pt-On(({L1+E}),55,Pic1)
:End
:Dispgraph
:.see if at edge
:For(F,1,5)
:If ({L1+F}=1) or ({L1+F}=86)
:((-1)*({L1+F}))->{L1+F}
:End
: End
:.actually move them
:For(C,1,5)
:({L1+C})+({L1+(C+5)})->{L1+C}
:End
:Pause 50
:  End
Title: Re: Jumping
Post by: MGOS on October 20, 2011, 01:35:29 pm
After skimming your code which looks OK, I found four things:
- usually, you start arrays with the value zero, change that everywhere else.
- You have to use signed multiplication ( ** ) to multiply with a value less than zero.
- You are storing the direction value into the x-value, that won't work, so just add 5 to the pointer.
- If you use a version below 1.0.1 of axe, use the addition sign for conditions, not the 'or' keyword

Code: [Select]
:If ({L1+F}=1)+({L1+F}=86)
:-1**{L1+F+5}->{L1+F+5}
:End

To optimize a bit, use just one for loop for everything, than the speed will increase drastically.

Code: [Select]
:For(E,0,4)
:.from 0 to 4
:Pt-On(({L1+E}),55,Pic1)
:.see if at edge
:If ({L1+E}=1)+({L1+E}=86)
:-1**{L1+E+5}->{L1+E+5}
:End
:.actually move them
:{L1+E}+{L1+E+5}->{L1+E}
:End
:DispGraph

Hope that works
Title: Re: Jumping
Post by: parserp on October 20, 2011, 01:36:51 pm
ooh yes it does. +1 XD
EDIT: but they just stop at the end, they don't reverse direction...
Title: Re: Jumping
Post by: C0deH4cker on October 20, 2011, 02:51:03 pm
to optimize further, replace the parts where you use a for loop to set values with the Fill() command.

Example:

This:
Code: [Select]
:For(A,6,10)  // A = [6,7,8,9,10]
:1->{L1+A}  // {L1+6} = [1,1,1,1,1]
:End

could be this:

Code: [Select]
:Fill(L1+6,5,1)  // {L1+6} = 5*[1] = [1,1,1,1,1]


See?
Title: Re: Jumping
Post by: Quigibo on October 20, 2011, 05:14:46 pm
** Is fixed point multiplication, not signed multiplication.  The regular * multiplication works for both signed and unsigned numbers.
Title: Re: Jumping
Post by: parserp on October 20, 2011, 06:42:31 pm
** Is fixed point multiplication, not signed multiplication.  The regular * multiplication works for both signed and unsigned numbers.
hey yeah that was the error. thanx XD
Title: Re: Jumping
Post by: MGOS on October 21, 2011, 12:55:23 am
really, Quigibo? I could swear that in 0.5.3 it was signed.
Title: Re: Jumping
Post by: Quigibo on October 21, 2011, 05:49:48 am
It multiplies 2 signed fixed point numbers, the command has never changed since it was introduced.  The only time ** is used is when dealing with decimal numbers or inflated coordinate systems, which is why its in the advanced math category.
Title: Re: Jumping
Post by: MGOS on October 21, 2011, 08:03:02 am
Ok, thanks - now I learned something.  ;)
Title: Re: Jumping
Post by: LincolnB on October 21, 2011, 11:50:28 am
Parser, do you still need help with jumping code?
Title: Re: Jumping
Post by: parserp on October 21, 2011, 01:49:58 pm
Parser, do you still need help with jumping code?
no, I was able to figure it out, but thanks for asking. :)