You can jump, wall jump, stomp on enemies, and hold A to run faster. I mimicked Mario physics, so it should feel pretty familiar (albeit with slightly different acceleration/velocity values).
To be honest, the whole thing is a bit over-engineered right now. I've made a C++ game engine for the Gamebuino (which may be more overhead than it's worth right now... but to be honest, I'm liking the inheritence, because all of the world and object collisions happen in the base class).
Example of why this is nice... all the collision detection is handled in base classes, so all you gotta write is this:
- Code: Select all
// In Player.cpp
void Player::collideWith(Actor* other) {
switch (other->type) {
case T_ENEMY:
Enemy* o = static_cast<Enemy*>(other);
if (vy > 0) { // Same check as in Super Mario Bros., bugs and all :)
o->die();
jump();
} else {
die();
}
break;
}
}
(speaking of which, does anyone know if dynamic casting is possible with Arduino's C++ implementation?)
It has an animation engine, too, but it's currently only used by the player and hasn't been abstracted out. It supports instantiating new game actors on the fly (that go into stasis when off-screen to save CPU/RAM), so it's pretty flexible.
The level is stored in PROGMEM. I generate the map data from a .bmp, so I use an image editor as a level editor. I hope to add SD card streaming for levels soon (provided it's fast enough to do so), otherwise I'll run out of program space. SD card streaming would also allow for a companion game to let you make levels on the Gamebuino itself and save them to SD to play in the real game. If SD card streaming isn't fast enough, I could always read a level from the SD card to EEPROM, but the 100,000 rewrites makes me nervous.
I'm planning on adding music, more levels, more enemies, menus, and so on. Really, what I have now is all the groundwork so I can test streaming assets from the SD card. If all goes well, this game will pave my way for some more ambitious projects. Or maybe I'm just too optimistic
Plus, I'll probably release a less-specific pared-down version of my engine if anyone else wants to use it and improve it!
Here's what I have so far. Ignore the awkward level design, I just needed something to test the engine out:
Try it out and let me know how it feels! It's hard to play on an emulator, but it feels great to me on the real hardware. https://dl.dropboxusercontent.com/u/4239184/gamebuino/JAMISH.HEX