So, I’ve been making my own tools to help me programming my game, and strangely I’ve stumbled upon a LOT more (interesting) questions than I imagined, mostly about engine design if such a term exist, and good practices (and evil optimizations, which I’m definitely NOT doing).
Anyway, here’s something that’s been buggering me.
Most of the time, at least for a 2D game, the x,y coordinates are integers, while the velocity is a float.
After lots of reading again, I think I understand the whole choice behind it, but still, let me show you an example :
Let say that I have a character with a vx=0.6 speed :
Step 1: x = 0
Step 2: x = 0.6 -> rounded to 1
Step 3: x = 1.6 -> rounded to 2
And so on.
Basically, when we’ll have 0.5 < vx <= 1.5, the character will just move 1 pixel per step.
From there, I wonder if it wouldn’t be easier to just use an integer as well for the velocity? At least I’ll be able to forget about good-timing cast and such.
I also did think about using float (cash) for everything, but then I heard that casts may act different on others spec? (Even though my assumptions are that it’s safe for us, java user, thanks to the JVM…?)
Second question :
I’ve been using the “school” way of creating my classes so far, but i’m getting a bit annoyed at the overload of get()/set() methods.
To be honest, I somewhat found them boring confusing and I’d rather use public attributes for my classes (even though it’s BAAAAAAD for encapsulation and people might actually really want to kill me for that).
For example, i’d rather use (already done it actually):
Character.sprite.speed.acceleration.x
than :
Character.getSprite().getSpeed().getAcceleration().getX()
Since “get/set are god-send!” in the left part of internet and “get/set are EVIL” in the right part, I just figured I might ask directly for opinions here.
Oh right… princec, I demand a keyboard configuration for Ultratron because I have an AZERTY one !!! ;D (and I’m lazy to change the settings myself)