Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Revision 20:762297435411, committed 2021-12-01
- Comitter:
- ranroun3
- Date:
- Wed Dec 01 19:44:43 2021 +0000
- Parent:
- 19:b6a0089535c3
- Child:
- 21:9c414fbf4a6f
- Commit message:
- added inventory, potions, items, and new buttons for using inventory
Changed in this revision
--- a/globals.h Wed Dec 01 17:46:03 2021 +0000
+++ b/globals.h Wed Dec 01 19:44:43 2021 +0000
@@ -32,6 +32,7 @@
extern PwmOut speaker;
extern wave_player waver;
+
// === [define the macro of error heandle function] ===
// when the condition (c) is not true, assert the program and show error code
#define ASSERT_P(c,e) do { \
--- a/graphics.cpp Wed Dec 01 17:46:03 2021 +0000
+++ b/graphics.cpp Wed Dec 01 19:44:43 2021 +0000
@@ -11,134 +11,143 @@
*/
static uint32_t duck3_arr[121] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16707840, 16707840, 0, 0, 0,
- 0, 0, 0, 0, 0, 16707840, 16707840, 0, 16707840, 0, 0, 16707840, 0, 0, 0, 0, 16707840,
- 16773632, 16707840, 16746496, 0, 0, 16707840, 16707840, 0, 0, 16707840, 16707840,
- 16707840, 16707840, 0, 0, 0, 16707840, 16707840, 16707840, 16707840, 16707840, 16707840,
- 16707840, 0, 0, 0, 0, 0, 16707840, 16707840, 16707840, 16707840, 16707840, 16707840,
- 0, 0, 0, 0, 0, 0, 16707840, 16707840, 16707840, 16707840, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0};
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16707840, 16707840, 0, 0, 0,
+ 0, 0, 0, 0, 0, 16707840, 16707840, 0, 16707840, 0, 0, 16707840, 0, 0, 0, 0, 16707840,
+ 16773632, 16707840, 16746496, 0, 0, 16707840, 16707840, 0, 0, 16707840, 16707840,
+ 16707840, 16707840, 0, 0, 0, 16707840, 16707840, 16707840, 16707840, 16707840, 16707840,
+ 16707840, 0, 0, 0, 0, 0, 16707840, 16707840, 16707840, 16707840, 16707840, 16707840,
+ 0, 0, 0, 0, 0, 0, 16707840, 16707840, 16707840, 16707840, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0
+};
static int* duck3 = (int*)duck3_arr;
static uint32_t portal1_arr[121] = {
- 0, 0, 0, 0, 0, 7028270, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7028270, 3516744, 7028270, 0,
- 0, 0, 0, 0, 0, 0, 7028270, 3516744, 1807455, 3516744, 7028270, 0, 0, 0, 0, 7028270,
- 7028270, 3516744, 1807455, 1807455, 1807455, 3516744, 7028270, 7028270, 0, 7028270,
- 7028270, 3516744, 1807455, 10411914, 10411914, 10411914, 1807455, 3516744, 7028270,
- 7028270, 7028270, 3516744, 1807455, 10411914, 10411914, 1807455, 10411914, 10411914,
- 1807455, 3516744, 7028270, 7028270, 3516744, 1807455, 10411914, 1807455, 3516744,
- 1807455, 10411914, 1807455, 3516744, 7028270, 7028270, 3516744, 1807455, 10411914,
- 1807455, 3516744, 1807455, 10411914, 1807455, 3516744, 7028270, 7028270, 3516744,
- 1807455, 10411914, 10411914, 1807455, 10411914, 10411914, 1807455, 3516744, 7028270,
- 7028270, 3516744, 1807455, 1807455, 10411914, 10411914, 10411914, 1807455, 1807455,
- 3516744, 7028270, 7028270, 3516744, 3516744, 1807455, 1807455, 10411914, 1807455,
- 1807455, 3516744, 3516744, 7028270};
+ 0, 0, 0, 0, 0, 7028270, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7028270, 3516744, 7028270, 0,
+ 0, 0, 0, 0, 0, 0, 7028270, 3516744, 1807455, 3516744, 7028270, 0, 0, 0, 0, 7028270,
+ 7028270, 3516744, 1807455, 1807455, 1807455, 3516744, 7028270, 7028270, 0, 7028270,
+ 7028270, 3516744, 1807455, 10411914, 10411914, 10411914, 1807455, 3516744, 7028270,
+ 7028270, 7028270, 3516744, 1807455, 10411914, 10411914, 1807455, 10411914, 10411914,
+ 1807455, 3516744, 7028270, 7028270, 3516744, 1807455, 10411914, 1807455, 3516744,
+ 1807455, 10411914, 1807455, 3516744, 7028270, 7028270, 3516744, 1807455, 10411914,
+ 1807455, 3516744, 1807455, 10411914, 1807455, 3516744, 7028270, 7028270, 3516744,
+ 1807455, 10411914, 10411914, 1807455, 10411914, 10411914, 1807455, 3516744, 7028270,
+ 7028270, 3516744, 1807455, 1807455, 10411914, 10411914, 10411914, 1807455, 1807455,
+ 3516744, 7028270, 7028270, 3516744, 3516744, 1807455, 1807455, 10411914, 1807455,
+ 1807455, 3516744, 3516744, 7028270
+};
static int* portal1 = (int*)portal1_arr;
static uint32_t tree_arr[121] = {
- 0, 0, 0, 6929217, 8047419, 7652919, 5023061, 4825944, 0, 0, 0, 0, 6928719, 7718968,
- 9888590, 10085712, 10085712, 7455797, 6995504, 6995504, 4365920, 0, 6995504, 6995504,
- 10085712, 6995504, 10085712, 9954126, 9493834, 6995504, 6995504, 6863923, 3642478,
- 7784504, 8047419, 10085712, 6995504, 7390004, 4102758, 6995504, 6995504, 6995504,
- 3642478, 0, 0, 2135397, 7784504, 7784504, 5919319, 4405572, 7784504, 6995504, 3642478,
- 0, 0, 0, 0, 2135397, 7784504, 8477784, 7356467, 3642478, 0, 0, 0, 0, 0, 0, 0, 0,
- 8477784, 8013622, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8477784, 8013622, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 8477784, 8013622, 6243668, 0, 0, 0, 0, 0, 0, 0, 0, 8671032, 8013622, 6174004,
- 0, 0, 0, 0, 0, 0, 0, 6702669, 9196602, 8867897, 6699313, 5715777, 0, 0, 0};
+ 0, 0, 0, 6929217, 8047419, 7652919, 5023061, 4825944, 0, 0, 0, 0, 6928719, 7718968,
+ 9888590, 10085712, 10085712, 7455797, 6995504, 6995504, 4365920, 0, 6995504, 6995504,
+ 10085712, 6995504, 10085712, 9954126, 9493834, 6995504, 6995504, 6863923, 3642478,
+ 7784504, 8047419, 10085712, 6995504, 7390004, 4102758, 6995504, 6995504, 6995504,
+ 3642478, 0, 0, 2135397, 7784504, 7784504, 5919319, 4405572, 7784504, 6995504, 3642478,
+ 0, 0, 0, 0, 2135397, 7784504, 8477784, 7356467, 3642478, 0, 0, 0, 0, 0, 0, 0, 0,
+ 8477784, 8013622, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8477784, 8013622, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 8477784, 8013622, 6243668, 0, 0, 0, 0, 0, 0, 0, 0, 8671032, 8013622, 6174004,
+ 0, 0, 0, 0, 0, 0, 0, 6702669, 9196602, 8867897, 6699313, 5715777, 0, 0, 0
+};
static int* tree = (int*)tree_arr;
static uint32_t npc_arr[121] = {
- 0, 0, 16313309, 16567203, 16567203, 16567203, 16567203, 16567203, 16313309, 16313309,
- 0, 0, 16313309, 16313309, 16567203, 16567203, 16567203, 16567203, 16567203, 16567203,
- 16313309, 0, 0, 16313309, 16313309, 16567203, 12047711, 12047711, 16567203, 12047711,
- 12047711, 0, 0, 0, 0, 0, 16567203, 12047711, 12047711, 16567203, 12047711, 12047711,
- 0, 0, 0, 0, 0, 16567203, 16567203, 16567203, 16567203, 16567203, 16567203, 0, 0,
- 0, 0, 0, 16567203, 16313309, 16567203, 16567203, 16567203, 16313309, 0, 0, 0, 0,
- 4666745, 8476330, 16313309, 16313309, 16567203, 16313309, 16313309, 4666745, 0, 0,
- 0, 4666745, 8476330, 8476330, 16313309, 16313309, 16313309, 8476330, 4666745, 0,
- 0, 4666745, 4666745, 8476330, 8476330, 8476330, 16313309, 8476330, 8476330, 4666745,
- 0, 0, 4666745, 8476330, 8476330, 8476330, 8476330, 8476330, 8476330, 8476330, 4666745,
- 0, 0, 4666745, 4666745, 4666745, 4666745, 4666745, 4666745, 4666745, 4666745, 4666745,
- 0};
+ 0, 0, 16313309, 16567203, 16567203, 16567203, 16567203, 16567203, 16313309, 16313309,
+ 0, 0, 16313309, 16313309, 16567203, 16567203, 16567203, 16567203, 16567203, 16567203,
+ 16313309, 0, 0, 16313309, 16313309, 16567203, 12047711, 12047711, 16567203, 12047711,
+ 12047711, 0, 0, 0, 0, 0, 16567203, 12047711, 12047711, 16567203, 12047711, 12047711,
+ 0, 0, 0, 0, 0, 16567203, 16567203, 16567203, 16567203, 16567203, 16567203, 0, 0,
+ 0, 0, 0, 16567203, 16313309, 16567203, 16567203, 16567203, 16313309, 0, 0, 0, 0,
+ 4666745, 8476330, 16313309, 16313309, 16567203, 16313309, 16313309, 4666745, 0, 0,
+ 0, 4666745, 8476330, 8476330, 16313309, 16313309, 16313309, 8476330, 4666745, 0,
+ 0, 4666745, 4666745, 8476330, 8476330, 8476330, 16313309, 8476330, 8476330, 4666745,
+ 0, 0, 4666745, 8476330, 8476330, 8476330, 8476330, 8476330, 8476330, 8476330, 4666745,
+ 0, 0, 4666745, 4666745, 4666745, 4666745, 4666745, 4666745, 4666745, 4666745, 4666745,
+ 0
+};
static int* npc = (int*)npc_arr;
static uint32_t dead_arr[121] = {
- 0, 0, 0, 16777215, 16777215, 16777215, 16777215, 16777215, 0, 0, 0, 0, 0, 16777215,
- 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 0, 0, 0, 16777215, 16777215,
- 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 0, 16777215,
- 16777215, 0, 0, 16777215, 16777215, 16777215, 0, 0, 16777215, 16777215, 16777215,
- 16777215, 0, 0, 16777215, 16777215, 16777215, 0, 0, 16777215, 16777215, 16777215,
- 16777215, 16777215, 16777215, 16777215, 0, 16777215, 16777215, 16777215, 16777215,
- 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 0, 16777215, 16777215,
- 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215,
- 16777215, 16777215, 16777215, 16777215, 16777215, 0, 16777215, 16777215, 16777215,
- 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 0, 0, 0, 16777215, 0,
- 0, 16777215, 0, 0, 16777215, 0, 0, 0, 0, 16777215, 0, 0, 16777215, 0, 0, 16777215,
- 0, 0};
+ 0, 0, 0, 16777215, 16777215, 16777215, 16777215, 16777215, 0, 0, 0, 0, 0, 16777215,
+ 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 0, 0, 0, 16777215, 16777215,
+ 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 0, 16777215,
+ 16777215, 0, 0, 16777215, 16777215, 16777215, 0, 0, 16777215, 16777215, 16777215,
+ 16777215, 0, 0, 16777215, 16777215, 16777215, 0, 0, 16777215, 16777215, 16777215,
+ 16777215, 16777215, 16777215, 16777215, 0, 16777215, 16777215, 16777215, 16777215,
+ 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 0, 16777215, 16777215,
+ 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215,
+ 16777215, 16777215, 16777215, 16777215, 16777215, 0, 16777215, 16777215, 16777215,
+ 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 0, 0, 0, 16777215, 0,
+ 0, 16777215, 0, 0, 16777215, 0, 0, 0, 0, 16777215, 0, 0, 16777215, 0, 0, 16777215,
+ 0, 0
+};
static int* dead = (int*)dead_arr;
static uint32_t boss_arr[121] = {
- 62208, 62208, 0, 0, 0, 0, 0, 0, 0, 62208, 62208, 0, 62208, 62208, 0, 0, 0, 0, 0,
- 62208, 62208, 0, 0, 0, 62208, 62208, 0, 0, 0, 62208, 62208, 0, 0, 0, 0, 62208, 62208,
- 62208, 62208, 62208, 62208, 62208, 0, 0, 0, 0, 62208, 0, 0, 62208, 0, 0, 62208, 0,
- 0, 62208, 62208, 62208, 0, 0, 62208, 0, 0, 62208, 62208, 62208, 62208, 0, 62208,
- 62208, 62208, 62208, 62208, 62208, 62208, 0, 62208, 62208, 0, 62208, 193024, 0, 0,
- 0, 193024, 62208, 0, 62208, 62208, 0, 62208, 62208, 62208, 62208, 62208, 62208, 62208,
- 0, 62208, 0, 0, 62208, 0, 0, 0, 0, 0, 62208, 0, 0, 0, 0, 62208, 0, 0, 0, 0, 0, 62208,
- 0, 0};
+ 62208, 62208, 0, 0, 0, 0, 0, 0, 0, 62208, 62208, 0, 62208, 62208, 0, 0, 0, 0, 0,
+ 62208, 62208, 0, 0, 0, 62208, 62208, 0, 0, 0, 62208, 62208, 0, 0, 0, 0, 62208, 62208,
+ 62208, 62208, 62208, 62208, 62208, 0, 0, 0, 0, 62208, 0, 0, 62208, 0, 0, 62208, 0,
+ 0, 62208, 62208, 62208, 0, 0, 62208, 0, 0, 62208, 62208, 62208, 62208, 0, 62208,
+ 62208, 62208, 62208, 62208, 62208, 62208, 0, 62208, 62208, 0, 62208, 193024, 0, 0,
+ 0, 193024, 62208, 0, 62208, 62208, 0, 62208, 62208, 62208, 62208, 62208, 62208, 62208,
+ 0, 62208, 0, 0, 62208, 0, 0, 0, 0, 0, 62208, 0, 0, 0, 0, 62208, 0, 0, 0, 0, 0, 62208,
+ 0, 0
+};
static int* boss = (int*)boss_arr;
static uint32_t water_arr[121] = {
- 0, 0, 0, 0, 0, 0, 40420, 424382, 0, 0, 0, 0, 0, 0, 0, 0, 40420, 40420, 424382, 0,
- 0, 0, 0, 0, 0, 0, 40420, 40420, 424382, 0, 0, 0, 0, 0, 0, 0, 0, 40420, 40420, 40420,
- 0, 0, 0, 0, 0, 0, 0, 40420, 40420, 40420, 40420, 424382, 0, 0, 0, 0, 0, 0, 40420,
- 13888759, 40420, 40420, 424382, 0, 0, 0, 0, 0, 40420, 13888759, 40420, 40420, 40420,
- 424382, 1190278, 0, 0, 0, 0, 40420, 13888759, 40420, 40420, 40420, 424382, 1190278,
- 0, 0, 0, 0, 40420, 40420, 13888759, 40420, 424382, 424382, 1190278, 0, 0, 0, 0, 0,
- 40420, 40420, 40420, 424382, 1190278, 0, 0, 0, 0, 0, 0, 0, 40420, 40420, 1190278,
- 0, 0, 0, 0};
+ 0, 0, 0, 0, 0, 0, 40420, 424382, 0, 0, 0, 0, 0, 0, 0, 0, 40420, 40420, 424382, 0,
+ 0, 0, 0, 0, 0, 0, 40420, 40420, 424382, 0, 0, 0, 0, 0, 0, 0, 0, 40420, 40420, 40420,
+ 0, 0, 0, 0, 0, 0, 0, 40420, 40420, 40420, 40420, 424382, 0, 0, 0, 0, 0, 0, 40420,
+ 13888759, 40420, 40420, 424382, 0, 0, 0, 0, 0, 40420, 13888759, 40420, 40420, 40420,
+ 424382, 1190278, 0, 0, 0, 0, 40420, 13888759, 40420, 40420, 40420, 424382, 1190278,
+ 0, 0, 0, 0, 40420, 40420, 13888759, 40420, 424382, 424382, 1190278, 0, 0, 0, 0, 0,
+ 40420, 40420, 40420, 424382, 1190278, 0, 0, 0, 0, 0, 0, 0, 40420, 40420, 1190278,
+ 0, 0, 0, 0
+};
static int* water = (int*)water_arr;
static uint32_t fire_arr[121] = {
- 0, 0, 13574443, 0, 0, 0, 0, 0, 13574443, 13574443, 13574443, 0, 0, 0, 0, 0, 13574443,
- 13574443, 15758881, 13574443, 0, 0, 0, 0, 13574443, 13574443, 15758881, 15758881,
- 15758881, 15758881, 0, 13574443, 0, 13574443, 0, 13574443, 15758881, 13574443, 15758881,
- 13574443, 13574443, 13574443, 0, 0, 13574443, 13574443, 13574443, 15758881, 13574443,
- 13574443, 13574443, 13574443, 0, 0, 0, 0, 13574443, 13574443, 15758881, 15758881,
- 15758881, 0, 0, 0, 13574443, 0, 13574443, 13574443, 15758881, 15758881, 15910701,
- 15758881, 13574443, 13574443, 13574443, 0, 0, 13574443, 15758881, 15758881, 15910701,
- 15910701, 15758881, 15758881, 13574443, 13574443, 13574443, 0, 13574443, 15758881,
- 15758881, 15910701, 15910701, 15910701, 15758881, 15758881, 13574443, 13574443, 0,
- 13574443, 15758881, 15758881, 15910701, 15910701, 15910701, 15758881, 15758881, 13574443,
- 13574443, 0, 13574443, 13574443, 15758881, 15910701, 15910701, 15910701, 15758881,
- 15758881, 13574443, 13574443, 0};
+ 0, 0, 13574443, 0, 0, 0, 0, 0, 13574443, 13574443, 13574443, 0, 0, 0, 0, 0, 13574443,
+ 13574443, 15758881, 13574443, 0, 0, 0, 0, 13574443, 13574443, 15758881, 15758881,
+ 15758881, 15758881, 0, 13574443, 0, 13574443, 0, 13574443, 15758881, 13574443, 15758881,
+ 13574443, 13574443, 13574443, 0, 0, 13574443, 13574443, 13574443, 15758881, 13574443,
+ 13574443, 13574443, 13574443, 0, 0, 0, 0, 13574443, 13574443, 15758881, 15758881,
+ 15758881, 0, 0, 0, 13574443, 0, 13574443, 13574443, 15758881, 15758881, 15910701,
+ 15758881, 13574443, 13574443, 13574443, 0, 0, 13574443, 15758881, 15758881, 15910701,
+ 15910701, 15758881, 15758881, 13574443, 13574443, 13574443, 0, 13574443, 15758881,
+ 15758881, 15910701, 15910701, 15910701, 15758881, 15758881, 13574443, 13574443, 0,
+ 13574443, 15758881, 15758881, 15910701, 15910701, 15910701, 15758881, 15758881, 13574443,
+ 13574443, 0, 13574443, 13574443, 15758881, 15910701, 15910701, 15910701, 15758881,
+ 15758881, 13574443, 13574443, 0
+};
static int* fire = (int*)fire_arr;
static uint32_t peanut_arr[121] = {
- 0, 12910592, 12910592, 12910592, 12910592, 12910592, 12910592, 12910592, 12910592,
- 12910592, 0, 0, 12910592, 12910592, 12910592, 12910592, 12910592, 12910592, 12910592,
- 12910592, 12910592, 0, 0, 0, 16742144, 16742144, 16742144, 16742144, 16742144, 16742144,
- 16742144, 0, 0, 0, 16742144, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215,
- 16777215, 16742144, 0, 0, 16742144, 16777215, 16777215, 16777215, 16777215, 12408832,
- 12408832, 16777215, 16742144, 0, 0, 16742144, 16777215, 16777215, 16777215, 16777215,
- 12408832, 12408832, 16777215, 16742144, 0, 0, 16742144, 16777215, 16777215, 12408832,
- 12408832, 16777215, 16777215, 16777215, 16742144, 0, 0, 16742144, 16777215, 16777215,
- 12408832, 12408832, 16777215, 16777215, 16777215, 16742144, 0, 0, 16742144, 16777215,
- 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16742144, 0, 0, 0, 16742144,
- 16742144, 16742144, 16742144, 16742144, 16742144, 16742144, 0, 0, 0, 0, 0, 16742144,
- 16742144, 16742144, 16742144, 16742144, 0, 0, 0};
+ 0, 12910592, 12910592, 12910592, 12910592, 12910592, 12910592, 12910592, 12910592,
+ 12910592, 0, 0, 12910592, 12910592, 12910592, 12910592, 12910592, 12910592, 12910592,
+ 12910592, 12910592, 0, 0, 0, 16742144, 16742144, 16742144, 16742144, 16742144, 16742144,
+ 16742144, 0, 0, 0, 16742144, 16777215, 16777215, 16777215, 16777215, 16777215, 16777215,
+ 16777215, 16742144, 0, 0, 16742144, 16777215, 16777215, 16777215, 16777215, 12408832,
+ 12408832, 16777215, 16742144, 0, 0, 16742144, 16777215, 16777215, 16777215, 16777215,
+ 12408832, 12408832, 16777215, 16742144, 0, 0, 16742144, 16777215, 16777215, 12408832,
+ 12408832, 16777215, 16777215, 16777215, 16742144, 0, 0, 16742144, 16777215, 16777215,
+ 12408832, 12408832, 16777215, 16777215, 16777215, 16742144, 0, 0, 16742144, 16777215,
+ 16777215, 16777215, 16777215, 16777215, 16777215, 16777215, 16742144, 0, 0, 0, 16742144,
+ 16742144, 16742144, 16742144, 16742144, 16742144, 16742144, 0, 0, 0, 0, 0, 16742144,
+ 16742144, 16742144, 16742144, 16742144, 0, 0, 0
+};
static int* peanut = (int*)peanut_arr;
@@ -196,27 +205,28 @@
}
void draw_npc(int u, int v)
{
- uLCD.BLIT(u,v,11,11,npc);
+ uLCD.BLIT(u,v,11,11,npc);
}
void draw_boss(int u, int v)
{
uLCD.BLIT(u,v,11,11,boss);
}
-void draw_dead(int u, int v) {
+void draw_dead(int u, int v)
+{
uLCD.BLIT(u,v, 11,11, dead);
- }
+}
void draw_fire(int u, int v)
{
- uLCD.BLIT(u,v,11,11,fire);
+ uLCD.BLIT(u,v,11,11,fire);
}
void draw_water(int u, int v)
{
- uLCD.BLIT(u,v,11,11,water);
+ uLCD.BLIT(u,v,11,11,water);
}
void draw_taco(int u, int v)
{
- uLCD.BLIT(u,v,11,11,peanut);
+ uLCD.BLIT(u,v,11,11,peanut);
}
void draw_door(int u, int v)
{
@@ -224,17 +234,34 @@
uLCD.line(u+10, v, u, v+10, WHITE);
}
-void draw_red(int u, int v){
- uLCD.filled_rectangle(u, v, u+10, v+10, 0xFF0000);
-
- }
-void draw_blue(int u, int v){
- uLCD.filled_rectangle(u, v, u+10, v+10, BLUE);
- }
-void draw_treasure(int u, int v){
+void draw_red(int u, int v)
+{
+ uLCD.filled_rectangle(u, v, u+10, v+10, 0xFF0000);
+
+}
+void draw_blue(int u, int v)
+{
+ uLCD.filled_rectangle(u, v, u+10, v+10, BLUE);
+}
+void draw_treasure(int u, int v)
+{
uLCD.filled_rectangle(u, v, u+10, v+10, YELLOW);
- }
+}
+
+void draw_hammer(int u, int v)
+{
+ uLCD.filled_rectangle(u, v, u+10, v+10, YELLOW);
+}
+void draw_healthPotion(int u, int v)
+{
+ uLCD.filled_rectangle(u, v, u+10, v+10, WHITE);
+}
+
+void draw_heart(int u, int v)
+{
+ uLCD.filled_rectangle(u, v, u+10, v+10, 0xFF0000);
+}
void draw_upper_status(int currX, int currY, int health, int lives)
{
@@ -245,8 +272,17 @@
// Add other status info drawing code here
}
-void draw_lower_status()
+void draw_lower_status(int item, int potion1, int potion2)
{
+ if(item){
+ draw_hammer(1, 118);
+ }
+ if(potion1) {
+ draw_healthPotion(13, 118);
+ }
+ if(potion2) {
+ draw_heart(25, 118);
+ }
// Draw top border of status bar
uLCD.line(0, 118, 127, 118, GREEN);
--- a/graphics.h Wed Dec 01 17:46:03 2021 +0000 +++ b/graphics.h Wed Dec 01 19:44:43 2021 +0000 @@ -42,6 +42,9 @@ void draw_blue(int u , int v); void draw_door(int u, int v); void draw_treasure(int u, int v); +void draw_hammer(int u, int v); +void draw_healthPotion(int u, int v); +void draw_heart(int u, int v); /** * Draw the upper status bar. @@ -52,7 +55,7 @@ /** * Draw the lower status bar. */ -void draw_lower_status(); +void draw_lower_status(int item, int potion1, int potion2); /** * Draw the border for the map.
--- a/hardware.cpp Wed Dec 01 17:46:03 2021 +0000
+++ b/hardware.cpp Wed Dec 01 19:44:43 2021 +0000
@@ -16,6 +16,8 @@
DigitalIn button1(p21); // Pushbuttons (pin)
DigitalIn button2(p22);
DigitalIn button3(p23);
+DigitalIn button4(p24);
+DigitalIn button5(p25);
AnalogOut DACout(p18); // Speaker (pin)
PwmOut speaker(p26);
wave_player waver(&DACout);
@@ -45,6 +47,8 @@
in.b1 = button1;
in.b2 = button2;
in.b3 = button3;
+ in.b4 = button4;
+ in.b5 = button5;
// pc.printf("button 1, 2, 3, %d, %d, %d", in.b1, in.b2, in.b3);
acc.readXGravity(&in.ax);
acc.readYGravity(&in.ay);
--- a/hardware.h Wed Dec 01 17:46:03 2021 +0000
+++ b/hardware.h Wed Dec 01 19:44:43 2021 +0000
@@ -6,7 +6,7 @@
* If additional hardware is added, new elements should be added to this struct.
*/
struct GameInputs {
- int b1, b2, b3; // Button presses
+ int b1, b2, b3, b4, b5; // Button presses
double ax, ay, az; // Accelerometer readings
};
--- a/main.cpp Wed Dec 01 17:46:03 2021 +0000
+++ b/main.cpp Wed Dec 01 19:44:43 2021 +0000
@@ -29,6 +29,7 @@
void youWinScreen();
void youLoseScreen();
void decreaseLife();
+void conditionals();
int main ();
@@ -45,6 +46,10 @@
void *currBoss;
int health;
int lives;
+ int item1;
+ int potion1;
+ int potion2;
+// void *Player.item2;
// You can add other properties for the player here
} Player;
GameInputs in;
@@ -60,15 +65,22 @@
#define GO_UP 5
#define GO_DOWN 6
#define OMNI_BUTTON 7
+#define ITEM_1 8
+#define ITEM_2 9
+#define ITEM_3 10
int get_action(GameInputs inputs)
{
if (!inputs.b1) {
return ACTION_BUTTON;
} else if (!inputs.b2) {
- return MENU_BUTTON;
+ return OMNI_BUTTON;
} else if (!inputs.b3) {
- return OMNI_BUTTON;
+ return ITEM_1;
+ } else if (!inputs.b4) {
+ return ITEM_2;
+ } else if (!inputs.b5) {
+ return ITEM_3;
} else if (inputs.ax < -0.25) {
return GO_UP;
} else if (inputs.ax > 0.25) {
@@ -85,6 +97,27 @@
}
+
+void conditionals()
+{
+ MapItem *current = get_here(Player.x, Player.y);
+ if (current->type == HAMMER) {
+ //Item *currItem = (currItem *)current->data;
+ Player.item1 =1;
+ map_erase(Player.x, Player.y);
+ }
+ if(current->type == POTION) {
+ Player.potion1 = 1;
+ map_erase(Player.x, Player.y);
+ }
+ if(current->type == HEART) {
+ Player.potion2 = 1;
+ map_erase(Player.x, Player.y);
+ }
+
+}
+
+
/**
* Update the game state based on the user action. For example, if the user
* requests GO_UP, then this function should determine if that is possible by
@@ -112,7 +145,7 @@
MapItem *below = get_south(Player.x, Player.y);
MapItem *current = get_here(Player.x, Player.y);
-
+ conditionals();
// Do different things based on the each action.
// You can define functions like "go_up()" that get called for each case.
switch (action) {
@@ -252,6 +285,7 @@
if(thisBossNum == 1) {
if(Player.questStatus == 1) {
boss_speech(0);
+
}
@@ -321,6 +355,12 @@
add_dead(newX, newY);
spell_speech(10);
Player.currBoss = NULL;
+ add_stairs(8, 1, 8, 1, 2);
+ add_stairs(1, 1, 5, 5, 0);
+ add_hammer(boss1->x -1, boss1->y -1);
+ add_healthPotion(6, 4);
+ add_heart(6, 5);
+ add_door(5, 3, 2, 3);
return FULL_DRAW;
} else if(thisSpell == WATER) {
spell_speech(7);
@@ -329,8 +369,6 @@
} else if(thisSpell == LAVA) {
spell_speech(11);
Player.health -= 30;
-// playerHealthCheck();
- //TODO: player health decrement, not kill
}
}
//defeated first boss, not second
@@ -351,12 +389,17 @@
map_erase(boss1->x, boss1->y);
add_dead(newX, newY);
spell_speech(8);
+ add_stairs(1,1,5,5,0);
+ add_stairs(8,1, 8, 1, 1);
+ //TODO drop item
+ add_hammer(boss1->x -1, boss1->y -1);
+ add_healthPotion(6, 4);
+ add_heart(6, 5);
+ add_door(5, 3, 2, 3);
return FULL_DRAW;
} else {
- //TODO add spell that kills player and ends game
spell_speech(12);
Player.health -= 100;
-// playerHealthCheck();
boss1->state = 2;
@@ -384,7 +427,24 @@
} else if (right->type == DOOR) {
door1 = (Door *)right->data;
}
-
+ if(Player.item1) {
+ char using_hammer[] = "Using hammer!";
+ speech(using_hammer, NULL);
+ Player.item1 = 0;
+ int startX = door1->startX;
+ int startY = door1->startY;
+ int endX = door1->endX;
+ int endY = door1->endY;
+ for (int i = startX; i <= endX; i++) {
+ map_erase(i, startY);
+ map_erase(i, endY);
+ }
+ for (int i = startY; i <= endY; i++) {
+ map_erase(startX, i);
+ map_erase(endX, i);
+ }
+ return FULL_DRAW;
+ }
if (Player.has_key) {
char unlocked_door_0[] = "Congratulations!";
@@ -404,12 +464,14 @@
map_erase(endX, i);
}
return FULL_DRAW;
- } else {
- char door_locked_0[] = "Where's your key!";
- char door_locked_1[] = "Try again!";
- speech(door_locked_0, door_locked_1);
}
+
+ char door_locked_0[] = "Where's your key!";
+ char door_locked_1[] = "Try again!";
+ Player.health -= 10;
+ speech(door_locked_0, door_locked_1);
}
+
/*********************************************
TREASURE CODE
*********************************************/
@@ -434,13 +496,25 @@
return NO_ACTION;
}
-
- case MENU_BUTTON:
- break;
- case OMNI_BUTTON:
+//
+// case MENU_BUTTON:
+// break;
+ case OMNI_BUTTON: {
Player.isOmniEnabled = !Player.isOmniEnabled;
return FULL_DRAW;
+ }
+ case ITEM_1: {
+ break;
+ }
+ case ITEM_2: {
+ break;
+ }
+ case ITEM_3: {
+ break;
+ }
+
}
+
return NO_RESULT;
}
@@ -502,7 +576,7 @@
// Draw status bars
draw_upper_status(Player.x, Player.y, Player.health, Player.lives);
- draw_lower_status();
+ draw_lower_status(Player.item1, Player.potion1, Player.potion2);
}
@@ -528,8 +602,8 @@
pc.printf("Walls done!\r\n");
//adding stairs objects
- add_stairs(10, 1, 5, 5, 2);
- add_stairs(1, 1, 5, 5, 1);
+ //add_stairs(10, 1, 5, 5, 2);
+ add_stairs(1, 1, 1, 1, 1);
//add npc
add_npc(1, 5);
@@ -550,12 +624,7 @@
void init_boss_map()
{
- // "Random" plants
-// Map* map = set_active_map(0);
-// for(int i = map_width() + 3; i < map_area(); i += 39) {
-// add_plant(i % map_width(), i / map_width());
-// }
- //pc.printf("plants\r\n");
+
Map* map = set_active_map(1);
pc.printf("Adding walls!\r\n");
add_wall(0, 0, HORIZONTAL, map_width());
@@ -565,8 +634,8 @@
pc.printf("Walls done!\r\n");
//adding stairs objects
- add_stairs(5, 5, 3, 5, 0);
- add_stairs(8, 1, 5, 5, 2);
+ // add_stairs(1, 8, 3, 5, 0);
+
//adding enemy
add_boss(8,8, TACO, 1);
@@ -591,7 +660,6 @@
add_boss(8,8, REDSP, 2);
- add_stairs(1,1,5,5,0);
add_spell(5, 5, REDSP);
add_spell(5, 7, BLUESP);
print_map();
@@ -683,7 +751,7 @@
do {
in = read_inputs();
currAction = get_action(in);
- } while(currAction != MENU_BUTTON);
+ } while(currAction != OMNI_BUTTON);
uLCD.cls();
@@ -706,6 +774,7 @@
Player.has_key = false;
Player.health = 99;
Player.lives = 3;
+ Player.item1 = Player.potion1 = Player.potion2 = 0;
// Initial drawing
@@ -738,6 +807,7 @@
decreaseLife();
}
}
+ //updateCounter()
// Actually do the game update:
// 1. Read inputs
--- a/map.cpp Wed Dec 01 17:46:03 2021 +0000
+++ b/map.cpp Wed Dec 01 19:44:43 2021 +0000
@@ -367,3 +367,35 @@
if (val) free(val); // If something is already there, free it
}
+void add_hammer(int x, int y)
+{
+ MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+ w1->type = HAMMER;
+ w1->draw = draw_hammer;
+ w1->walkable = true;
+ w1->data = NULL;
+ void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+ if (val) free(val); // If something is already there, free it
+}
+void add_healthPotion(int x, int y)
+{
+ MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+ w1->type = POTION;
+ w1->draw = draw_healthPotion;
+ w1->walkable = true;
+ w1->data = NULL;
+ void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+ if (val) free(val); // If something is already there, free it
+}
+
+void add_heart(int x, int y)
+{
+ MapItem* w1 = (MapItem*) malloc(sizeof(MapItem));
+ w1->type = HEART;
+ w1->draw = draw_heart;
+ w1->walkable = true;
+ w1->data = NULL;
+ void* val = insertItem(get_active_map()->items, XY_KEY(x, y), w1);
+ if (val) free(val); // If something is already there, free it
+}
+
--- a/map.h Wed Dec 01 17:46:03 2021 +0000 +++ b/map.h Wed Dec 01 19:44:43 2021 +0000 @@ -96,6 +96,9 @@ #define DOOR 6 #define TREASURE 7 #define DEAD 8 +#define HAMMER 9 +#define POTION 10 +#define HEART 11 /** * Initializes the internal structures for all maps. This does not populate @@ -219,4 +222,10 @@ void add_dead(int x, int y); +void add_hammer(int x, int y); + +void add_healthPotion(int x, int y); + +void add_heart(int x, int y); + #endif //MAP_H \ No newline at end of file