Results 1 to 12 of 12

Thread: New TileMap example

  1. #1
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default New TileMap example

    An new example in the ClanLib SVN (for the 2.2.8 release)

    TileMap demonstrates a simple smooth-scrolling, multi-layered tilemap engine.

    The tilemap level is defined in a resource file, and can contain any number of layers.


  2. #2

    Default

    That's great, just what I needed.

    Quick question (I haven't had a look at the source code yet), will it be possible to scale the tilemap?

  3. #3
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    The drawing part of the example is just really simple - about 40 lines of code. I'm sure you can find ways to scale the entire tilemap, for instance by calling set_scale on the tilemap sprite and calculating the screen positions accordingly. You could also perhaps set scale on the entire gc... many options

  4. #4

    Default

    Cool. I wrote something similar myself, but I'm not using any buffering, so it's a bit slower then it could be.

    I've tried scaling the entire gc but I can't seem to disable linear scaling (I want to achieve a retro effect).

    I'll have a look at your code in the evening. Thanks!

    EDIT:

    I had a look at your code. It's nice, but unfortunately it doesn't solve my problem.

    Is there a way of "pre-rendering" the map instead of rendering all the sprites at every iteration? I found some examples using CL_Surface and CL_Canvas, but these don't seem to be available anymore...
    Last edited by Maciej Baron; 04-04-2011 at 06:55 PM. Reason: Update

  5. #5
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    CL_Surface and CL_Canvas (from Clanlib V1.0) are now known as CL_FrameBuffer

    The canvas example is still there, Examples/Display_Render/Canvas http://clanlib.org/wiki/Canvas

  6. #6
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Quote Originally Posted by Maciej Baron View Post

    I've tried scaling the entire gc but I can't seem to disable linear scaling (I want to achieve a retro effect).

    ...

    Is there a way of "pre-rendering" the map instead of rendering all the sprites at every iteration?
    This is not required. For my methane brothers game, I render the 20x20 blocks (16x16 pixels per block) tile map every frame. This is still very fast.

    Also my game scales the entire gc and disables linear scaling.

    The game used to render the map to a buffer and blit the buffer every frame. But, I removed that to simplify the code.

    ( http://methane.sourceforge.net/ )

  7. #7

    Default

    But if I were to buffer the output beforehand? I will be rendering well over 20x20 blocks on the screen (I will be covering the whole screen with blocks that are 32x32 pixels) so that might be a lot of blocks. Moreover I will have several layers of objects.

    What would be the best solution?

  8. #8
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    In the past (around 1990's), it was slow drawing an entire screen.

    You needed to use "damage maps" to only draw areas that have been updated.

    With OpenGL, you would need to draw to the screen buffer (CL_FrameBuffer), then each frame copy the screen buffer to the screen.

    That's how clanGUI Texture Window manager works.

    ...But...

    If you are using OpenGL (clanGL1 or clanGL), it is sometimes faster to redraw the entire screen, without a screen buffer.

    The Pacman example redraws the entire tile map (51*51 tiles at 28x32 block size) at 1000fps.

    Internally ClanLib batch draws graphic operations, which is very fast.

  9. #9
    Lesser Knight
    Join Date
    Jun 2011
    Location
    Shanghai in China
    Posts
    53

    Default

    It's a excellent example.
    Make excellent games,make happly life.

  10. #10

    Default Cool Example - Where to Download?

    I'd like to see your source code. Is there a place I can download it? I might just be blind, but as far as I can tell the page on the ClanLib wiki only has a picture and description . . .

  11. #11
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    http://clanlib.org/wiki/Download

    Download the source package, it has all the ClanLib source and examples.

  12. #12

    Default Thanks

    Quote Originally Posted by sphair View Post
    http://clanlib.org/wiki/Download

    Download the source package, it has all the ClanLib source and examples.

    OK, thanks, I didn't realize you had to download them all at once.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •