Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7884163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:43:27+00:00 2026-06-03T04:43:27+00:00

So i had a console game i made, and i thought in making it

  • 0

So i had a console game i made, and i thought in making it 2d.
So far so good everything was fine.
I have movement and other things working fine.
And the drawing was fine,until i had this idea.

( my “map” is a Tile[][] )
I thought in creating a class that would represent a layer then a playable map would be a
Layer[] and i would draw the layers over each others and maybe store some on memory for faster drawing.

I thought this was a ‘good’/’okay’ idea.(i would appreciate if someone would tell me if it is a good idea or not)

The problem is when i use 2 Layers the second layer always messes the first one.
The code i use to draw the ‘map’ looks like this:

    for (TileLayer layer : layers)
        g.drawImage(layer.getImage(), 0, 0, null);

the layer.getImage() is correct (pretty sure, works with just one layer).
The problem is that when i draw 2 layers the second one blacks out everything in the first layer.
I have the layer draw code like this:

    BufferedImage img = new BufferedImage(tiles.length * Tile.TILE_SIZE,
                                          tiles[0].length*Tile.TILE_SIZE, 
                                          ColorSpace.TYPE_RGB);

    for (int x = 0; x < tiles.length; x++) {
        for (int y = 0; y < tiles[0].length; y++) {
            //System.out.println("ID:" + tiles[x][y].getId());
                img.getGraphics().drawImage(tiles[x][y].getImage(),
                                        x * Tile.TILE_SIZE,
                                        y * Tile.TILE_SIZE,
                                        null);
        }
    }

Its a java applet i was overriding ‘paint’, i have changed that.
I tried using a transparent image to represent ‘air’ ( thought this should work probably messed it up).
tried adding a condition to prevent drawing when it shouldn’t.

I might have made something that works in a wrong way.
Help on a proper way to do this would be nice.
(or tell me where I might have it wrong)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:43:29+00:00Added an answer on June 3, 2026 at 4:43 am

    In the example, you appear to be using the wrong constant as the BufferedImage type.

    If you want your BufferedImage to allow transparency, set the last parameter to BufferedImage.TYPE_INT_ARGB (or one of the type constants on BufferedImage that has “A” in the last bit).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Had a page that was working fine. Only change I made was to add
Had a problem with the recursive conflictCheck() method. That seems fine now. I have
Making game of life I need to a have a grid that is 30x20
I had this console application. Now i have added Environment variable PATH to its
I have a game project which runs very fine in device in both debug
I have a Qt project which I have had a debug console displayed whilst
Had a few problems getting background-image displaying in Firefox, I made it work but
Had a good search here but can't see anything that gets my mind in
Had this working; at one stage. The problem is the following text is now
I had made an application on Struts 1 with AJAX and JQuery. Now I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.