What is the output of this program going to look like?
"1", one would probably think.
You are wrong, it's "-1".
But mind you, this is not a bug. It's merely a result of how signed integers work. The absolute value of a number with only the highest bit set (in any kind of integer, so it applies to Byte, Short, Integer and LongInt) will be negative! Actually, Abs(x) will return x in this case.
Think about it! The range of a signed 32-bit integer goes from -2147483648 (-&h80000000, which is +&h80000000 if you cast treat it as unsigned!) to +2147483647 (+&h7FFFFFFF). The absolute value of -2147483648 would be +2147483648, but this value needs 33 bits including the positive sign bit! Thus, an overflow occurs and the 32-bit value returned by Abs() will again be -2147483648.
A variation of this pitfall is:
This code will output "Neutral number!" if you input 0, but also if you input 2147483648 or -2147483648!
Just keep this in mind. It might produce some nasty bug one day if you blindly assume that Abs(x) will never be a negative number!
Coole Sache! Mit libGDX haben wir über das letzte Jahr hinweg auch ein Projekt entwickelt, das ist echt ein schönes Framework. Bin gespannt auf deine Engine.
Aktuell macht der Entwickler Tests um zu schauen ob er das Ganze nicht auch auf Console zum laufen bringt (Android, iOS und WebGL geht ja schließlich auch so why not). Es gibt aber einige Sachen die mich stören und wo ich mit wünschte man würde mehr plattform spezifische Features einbaut (vor allem was sound angeht)
Ich arbeite eigentlich die ganze Zeit dran und man kann schon damit arbeiten, eine einfache Klasse die z.B. BasicGame oder Game implementiert und vom GameContainer verwaltet wird kann schon für einfache Sachen genutzt werden. Als Test soll auf jeden Fall ein Tetrisklon her (Will auch gleich zeigen wie man Speicher sparen kann, z.B. mit der ObjectIntMap).