Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: hellninjas on February 29, 2012, 12:14:50 pm

Title: Axe Physics (Thanks ephan!)
Post by: hellninjas on February 29, 2012, 12:14:50 pm
Okay, im starting to REALLY understand physics in Axe!! (Thanks to Ephan, butts, and builderp!)
But I'm still having trouble trying to keep my sprite on the screen!
Along with the sprite CONSTANTLY moving D:
So am SO CLOSE to finnaly getting it!
Thank you omnimaga!
Title: Re: Axe Physics (Thanks ephan!)
Post by: Xeda112358 on February 29, 2012, 01:12:50 pm
Okay, so from IRC, I saw you want gravity to be constant and:
A=X velocity,
B=Y velocity.

So what I would do is something like this:
Code: [Select]
If pxl-Test(X/64,Y/64+1
0→A→B                        ;If it hits a barrier, zero the velocity
Else
B+2→B+Y→Z      ;2 is the value of gravity, so increment the velocity by 2, then add it to the position
If (Z/64)-(Y/64)=2*pxl-Test(X/64,Z/64   ;in case you fell 2 pixels, test if you are on a barrier
Z-64→Z
End
Z→Y
End
I am not sure if that works in Axe, but I tried turning my Grammer code into Axe code .__. It will still need tweaking :/
Title: Re: Axe Physics (Thanks ephan!)
Post by: aeTIos on February 29, 2012, 03:13:14 pm
So could you explain a bit what you are actually trying to? (a little image would be great)
Title: Re: Axe Physics (Thanks ephan!)
Post by: hellninjas on February 29, 2012, 03:16:25 pm
I cant give pics D:
wabbitemu never works D:
But im just trying to allow a square to have physiscs acceleration (Which i can do now!)
But i cant get him to stay ON the screen, he ends up flying off of the bottom, left, or right...
Title: Re: Axe Physics (Thanks ephan!)
Post by: aeTIos on February 29, 2012, 03:23:35 pm
ok ill post some code tomorrow (have to stop now)
Title: Re: Axe Physics (Thanks ephan!)
Post by: Quigibo on February 29, 2012, 03:41:02 pm
How about this clipping code?  Insert it right after the movement and acceleration code:

X<<0?0→X
Y<<0?0→Y
Y>56?56→Y
X>88?88→X

This is assuming a square 8x8 sprite, otherwise you can change the bounds.

EDIT:  This is also assuming a regular coordinate system.  If you're using fixed point "inflation", then the 56 and 88 should be 56.0 and 88.0 respectively.
Title: Re: Axe Physics (Thanks ephan!)
Post by: aeTIos on February 29, 2012, 04:36:09 pm
Heck i missed a lot in the axe updates O.o
Title: Re: Axe Physics (Thanks ephan!)
Post by: ZippyDee on February 29, 2012, 05:13:17 pm
If you're referring to Quigibo's code,
    X<<0?0->X
is the same thing as
    if X<<0
    0->x
Title: Re: Axe Physics (Thanks ephan!)
Post by: LincolnB on February 29, 2012, 05:23:44 pm
Yeah, you basically just check to see if the character is off the screen, and if he is, move him back on the screen. The way to check if the character is off the screen is pretty simple, you just check to see if the X coordinate is bigger than ( 96 - SPRITE_SIZE ) or if the Y coordinate is bigger than ( 64 - SPRITE_SIZE ).
Title: Re: Axe Physics (Thanks ephan!)
Post by: hellninjas on February 29, 2012, 08:50:52 pm
Heres my code so you can see what im doing (I know its not optimized, but it helps me understand it!)
Code: [Select]
:.ACCELL
:44*256->X
:28*256->Y
:.X Accelleration
:0->A
:.Y Accelleration
:0->B
:repeat getkey(15)
:ClrDraw
:Pt-On(X\256,Y\256,[FFFFFFFFFFFFFFFF])
:If getkey(2)
:A-10->A
:End
:If getkey(3)
:A+10->A
:End
:X+A->X
:Y+B->Y
:DispGraph
:End

Something like that i guess. But i cant have the sprites going off screen and need gravity! D:
Title: Re: Axe Physics (Thanks ephan!)
Post by: LincolnB on February 29, 2012, 08:52:54 pm
My bad Builder :P

OK, for gravity, you need to increase the Y_Offset, which looks like it's the variable B, and for border checking, you need to check to see if the character's X and Y coordinates denote that the character is off the screen. If the character is off the screen, put him back on the screen by changing the X and Y coordinates as such, and set the respective velocity to zero.

And yeah, try Quigibo's code cept make sure to account for inflation.
Title: Re: Axe Physics (Thanks ephan!)
Post by: Builderboy on February 29, 2012, 08:54:58 pm
Butts, A is X velocity, you would want to accelerate the Y velocity, so you would use the B variable.  As for going off the screen, did you try Quigibo's code?
Title: Re: Axe Physics (Thanks ephan!)
Post by: hellninjas on February 29, 2012, 09:01:08 pm
Yes i tried it right after
:X+A->X
:Y+B->Y
and before it, all it does it place the block in the upper left of my screen which is kinda wierd :P
and might i also ask... What does the ? exactly mean?
Title: Re: Axe Physics (Thanks ephan!)
Post by: Builderboy on February 29, 2012, 09:41:20 pm
Actually Quigibo's code is a bit redundant, you can just do

Code: [Select]
Y>56?56→Y
X>88?88→X

But since your code is inflated by 256, you want to multiply each of those constants by 256.  The ? Operator works like this:  Given A?B, B will only be executed if A evaluates to be true.  It's basically a more compact way of saying If A:B
Title: Re: Axe Physics (Thanks ephan!)
Post by: hellninjas on February 29, 2012, 10:01:07 pm
Ok heres my code, i seem to have gotten it working!
But the jumping wont work? Weird, anyone have a fix?
Code: [Select]
:.ACCELL
:44*256→X
:28*256→Y
:0→A
:0→B
:Repeat getKey(15)
:ClrDraw
:Pt-On(X/256,Y/256,[FFFFFFFFFFFFFFFF])
:If getKey(2)
:A-10→A
:End
:If getKey(3)
:A+10→A
:End
:If getKey(54)
:B-100→B
:End
:If X>>22528
:22528→X
:0→A
:End
:If X<<0
:0→X→A
:End
:If Y>>14336
:14336→Y
:0→B
:End
:If Y<<0
:0→Y→B
:End
:If getKey(2)=0 and (getKey(3)=0)
:A//2→A
:End
:X+A→X
:Y+B→Y
:DispGraph
:End
Title: Re: Axe Physics (Thanks ephan!)
Post by: LincolnB on February 29, 2012, 10:02:26 pm
What exactly does it do?
Title: Re: Axe Physics (Thanks ephan!)
Post by: leafy on February 29, 2012, 10:06:28 pm
Code: [Select]
:.ACCELL
:44*256→X
:28*256→Y
:0→A→B

:Repeat getKey(15)
:Pt-On({°X+1},{°Y+1},[FFFFFFFFFFFFFFFF])
:getKey(3)-getKey(2)*10+A→A

:If getKey(54)
:B-216→B
:End

:If X>>22528
:22528→X
:0→A
:End

:If X<<0
:0→X→A
:End

:If Y>>14336
:14336→Y
:0→B
:End

:If Y<<0
:0→Y→B
:End

:!If getKey(2)
:!If getKey(3)
:A//2→A
:End:End

:X+A→X
:B+6→B+Y→Y

:DispGraphClrDraw
:End

I'm not quite sure what the problem was, but you are missing acceleration, so I added that back in. I also increased the jump push, so maybe it was too low before as to not be noticeable?
Title: Re: Axe Physics (Thanks ephan!)
Post by: Builderboy on February 29, 2012, 10:26:54 pm
I modified leafy's code such that it hopefully now works.
*Builderboy runs*

Code: [Select]
:.ACCELL
:44*256→X
:28*256→Y
:0→A→B
:
:Repeat getKey(15)
:Pt-On({°X+1},{°Y+1},[FFFFFFFFFFFFFFFF])
:getKey(3)-getKey(2)*10+A→A
:
:If getKey(54)
:B-32→B
:End
:
:!If getKey(2)
:!If getKey(3)
:A//2→A
:End:End
:
:X+A→X
:B+6→B+Y→Y

:If X>22528
:X-A→X
:0→A
:End
:
:
:If Y>14336
:Y-B→Y
:0→B
:End
:
:DispGraphClrDraw
:End
Title: Re: Axe Physics (Thanks ephan!)
Post by: hellninjas on February 29, 2012, 11:23:15 pm
WOO! I get it now!
Thanks goes to you all! :D!!!
Title: Re: Axe Physics (Thanks ephan!)
Post by: LincolnB on March 01, 2012, 05:11:05 pm
Glad you figured everything out!