After giving up on using Box2D for Dart (the language), and then giving up on porting my Java code to Dart, I've started afresh.
I've learnt a fair bit about Dart, and how I want to program with it. Here's my 3rd attempt, with a level editor (in green space)
I've used the model from my previous post as the character (it still needs cleaning up) which I believe looks much better than my previous attempt.
The idea is to have the walls and floors filled in automatically, instead of needing to create a model for each possible combination. I can see that rendering so many small meshes (2 triangles) is inefficient, so I'll probably have to merge them into one after editing is complete.
One of the cool features in Dart is this:
bool get isItemSolid => _solidity ~/ 2 == 1;
It's a cool example of:
- Arrow functions (one-liners using "=>")
- Getters (looks like a field, actally invokes a method. Less clutter)
- Integer division (no unnecessary casting)
- Private fields (start with "_" always)