Omnimaga
Calculator Community => TI Calculators => Axe => Topic started 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!
-
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:
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 :/
-
So could you explain a bit what you are actually trying to? (a little image would be great)
-
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...
-
ok ill post some code tomorrow (have to stop now)
-
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.
-
Heck i missed a lot in the axe updates O.o
-
If you're referring to Quigibo's code,
X<<0?0->X
is the same thing as
if X<<0
0->x
-
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 ).
-
Heres my code so you can see what im doing (I know its not optimized, but it helps me understand it!)
:.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:
-
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.
-
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?
-
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?
-
Actually Quigibo's code is a bit redundant, you can just do
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
-
Ok heres my code, i seem to have gotten it working!
But the jumping wont work? Weird, anyone have a fix?
:.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
-
What exactly does it do?
-
:.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?
-
I modified leafy's code such that it hopefully now works.
*Builderboy runs*
:.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
-
WOO! I get it now!
Thanks goes to you all! :D!!!
-
Glad you figured everything out!