Tag: tilemap

Unity Library: Tiled Tilemaps. Load tilemaps created with Tiled Map Editor.

 

The Tiled Tilemaps library is now available on the Unity Asset Store! With it you can create levels and tilemaps with the free, open source and multiplatform Tiled Map Editor. The initial package price will be ONLY US$ 5.00! You can get it here: http://u3d.as/2SM.

Features

  • Drag and drop the Tiled Tilemaps prefab, drag your Tiled map XML, drag the tilesets textures and the map is created.
  • Orthogonal maps.
  • Multiple Layers and Transparency.
  • Multiple Tilesets across different layers and even on the same layer.
  • Big maps without gaps between the tiles.
  • Bleeding correction (if you get gaps, you can correct with an available property).

Examples

You can see some examples in a web playable build here: http://karnakgames.com/products/tiledtilemaps/.

Reference and HOW TO

Documentation available here: http://karnakgames.com/wp/unity-tiled-tilemaps/.

Roadmap

  • Object layers.
  • Map, Layer and Tile properties.
  • Tile switching.
  • Object layers.
  • Map, Layer and Tile properties.
  • Tile switching.
  • Isometric maps.

Learning Diary #10: Lua, socket server, path finding, quaternions

 

12/Jul/2010

Using Lua and a Socket Server to test and debug iPhone Games

Damn, too many balloons. Ops, just change the Lua code real time!

Damn, too many balloons. Ops, just change the Lua code real time!

I already talked about #iDevBlogADay. But let’s say it again: I just love this “group”! The first thing I do when I wake up is checking the feed for the day’s articles. And how sad I get if an author hadn’t published his take yet.

Everyday we get 2 new nice articles from fellow indie (or established or beginners – like me)  game developers. One of these articles “Tweak Away” from Mystery Coconut brings Lua and socket servers into your iPhone game development.

Main points you’ll learn from the article:

  • How to open a debug server for your game.
  • How to integrate Lua into your game and how it can access your game elements.
  • Change your game behaviors and state via command line (e.g.: no more re-compiling to change the speed of a ball).
  • Scripting all of your game content and behavior.

And yes, Miguel makes everything that easy for us :)

Path Finding

  • Path finding class for a RTS game: ASIPathFinder. “ASIPathFinder is a complete implementation of a cooperative path finding algorithm, and will probably be most useful for writing Real Time Strategy games. It is written in Objective-C, and is compatible with Mac OS and iPhone OS.”
  • Cocos2D, Path finding and Tile maps – sample app: cool working code which I found on Cocos2D forums.

Cocos2D

  • RenderTexture: let’s explain via an example: for a shooter game which leaves bullet holes, we could use sprites for these holes, but a RenderTexture is memory saver.
    a) Sprites: 500 holes – 500 sprites – 1000 triangles – 2000 vertexes.
    b) RenderTexture: will draw only one sprite – it takes a picture and work in that picture.
  • EAGLView: create the OpenGL context.

Drawing with Quartz2D

  1. Save current context
  2. Perform a single combined matrix transformation
  3. Draw graphics to this transformation
  4. Restore context

Source: Beginning iPhone Games Development

Quaternion

  • Sum of a scalar and a vector
  • The quotient of two vectors
  • Imaginary number: i * i = -1
  • A quaterion is a complex number extension: 3 numbers all square roots of -1: i, j, k
  • j * j = -1, k * k  = -1
  • q = w + xi + yj + zk (w = real, x, y, z = complex).
  • or q = [w, v] (w = scalar, v = (x,y,z) – vector)

Source: http://www.gamedev.net/reference/articles/article1095.asp, http://www.paradeofrain.com/2010/07/lessons-learned-in-tilt-controls/

Learning Diary #9: Cocos2D and Tile maps and more Box2D

 

06/Jul/2010

Tiled (my map is awful, I know)

Tiled (my map is awful, I know)

  • Another day invested reading Ray Wenderlich tutorials! This time, I’ve read his last two tutorials @Box2D and the ones about Cocos2D with tiled maps from Tiled. Pretty easy and clear:
    - How To Create A Breakout Game with Box2D and Cocos2D Tutorial: Part 1 and Part 2.
    - How To Make a Tile Based Game with Cocos2D and Collisions and Collectables: How To Make a Tile Based Game with Cocos2D Part 2.
  • What can I say about these tutorials? Well, I learned almost every concept behind Cocos2D, Box2D, tiled maps and some more concepts (like general game structure, how to put together Physics, general game loop, AI – even if he doesn’t cite AI, and so on). I already had some game development background (I read gamedev books for 6 years already), but even if you are starting, you will get a lot of knowledge reading them.
  • Objective-C: GamingHorror commented on last post that Objective-C can remove an object from an array while iterating through it if using a regular loop (as in C and C++). We just can’t remove an object if using a fast numerator (for..in). Thanks Steffen for the tip!
  • I was reading the source code from C++ STL find iterator and I saw on the documentation:
    // @return The first iterator @c i in the range @p [first,last) such that @c *i == @p val, or @p last if no such iterator exists.

    I was scared for not remembering what [a,b) meant. So, time for some Wikipedia about math and here we have a little refreshment on math sets and intervals notations:

    () exclude
    [] include
    ][ exclude
    Ex: [a,b) = a <= x < b

Cocos2D and Tiled

  • For the sake of curiosity, on 2004 I posted on Gamedev.net (I am the poster Maquiavel) forums a topic with links to sprites' sites: http://www.gamedev.net/community/forums/topic.asp?topic_id=272386. It is still rocking! Although most of the listed sprites are copyrighted, they may be useful to in-house prototyping or just curiosity. I don't know why I made that topic, since I'm only make into game development now, maybe because I love to see those sheets full of colors and life.
  • We get performance if we put all of our animations in one big sprite sheet (max. dimension: 1024x1024). That can be easily accomplished using Zwoptex.
  • Tiled has tile layers and object layers (boxes around portions of the map to specify events).
  • Cocos' convertToNodeSpace: as an example the user clicks in the viewpoint (scrolling camera) at 100,100. But let's say the map is scrolled to 800,800. convertToNodeSpace matches the touch with the scrolling / node zoom / etc.
  • CCTMXTiledMap: it's a CCNode (position, scale, rotation, etc). Its children are layers (CCTMXLayer) of the map generated with Tiled. CCTMXLayer is a CCSpriteSheet, which means we can only have one tileset per layer.
  • Helper function to convert from screen coordinates to tile coordinates:
    // Helper: Position to Tile Coord (upper left, increments each tile)
    // @author http://www.raywenderlich.com
    - (CGPoint)tileCoordForPosition:(CGPoint)position {
        int x = position.x / _tileMap.tileSize.width;
        int y = ((_tileMap.mapSize.height * _tileMap.tileSize.height) - position.y) / _tileMap.tileSize.height;
        return ccp(x, y);
    }

Box2D

  • Box2D

    When giving values to Box2D: pixels/PTM_RATIO

  • When getting values from Box2D: boxvalue * PTM_RATIO (obviously)
  • Mouse joint: makes a body move toward a specific point. Requires:
    - 2 bodies: static or moving body and body you want to move (Box2D manual note: All joints are connected between two different bodies. One body may static. Joints between static and/or kinematic bodies are allowed, but have no effect and use some processing time.).
    - Target: where to move.
    - Collide Connected: when both bodies collide, treat as collision.
    - Max Force: less force, less reaction from our movements.
  • setAwake: for objects that sleep.
  • linearDamping: to reduce speed from a moving body.
  • Contact Listener: it will be called by Box2D when 2 objects begin to touch and stop touching. Btw, we can't store references to the contact points, because Box2D reuses them. We need to copy them inside our contact listener.
  • setAsBox: we have to pass half dimensions.