Bloggage: http://www.puppygames.net/blog/?p=914
Download: http://www.puppygames.net/downloads/RevengeOfTheTitansSource.zip
Don’t complain about it Or ask any questions.
Cas
Bloggage: http://www.puppygames.net/blog/?p=914
Download: http://www.puppygames.net/downloads/RevengeOfTheTitansSource.zip
Don’t complain about it Or ask any questions.
Cas
A very good and generous decision. I will enjoy decrypting it and probably learning a lot!
Not even report bugs? I see two in IntGrid :clue:
Arggh! Where?
Cas
private int getIndex(int x, int y) {
if (x < 0 || y < 0 || x >= width || y >= height) {
return -1;
}
return x + y * width;
}
public int getValue(int x, int y) {
if (x < 0) {
x = 0;
} else if (x >= width) {
x = width; // must be x = width-1; or getIndex will return -1 and you could just as well not have adjusted x
}
if (y < 0) {
y = 0;
} else if (y >= height) {
y = height; // must be y = height-1; or getIndex will return -1 and you could just as well not have adjusted y
}
int idx = getIndex(x, y);
if (idx == -1) {
return fill;
}
return value[idx];
}
I just spotted that
It never seems to have had any effect on the game, probably because in this game width/height are never actually exceeded.
Cas
GeomUtil.rectangleContainsCircle( ) is bugged too :persecutioncomplex:
public static boolean rectangleContainsCircle(float x, float y, float radius, float rx, float ry, float width, float height) {
// Treat the circle like an AABB and see if it lies within the bounds
float halfSize = radius / 2f;
float boundsXMax = rx + width;
float boundsYMax = ry + height;
// snip
// Top edge
if (y - halfSize < boundsYMax) { // should be: if (y - halfSize < ry)
return false;
}
if (y + halfSize > ry) { // should be: if (y + halfSize > boundsYMax)
return false;
}
// All edges ok, circle is within bounding rect
return true;
}
FWIW, I actually rendered it for no apparent reason. :cranky:
I can blame Orangytang for that one
Cas
Neat, thanks a bunch for that.
edit: you really like XML. And your DefaultSpriteRenderer is pretty much the same as our SpriteBatch. We’d probably even out in the big sprite shootout. Glad to know we are not that far away from people publishing on Steam
Very cool, thanks for sharing
Haha no I hate XML Fortunately I don’t have to do an awful lot of it - Chaz gets most of the miserable drudgery. I was wondering about switching to some derivative of JSON (with less double quotes) instead as it’s much more compact.
Cas
Lol I like your comments:
[quote]// For fuck’s sake, why doesn’t it take the byteorder from the original buffer???
[/quote]
That’ll be one of the rare, useful, accurate comments
Cas
Nice.
That’s a lot of code… probably not how I would organize things. :\ but still useful.
Someone have a look on this source code? Any good ideas to learn from it? I’m ready to share my thoughts too!
Just want to note that as an alternative to XML you also have YAML. One of the benefits of XML is that it is pretty human readable, but the major downside is that it is so effing verbose and inefficient. YAML is human readable and adds minimal clutter. For a usage example, see how it is implemented in Play framework for example:
http://www.playframework.org/documentation/1.2.3/guide2
(search for data.yml)
Every extant YAML parser I’ve seen is a bug-ridden ad hoc mess that’s slower and eats more memory than any XML parser. Stuff like syck that does aim for performance uses direct memory tricks in high level languages that just screams “exploitable”. And when it gets at all complex, it’s not even particularly “human readable”, or at least all the little quirky bits of syntax you have to dangle off elemen ts aren’t obvious in what they do. YAML needs a stake driven through it.
While I’m ranting: whither JSON? It was conceived as a clever hack to allow javascript clients to generate it with toString() and parse it with eval(). Except that’s not how any JSON parser works anymore, for very good reason. So why not use real sexps instead? Inertia of course.
YAML looks like the Devil’s own format. Quite why anyone would condone it is a mystery. XML is another of the Devil’s creations though. Something similar to JSON would probably be quite nice.
Cas
Other ideas? I’ve found on puppy blog this:
http://www.puppygames.net/blog/?p=178
I remember some article about handling animations in Titans but forgot where it is
This statement is a bit ironic, considering json is a subset of yaml, which is the Devil’s own format
Just saying …