2. Graphics processing and collisions
Game graphic is mostly based on 32x32 pixels tiles. By default size of first two levels are 32x24 blocks (1024x768) with Pixels to Units set to 32. The last two levels are 64x48 blocks (2048x1536). To make the game "lighter" all huge static surfaces like walls and floors was exported by Tiled Map Editor to PNG files. Tiled Map Editor is a very useful free software to build whole levels out of tiles. Program has few really useful options like layers and export to PNG which I needed the most. Created PNG file are used in 2D Unity Project as sprites, instead of surfaces build out of hundreds of small objects. Each object is traced by our CPU and if game will get bigger we can easily overload processor. To prepare the tiles I mostly used Photoshop and another really good free feature called Sprite Splitter but Paint.NET or Gimp are sufficient enough.
For collisions I used Box Colliders 2D drawing them around walls and other objects that I want to collide with.
Really important is to center camera and all sprites, put them on numbered layers and set values to them in order from bottom up. That allowed me to manipulate what will be drawn on top of what in easy way.
I strongly recommend using tools like Tiled Map Editor. I saved a lot of time producing whole levels graphics using this small program.
Example of PNG graphic representing walls of of my ground level building; assembled out of 32x32 small blocks using "Tiled" program:
Another PNG graphic for floors:
When you join then together:
The only thing you have to keep in mind is layers (what is displayed on top of what) and to add "Polygon collider 2D" for walls.
No comments:
Post a Comment