# Slick Forums

Discuss the Slick 2D Library
 It is currently Tue May 21, 2019 5:10 am

 All times are UTC

 Page 1 of 1 [ 1 post ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Tiled Rendering certain parts of map?Posted: Wed Mar 06, 2013 4:29 pm

Joined: Thu Feb 28, 2013 3:20 am
Posts: 1
Hi,

I've looked through the Documentation for this and tried to apply the theory to my game and it didn't work out. I've also looked around on the forums for a thread similar and I haven't found one (if there is one though, I apologise).

Slick2D offers a rendering method for TiledMaps that allows you to render only a certain part of the map.

Code:
map.render(x, y, sx, sy, ex, ey); // x, y, startX, startY, endX, endY

I want to use this for infinitely large maps (it doesn't matter how big the map is because you're only rendering a certain part of it).

The system I used to use was basically like a "Prelude of the Chambered" type thing where the map was an image containing colors that represented a tile at that position on the map. I would use this method again but given Slick has support for Tiled I want to make use of it.

The code for the, what I called a "Bitmapping" system, was this:
Code:
int x0 = xScroll >> 5; // 5 because my sprites are 32 bit, 5 zeros in binary 32.
int y0 = yScroll >> 5;
int x1 = (gc.getWidth() + 32) >> 5; // my sprites are 32 bit (32 x 32).
int y1 = (gc.getHeight() + 32) >> 5;
for (int y = y0; y < y1 + y0; y++) {
for (int x = x0; x < x1 + x0; x++) {
getTile(x, y).render();
}
}

// and xScroll and yScroll are:
int xScroll = player.pos.x - (Game.WIDTH / 2);
int yScroll = player.pos.y - (Game.HEIGHT / 2);

I'm no longer getting each and every individual tile (not really any need now since Slick can do that for me).

I tried using the first four vars in the previous code and xScroll and yScroll haven't changed, which led to this:
Code:
map.render(-xScroll, yScroll, x0, y0, x1, y1); // negative scrolling because the map has to move in the opposite direction of the player.

The map was rendering, but it would jump a tile after passing every other tile in the map. I'm also pretty sure it was even doing the, what I'll call "chunking".

I'm pretty sure there aren't any forum questions because people have figured this out really quickly and easily, but I'm struggling for some reason. I'm sorry if this is painfully obvious.

So what am I doing wrong? What do I need to do? I hope I've given enough code and enough explanation.

Thanks.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 1 post ]

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ General    Games / Demos    Help / Discussion    Community Projects    Game Ideas/Design    Slick Competition 2011    Android Slick - LWJGL 2D Game Library    Announcements    Bug Reports / RFE    Extensions    Contribution depot Related Libraries and Tools    Phys2D    Tiled    TWL    Fizzy    Artemis Archive    Resolved Bugs/RFE    Useful Posts