Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


TileMap java side/up scrolling


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Winter dragon   Members   -  Reputation: 105

Like
0Likes
Like

Posted 06 April 2012 - 03:41 PM

Hey, im very new game development, but i've tried very basic games like tetris and such, right now im Using LWJGL as i find it much easier to handle things with that library, right now im working on a very basic RTS game for testing purpose. But im having problems with the "camera" im using a tilemap to display my textures but how do i move my camera around in such a map? i've tried searching for it but i can't seem to find it anywhere with a tilemap any feedback would be a great help :).

Sponsor:

#2 Narf the Mouse   Members   -  Reputation: 318

Like
0Likes
Like

Posted 06 April 2012 - 09:41 PM

http://www.youtube.com/user/nickgravelyn/videos?sort=dd&view=0&page=4 - Do you mean a sprite map?

If you mean 3D, the basic idea is similar, but the implementation changes.

#3 Winter dragon   Members   -  Reputation: 105

Like
0Likes
Like

Posted 07 April 2012 - 07:31 AM

I see where my post could have caused some confusion sry, i meant 2D and as i understand it there is no actual camera in 2D.

#4 Narf the Mouse   Members   -  Reputation: 318

Like
0Likes
Like

Posted 07 April 2012 - 12:37 PM

I see where my post could have caused some confusion sry, i meant 2D and as i understand it there is no actual camera in 2D.

There's a camera; if you watch the tile engine videos at the link, it'll be explained. :)

#5 Kyan   Members   -  Reputation: 395

Like
0Likes
Like

Posted 07 April 2012 - 01:24 PM

I see where my post could have caused some confusion sry, i meant 2D and as i understand it there is no actual camera in 2D.

Indeed. The typical way to do this is to "scroll" your background as you move, just as you would for a typical sidescroller (platformer) except your view is top-down instead of side-on. A "camera" object helps to keep track of where the player is actually looking, but for 2D purposes it's nothing more than a simplified frustum in the form of a bounding box.

For an RTS, your basic map should be several times the size of the visible screen (for this example only, there's a lot of different ways to break up terrain). Since you mention that you are using a tilemap, I will assume you know how to handle your map data. Thus, at any given point in time, your user's visible position can be calculated as an offset from wherever you consider the map origin (OpenGL considers it at the bottom left of the screen) and the total dimensions, like this:

[(offsetX, offsetY), (offsetX + screen width, offsetY + screenHeight)]


which is better demonstrated by this super-quality diagram:
Posted Image
where the orange rectangle represents the visible area and the grid itself represents your map broken up into various tiles. Essentially, every time your player moves you draw a different portion of your map. Keep in mind that there are two different coordinate systems in play here: your world coordinates and the local, screen coordinates that you'll use to render. Pretty simple, just ensure you have boundary checks in place so you don't run afoul of out-of-bounds problems, etc.

#6 Winter dragon   Members   -  Reputation: 105

Like
0Likes
Like

Posted 07 April 2012 - 04:25 PM

Thanks for the replies, Specially the last one i got it working with that (really nice) diagram :)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS