Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (429)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (468)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Map Editor performance question  (Read 494 times)
0 Members and 1 Guest are viewing this topic.
Offline Onatoko

Senior Newbie





« Posted 2011-12-14 19:50:27 »

I'm working on a 2D tile-based map editor and I have a question about how best to manage the tile images. If, for example, I have a 1,000 x 1,000 tile map, what is the best way to display the image in the window so it can be updated quickly?

I have a TileMap class which stores the tile information, and my first thought was to combine the tiles into one image whenever the map is updated. But upon further thinking, I imagined that a map with a million tiles might take a long time to do that so I was curious if there was a better way to achieve this. Perhaps by only making the part of the map that is currently in the window? And if that is the case, how would this be done?

Another thought: Is there a way to have one image like I originally thought, but to just update that image whenever a cell is changed?

I'm just looking for options with how to procede, so any help is greatly appreciated Smiley
Offline Embedded

Junior Member


Medals: 1



« Reply #1 - Posted 2011-12-14 20:04:18 »

The way i would do it would be to draw all the tiles relative to a rectangle and just move that rectangle about

To make it only draw stuff on screen I find a point on the screen and then find the points potition in tiles, then i take some away from it
upperX = pointXInTiles - 14
upperY = pointYInTiles - 14

Now your for loops dont have to run through every tile for example

20 being the width of the screen in tiles
   for (int i = upperViewY; i < (20 + upperViewY); i++) {
      for (int p = upperViewX; p < (20 + upperViewX); p++) {
                  //Do stuff like paint
              }
         }
Offline theagentd
« Reply #2 - Posted 2011-12-14 20:43:08 »

This maybe? If you have enough knowledge of OpenGL, it will work very well (just look at that frame rate!).

Anyway, start with what Embedded said, and see if it gives you satisfying performance.

Myomyomyo.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (81 views)
2014-04-15 18:08:23

BurntPizza (73 views)
2014-04-15 03:46:01

UprightPath (84 views)
2014-04-14 17:39:50

UprightPath (67 views)
2014-04-14 17:35:47

Porlus (84 views)
2014-04-14 15:48:38

tom_mai78101 (107 views)
2014-04-10 04:04:31

BurntPizza (167 views)
2014-04-08 23:06:04

tom_mai78101 (263 views)
2014-04-05 13:34:39

trollwarrior1 (214 views)
2014-04-04 12:06:45

CJLetsGame (223 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org 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‑gaming.org
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!