Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: An interesting Dilemma with coordinates  (Read 4508 times)

0 Members and 1 Guest are viewing this topic.

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
An interesting Dilemma with coordinates
« on: April 06, 2014, 09:36:16 pm »
I'm puzzled as to what would happen and how to get around a few things to do with hitting the float max when using the view to show what the player is up to and were.


Say the ship approaches float max but we all know the view is going to hit is sooner due to its coordinates being further ahead on that side the player is moving.  I've got a Sector Counter that I should just have to up/lower by one on the respective axis and just set the view's coordinates to what would normally be used to cause a wrap around effect on size limited maps.
The Green is what I want to happen to the ship.
Purple is what I know happens when you do wrapping maps.
Red is where the ships is now.
Keep in mind I also want to do this with bullets, beams, and shockwaves when interacting with the sector borders so that might end up with some creative partial drawing of being on both sides of the line.



Want to not just jump into but be able to see and shoot into other sectors without ending up on the opposite side of the one I'm in. >.>  Any ideas?  Meantime I'll try and get a working example up and running to show off and see if anyone can help then.
I have many ideas but need the help of others to find way to make use of them.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: An interesting Dilemma with coordinates
« Reply #1 on: April 06, 2014, 09:51:46 pm »
How big is the maximum float value in C#? In C++, it's something in the order of 1038 if I remember correctly. Are you aware how big that number actually is? Don't make yourself problems that are none...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: An interesting Dilemma with coordinates
« Reply #2 on: April 06, 2014, 09:56:45 pm »
lol yep I know but I'm trying to figure out what to do when some crazy player makes it out that far. :D

I can either wrap them back around to the other side of the current map or send them to another sector which is basically another map of the same size. :)

I'll stick with wrapping to the other side for now until I figure out this one. :)
I have many ideas but need the help of others to find way to make use of them.

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: An interesting Dilemma with coordinates
« Reply #3 on: April 06, 2014, 10:09:37 pm »
hmm just though of something with views.  I could use multiple Views one on each map they are near at the borderlines and if done right and the sprites themselves don't cause memory errors the player wouldn't even know there's a border there or that they've hit max/min values.  Worst case that would happen is 4 views and the sprite redrawn in 4 places or at least part of it anyways.  :)
I have many ideas but need the help of others to find way to make use of them.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: An interesting Dilemma with coordinates
« Reply #4 on: April 06, 2014, 10:09:56 pm »
lol yep I know but I'm trying to figure out what to do when some crazy player makes it out that far. :D
Think about it once again.

Let's say you have insane metrics, like a velocity of 1 million units per second = 106 s-1.
In order to reach the maximum float, the player therefore needs
1038/106 seconds
= 1032 seconds
~ 3.17 * 1024 years
~ 2.3 * 1014 * the age of our universe

Do you see how ridiculous this is? Long time before a player ever comes close to that value, there will be other problems like the float imprecision that give you trouble.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: An interesting Dilemma with coordinates
« Reply #5 on: April 06, 2014, 11:20:04 pm »
Yep we both know it is unrealistic for this to be an issue.  The issue lies with this equation though: Gamer Brain + Unrealistic = Challenge.  >_>  Also hackers that find a fast way to the edge of the map or me just warping myself there to see what happens being the other two things to keep in mind. :)


That aside yes I know it is unlikely but as unlikely as it is someone will try to do the impossible be it by legal means or not. :p

The fastest ships in the game wouldn't be able to break a vector speed of 300 without going through a warp gate so the normal player isn't ever reaching the edge without sending their whole family to play that character for a few thousand years. :)
I have many ideas but need the help of others to find way to make use of them.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: An interesting Dilemma with coordinates
« Reply #6 on: April 06, 2014, 11:30:49 pm »
The imprecision issue would yield ridiculous numbers too. A float has 7 significant digits. At 1038, it means that you have a precision of 1031. In other words, you can only add or subtract 1031 to the ship's position if you want to change it; anything lower will get lost in the imprecision of the float format.

So even if someone manages to hack to go this far, your coordinates will be totally messed up.

So no, this is not a challenge. You'd rather find a way to avoid such big numbers. There's nothing you can do with them.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: An interesting Dilemma with coordinates
« Reply #7 on: April 06, 2014, 11:33:30 pm »
Even if somebody teleported there, you would have completely different problems: floating point values of that scale are very unprecise in lower decimal places (because the point is floating). You wouldn't even be able to move, because the velocity is by tens of orders of magnitude too tiny to make any difference.

Believe me, it's not worth the trouble, and if you start to protect against "hackers" you have again fundamentally different problems...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything