NOGDUS $1670.00 has been donated to NOGDUS!
September 20, 2017, 08:29:36 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Question about using Float instead of Int  (Read 6600 times)
0 Members and 1 Guest are viewing this topic.
Cycl0ne
Guest
« on: April 08, 2011, 07:11:43 AM »

Hi,

i was stumbling about the code, that you use float for your sprites, how come? Im just curious, because the ARM Cpus have no FPU, thus Google says on Android:
"As a rule of thumb, floating-point is about 2x slower than integer on Android devices." It could be even that the device doenst even have an FPU (and to be worse, even no divider ;-).

So one Question that arises from me, why are sprites then in Float and not in INT ? (Thought float was used in opengl or any other 3d engine)?

Brgds

C.
Logged
Mattias Gustavsson
Moderator
Offline Offline

Respect: 58
« Reply #1 on: April 12, 2011, 01:05:40 PM »

Well, at an early stage of the development, I did actually use integers for sprite positions etc. The reason I changed it, was because I noticed while making games, that I often had to keep track of, for example, a characters x and y position (which had to be floats, as I'm deciding how far to move things depending on the time elapsed since last frame, to get framerate independent movement) and then every frame pass it to the sprite. By changing the sprite position to float, I could just store the positions of the characters directly in the sprite, and that was a bit neater.

There's a few different ways to solve this... you could change the sprites to use integer, and leave it up to the game to store correct positions and pass them to the sprites. Or, you could have the sprites use a fixed-point datatype, which means it would work pretty much the same as it does now, as the floating precision you'd get in a float is not really relevant in this particular case.

Let me know if you'd like any more details on this (or if you need help implementing a fixed-point type, should you opt to go down that route)  Smiley
Logged
Cycl0ne
Guest
« Reply #2 on: April 12, 2011, 01:38:11 PM »

Ohh its ok. Since im still waiting for my android to get the 2.3 update for the full c/c++ Api, i cant really test this speed issue. We will see, when i get the baby compiled, until then i still code on Windows to get pixie better to know. Wink
Logged
Tags:
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
.: Theme by Richard Marks :.
Valid XHTML 1.0! Valid CSS!