Hi !
Featured games (88)
games approved by the League of Dukes
Games in Showcase (679)
Games in Android Showcase (194)
games submitted by our members
Games in WIP (732)
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 666 times)
0 Members and 1 Guest are viewing this topic.
Offline Onatoko

Senior Newbie

« Posted 2011-12-14 18: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 Devvie

Medals: 1

« Reply #1 - Posted 2011-12-14 19: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

« JGO Bitwise Duke »

Medals: 748
Projects: 4
Exp: 8 years

« Reply #2 - Posted 2011-12-14 19: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.

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

Hydroque (2 views)
2016-05-26 14:45:46

Mac70 (33 views)
2016-05-24 21:16:33

theagentd (42 views)
2016-05-14 18:38:35

theagentd (73 views)
2016-05-10 22:37:41

theagentd (79 views)
2016-05-10 22:33:46

IanParcs (110 views)
2016-04-18 14:18:53

KaiHH (104 views)
2016-04-18 08:35:41

KaiHH (129 views)
2016-04-15 12:43:58

theagentd (133 views)
2016-04-14 02:16:17

theagentd (157 views)
2016-04-14 02:15:43
FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17

List of Learning Resources
by SilverTiger
2016-02-05 09:39:47

List of Learning Resources
by SilverTiger
2016-02-05 09:38:38

List of Learning Resources
by SilverTiger
2016-02-05 09:35:50 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‑
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!