Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  Print  
  Revenge of the Titans Source Code  (Read 5793 times)
0 Members and 3 Guests are viewing this topic.
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8089
Medals: 96


Eh? Who? What? ... Me?


« on: 2011-04-20 18:03:44 »

Bloggage: http://www.puppygames.net/blog/?p=914
Download: http://www.puppygames.net/downloads/RevengeOfTheTitansSource.zip

Don't complain about it Smiley Or ask any questions.

Cas Smiley

Offline krasse

Sr. Member
**

Posts: 287
Medals: 14



« Reply #1 on: 2011-04-20 18:10:40 »

A very good and generous decision. I will enjoy decrypting it and probably learning a lot! Smiley

Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #2 on: 2011-04-20 18:31:20 »

Not even report bugs? I see two in IntGrid Clueless

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Games published by our own members! Go get 'em!
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8089
Medals: 96


Eh? Who? What? ... Me?


« Reply #3 on: 2011-04-20 18:40:17 »

Arggh! Where?

Cas Smiley

Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #4 on: 2011-04-20 18:42:53 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
   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];
   }

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8089
Medals: 96


Eh? Who? What? ... Me?


« Reply #5 on: 2011-04-20 18:44:31 »

I just spotted that Smiley
It never seems to have had any effect on the game, probably because in this game width/height are never actually exceeded.

Cas Smiley

Offline Riven
« League of Dukes »

JGO Kernel
*****

Posts: 5871
Medals: 255


Hand over your head.


« Reply #6 on: 2011-04-20 19:06:04 »

GeomUtil.rectangleContainsCircle( ) is bugged too persecutioncomplex

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
   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

Hi, appreciate more people! Σ ♥ = ¾

Learn how to award medals... and work your way up the social rankings
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8089
Medals: 96


Eh? Who? What? ... Me?


« Reply #7 on: 2011-04-20 19:41:04 »

I can blame Orangytang for that one Smiley

Cas Smiley

Offline badlogicgames

Full Member
**

Posts: 145
Medals: 3152



« Reply #8 on: 2011-04-20 19:41:58 »

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 Smiley

http://www.badlogicgames.com - musings on Android and Java game development
Offline Sinuath

Jr. Member
**

Posts: 55
Medals: 2



« Reply #9 on: 2011-04-20 20:13:09 »

Very cool, thanks for sharing

Hey [you][/you], you should totally check out my boring Site ~ http://davediel.com/chris
Games published by our own members! Go get 'em!
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8089
Medals: 96


Eh? Who? What? ... Me?


« Reply #10 on: 2011-04-21 05:02:58 »

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 Smiley
Haha no I hate XML Smiley 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 Smiley

Offline gouessej

JGO Kernel
*****

Posts: 3560
Medals: 30


TUER


« Reply #11 on: 2011-04-21 09:06:04 »

Lol I like your comments:
Quote
// For f**k's sake, why doesn't it take the byteorder from the original buffer???

Julien Gouesse
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8089
Medals: 96


Eh? Who? What? ... Me?


« Reply #12 on: 2011-04-21 09:17:27 »

That'll be one of the rare, useful, accurate comments Smiley

Cas Smiley

Offline appel

JGO Wizard
****

Posts: 1477
Medals: 23


I always win!


« Reply #13 on: 2011-04-21 09:28:57 »

Nice.

That's a lot of code... probably not how I would organize things. :\ but still useful.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline Gornova

JGO n00b
*

Posts: 31



« Reply #14 on: 2011-10-04 09:59:40 »

Someone have a look on this source code? Any good ideas to learn from it? I'm ready to share my thoughts too!

Blog | Last game Childhood toys | In progress Drone Defense
Offline gimbal

Full Member
**

Posts: 188
Medals: 11



« Reply #15 on: 2011-10-04 12:11:57 »

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)
Offline sproingie

JGO Strike Force
***

Posts: 899
Medals: 55



« Reply #16 on: 2011-10-04 12:20:56 »

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.
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8089
Medals: 96


Eh? Who? What? ... Me?


« Reply #17 on: 2011-10-04 14:46:32 »

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 Smiley

Offline Gornova

JGO n00b
*

Posts: 31



« Reply #18 on: 2011-10-05 03:50:20 »

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 Sad

Blog | Last game Childhood toys | In progress Drone Defense
Offline xsvenson

JGO n00b
*

Posts: 31



« Reply #19 on: 2011-10-05 05:44:05 »

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 Smiley

This statement is a bit ironic, considering json is a subset of yaml, which is the Devil's own format Tongue
Just saying ...

“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8089
Medals: 96


Eh? Who? What? ... Me?


« Reply #20 on: 2011-10-05 08:29:20 »

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 Smiley

This statement is a bit ironic, considering json is a subset of yaml, which is the Devil's own format Tongue
Just saying ...

JSON without the unnecessary quotes would probably work quite nicely.

Cas Smiley

Offline ReBirth

JGO Wizard
****

Posts: 1279
Medals: 19



« Reply #21 on: 2011-10-05 11:48:09 »

Just say thanks! Cool

Follow me, your mastah, on TWITTAH!
Offline Eli Delventhal
« League of Dukes »

JGO Kernel
*****

Posts: 3575
Medals: 44


Game Engineer


« Reply #22 on: 2011-10-05 18:10:24 »

JSON is like. YAML is pretty good. XML blows hard. I like JSON because it's closest to the data structures I expect to see in memory. There are a lot of parsers that will just turn {} into HashMap and [] into Array. Then it's ultra easy to go through the data in code. I also find it very readable. I agree the quotes that can be annoying, especially because in straight javascript you don't even need them ( {key: "value"} is totally valid). I personally wouldn't make my own version of it though because then you can't use convenient sites like jsonlint.com and the sort.

The code looks nifty enough. I personally have never found much benefit from taking code from other people, but who knows. Maybe if I decide to use a VBO I'll look into your approach.

See my work:
OTC Software
<br />
Currently Working On:
Secret project...
Quote from: _Riven
I edit JGO in production, because I simply don't waste time writing bugs
Offline jezek2

Sr. Member
**

Posts: 357
Medals: 3



« Reply #23 on: 2011-10-06 02:47:11 »

I don't find alternatives to XML readable. Previously I didn't like XML, but realized it was mostly because of bad schema that isn't human friendly. If someone take care to make it nice (eg. more usage of attributes, no DTD/CDATA and other mess, etc) then it's quite nice actually. The verbosity and syntax also make more obvious what is data and what is the rest.
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8089
Medals: 96


Eh? Who? What? ... Me?


« Reply #24 on: 2011-10-06 05:12:46 »

Hm it's subtle but I find this more readable and certainly a bit easier to type and probably parse too than the XML alternative:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
<animation name="crab2.animation">

   <label id="start"/>

   <frame i="spriteimage.crab2_01" d="1"/>
   <frame i="spriteimage.crab2_02" d="1"/>
   <frame i="spriteimage.crab2_03" d="1"/>
   <frame i="spriteimage.crab2_04" d="1"/>

   <random>
      <dest>start</dest>
      <dest>start</dest>
      <dest>start</dest>
      <dest>start</dest>
      <dest>start</dest>
      <dest>start</dest>
      <dest>start</dest>
      <dest>start</dest>
      <dest>pinch</dest>
   </random>  

   <label id="pinch"/>

   <frame i="spriteimage.crab2_05" d="1"/>
   <frame i="spriteimage.crab2_06" d="1"/>
   <frame i="spriteimage.crab2_07" d="1"/>
   <frame i="spriteimage.crab2_08" d="1"/>

   <frame i="spriteimage.crab2_05" d="1"/>
   <frame i="spriteimage.crab2_06" d="1"/>
   <frame i="spriteimage.crab2_07" d="1"/>
   <frame i="spriteimage.crab2_08" d="1"/>  

   <frame i="spriteimage.crab2_05" d="1"/>
   <frame i="spriteimage.crab2_06" d="1"/>
   <frame i="spriteimage.crab2_07" d="1"/>
   <frame i="spriteimage.crab2_08" d="1"/>

   <goto id="start"/>

</animation>


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
animation {
   name: crab2.animation
   
   label { id: start}
   
   frame { i: spriteimage.crab2_01 d: 1 }
   frame { i: spriteimage.crab2_02 d: 1 }
   frame { i: spriteimage.crab2_03 d: 1 }
   frame { i: spriteimage.crab2_04 d: 1 }
   random {
      dest "start"
      dest "start"
      dest "start"
      dest "start"
      dest "start"
      dest "start"
      dest "start"
      dest "start"
      dest "pinch"
   }
   
   label { id: pinch }
   
   frame { i: spriteimage.crab2_05 d:1 }
   frame { i: spriteimage.crab2_06 d:1 }
   frame { i: spriteimage.crab2_07 d:1 }
   frame { i: spriteimage.crab2_08 d:1 }

   frame { i: spriteimage.crab2_05 d:1 }
   frame { i: spriteimage.crab2_06 d:1 }
   frame { i: spriteimage.crab2_07 d:1 }
   frame { i: spriteimage.crab2_08 d:1 }

   frame { i: spriteimage.crab2_05 d:1 }
   frame { i: spriteimage.crab2_06 d:1 }
   frame { i: spriteimage.crab2_07 d:1 }
   frame { i: spriteimage.crab2_08 d:1 }

   goto { id: start }
}



Cas Smiley

Offline nsigma

Sr. Member
**

Posts: 342
Medals: 18



« Reply #25 on: 2011-10-06 05:24:11 »

JSON without the unnecessary quotes would probably work quite nicely.

Cas Smiley

Quite agree!  The patch script syntax I developed for Praxis is influenced partly by JSON, but more as if it had been called TON - (ie. TCL Object Notation).  The structured string approach of a typical TCL parser means no colons, and no quotes unless the key or value has whitespace.  I find this simple, quick and intuitive to work with by hand - unlike XML! 

Obviously, what I have is useless outside Praxis as is, but the general principle is pretty simple.

Offline Chromanoid

Jr. Member
**

Posts: 91
Medals: 3



« Reply #26 on: 2011-10-06 06:00:32 »

I always wonder if a LISP like notation would be nice for games. One could easily combine data with some light logic and one could even precompile data for faster loading. I never used Clojure, I wonder how big its jar is. (edit: the slim version is 840kb)
Offline kilvati

JGO n00b
*

Posts: 19



« Reply #27 on: 2011-10-06 06:09:37 »

Json could also be simplefied to:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
animation {
    name: crab2.animation,
    parts: [
        {name: "start",  d:1, base: "spriteimage.crab2_", frames: ["01","02","03","04"]},
        {name: "pinch",  d:1, base: "spriteimage.crab2_", frames: ["05","06","07","08","05","06","07","08","05","06","07","08"]}
    ],
    loop: [
        {item: "start", chance:"100%"},
        {item: "pinch", chance:"15%"}
    ]
}

Give a man a fire and he is warm for a day, set a man on fire and he is warm for the rest of his live.
Offline princec
« League of Dukes »

JGO Kernel
*****

Posts: 8089
Medals: 96


Eh? Who? What? ... Me?


« Reply #28 on: 2011-10-06 06:59:40 »

That wouldn't map very well to my internal structures though Wink

Cas Smiley

Offline sproingie

JGO Strike Force
***

Posts: 899
Medals: 55



« Reply #29 on: 2011-10-06 12:08:17 »

Here's why XML > sexps (sometimes):  There's a syntax error in the code below.  Tell me which construct got too many close parens:

1  
((foo bar (blah (foo (abc def) blah (foo (xyzzy abcd)))))))


Okay, it's contrived.  But the fact is, no matter how meaningful the data, the parser has to get all the way to the end to report that there's a balancing error, and it still can't tell you where it is
Pages: [1] 2
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.216 seconds with 19 queries.