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 MotionSensor
Revision 33:4f3948dcd2f7, committed 2019-05-06
- Comitter:
- el17sm
- Date:
- Mon May 06 13:27:26 2019 +0000
- Parent:
- 32:fe6359ef9916
- Child:
- 34:1d5b4da3935e
- Commit message:
- Saved space using char to print screen instead of int (reduction by 4x)
Changed in this revision
--- a/Entity/Bosses/Skull/Skull.cpp Mon May 06 08:56:48 2019 +0000
+++ b/Entity/Bosses/Skull/Skull.cpp Mon May 06 13:27:26 2019 +0000
@@ -1,2 +1,43 @@
-//#include "Skull.h"
-//
+#include "Skull.h"
+Skull::Skull(float pos_x, float pos_y)
+{
+ hp = 5;
+ attack = 1;
+
+ moving = false;
+ hitbox.width = 0;
+ hitbox.height = 0;
+
+ sprite_size.width = 0;
+ sprite_size.height = 0;
+ sprite_size.offset_x = 0;
+ sprite_size.offset_y = 0;
+
+ position.x = 31;
+ position.y = 12;
+ update_prev_pos();
+
+ frame.count = 0;
+ frame.number = 0;
+ frame.max = 4;
+ face = 0;
+
+ velocity = 0.1;
+ _damage_self_upon_collision = false;
+ _hp_drop_chance = 30;
+}
+
+void Skull::move(float player_x, float player_y, int * map, bool * doorways)
+{
+
+}
+
+void Skull::draw(N5110 &lcd)
+{
+
+}
+
+void Skull::take_damage(int damage)
+{
+
+}
\ No newline at end of file
--- a/Entity/Bosses/Skull/Skull.h Mon May 06 08:56:48 2019 +0000
+++ b/Entity/Bosses/Skull/Skull.h Mon May 06 13:27:26 2019 +0000
@@ -1,89 +1,89 @@
-//#ifndef SKULL_H
-//#define SKULL_H
-//
-//class Skull : public Entity {
-//
-//public:
-// // Constructor
-// Skull(float, float);
-//
-// // Functions
-// virtual void move(float player_x, float player_y, int * map, bool * doorways);
-// virtual int * get_frame();
-// virtual void take_damage(int damage);
-//
-//};
-//
-//const int skull_sprite[2][23][21] = //skull_sprite[mouthclose/mouthopen][Size_Y][Size_X]
-//{
-// {
-// {0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0},
-// {0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0},
-// {0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0},
-// {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0},
-// {0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0},
-// {0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0},
-// {0,1,0,0,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0,1,0},
-// {1,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,1},
-// {1,0,0,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,0,0,1},
-// {1,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,1},
-// {1,0,0,0,1,1,1,0,0,0,1,0,0,0,1,1,1,0,0,0,1},
-// {1,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1},
-// {1,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,1},
-// {0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0},
-// {0,1,0,0,1,1,1,0,0,0,1,0,0,0,1,1,1,0,0,1,0},
-// {0,0,1,0,1,1,1,0,1,0,1,0,1,0,1,1,1,0,1,0,0},
-// {0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0},
-// {0,0,1,0,0,1,1,0,1,0,1,0,1,0,1,1,0,0,1,0,0},
-// {0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0},
-// {0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0},
-// {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0},
-// {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0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0},
-// {0,0,0,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0},
-// {0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0}
-// }
-//};
-//
-//const int skull_shadow_sprite[2][5][19] =
-//{
-// {
-// {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0},
-// {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0},
-// {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
-// {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0},
-// {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0}
-// },
-// {
-// {0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
-// {0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0},
-// {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0},
-// {0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0},
-// {0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0}
-// }
-//}
-//
-//#endif
\ No newline at end of file
+#ifndef SKULL_H
+#define SKULL_H
+#include "Entity.h"
+
+class Skull : public Entity {
+
+public:
+ // Constructor
+ Skull(float pos_x, float pos_y);
+
+ // Functions
+ virtual void move(float, float, int * map, bool * doorways); // movement control and miscellaneous updates
+ virtual void take_damage(int);
+ virtual void draw(N5110 &lcd);
+};
+
+const char skull_sprite[2][23][21] = //skull_sprite[mouthclose/mouthopen][Size_Y][Size_X]
+{
+ {
+ {0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0},
+ {0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0},
+ {0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0},
+ {0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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1,1,1,1,1,1,1,1,1,1,0},
+ {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
+ {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0},
+ {0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0}
+ },
+ {
+ {0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
+ {0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0},
+ {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0},
+ {0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0},
+ {0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0}
+ }
+};
+
+#endif
\ No newline at end of file
--- a/Entity/Collectibles/Health/Health.cpp Mon May 06 08:56:48 2019 +0000
+++ b/Entity/Collectibles/Health/Health.cpp Mon May 06 13:27:26 2019 +0000
@@ -32,9 +32,9 @@
get_frame());
}
-int * Health::get_frame()
+char * Health::get_frame()
{
- return (int *) health_sprite;
+ return (char *) health_sprite;
}
void Health::take_damage(int damage)
--- a/Entity/Collectibles/Health/Health.h Mon May 06 08:56:48 2019 +0000
+++ b/Entity/Collectibles/Health/Health.h Mon May 06 13:27:26 2019 +0000
@@ -15,7 +15,7 @@
private:
// Private Functions
- int * get_frame();
+ char * get_frame();
};
const int health_sprite[7][7] = {
--- a/Entity/Mobs/Headless/Headless.cpp Mon May 06 08:56:48 2019 +0000
+++ b/Entity/Mobs/Headless/Headless.cpp Mon May 06 13:27:26 2019 +0000
@@ -17,7 +17,7 @@
sprite_size.width = 6;
sprite_size.height = 9;
sprite_size.offset_x = 0;
- sprite_size.offset_y = 4;
+ sprite_size.offset_y = -4;
frame.count = 0;
frame.number = 0;
frame.max = 4;
@@ -53,8 +53,8 @@
void Headless::draw(N5110 &lcd)
{
- lcd.drawSpriteTransparent(position.x-sprite_size.offset_x,
- position.y-sprite_size.offset_y,
+ lcd.drawSpriteTransparent(position.x+sprite_size.offset_x,
+ position.y+sprite_size.offset_y,
sprite_size.height,
sprite_size.width,
get_frame());
@@ -65,7 +65,7 @@
hp -= damage;
}
-int * Headless::get_frame()
+char * Headless::get_frame()
{
- return (int *) sprite_headless[face][frame.number];
+ return (char *) sprite_headless[face][frame.number];
}
\ No newline at end of file
--- a/Entity/Mobs/Headless/Headless.h Mon May 06 08:56:48 2019 +0000
+++ b/Entity/Mobs/Headless/Headless.h Mon May 06 13:27:26 2019 +0000
@@ -16,10 +16,10 @@
private:
// Private Functions
- int * get_frame();
+ char * get_frame();
};
-const int sprite_headless[4][4][9][6] = { // Player [Face][SpriteAnimationFrame][Size_Y][Size_X]
+const char sprite_headless[4][4][9][6] = { // Player [Face][SpriteAnimationFrame][Size_Y][Size_X]
{
// Up
{
--- a/Entity/Mobs/Snake/Snake.cpp Mon May 06 08:56:48 2019 +0000
+++ b/Entity/Mobs/Snake/Snake.cpp Mon May 06 13:27:26 2019 +0000
@@ -18,8 +18,8 @@
position.y = pos_y;
sprite_size.width = 6;
sprite_size.height = 12;
- sprite_size.offset_x = 1;
- sprite_size.offset_y = 6;
+ sprite_size.offset_x = -1;
+ sprite_size.offset_y = -6;
frame.count = 0;
frame.number = 0;
frame.max = 6;
@@ -74,16 +74,16 @@
// Movement
if (face == 0) {
position.y += velocity;
- update_hitbox(4, 7, 6, 12, 1, 6, 6);
+ update_hitbox(4, 7, 6, 12, -1, -6, 6);
} else if (face == 1) {
position.x += velocity;
- update_hitbox(7, 4, 12, 7, 6, 4, 4);
+ update_hitbox(7, 4, 12, 7, -6, -4, 4);
} else if (face == 2) {
position.y -= velocity;
- update_hitbox(4, 7, 6, 12, 1, 5, 6);
+ update_hitbox(4, 7, 6, 12, -1, -5, 6);
} else if (face == 3) {
position.x -= velocity;
- update_hitbox(7, 4, 12, 7, 0, 4, 4);
+ update_hitbox(7, 4, 12, 7, -0, -4, 4);
}
undo_move_x(entity_to_map_collision_test(position.x, prev_pos.y, map, doorways));
@@ -108,24 +108,24 @@
hp -= damage;
}
-int * Snake::get_frame()
+char * Snake::get_frame()
{
if(face == 0) {
- return (int *) sprite_snake_y[1][frame.number];
+ return (char *) sprite_snake_y[1][frame.number];
} else if(face == 1) {
- return (int *) sprite_snake_x[0][frame.number];
+ return (char *) sprite_snake_x[0][frame.number];
} else if(face == 2) {
- return (int *) sprite_snake_y[0][frame.number];
+ return (char *) sprite_snake_y[0][frame.number];
} else if(face == 3) {
- return (int *) sprite_snake_x[1][frame.number];
+ return (char *) sprite_snake_x[1][frame.number];
}
return 0;
}
void Snake::draw(N5110 &lcd)
{
- lcd.drawSpriteTransparent(position.x-sprite_size.offset_x,
- position.y-sprite_size.offset_y,
+ lcd.drawSpriteTransparent(position.x+sprite_size.offset_x,
+ position.y+sprite_size.offset_y,
sprite_size.height,
sprite_size.width,
get_frame());
--- a/Entity/Mobs/Snake/Snake.h Mon May 06 08:56:48 2019 +0000
+++ b/Entity/Mobs/Snake/Snake.h Mon May 06 13:27:26 2019 +0000
@@ -17,7 +17,7 @@
private:
// Member Function
void update_prev_face();
- int * get_frame();
+ char * get_frame();
// Member Mutator
void update_hitbox(int, int, int, int, int, int, int);
@@ -30,7 +30,7 @@
const float velocity_pattern[6] = {0, 0.15, 0.25, 0.35, 0.25, -0.1};
-const int sprite_snake_x[2][4][7][12] = { // Player [Face][SpriteAnimationFrame][Size_Y][Size_X]
+const char sprite_snake_x[2][4][7][12] = { // Player [Face][SpriteAnimationFrame][Size_Y][Size_X]
{
// Right
{
@@ -111,7 +111,7 @@
}
};
-const int sprite_snake_y[2][6][12][6] = { // Player [Face][SpriteAnimationFrame][Size_Y][Size_X]
+const char sprite_snake_y[2][6][12][6] = { // Player [Face][SpriteAnimationFrame][Size_Y][Size_X]
{
// Up
{
--- a/Entity/Player/Bullets/Bullets.cpp Mon May 06 08:56:48 2019 +0000
+++ b/Entity/Player/Bullets/Bullets.cpp Mon May 06 13:27:26 2019 +0000
@@ -55,7 +55,7 @@
return false;
}
-int * Bullets::get_frame()
+char * Bullets::get_frame()
{
- return (int *) bullets_sprite;
+ return (char *) bullets_sprite;
}
\ No newline at end of file
--- a/Entity/Player/Bullets/Bullets.h Mon May 06 08:56:48 2019 +0000
+++ b/Entity/Player/Bullets/Bullets.h Mon May 06 13:27:26 2019 +0000
@@ -17,12 +17,12 @@
private:
// Private Functions
- int * get_frame();
+ char * get_frame();
// Member Variable
int direction;
};
-const int bullets_sprite[3][3] = {{1,1,1},
+const char bullets_sprite[3][3] = {{1,1,1},
{1,1,1},
{1,1,1}
};
--- a/Entity/Player/Player.cpp Mon May 06 08:56:48 2019 +0000
+++ b/Entity/Player/Player.cpp Mon May 06 13:27:26 2019 +0000
@@ -24,7 +24,8 @@
valid_bullets[i] = false;
}
fire_rate_counter = 0;
- invulnerability_counter = invulnerability_period;
+
+ invulnerability_counter = INVULNERABILITY_PERIOD;
// Upgradable status
fire_rate_delay = 30;
@@ -50,9 +51,9 @@
{
return 9;
}
-int * Player::get_hearts_sprite()
+char * Player::get_hearts_sprite()
{
- return (int *) sprite_heart;
+ return (char *) sprite_heart;
}
// Functions
@@ -113,7 +114,7 @@
if (damage < 0){
hp -= damage;
}
- else if (invulnerability_counter >= invulnerability_period) {
+ else if (invulnerability_counter >= INVULNERABILITY_PERIOD) {
hp -= damage;
invulnerability_counter = 0;
}
@@ -169,12 +170,12 @@
}
}
-int * Player::get_frame()
+char * Player::get_frame()
{
- if ((invulnerability_counter < invulnerability_period) && (invulnerability_counter % 10 <= 4)) {
- return (int*) sprite_transparent_player;
+ if ((invulnerability_counter < INVULNERABILITY_PERIOD) && (invulnerability_counter % 10 <= 4)) {
+ return (char*) sprite_transparent_player;
}
- return (int *) sprite_player[face][frame.number];
+ return (char *) sprite_player[face][frame.number];
}
void Player::buttons(bool button_A, bool button_B, bool button_Y, bool button_X)
--- a/Entity/Player/Player.h Mon May 06 08:56:48 2019 +0000
+++ b/Entity/Player/Player.h Mon May 06 13:27:26 2019 +0000
@@ -2,6 +2,7 @@
#define PLAYER_H
#include "Entity.h"
#include "Bullets.h"
+#define INVULNERABILITY_PERIOD 50
const int bullets_max = 20;
@@ -13,14 +14,13 @@
int fire_rate_counter;
int fire_rate_delay;
int _bullet_speed;
- const static int invulnerability_period = 50;
int invulnerability_counter;
// Private Functions
void move_player(float mapped_x, float mapped_y, int * map, bool * doorways);
void move_bullets();
void increment_frames(float mapped_x, float mapped_y);
- int * get_frame();
+ char * get_frame();
void draw_player(N5110 &lcd);
void draw_bullets(N5110 &lcd);
@@ -34,7 +34,7 @@
int get_bullet_speed();
int get_hearts_width();
int get_hearts_height();
- int * get_hearts_sprite();
+ char * get_hearts_sprite();
// Functions
virtual void move(float, float, int * map, bool * doorways);
@@ -51,7 +51,7 @@
};
// Sprite
-const int sprite_heart[9][9] = {
+const char sprite_heart[9][9] = {
{0,1,1,0,0,0,1,1,0,},
{1,1,1,1,0,1,1,1,1,},
{1,2,1,1,1,1,1,1,1,},
@@ -63,7 +63,7 @@
{0,0,0,0,1,0,0,0,0,}
};
-const int sprite_dying_player [5][12][12] = { // sprite_dying_player [Frame][Size_Y][Size_X]
+const char sprite_dying_player [5][12][12] = { // sprite_dying_player [Frame][Size_Y][Size_X]
{
{0,1,1,1,1,0,0,0,0,0,0,0,},
{1,1,1,1,1,1,0,0,0,0,0,0,},
@@ -137,7 +137,7 @@
};
-const int sprite_transparent_player[12][6] = {
+const char sprite_transparent_player[12][6] = {
{0,0,0,0,0,0,},
{0,0,0,0,0,0,},
{0,0,0,0,0,0,},
@@ -152,7 +152,7 @@
{0,0,0,0,0,0,}
};
-const int sprite_player [4][4][12][6] = { // Player [Face][SpriteAnimationFrame][Size_Y][Size_X]
+const char sprite_player [4][4][12][6] = { // Player [Face][SpriteAnimationFrame][Size_Y][Size_X]
{
// Up
{
--- a/Peripherals/N5110/N5110.cpp Mon May 06 08:56:48 2019 +0000
+++ b/Peripherals/N5110/N5110.cpp Mon May 06 13:27:26 2019 +0000
@@ -485,12 +485,12 @@
int y0,
int nrows,
int ncols,
- int *sprite)
+ char *sprite)
{
for (int i = 0; i < nrows; i++) {
for (int j = 0 ; j < ncols ; j++) {
- int pixel = *((sprite+i*ncols)+j);
+ int pixel = (int)*((sprite+i*ncols)+j);
if (pixel == 2) {
pixel = 0;
}
@@ -503,12 +503,12 @@
int y0,
int nrows,
int ncols,
- int *sprite)
+ char *sprite)
{
for (int i = 0; i < nrows; i++) {
for (int j = 0 ; j < ncols ; j++) {
- int pixel = *((sprite+i*ncols)+j);
+ int pixel = (int)*((sprite+i*ncols)+j);
if (pixel != 0) {
if (pixel == 2) {
pixel = 0;
@@ -519,7 +519,7 @@
}
}
-int * N5110::readScreen()
+char * N5110::readScreen()
{
for (unsigned int i = 0; i < WIDTH; i++) {
for (unsigned int j = 0; j < HEIGHT; j++) {
--- a/Peripherals/N5110/N5110.h Mon May 06 08:56:48 2019 +0000
+++ b/Peripherals/N5110/N5110.h Mon May 06 13:27:26 2019 +0000
@@ -189,7 +189,7 @@
// variables
unsigned char buffer[84][6]; // screen buffer - the 6 is for the banks - each one is 8 bits;
- int screen_array[48][84];
+ char screen_array[48][84];
public:
/** Create a N5110 object connected to the specified pins
@@ -416,15 +416,15 @@
int y0,
int nrows,
int ncols,
- int *sprite);
+ char *sprite);
void drawSpriteTransparent(int x0,
int y0,
int nrows,
int ncols,
- int *sprite);
+ char *sprite);
- int * readScreen();
+ char * readScreen();
private:
--- a/RoomEngine/Room/Room.cpp Mon May 06 08:56:48 2019 +0000
+++ b/RoomEngine/Room/Room.cpp Mon May 06 13:27:26 2019 +0000
@@ -68,7 +68,7 @@
void Room::draw_room(N5110 &lcd)
{
- lcd.drawSprite(0, 0, screen_height, screen_width, (int *)level_map[_room_type][1]); // drawing 3d map
+ lcd.drawSprite(0, 0, screen_height, screen_width, (char *)level_map[_room_type][1]); // drawing 3d map
//draw_walls(lcd);
}
@@ -76,38 +76,38 @@
void Room::draw_walls(N5110 &lcd)
{
if(_doorways[0]) { // N
- lcd.drawSprite(36, 0, 12, 10, (int *)wall_n);
+ lcd.drawSprite(36, 0, 12, 10, (char *)wall_n);
}
if(_doorways[1]) { // E
- lcd.drawSprite(81, 15, 3, 11, (int *)wall_x[0]);
+ lcd.drawSprite(81, 15, 3, 11, (char *)wall_x[0]);
}
if(_doorways[2]) { // S
- lcd.drawSprite(36, 45, 12, 3, (int *)wall_s);
+ lcd.drawSprite(36, 45, 12, 3, (char *)wall_s);
}
if(_doorways[3]) { // W
- lcd.drawSprite(0, 15, 3, 11, (int *)wall_x[1]);
+ lcd.drawSprite(0, 15, 3, 11, (char *)wall_x[1]);
}
}
void Room::draw_room_overlay(N5110 &lcd)
{
- lcd.drawSpriteTransparent(0, 0, screen_height, screen_width, (int *)level_map[_room_type][2]); // drawing 3d map overlay
+ lcd.drawSpriteTransparent(0, 0, screen_height, screen_width, (char *)level_map[_room_type][2]); // drawing 3d map overlay
//draw_walls_overlay(lcd);
}
void Room::draw_walls_overlay(N5110 &lcd)
{
if(_doorways[0]) { // N
- lcd.drawSpriteTransparent(36, 0, 12, 10, (int *)wall_n);
+ lcd.drawSpriteTransparent(36, 0, 12, 10, (char *)wall_n);
}
if(_doorways[1]) { // E
- lcd.drawSpriteTransparent(81, 15, 3, 11, (int *)wall_x[0]);
+ lcd.drawSpriteTransparent(81, 15, 3, 11, (char *)wall_x[0]);
}
if(_doorways[2]) { // S
- lcd.drawSpriteTransparent(36, 45, 12, 3, (int *)wall_s);
+ lcd.drawSpriteTransparent(36, 45, 12, 3, (char *)wall_s);
}
if(_doorways[3]) { // W
- lcd.drawSpriteTransparent(0, 15, 3, 11, (int *)wall_x[1]);
+ lcd.drawSpriteTransparent(0, 15, 3, 11, (char *)wall_x[1]);
}
}
--- a/RoomEngine/Room/Room.h Mon May 06 08:56:48 2019 +0000
+++ b/RoomEngine/Room/Room.h Mon May 06 13:27:26 2019 +0000
@@ -45,7 +45,7 @@
int enemies_type[MAX_ENEMIES];
};
-const int wall_x[2][11][3] = { // [E/W][Size_Y][Size_X]
+const char wall_x[2][11][3] = { // [E/W][Size_Y][Size_X]
{ // E
{1,2,2},
{1,2,2},
@@ -74,7 +74,7 @@
}
};
-const int wall_n[10][12] = { // [Size_Y][Size_X]
+const char wall_n[10][12] = { // [Size_Y][Size_X]
{0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,},
{1,1,1,1,1,1,1,1,1,1,1,1,},
@@ -87,7 +87,7 @@
{1,1,1,1,1,1,1,1,1,1,1,1,},
};
-const int wall_s[3][12] = { // [Size_Y][Size_X]
+const char wall_s[3][12] = { // [Size_Y][Size_X]
{1,1,1,1,1,1,1,1,1,1,1,1,},
{2,2,2,2,2,2,2,2,2,2,2,2,},
{2,2,2,2,2,2,2,2,2,2,2,2,},
--- a/RoomEngine/RoomEngine.cpp Mon May 06 08:56:48 2019 +0000
+++ b/RoomEngine/RoomEngine.cpp Mon May 06 13:27:26 2019 +0000
@@ -373,15 +373,15 @@
{
if(gamepad.check_event(Gamepad::START_PRESSED)) {
draw_health(lcd);
- int * paused_screen = lcd.readScreen();
+ char * paused_screen = lcd.readScreen();
int pause_timer = 2;
- lcd.drawSpriteTransparent(20, 20, 9, 45, (int *)pause_sprite);
+ lcd.drawSpriteTransparent(20, 20, 9, 45, (char *)pause_sprite);
wait(0.05);
while(gamepad.check_event(Gamepad::START_PRESSED)) {
lcd.clear();
lcd.drawSprite(0, 0, HEIGHT, WIDTH, paused_screen);
if (pause_timer % 10 <= 4) {
- lcd.drawSpriteTransparent(20, 20, 9, 45, (int *)pause_sprite);
+ lcd.drawSpriteTransparent(20, 20, 9, 45, (char *)pause_sprite);
}
lcd.refresh();
pause_timer++;
@@ -393,7 +393,7 @@
lcd.clear();
lcd.drawSprite(0, 0, HEIGHT, WIDTH, paused_screen);
if (pause_timer % 10 <= 4) {
- lcd.drawSpriteTransparent(20, 20, 9, 45, (int *)pause_sprite);
+ lcd.drawSpriteTransparent(20, 20, 9, 45, (char *)pause_sprite);
}
lcd.refresh();
pause_timer++;
@@ -405,7 +405,7 @@
lcd.clear();
lcd.drawSprite(0, 0, HEIGHT, WIDTH, paused_screen);
if (pause_timer % 10 <= 4) {
- lcd.drawSpriteTransparent(20, 20, 9, 45, (int *)pause_sprite);
+ lcd.drawSpriteTransparent(20, 20, 9, 45, (char *)pause_sprite);
}
lcd.refresh();
pause_timer++;
--- a/Title/Title.cpp Mon May 06 08:56:48 2019 +0000
+++ b/Title/Title.cpp Mon May 06 13:27:26 2019 +0000
@@ -42,16 +42,16 @@
void Title::draw_title_screen(N5110 &lcd)
{
- lcd.drawSprite(11, 4, 15, 44, (int *)title_name_0);
- lcd.drawSpriteTransparent(19, 14, 17, 53, (int *)title_name_1);
+ lcd.drawSprite(11, 4, 15, 44, (char *)title_name_0);
+ lcd.drawSpriteTransparent(19, 14, 17, 53, (char *)title_name_1);
lcd.drawCircle(79, 7, 10, FILL_BLACK);
lcd.drawCircle(81, 5, 8, FILL_WHITE);
- lcd.drawSprite(56, 6, 11, 5, (int *)star_sprite[abs(((title_count/20) % 7) - 3)]);
- lcd.drawSprite(12, 34, 8, 8, (int *)button_A_sprite);
- lcd.drawSprite(22, 37, 3, 2, (int *)arrow_left_sprite);
- lcd.drawSprite(59, 37, 3, 2, (int *)arrow_right_sprite);
- lcd.drawSprite(69, 31, 12, 6, (int *)sprite_player[(title_count/40) % 4][(title_count/10) % 4]);
- lcd.drawSprite(26, 35, 9, 32, (int *)title_options_sprite[title_option]);
+ lcd.drawSprite(56, 6, 11, 5, (char *)star_sprite[abs(((title_count/20) % 7) - 3)]);
+ lcd.drawSprite(12, 34, 8, 8, (char *)button_A_sprite);
+ lcd.drawSprite(22, 37, 3, 2, (char *)arrow_left_sprite);
+ lcd.drawSprite(59, 37, 3, 2, (char *)arrow_right_sprite);
+ lcd.drawSprite(69, 31, 12, 6, (char *)sprite_player[(title_count/40) % 4][(title_count/10) % 4]);
+ lcd.drawSprite(26, 35, 9, 32, (char *)title_options_sprite[title_option]);
}
void Title::title_options_joystick(Gamepad &gamepad)
--- a/sprites.h Mon May 06 08:56:48 2019 +0000
+++ b/sprites.h Mon May 06 13:27:26 2019 +0000
@@ -3,7 +3,7 @@
const int screen_width = 84;
const int screen_height = 48;
-const int star_sprite[4][11][5] = { // star_sprite[frame][Size_Y][Size_X]
+const char star_sprite[4][11][5] = { // star_sprite[frame][Size_Y][Size_X]
{
{0,0,0,0,0},
{0,0,0,0,0},
@@ -58,7 +58,7 @@
}
};
-const int title_options_sprite[4][9][32] = {
+const char title_options_sprite[4][9][32] = { // title_options_sprite[Option][Size_Y][Size_X]
{
{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,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0},
@@ -105,18 +105,18 @@
}
};
-const int arrow_right_sprite[3][2] = {
+const char arrow_right_sprite[3][2] = {
{1,0},
{1,1},
{1,0}
};
-const int arrow_left_sprite[3][2] = {
+const char arrow_left_sprite[3][2] = {
{0,1},
{1,1},
{0,1}
};
-const int button_A_sprite[8][8] = {
+const char button_A_sprite[8][8] = {
{0,0,1,1,1,1,0,0},
{0,1,1,1,1,1,1,0},
{1,1,1,0,0,1,1,1},
@@ -128,7 +128,7 @@
};
-const int pause_sprite[9][45] = {
+const char pause_sprite[9][45] = {
{0,1,1,1,1,1,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,1,0,0,0,0,},
{1,1,1,0,0,1,1,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,1,1,1,0,0,0,},
{0,1,1,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,1,1,0,0,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,},
@@ -140,7 +140,7 @@
{0,1,0,0,0,0,0,0,0,1,1,1,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,1,0,0,0,0,0,1,1,1,0,0,0,1,1,1,1,0,0,},
};
-const int title_name_0[15][44] = {
+const char title_name_0[15][44] = {
{0,1,1,1,1,1,1,1,1,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,1,1,1,1,1,1,1,1,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,1,1,0,0,1,1,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},
@@ -158,7 +158,7 @@
{0,1,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}
};
-const int title_name_1[17][53] = {
+const char title_name_1[17][53] = {
{0,1,1,1,1,1,1,1,1,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,1,1,1,1,1,1,1,1,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,1,1,0,0,1,1,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},
@@ -178,7 +178,7 @@
{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,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
};
-const int level_map[1][3][48][84] = { // map[map number][2d/3d/overlay][y][x]
+const char level_map[1][3][48][84] = { // map[map number][2d/3d/overlay][y][x]
{
{
{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,1,0,0,0,0,0,0,0,0,0,0,1,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,},