Dead End...

Hello all,

Im fairly new to java but have been working on a game that i’ve been planing out for some time now. The game is still in the development stage and i have programmed a few classes the take care of some parts of the game but i’ve come to a dead end and can’t seem to find a way to get the graphics i would like to see.

So, so far i have a classes for these things:

  • Entity (super class for objects in the class… such as character, wall, door, enemy, etc)
  • Characters (sub-class of entity)
  • Main Panel (will hold all of the graphics and handles mouse/keyboard events)
  • Tiles (a class the holds all of the tiles…)
  • Item (sub-class of entity… will do general “item”-like things)
  • Game (class will control general game flow and logic)

Now that i’ve gotten these i’m not sure where to go next. I want to get the display to work but im having trouble implementing this. I was thinking about using arrays to store the maps for the tiles… I would to use 2D graphics in this rpg but im also having trouble deciding an size.

Here (in psudo-code) is what i was thinking about using:


declare map
...
    // store the layout for the tiles in an array
    map = { [1,0,0,1,1,1,1],
                   [1,1,1,1,1,1,1],
                   ...
                }
...

displayMap(map){
for(int j=0; j<map.length; j++){
     for(int i=0; i < map[j].length; i++){
          // draw a tile at the location its correct location
          draw(map[i])
    }
}
...

so if anyone have any ideas then…
Thanks for what ever amounts of time you decide to donate to me :slight_smile:

Here are the files i’ve been working on… its a zip file with the .txt ending… just change it to .zip and you can open it with winzip

The pseudocode looks fine.

Generally, the FIRST thing I do is make it so the game gets drawn on the screen. How can you test any of that other stuff if nothing is displayed?

This part makes it sound like you just need an artist to draw art for you, but the rest makes it sound like you’re having a programming problem. If you convert your pseudocode to code, it should work fine.

I’m not sure what to use for displaying tiles… if i have like picture that im going to use should i use the the ImageIcon class to hold them/ display or is there a better way?

currently this is what i have:


...
private ImageIcon tile;
private final ImageIcon[] tiles = new ImageIcon[7] //currently i only have 7 pics 
private final String[] tileNames = {
                                                       ...
                                                    }
public Tile(String s){
    //store the location of the Image into the array
    tiles[0] = new ImageIcon("C:...");
    ...
    if (s != null || s != "" || s != " "){
          // if name is valid...
          tile = setTile(s);
     }
}

public ImageIcon setTile(String s){
    ImageIcon t = new ImageIcon();
    for(int i = 0; i < tiles.length; i++){
        if(tileNames[i] == s){
            // if get the index of the tilename
            if(tiles[i] == null)
                return null;
            else
                 // if tile exists then store it in t so that it can be returned
                 t = tiles[i];
               }
        }
    return t;
}


I would use BufferedImage instead of ImageIcon, but ImageIcon will work.

One issue with BufferedImages is that you need to load them the “right” way so that they get hardware accelerated. You can search the Java2D forums for more information about this - it’s what everyone always asks about.

ImageIcons just store Images inside them, so the have a little extra overhead.

I would suggest buying a book, such as Killer Game Programming in Java or Developing Games in Java because they both address these sorts of issues.

Do you know were i could find the source for JRPG (i think it was called). I would like to see what he used and how he implemented a game with such graphics.

Thanks for that

Take a look at this tutorial http://www.cokeandcode.com/tutorials. It might help you out.

Thanks… btw, i downloaded jRPG to see how the gameplay and graphics were before i started looking at the code. When i click on the demon campaign it started but once it the message comes up and i press the arrow keys to scroll or the d/esc buttons to close the box it doesn’t do anything. Before i get into the code and everything is there a solution to this so i don’t have to go through the trouble of coding when theres already a solution out there somewhere.

I’ve looked through the stuff provided and i’ve did some editing to my source code but this seems a bit over me with my level of experience. When i looked through the source code for the space invaders game i went along and edited my source to meet the necessary needs. The only problem is some of the classes i haven’t worked with before and it makes me feel like im just copying codes when i read and edit mine. I was wondering what sort of game do you all usually start of with when you first started making games?

That’s what you do. You copy the code and try to understand some of it. Play with each part until you understand a little at a time. Eventually you can just look at the API and make it yourself.

When I first starting programming games in Java, I did a puzzle game that wasn’t all that great. I learned how to work with Swing and so forth by looking at code examples on the Internet.

When I finally bought a good book about game programming in Java, my ability really started to take off. I can’t stress enough how much reading lots of programming books helps out.

what book would you suggest?

http://fivedots.coe.psu.ac.th/~ad/jg/

Either KIller Game Programming in Java (as he suggested) or Developing Games in Java (not quite as good). Or both - they cover alot of the same material, but I think reading both would be beneficial. I would suggest something newer, but I don’t know of any newer Java game programming books.

Some books you shouldn’t buy: Advanced Game Programming in Java and Black Art of Game Programming in Java. Of course, someone else might write new books with the same (or at least similar) names, in which case, new books with the same names might be good. In general, it’s good to avoid any old technology-oriented books.