Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 1086 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
« 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  

EgonOlsen (45 views)
2018-06-10 19:43:48

EgonOlsen (25 views)
2018-06-10 19:43:44

EgonOlsen (47 views)
2018-06-10 19:43:20

DesertCoockie (202 views)
2018-05-13 18:23:11

nelsongames (127 views)
2018-04-24 18:15:36

nelsongames (126 views)
2018-04-24 18:14:32

ivj94 (867 views)
2018-03-24 14:47:39

ivj94 (128 views)
2018-03-24 14:46:31

ivj94 (771 views)
2018-03-24 14:43:53

Solater (143 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!