Author Topic: Velocity  (Read 10474 times)

0 Members and 1 Guest are viewing this topic.

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Velocity
« Reply #15 on: December 08, 2011, 12:32:25 am »


Yeah I' having the same problem!
« Last Edit: December 08, 2011, 12:32:49 am by saintrunner »
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Velocity
« Reply #16 on: December 08, 2011, 01:03:29 am »
Actually, collision checking with legit gravity is fairly trivial. Do something like this:

1) Move the object by velocity
2) While there is a tile under the object, move it back up however much you inflated the position by (if you inflated the positions by 256, subtract 256 from the position)
3) Use this to make sure that your object is at the bottom of the sub-pixel: Y/256*256+255->Y

Alternatively, if you want to get fancy just do 255->{oY}
And that's it!
In-progress: Graviter (...)

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Velocity
« Reply #17 on: December 08, 2011, 01:05:36 am »
I dont get where you pull these extremly large numbers out of :O
256? 768? 15265? What does it all mean bazzle?

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Velocity
« Reply #18 on: December 08, 2011, 03:19:16 pm »
Large numbers from the 256 inflation. For example, 1 in x would be 256, coordinate 2 would be 512, pixel 3 would be 768, and by the time you reach the end of the screen, the numbers will be big (96*256).

And of course backwards velocity will be big, since it counts down from 65335 to show negative.

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Velocity
« Reply #19 on: December 08, 2011, 04:49:24 pm »
Yah... Too many numbers xD

Offline LincolnB

  • Check It Out Now
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1115
  • Rating: +125/-4
  • By Hackers For Hackers
    • View Profile
Re: Velocity
« Reply #20 on: December 09, 2011, 09:50:14 am »
Do you understand the idea behind 256x inflation, and why it's a good idea?
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: Velocity
« Reply #21 on: December 09, 2011, 12:05:17 pm »
Not really D:

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Velocity
« Reply #22 on: December 09, 2011, 10:40:38 pm »
It is for accuracy reasons. Its like measuring fine detail in millimeters rather than feet.

It makes it a lot easier. You have X be 256 times larger than what it will really be, do it will be measured in very small lengths. When you pt-on, it will be pt-on(X/256,y/256,pic1) and displays it to the nearest pixel.

Offline LincolnB

  • Check It Out Now
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1115
  • Rating: +125/-4
  • By Hackers For Hackers
    • View Profile
Re: Velocity
« Reply #23 on: December 10, 2011, 01:51:25 pm »
Think of it this way: let's say you want to move to the right 1.5 pixels per frame. But you can't have half pixels - so instead, you double your X coordinate, and divide by two. Make an improper fraction of sorts, because Axe can easily store those, instead of a decimal, which is harder. Change it so that instead of moving 1.5 pixels per frame, you use 2x inflation and move 3 pixels, but divide your X coordinate by 2 each frame. Axe rounds all division operations, so it's going to round the fraction to the nearest pixel.

That probably made no sense. Example:

Code: [Select]
.Move character 1.5 pixels per frame to the right
.when the User presses the right key

0->X
[CHARACTER_SPRITE]->Pic1

Repeat getkey(15)

.If they press right
If getkey(3)
X+3->X
.Add 3/2, not 1.5
.They look like the same - however, since 3/2 always returns
.1 in Axe (because it rounds down), we had 3, and divide
.by 2 later on in the code.
End

ClrDraw
Pt-On(X/2,0,Pic1)
Dispgraph

End

^^In this example, I'm only using 2x inflation. 256x inflation means you can move 1/256 of a pixel each frame.

Did that make sense?
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 parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: Velocity
« Reply #24 on: December 10, 2011, 02:08:52 pm »
ok, so I get the 256 inflation stuff, but I'm wondering: why 256?
why not 100? is 256 better? I'm assuming so because it's 2^8...

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Velocity
« Reply #25 on: December 10, 2011, 02:26:13 pm »
I'm assuming so because it's 2^8...
Exactly. So the calculator makes it a lot faster than if you chose another number (yes, it is all about speed :))
« Last Edit: December 10, 2011, 02:26:27 pm by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: Velocity
« Reply #26 on: December 10, 2011, 02:28:04 pm »
I'm assuming so because it's 2^8...
Exactly. So the calculator makes it a lot faster than if you chose another number (yes, it is all about speed :))
oh ok. Thanks :)

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Velocity
« Reply #27 on: December 10, 2011, 02:28:44 pm »
256 is exactly one byte in hex, so it's the most optimized number for calculations. It's also extremely useful because you can bypass the /256 altogether and just pull the byte you need from whatever array it's in.
In-progress: Graviter (...)