Author Topic: More accurate positioning  (Read 2561 times)

0 Members and 1 Guest are viewing this topic.

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
More accurate positioning
« on: February 01, 2011, 01:52:24 am »
I've noticed that in games like portal x position is calculated using the floor function of divison by a large number (256?) because if you just use integral increments you get choppy animations, like in my game.
So how does more accurate positioning work?
In-progress: Graviter (...)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: More accurate positioning
« Reply #1 on: February 01, 2011, 02:06:27 am »
Well Axe works in integers, so the decimal is not calculated and you are left with 1.  The concept is basically this:  You store the coordinates to a screen that is 256 times bigger than the calculator one, and when you display your character you zoom out by dividing by 256.  This means you have 65536x the positions of a normal screen, so you have much more precision.  Everything you do to the value now will have 1/256 as much effect.  Instead of adding 1, it will now be like adding 1/256 :)

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: More accurate positioning
« Reply #2 on: February 02, 2011, 05:33:46 pm »
so this would be easier for Physics were things travel parabolically, I assume?

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline Compynerd255

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +53/-4
  • Betafreak Games
    • View Profile
    • Betafreak Games
Re: More accurate positioning
« Reply #3 on: February 09, 2011, 10:29:42 am »
Yes, this would allow you to create parabolas, as well as more natural, precise movement. The difficult thing about doing this, however, is simply remembering when to translate your coordinate system. For a simple 2D game, it's not that bad, but with a 3D (raycast, Mode 7) game, you would also be scaling when referencing your environment's tilemap.
The Slime: On Hold, preparing to add dynamic tiles

Axe Eitrix: DONE

Betafreak Games: Fun filled games for XBox and PC. Check it out at http://www.betafreak.com



Ashbad

  • Guest
Re: More accurate positioning
« Reply #4 on: February 09, 2011, 03:21:40 pm »
yes, this is kinda what I am using in Colell ball toy.  except about only 64 times instead of 256.  It's actually quite effective :)