Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am building a Java game from scratch right now. So far, it runs fine, but the issue is with my GUI and how it works. Basically, it's a tile-based game. Each time the person moves a different image is displayed (basically I check to see what terrain they are on, and in what direction they moved then update that tile's Imageicon). I feel like it is a lot of brute force graphic work and I was wondering if anyone here could help me find a simpler method or class to preform the action. I use ImageIcons to basically make the game's GUI function right now. I was thinking about finding a way to have "layers", so I could have the terrain in the background and my person could just walk over it. Unless someone has a better idea.

Another long-term goal is to make the walk movement an animation. Right now, the person just pops over 1 tile, I want to implement some basic walking animation for that movement of tile to tile. I feel like that would be easier to do if I had a way make the person be a separate object compared to the terrain/map.

Any suggestions on how to do this would be very helpful! :)

IMAGE REQUEST: Here is an older and later dated image of one region. Basically, I have a tile (ImageIcon) for each possible instance of where the hero is, and which way he is facing. But as stated, I want to get rid of that because it requires soooo much. There has to be an easier way to overlap the person and allow animation to each tile. enter image description here

share|improve this question
    
can you give us any images of what you are doing it will be easier to grasp your problem :) –  AbstractChaos Jul 19 '12 at 13:20
    
Can't add images yet since I am new. I posted an imageshack url instead. Thanks! –  Austin Jul 19 '12 at 13:28
    
are all your images for example your buildings, grass texture, same size or are your buildings one image bigger than your grid? –  AbstractChaos Jul 19 '12 at 13:43
    
Requests for a tutor are off topic for the site. I suggest you look into some of the libraries specifically designed to be GUIs. TWL, Nifty or Slick2D. –  Byte56 Jul 19 '12 at 13:46
    
@AbstractChaos all same size (40x40), it's pieced together as you enter a new region. –  Austin Jul 19 '12 at 13:58
show 6 more comments

1 Answer 1

OK, i hope you don't try to market your game with the current obvious copyright issues.

Aside from that if I understand your problem your hero sprite has a background of every combination of background. In response I will say all you need to do is render top to bottom of your view port and make sure the hero has a transparent background.

As for the UI you could also draw it onto the map in a separate layer above the map making it able to be slightly transparent and any other effects.

EDIT

Since your player is a single cell in size it would be easy to render your grid like you are doing then simply render the player afterwards with a transparent background to ensure that what the play is standing on is seen.

A more advanced way is to render in layers in such a way that your player can walk behind backs of buildings and trees.

To do this you will need to multiple passes of rendering for example one way could be

  1. Render the ground information, in your current map you have grass and water etc.
  2. Render the tiles that cant be passed through sprites such as bottom part of buildings and bottoms of trees and your bushes.
  3. Render the player on top of all that.
  4. Render the tops of buildings and tree, this will allow a player to be rendered behind the tops of objects.
  5. Finally render your UI layer with buttons etc (these will be drawn and the click handled by you not java).

The advantage to doing 1 and 2 separately comes into play when you want different ground textures for example, rocky grass, desert. by having transparency on all objects backgrounds it will allow the background through for example your bushes could be rendered on desert or grass with no extra images.

Remember tho to render all of this to an off screen image and then display the image after completions as it will ensure your frame rate don't drop to the increase in rendering.

If I haven't understood your question please clarify and i will update my answer.

share|improve this answer
    
Yes, I am changing all the images. I just wanted something for a basic feel to start the game off... Yes, you are right. Now the problem is that I have no clue how to do that...and with something like this I feel like it will take me awhile to figure it out. My question (and maybe I will have to show you some code if you willing to quick glance at it Saturday) is how to implement, and how to implement it without redo'ing a lot of the movement engine. –  Austin Jul 19 '12 at 14:06
    
@Austin I have updated my answer to include a basic idea of what would be needed. And sure but you have no other way to contact me other than here. –  AbstractChaos Jul 19 '12 at 20:24
    
This what I want to do...the only problem is..I have no clue how or what packages of Java I should use to be doing this, based on the code right now... Since I can have someone talk to me via skype about this, should I try finding a place where someone could look at it personally...how I have it setup it decently unique I think. And due to that, I need something more to grasp to start with. Thank you though! :) –  Austin Jul 19 '12 at 22:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.