Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (715)
Games in Android Showcase (214)
games submitted by our members
Games in WIP (788)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Game Play & Game Design / Tile based map formats for fast display -- on: 2005-04-20 21:58:08
Hello everyone! I've made a editor for a tile based game I'm working on, and it's OKAY for now.
I'm not sure about premade map editors, because  I might not like the format these give out. I hope there is one that can save the map as a xml file which I could use a xml transformation to change it to a format I can use.

So the big problem now is how the map is stored in memory. I was thinking of using a ArrayList<Image> that I could index into using an int[][][], or short[][][], the first index would be the layer. This seemed like a fine idea at the time, until I realized this would waste a large amount of memory for a layer that doesn't have much on it. So I heard of a solution which is to represent a tile as a linked list, such a Tile would be linked to the the next Tile (for the next layer) and so on, they would be painted in this order. This would allow for the map to have the smallest amount of memory required. I realised there were different ways of doing this:


Represent the map as a 2D array of ArrayList<Tile> or LinkedList<Tile> objects, each Tile would have an index into the image array and blocking information:

class Tile {
 boolean blocking;
 int image;

the ArrayList<Tile> would grow as required by memory. The map would look something like this:

class Map {
  ArrayList<Tile>[][] background; // renders behind player
  ArrayList<Tile>[][] foreground; // renders over player
  ArrayList<Tile>[][] roof; // invisible when the player walks under it

I was thinking that the ArrayList<Tile> is possibly too heavy weight?


Make a Tile class with a link to the next one:

class Tile {
 boolean blocking;
 int image;
 Tile next;
 public Tile getTile(int index) {
    Tile next = this;
    for(int i = 0; i < index; i++) {
        next = next.getNext();
        if(next == null) {
           return null; // break out of the loop early to avoid exception
    return next;

 public Tile getNext() {
   return next;

this would probably be less heavy weight than the original but would require me to do some more research about how to make a good linked list, probably wouldn't be too hard.

Should I store the Tiles or ArrayList<Tile> (for the first method) in a one dimensional array like this:

1:  ArrayList<Tile>[] background = new ArrayList<Tile>[mapWidth * mapHeight]

for accesses: images.get(background[tileY * width + tileX].get(1).image);

2: Tile[] background = new Tile[mapWidth*mapHeight];

for accesses:

Tile tile = background[tileY * width + tileX].get(1);

if(tile != null) {
 BufferedImage bi = images.get(tile.image);

is it better to have the map width and height a power of two?

I know there are a lot of questions, you don't have to answer each one. I'm grateful for any advice.


2  Discussions / Community & Volunteer Projects / Re: wondering about volunteering on: 2004-11-29 22:30:50
Thanks for the suggestion Mikera, I might not have time for it.
I'll take a look at the code or documentation if I can find them. And if I can understand it, maybe I can make a few items or creatures Smiley  
3  Discussions / Community & Volunteer Projects / wondering about volunteering on: 2004-11-28 22:06:41
Hello everyone.

I'm wondering if volunteering is a good idea vs
being a individual, and if it I would get any
insights into java/game programming.

I've been programming a while
and read the few first chapters from a book about
java game development, I've read and understood "thinking in java (3rd edition)" by bruce eckel. I don't know anything about java 3D programming.

I'm not looking for a project where I'll have to do a LOT of programming, or program anything too sophisticated, or where I need to be around all the time, a simple job, like scripting or building guis or something like that...

I really need to stress that I don't want to be stuck in a project, where I'm the only person doing something...

I'm considering volunteering, if you have a fun project then I'd be happy to hear about it.
4  Game Development / Newbie & Debugging Questions / Re: Side scroller - collision detection on: 2004-11-24 17:20:40
I'm really sorry nonnus, I apologize for miss-spelling your name.
5  Game Development / Newbie & Debugging Questions / Re: Side scroller - collision detection on: 2004-11-24 17:19:07
Thank you nonsus. That will really help clean up my Sprite class.  Smiley
6  Game Development / Newbie & Debugging Questions / Side scroller - collision detection on: 2004-11-23 18:55:19
Hello everyone.

I'm making a side scroller fighting game and I have
a couple of questions. I've got the sprite animation
working and I'm wondering if I should have gravity
built into the Sprite (base class) or have it as
a implementation detail. It got me thinking that I could
use setters for speed, jumping power,
animations, etc.. So you could just extend Sprite and use these methods in your constructor. Another approach is to create a ConfiguredSprite class that subclasses Sprite and add a constructor to ConfiguredSprite that accepts the file name of a sprite configuration file, and the ConfiguredSprite class does the parsing.

another problem I have is collision detection.
I first check for collisions with the bounding rectangles
of the sprites current images. And then if a collision occurs
I use pixel perfect collision detection. The problem is I don't know what to do once I know that they are colliding, how to line them up side by side is a problem.
7  Discussions / General Discussions / Re: Open sourcing Java and its effect in games on: 2004-08-09 20:38:27

Pfft.  Assuming you're talking more than 10 years off, Java as a language will be long gone before then, and we'll all be using something more powerful, more developer-friendly, and much more appropriate to the tasks of the day.  I think the best you could hope for is that VM technology is still in there somewhere, and that Sun are still a big player in the language world. ;D

Languages tend to stick around. Look at fortran, IMHO one of the main reasons it's still around is because the huge amount of scientific libraries. Now take a look at java, it's grown so much in the past years, thousands of classes, and and a lot of packages. It seems that a lot of people are moving to .NET for its huge libraries, and it costs a lot to get into, and it's the same with fortran, java is completely free, if you want a cool IDE like .net has, than IBM has created one for free. I'm not trying to start a flame about 'java VS .NET', theres already a thread about that. What I'm saying is that java is something that's easy to get into, along with a huge amount of classes, it will be a while before some company invests as much money and time into a language as sun and IBM has. If some how a company does manage to spend the time and money, it will look like choped liver for a while before it starts looking like java...

As for open sourceing of java, it might help in certain ways, some of which are languages like groovy and jython which run on java, designers of those languages might like to ship their less buggy version of java with their SDK? Are there any problems with doing this?
8  Discussions / General Discussions / Re: Java acceleration using hardware? on: 2004-08-09 20:03:23
Could it be done without sacrificeing portability? I just looked at the game Chrome on amazon, and it's system requirements:

Windows 9x/ME/2000/XP
Pentium II 500 MHz
128 MB RAM

Wheres linux or macOSX? Did the creators of Chrome not write it in 100% pure java? What will stop this from becoming the fate of a game like Doom 3 in java?
9  Discussions / General Discussions / Re: Java acceleration using hardware? on: 2004-08-09 00:14:32
mainly whimsy Smiley wouldn't it be great if someone could make something as graphical as doom III and have it run fast? Java is already fast for most apps, I guess it will just take sometime for c++ programmers to realise that.
10  Discussions / Miscellaneous Topics / Re: Why is the "Java Technology Concept Map&q on: 2004-08-08 17:25:54
I think blahblahblah may have said before (but I'm not sure) that sun has a lot of money, and they don't want to use too much of their money to help java out. Is this why I don't see any java related commercials? I've seens m$ commercials promoting their software, but why doesn't sun do the same thing with java when they also have huge sums of money. Java could get much more popular, and used more widely by users of most operating systems, this is a great thing, since theres a huge amount of people not just using windows, but using linux, unix, macOSX, etc... Why doesn't sun run with java?
11  Discussions / General Discussions / Java acceleration using hardware? on: 2004-08-08 16:57:56
Is there any chance, now or in the future there will be a card to accelerate java code? A card might help in certain areas. For example, could you have a accelerated GC? or accelerated bytecode? what about a accelerated hot spot compiler? I know theres a certain limit with what you can do with hardware, but are there any parts at all in java that a company like sun or nvidia can speed up?

Chris Smiley
12  Discussions / Miscellaneous Topics / Re: What's JavaOne? on: 2004-08-08 16:45:59

At the same time, it's very useful that you have the option of running betas (...on a spare system), since it lets you experiment with new features and bugfixes well in advance of the release date. This enables you to bring out Cool Stuff (tm) within days of the next major release, rather than within months.

I'm learning java, so I haven't made a serious app yet. I'm looking at how code executes, and learning different apis. I think for java begginers theres not much reason for experimenting with difficult or dangerous betas, I'll save that stuff for later. For now, I'm going to read a lot more about java, and hopefully, sometime I'll make something good.

Thanks for all the help.

Chris Smiley
13  Discussions / Miscellaneous Topics / Re: What's JavaOne? on: 2004-08-07 12:18:21
I'm doing a lot of programming for 1.4, if I put 1.5 on my computer will both versions work?
14  Discussions / Miscellaneous Topics / Re: What's JavaOne? on: 2004-08-06 22:02:44
re of Catharsis: I can't wait to finish this bruce eckel book, than I can start coding using all the powerful features, there will be even more in jdk 1.5.0. Any idea of when jdk 1.5.0 will be released?

What's a BOF? is it like a discription of an application or something? if it is, do you need something to display your application? how old do you have to be to speak?
15  Discussions / Miscellaneous Topics / Re: Java vs .NET for games? on: 2004-08-05 04:45:23
Why doesn't sun do the same thing and create a BASIC like language for the java platform, it could be almost exactly like java, except for different syntax. The source files could be compiled into java bytecodes. And It might even attract a large amount of new programmers to the java platform, which would be very good for sun. If they learn the java platform, they can more easily learn the java programming language.
16  Discussions / Miscellaneous Topics / Re: What's JavaOne? on: 2004-08-05 03:35:29
Do you have to have a presentation, or can you just whatch the conferences and lectures? I'm not old enouth anyway, only 15 so they probably only let adults in there and no exceptions, huh? oh well... Probably will learn more from bruce eckels books Smiley
17  Discussions / Miscellaneous Topics / Re: What's JavaOne? on: 2004-08-04 05:07:54
That sounds cool. I couldn't find how much it costs. How often do they have JavaOne?
18  Discussions / Miscellaneous Topics / What's JavaOne? on: 2004-08-04 04:40:31
What is JavaOne, is it some type of convention or something? If it is, what do they show? And is it difficult to attend it?
19  Discussions / General Discussions / Re: need for speed, java vs c++ and the stack on: 2004-08-04 03:56:52
I want System.gc(long nanos)  which would force garbage collection to run for as close to the requested duration as possible.  I recall hearing that this wouldn't be all that hard.
The idea would be to use it to eat up the extra cycles during a frame by forcing a tiny GC every frame rather than letting the garbage build up enough that the GC pause might be too long.

That sounds like a very good idea. But you could do this in a slightly different way. You could create a global variable to contain how many objects in memory have no references. And after each frame, test if this variable is more than or equal to another variable which holds the amount of objects you allow, and if so, run the gc. You would want a predefined function that can return the number of objects with no references, so that you don't have to increase the global variable inside every single function, is there a function for this in the core apis?

public class Game {
  private static int numberOfAllocations;
  private static int limitOfAllocations;
  public static void main(String[] args) {
     while(true) {
20  Discussions / General Discussions / Re: need for speed, java vs c++ and the stack on: 2004-08-02 19:56:24
to Raghar
I'm not too experienced with 3D  graphics, so my example wasn't that realistic. But I was trying to show that the stack could be quite useful in algorithms, it could optimise the functions in a clear way, and might be a better alternative (in certain cases) to creating objects as static globals.
BTW assembly ga wakarimasen "I don't know assembly".

If you allocated a object on the stack at the beggining of a program, would it persist until the end of the program inside the stack frame? and does it keep it's state between calls to the function without reinitialization?

21  Discussions / General Discussions / Re: need for speed, java vs c++ and the stack on: 2004-08-02 07:20:30
Thanks for the replies everyone. Elias, I can't view those pages at the moment because I don't yet have a account on This escape analyisis sounds interesting, is it an elegant technique? If I can't use the stack for creating objects that never leave the scope of the function, should I make these objects private static?
BTW, what's an RFE?
22  Discussions / General Discussions / Re: need for speed, java vs c++ and the stack on: 2004-08-02 01:11:08

How do you make sure that this stack instance isn't passed to a place where it is stored and has to live longer than the function call?

I'm not sure if I understand what you are saying. In what situation does this happend? And why would it be bad?
23  Discussions / General Discussions / Re: need for speed, java vs c++ and the stack on: 2004-08-01 19:31:14
2) Secondly, you *want* the GC to be called often. The more often it is called, the less likely a GC-related pause.

A GC related pause would be caused by too many objects on the heap, if your not allocating them on the heap, how will you get a GC related pause? I could imagen a function declared as stack function or something like that, to tell the RTI to turn off the GC for the length of the function.

If your doing 3D rotation matix operations at 70 fps with 100000 3 vertex polygons, it might make a difference, because the function for rotation would be called for each vertex, in this case 300000 times for all vertices per fps, wouldn't it be wasteful to use the GC 300000 * 70 times per second each time your making in instance of matrix inside your function? You could say that a solution would be to create the matrix as a static instance, but isn't this a bad design because your using code farther from where it should be used? placing the stack instance inside a function would be more clear from a client programmers perspective.
24  Discussions / General Discussions / need for speed, java vs c++ and the stack on: 2004-08-01 04:04:44
Java needs to be faster, the question is how. I have a suggestion:

Allow objects to be created on the stack (static storage) for functions. This means that you don't need to allocate and initialize all the objects on the heap every time you call a function since their there when the program starts. theres another good advantage to this, garbage collection occurs when objects are created, this means that the less you use the 'new' keyword to allocate/instantiate the object the less the GC gets called. As a result, code execution:

1. Is faster
2. Does not call GC as much
3. Does not use as much heap space. The savings are usualy not that great, but possibly huge if your using many tables.

is static storage at all possible in the future for Java?

Pages: [1]
CopyableCougar4 (211 views)
2017-03-24 15:39:42

theagentd (193 views)
2017-03-24 15:32:08

Rule (252 views)
2017-03-19 12:43:22

Rule (234 views)
2017-03-19 12:42:17

Rule (239 views)
2017-03-19 12:36:21

theagentd (258 views)
2017-03-16 05:07:07

theagentd (254 views)
2017-03-15 22:37:06

theagentd (184 views)
2017-03-15 22:32:18

theagentd (178 views)
2017-03-15 22:31:11

ral0r2 (166 views)
2017-03-03 11:52:41
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51 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‑
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!