Author Topic: Axe Physics (Thanks ephan!)  (Read 7468 times)

0 Members and 1 Guest are viewing this topic.

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Axe Physics (Thanks ephan!)
« 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!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Axe Physics (Thanks ephan!)
« Reply #1 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 :/

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Axe Physics (Thanks ephan!)
« Reply #2 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)
I'm not a nerd but I pretend:

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Axe Physics (Thanks ephan!)
« Reply #3 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...

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Axe Physics (Thanks ephan!)
« Reply #4 on: February 29, 2012, 03:23:35 pm »
ok ill post some code tomorrow (have to stop now)
I'm not a nerd but I pretend:

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Axe Physics (Thanks ephan!)
« Reply #5 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.
« Last Edit: February 29, 2012, 03:44:59 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Axe Physics (Thanks ephan!)
« Reply #6 on: February 29, 2012, 04:36:09 pm »
Heck i missed a lot in the axe updates O.o
I'm not a nerd but I pretend:

Offline ZippyDee

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 729
  • Rating: +83/-8
  • Why not zoidberg?
    • View Profile
Re: Axe Physics (Thanks ephan!)
« Reply #7 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
There's something about Tuesday...


Pushpins 'n' stuff...


Offline LincolnB

  • Check It Out Now
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1115
  • Rating: +125/-4
  • By Hackers For Hackers
    • View Profile
Re: Axe Physics (Thanks ephan!)
« Reply #8 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 ).
Completed Projects:
   >> Spacky Emprise   >> Spacky 2 - Beta   >> Fantastic Sam
   >> An Exercise In Futility   >> GeoCore

My Current Projects:

Projects in Development:
In Medias Res - Contest Entry

Talk to me if you need help with Axe coding.


Spoiler For Bragging Rights:
Not much yet, hopefully this section will grow soon with time (and more contests)



Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Axe Physics (Thanks ephan!)
« Reply #9 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:
« Last Edit: February 29, 2012, 08:52:43 pm by hellninjas »

Offline LincolnB

  • Check It Out Now
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1115
  • Rating: +125/-4
  • By Hackers For Hackers
    • View Profile
Re: Axe Physics (Thanks ephan!)
« Reply #10 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.
« Last Edit: February 29, 2012, 08:57:58 pm by buttsfredkin »
Completed Projects:
   >> Spacky Emprise   >> Spacky 2 - Beta   >> Fantastic Sam
   >> An Exercise In Futility   >> GeoCore

My Current Projects:

Projects in Development:
In Medias Res - Contest Entry

Talk to me if you need help with Axe coding.


Spoiler For Bragging Rights:
Not much yet, hopefully this section will grow soon with time (and more contests)



Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Physics (Thanks ephan!)
« Reply #11 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?
« Last Edit: February 29, 2012, 08:55:18 pm by Builderboy »

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Axe Physics (Thanks ephan!)
« Reply #12 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?

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Physics (Thanks ephan!)
« Reply #13 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

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Axe Physics (Thanks ephan!)
« Reply #14 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