-
Notifications
You must be signed in to change notification settings - Fork 5
This Week in LesserPanda #10
Covering the days from 2016-06-23 to 2016-08-17.
It has been quite long since last post, but this time I'll anounce that the long-wait stable version comes.
No only tons of issues are solved, but also improvements are applied.
Previously the Tilemap
is feature ready yet hard to use, so I completely
re-design it to what it looks now. To seperate things into parts also evolved
a new concept "level".
Let'me introduce them in detail.
Tilemap is changed a lot and now seperated to several independent components. The new API is heavily inspired by impact.js framework, and contains 2 major part:
- BackgroundMap
- CollisionMap
BackgroundMap
is just a single layered tilemap, while CollisionMap
is a tilemap specificly for tile based collision.
A method called loadLevel
will be injected into Scene
if you requited
the engine/level
module. A level is simply a list of layers of various
types.
Just like impact.js users can build levels from
level editor and load that in the game, you can now design levels(including
map, layer and actors) by writing it down in the right format, and provide
it to loadLevel
method.
While the level format is quite straight-forward, here's an example:
[
// A tile map(layer)
{
type: 'tile',
tilesize: 16,
tileset: 'pizza-boy.png',
data: [
[45,46,46,46,46,46,46,47],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[45,46,46,46,46,46,46,47],
],
parent: 'bottomLayer',
},
// A collision map
{
type: 'collision',
tilesize: 16,
data: [
[1,1,1,1,1,1,1,1],
[1,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,1],
[1,1,1,1,1,1,1,1],
],
},
// An actor layer, including several actors
{
type: 'actor',
container: 'bottomLayer',
actors: [
['Box', 40, 40, { name: 'box' }],
],
},
]
The map format is JSON capable and will be used later in the official LesserPanda editor, but you won't need that long since there's also a Tiled importer that will take Tiled JSON file and convert to be able to load by the engine.
- Add some tile layers in Tiled editor, make sure that each layer uses only one tileset.
- Create some object layers, whose name will be also created during loading. And add some objects with
type
(the type should be registed as Actors before loading). - Export as JSON.
- Load the map file:
loader.addAsset('level01.json')
- Convert it to built-in format:
let mapData = tiledToMap('level01.json')
- Load the converted map data:
this.loadLevel(mapData)
Samples repo is kept updating to latest version of LesserPanda. And I decided to make samples along with any new features introduced to LesserPanda.
Project creating command is finally landed, now you can easily create
a new project with lpanda create MyAwesomeGame
.
More samples yeah! And better support of Tiled object layer. The Tiled editor will be supported before LesserPanda editor is out. To help developers improve the game making experience, I decided to continuously improve this feature.