Skip to content

Commit ed4eebc

Browse files
committed
Don't show big images on devices that cannot handle it
1 parent abdebf6 commit ed4eebc

7 files changed

Lines changed: 38 additions & 25 deletions

File tree

assets/images/levelinfo.bmp

-101 KB
Binary file not shown.

include/Board.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class Board {
177177

178178
private: //data
179179

180-
bool help_keys;
180+
bool help_keys = LARGE_TEXTURES_SUPPORTED;
181181
bool help_blocks;
182182
bool info;
183183
bool died;

include/Textures.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class Textures {
2626
SDL_Texture * getMainKeysSprite() { return mainKeysSprite; };
2727
SDL_Texture * getMainBlocksSprite() { return mainBlocksSprite; };
2828
SDL_Texture * getMessageSprite() { return messageSprite; };
29-
SDL_Texture * getLevelInfoSprite() { return levelInfoSprite; };
3029
SDL_Texture * getWaterSprite() { return waterSprite; };
3130

3231
private:
@@ -46,7 +45,6 @@ class Textures {
4645
SDL_Texture * mainKeysSprite;
4746
SDL_Texture * mainBlocksSprite;
4847
SDL_Texture * messageSprite;
49-
SDL_Texture * levelInfoSprite;
5048
SDL_Texture * waterSprite;
5149

5250
SDL_Texture * loadImage(const std::string &filename);

include/Tile.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,16 @@ class MessageCredits : public Static
11121112

11131113
protected: //functions
11141114
virtual void Display() {
1115-
draw->BlitSquare(textures->getMessageSprite(), rotation%14 ,rotation/14, x_pos, y_pos);
1115+
if (LARGE_TEXTURES_SUPPORTED) {
1116+
draw->BlitSquare(textures->getMessageSprite(), rotation%14 ,rotation/14, x_pos, y_pos);
1117+
} else {
1118+
const char * messages[] = {
1119+
"David Dewey",
1120+
"Ash Gilmore",
1121+
"Wouter Wijsman"
1122+
};
1123+
draw->BlitMessage("Credits", messages, 3);
1124+
}
11161125
}
11171126

11181127
protected: //members

include/constants.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@
55
inline constexpr int WINDOW_WIDTH = 640;
66
inline constexpr int WINDOW_HEIGHT = 480;
77
inline constexpr int BLOCK_SIZE = 40;
8+
inline constexpr bool LARGE_TEXTURES_SUPPORTED = true;
89
#elif defined(__vita__)
910
inline constexpr int WINDOW_WIDTH = 960;
1011
inline constexpr int WINDOW_HEIGHT = 544;
1112
inline constexpr int BLOCK_SIZE = 40;
13+
inline constexpr bool LARGE_TEXTURES_SUPPORTED = true;
1214
#elif defined(__PSP__)
1315
inline constexpr int WINDOW_WIDTH = 480;
1416
inline constexpr int WINDOW_HEIGHT = 272;
1517
inline constexpr int BLOCK_SIZE = 16;
18+
inline constexpr bool LARGE_TEXTURES_SUPPORTED = false;
1619
#else
17-
inline constexpr int WINDOW_WIDTH = 480;
18-
inline constexpr int WINDOW_HEIGHT = 272;
19-
inline constexpr int BLOCK_SIZE = 16;
20+
inline constexpr int WINDOW_WIDTH = 800;
21+
inline constexpr int WINDOW_HEIGHT = 600;
22+
inline constexpr int BLOCK_SIZE = 40;
23+
inline constexpr bool LARGE_TEXTURES_SUPPORTED = true;
2024
#endif
2125

2226
inline constexpr int COLUMNS = 20;

src/Board.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include "utils.h"
66

7-
Board::Board(Draw * draw, Textures * textures, Sound * sound) : help_keys(true), help_blocks(false), rows(ROWS), cols(COLUMNS), tank_x(0), tank_y(0), level(0), draw(draw), textures(textures), sound(sound) {
7+
Board::Board(Draw * draw, Textures * textures, Sound * sound) : help_blocks(false), rows(ROWS), cols(COLUMNS), tank_x(0), tank_y(0), level(0), draw(draw), textures(textures), sound(sound) {
88
CreateArray();
99
LoadLevel();
1010
}
@@ -381,8 +381,8 @@ void Board::FillDefault()
381381
}
382382

383383
int Board::AnyKey(Input key) {
384-
if (key==Input::HELPKEYS&&!help_keys) {help_keys=true;help_blocks=false; return 0;}
385-
if (key==Input::HELPBLOCKS&&!help_blocks) {help_blocks=true;help_keys=false; return 0;}
384+
if (key==Input::HELPKEYS&&!help_keys&&LARGE_TEXTURES_SUPPORTED) {help_keys=true;help_blocks=false; return 0;}
385+
if (key==Input::HELPBLOCKS&&!help_blocks&&LARGE_TEXTURES_SUPPORTED) {help_blocks=true;help_keys=false; return 0;}
386386
if (help_keys) {help_keys=false; return 0;}
387387
if (help_blocks) {help_blocks=false; return 0;}
388388
if (info&&!finished&&key!=Input::PREVIOUSLEVEL&&key!=Input::NEXTLEVEL) {info=false; return 0;}

src/Textures.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "Textures.h"
22

33
#include "utils.h"
4+
#include "constants.h"
45

56
Textures::Textures(SDL_Renderer * renderer) : renderer(renderer) {
67
if (!load()) {
@@ -17,12 +18,13 @@ Textures::~Textures() {
1718
SDL_DestroyTexture(rustySprites);
1819
SDL_DestroyTexture(staticSprites);
1920
SDL_DestroyTexture(tankSprites);
20-
21-
SDL_DestroyTexture(mainKeysSprite);
22-
SDL_DestroyTexture(mainBlocksSprite);
23-
SDL_DestroyTexture(messageSprite);
24-
SDL_DestroyTexture(levelInfoSprite);
2521
SDL_DestroyTexture(waterSprite);
22+
23+
if (LARGE_TEXTURES_SUPPORTED) {
24+
SDL_DestroyTexture(mainKeysSprite);
25+
SDL_DestroyTexture(mainBlocksSprite);
26+
SDL_DestroyTexture(messageSprite);
27+
}
2628
}
2729

2830
bool Textures::load() {
@@ -35,13 +37,14 @@ bool Textures::load() {
3537
staticSprites = loadImage("static.bmp");
3638
tankSprites = loadImage("tank.bmp");
3739
teeSprites = loadImage("tee.bmp");
38-
39-
mainKeysSprite = loadImage("maink.bmp");
40-
mainBlocksSprite = loadImage("mainb.bmp");
41-
messageSprite = loadImage("message.bmp");
42-
levelInfoSprite = loadImage("levelinfo.bmp");
4340
waterSprite = loadImage("water.bmp");
4441

42+
if (LARGE_TEXTURES_SUPPORTED) {
43+
mainKeysSprite = loadImage("maink.bmp");
44+
mainBlocksSprite = loadImage("mainb.bmp");
45+
messageSprite = loadImage("message.bmp");
46+
}
47+
4548
return
4649
barSprites != nullptr &&
4750
groundSprites != nullptr &&
@@ -52,11 +55,10 @@ bool Textures::load() {
5255
staticSprites != nullptr &&
5356
tankSprites != nullptr &&
5457
teeSprites != nullptr &&
55-
mainKeysSprite != nullptr &&
56-
mainBlocksSprite != nullptr &&
57-
messageSprite != nullptr &&
58-
levelInfoSprite != nullptr &&
59-
waterSprite != nullptr;
58+
waterSprite != nullptr &&
59+
(mainKeysSprite != nullptr || !LARGE_TEXTURES_SUPPORTED) &&
60+
(mainBlocksSprite != nullptr || !LARGE_TEXTURES_SUPPORTED) &&
61+
(messageSprite != nullptr || !LARGE_TEXTURES_SUPPORTED);
6062

6163
}
6264

0 commit comments

Comments
 (0)