Skip to content

Commit

Permalink
initial project release
Browse files Browse the repository at this point in the history
  • Loading branch information
m1cr0lab committed Oct 6, 2019
0 parents commit 38233e0
Show file tree
Hide file tree
Showing 32 changed files with 2,986 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Donkey-Kong-Jr.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// -------------------------------------------------------------------------
// Donkey Kong Jr
// a Nintendo's Game & Watch adaptation on Gamebuino META
// -------------------------------------------------------------------------
// © 2019 Steph
// https://gamebuino.com/@steph
// -------------------------------------------------------------------------

// include the game engine
#include "src/engine/Game.h"

// includes the official library
#include <Gamebuino-Meta.h>

// -------------------------------------------------------------------------
// Initialization
// -------------------------------------------------------------------------

// creates the game engine
Game game;

void setup() {
// initializes the META
gb.begin();
// default screen buffer won't be used
// so it must be set to 0x0 pixels
gb.display.init(0, 0, ColorMode::rgb565);
// sets the display frame rate
gb.setFrameRate(Game::FrameRate);
// initializes the game engine
game.setup();
}

// -------------------------------------------------------------------------
// Main control loop
// -------------------------------------------------------------------------

void loop() {
// makes sure that the Gamebuino Meta runs at a constant framerate
// (as long as the CPU load is not exceeded)
gb.waitForUpdate();
// delegates the control loop to the game engine
game.loop();
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Stéphane Calderoni

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
58 changes: 58 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Donkey Kong Jr

This is an adaptation for the [Gamebuino META][gamebuino] of the famous eponymous game, released in 1982 by Nintendo on his Game & Watch system.

I tried to stay consistent with the original version by scrupulously examining some demonstration videos on YouTube, but this task proved to be laborious and imprecise... I think I have managed to make a fairly faithful adaptation despite everything. You'll tell me what you think :-)

<table cols="2">
<tbody>
<tr>
<td>
<img width="428" src="https://gamebuino.caffe1ne.com/share/donkey-kong-jr/game-and-watch-1380x828.jpg" alt="Original Game & Watch" />
</td>
<td>
<img width="428" src="https://gamebuino.caffe1ne.com/share/donkey-kong-jr/demo-856x462.gif" alt="Demo" />
</td>
</tr>
</tbody>
</table>

This project was born out of [a request from Jicehel][request] in the beginning, who wanted a programming model on which to base itself to make another game, also released on Nintendo Game & Watch system: [Parachute][parachute]. I then provided him with a demo code implementing a methodology for making this type of game with the Gamebuino META. And I chose to apply it to a draft of Donkey Kong Jr. After a few days, I finally decided to make the game in its entirety.

The game uses the full resolution of the META: 160x128 pixels with a 16-bit color depth. Graphics rendering is done with low-level techniques based on the `gb.tft` API, and does not use the standard `gb.display` API.

## The story of the game

Mario has locked Donkey Kong in a cage, and you play the role of his son, Junior, who is trying by all means to save him. To open the cage, you will have to collect successively the four necessary keys, while avoiding the dangers that will arise in your path.

## Instructions for use

<img width="600" src="https://gamebuino.caffe1ne.com/share/donkey-kong-jr/gamebuino-meta-1399x551.png" alt="How to play" />

Button A starts Game A.
Button B starts Game B.
The pace of Game B is much faster than that of Game A.

Move Junior using the D-PAD, and press the A button to jump.
But beware, the pace of the game is accelerating over time...

Use button B to turn off the sound effects.

You can also use the MENU button to alternate the display of the score, CPU load and available memory space. I had added this feature for debugging, and finally kept it. It may help you to see that the optimization of the graphic rendering is quite successful 😎

## Source code

The source code is fully documented to help you better understand the implementation and create your own adaptations of Game & Watch on Gamebuino META.

## Acknowledgements

I would like to thank [Andy][aoneill], who explained us how to use the DMA controller to optimize framebuffer transfers to the display device and, at the same time, exploit the full resolution of the META (160x128 pixels in 16-bit color depth).

I would also like to thank [Valden][valden] who released [a small utility][gsfxgui] very useful to easily set up and integrate procedural sounds into our Gamebuino applications. I had initially chosen to integrate sound effects in the WAV format, but reading this format at runtime consumes far too much CPU, and I finally gave up the idea.

[gamebuino]: https://gamebuino.com/
[request]: https://community.gamebuino.com/t/demande-de-squelette-resolu/943
[parachute]: https://community.gamebuino.com/t/parachute-hd-meta/964
[aoneill]: https://gamebuino.com/@aoneill
[valden]: https://gamebuino.com/@valden
[gsfxgui]: https://gamebuino.com/creations/gamebuino-sound-fx-creation-tool-gsfx-gui
Binary file added assets/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/bootscene.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/digits.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/spritesheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added binaries/Donkey Kong Jr/Donkey Kong Jr.bin
Binary file not shown.
Binary file added binaries/Donkey Kong Jr/icon.bmp
Binary file not shown.
Binary file added binaries/Donkey Kong Jr/titlescreen.bmp
Binary file not shown.
2 changes: 2 additions & 0 deletions config-gamebuino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// sets the binary folder name on the META
#define FOLDER_NAME "Donkey Kong Jr"
9 changes: 9 additions & 0 deletions sounds/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Sound effects

I had managed to find some nice sounds in WAV format for the sound effects of the game...
But I finally decided not to use them, because reading such sounds at runtime consumes too much CPU.

So I preferred to use procedural sounds, which I set up with the [Valden utility][GSFX GUI].
And I would like to take this opportunity to thank him, because his little utility really made my job easier.

[GSFX GUI]: https://gamebuino.com/creations/gamebuino-sound-fx-creation-tool-gsfx-gui
Binary file added sounds/lost.wav
Binary file not shown.
Binary file added sounds/move.wav
Binary file not shown.
Binary file added sounds/score.wav
Binary file not shown.
Binary file added sounds/tick.wav
Binary file not shown.
61 changes: 61 additions & 0 deletions src/data/Score.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "Score.h"
#include "../sounds/Buzzer.h"

Score::Score() {
reset();
}

uint16_t Score::getValue() {
return value;
}

uint16_t Score::getHighA() {
return highA;
}

uint16_t Score::getHighB() {
return highB;
}

void Score::reset() {
value = 0;
target = 0;
}

void Score::inc(uint8_t amount) {
if (amount == 1) {
target = ++value;
Buzzer::play(Sound::Score);
} else {
target += amount;
}
}

bool Score::isIncreasing() {
return value < target;
}

void Score::update() {
if (value < target && gb.frameCount % 2 == 0) {
value++;
Buzzer::play(Sound::Score);
}
}

void Score::load() {
value = gb.save.get(0);
highA = gb.save.get(1);
highB = gb.save.get(2);
}

void Score::saveA() {
if (value > highA) highA = value;
gb.save.set(0, value);
gb.save.set(1, highA);
}

void Score::saveB() {
if (value > highB) highB = value;
gb.save.set(0, value);
gb.save.set(2, highB);
}
33 changes: 33 additions & 0 deletions src/data/Score.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef DONKEY_KONG_JR_SCORE
#define DONKEY_KONG_JR_SCORE

#include <Gamebuino-Meta.h>

class Score
{
private:

uint16_t target;
uint16_t value;
uint16_t highA;
uint16_t highB;

public:

uint16_t getValue();
uint16_t getHighA();
uint16_t getHighB();

void inc(uint8_t amount);
bool isIncreasing();
void reset();

Score();

void update();
void load();
void saveA();
void saveB();
};

#endif
Loading

0 comments on commit 38233e0

Please sign in to comment.