Tue Jul 29, 2014 9:47 pm
annyfm wrote:Limited wrote:Out of curiosity is there a reason why you use floats for positions and velocities for bullets rather than bytes? (Bytes usage is better)
Ignorance
edit: will expand on that a little... I'm not really a C or Arduino programmer, I actually come from a predominantly PHP background (which is how I make my living) and while I understand static tying in principle and casting, working in a dynamically typed language leaves me somewhat at a loss for the pros and cons of certain types (like I know float is more computationally expensive than int, but not a lot more than that!)
edit 2: on that note, any chance you could elucidate the benefits of byte over int/float?
Tue Jul 29, 2014 10:02 pm
const float bullet_xv = 2;
const float bullet_xv_mod_pship = 0.5;
typedef struct {
...
float xv;
...
} PlayerShip;
float bxv = bullet_xv + (bullet_xv_mod_pship*pship.xv);
const byte bullet_xv = 2;
const byte bullet_xv_div_pship = 2;
typedef struct {
...
byte xv; // with xv having an integer value only, requiring further division in the relevant movement code
...
} PlayerShip;
float bxv = bullet_xv + (pship.xv/bullet_xv_mod_pship);
Tue Jul 29, 2014 10:14 pm
Tue Jul 29, 2014 10:18 pm
Tue Jul 29, 2014 10:24 pm
94k wrote:I've seen a couple of demos (demos as in demo scene, not game demos) on limited hardware where they used ints as would be floats. Say you want to store some distance in meters, instead of representing 5 meters with the value 5 you'd represent it with 50000, essentially shifting the the value to gain more precision while still being able to use integer operations.
Tue Jul 29, 2014 10:27 pm
94k wrote:shifting the the value to gain more precision while still being able to use integer operations
Tue Jul 29, 2014 10:42 pm
Wed Jul 30, 2014 9:04 am
Sun Aug 17, 2014 6:24 am