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 6375405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:36:40+00:00 2026-05-25T01:36:40+00:00

I am writing a tile based platform game. At the moment I am trying

  • 0

I am writing a tile based platform game. At the moment I am trying to get 400 tiles to display at once. This is my panel. On the top and left sides everything is working great but on the right and bottom sides the images are cut off by a few pixels. Each image is 32*32. All of blocks are initialized. None are null. What is wrong here?

public class Pane extends JPanel implements ActionListener{

    private static final long serialVersionUID = 1L;
    Timer timer;
    boolean setup = false;
    Block[][] blocks;
    Level level;
    public Pane()
    {
        level = new Level();
        level.Generate();
        blocks = level.Parse();
        setBackground(Color.WHITE);
        timer = new Timer(25, this);
        timer.start();
    }

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2d = (Graphics2D)g;
        for(Block[] b : blocks)
        {
            for(Block bx : b)
            {
                // Debug code if(bx.letter.equals("D"))
                // Debug codeSystem.out.println(bx.y*32 +" = "+ bx.x*32);
                g2d.drawImage(bx.bpic, bx.x*32, bx.y*32, this);
            }
        }
        Toolkit.getDefaultToolkit().sync();
        g.dispose();
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        repaint();  
    }
}
  • 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-05-25T01:36:40+00:00Added an answer on May 25, 2026 at 1:36 am

    on the right and bottom sides the images are cut off by a few pixels

    If you mean the right and bottom sides of the whole panel (not on the single tiles), than it’s probably a LayoutManager related problem. The solution depends on the layout manager you are using for the component your JPanel will be added to.

    You could try to specify the minimum/preferred size of your JPanel with:

    Pane pane = new Pane();
    pane.setPreferredSize(...);
    pane.setMinimumSize(...);
    

    In order to specify its minimum dimension accordingly to the size of the generated image (32 * COL , 32 * ROW).
    Unfortunately the effectiveness of the setPreferredSize call depends on the layout manager of your Pane parent component.

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

Sidebar

Related Questions

I'm writing a little tile-based game, for which I'd like to support light sources.
I am working on a tile based, top-down 2D game with dinamically generated terrain,
I am writing a rogue-like game in Python and am defining my Tile class.
I'm trying to use a texture atlas in a game program I'm writing in
Writing a mapping application on iOS, making use of OpenStreetMap tiles. Map tile images
Suppose I'm writing a 2d tile based MMORPG. Furthermore suppose I hate flash. Lastly,
I'm teaching myself jQuery by writing the game of memory (where you turn tiles
I'm coding a tile based game in javascript using canvas and was wondering how
I am trying out different looks of a little game I am writing to
i am writing algorithm for puzzle game.I am putting puzzles in spiral in this

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.