Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (577)
games submitted by our members
Games in WIP (498)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Revenge of the Titans Source Code  (Read 11514 times)
0 Members and 1 Guest are viewing this topic.
Offline princec

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Posted 2011-04-21 00: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
« Reply #1 - Posted 2011-04-21 00: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 Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2011-04-21 00: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! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2011-04-21 00:40:17 »

Arggh! Where?

Cas Smiley

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2011-04-21 00: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

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #5 - Posted 2011-04-21 00: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 Overlord


Medals: 605
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2011-04-21 01: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

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #7 - Posted 2011-04-21 01:41:04 »

I can blame Orangytang for that one Smiley

Cas Smiley

Offline badlogicgames
« Reply #8 - Posted 2011-04-21 01: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

Junior Member


Medals: 2



« Reply #9 - Posted 2011-04-21 02: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! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #10 - Posted 2011-04-21 11: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

« In padded room »



TUER


« Reply #11 - Posted 2011-04-21 15:06:04 »

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

Offline princec

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #12 - Posted 2011-04-21 15:17:27 »

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

Cas Smiley

Offline appel

JGO Wizard


Medals: 49
Projects: 5


I always win!


« Reply #13 - Posted 2011-04-21 15: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

Senior Member


Medals: 1
Projects: 3



« Reply #14 - Posted 2011-10-04 15: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 Drone Defense 0.2 | In progress Drone Defense
Offline gimbal

JGO Coder


Medals: 25



« Reply #15 - Posted 2011-10-04 18: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
« Reply #16 - Posted 2011-10-04 18: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

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #17 - Posted 2011-10-04 20: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

Senior Member


Medals: 1
Projects: 3



« Reply #18 - Posted 2011-10-05 09: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 Drone Defense 0.2 | In progress Drone Defense
Offline xsvenson
« Reply #19 - Posted 2011-10-05 11: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

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #20 - Posted 2011-10-05 14: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
« Reply #21 - Posted 2011-10-05 17:48:09 »

Just say thanks! Cool

Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 12


Game Engineer


« Reply #22 - Posted 2011-10-06 00: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
Offline jezek2
« Reply #23 - Posted 2011-10-06 08: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

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #24 - Posted 2011-10-06 11: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
« Reply #25 - Posted 2011-10-06 11: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.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline Chromanoid

Junior Member


Medals: 3



« Reply #26 - Posted 2011-10-06 12: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

Senior Newbie





« Reply #27 - Posted 2011-10-06 12: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

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


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

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

Cas Smiley

Offline sproingie
« Reply #29 - Posted 2011-10-06 18: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
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (23 views)
2014-04-15 18:08:23

BurntPizza (18 views)
2014-04-15 03:46:01

UprightPath (32 views)
2014-04-14 17:39:50

UprightPath (16 views)
2014-04-14 17:35:47

Porlus (32 views)
2014-04-14 15:48:38

tom_mai78101 (58 views)
2014-04-10 04:04:31

BurntPizza (116 views)
2014-04-08 23:06:04

tom_mai78101 (216 views)
2014-04-05 13:34:39

trollwarrior1 (183 views)
2014-04-04 12:06:45

CJLetsGame (190 views)
2014-04-01 02:16:10
List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:05:20
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!