commit 5d36f49f
Started to add support for new backgrounds
Changed files
diff --git a/Game/data/sprites/sample_alt_gfx.sprite b/Game/data/sprites/sample_alt_gfx.sprite
new file mode 100644
index 0000000..23eb1ad
--- /dev/null
+++ b/Game/data/sprites/sample_alt_gfx.sprite
@@ -0,0 +1,14 @@
+{
+
+
+"back_board_sample_snow" : {
+ "texture" : "alt_gfx/back_board_sample_snow",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 1200,
+ "width" : 600,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+}
+
+}
diff --git a/Game/data/textures/alt_gfx/back_board_sample_snow.jpg b/Game/data/textures/alt_gfx/back_board_sample_snow.jpg
new file mode 100644
index 0000000..8672557
Binary files /dev/null and b/Game/data/textures/alt_gfx/back_board_sample_snow.jpg differ
diff --git a/source/AUTH b/source/AUTH
index ab1f219..a9889db 100644
--- a/source/AUTH
+++ b/source/AUTH
@@ -15,6 +15,7 @@ freeserif.ttf Free Software Foundation
penguinattack.ttf Dustin Norlander - GPLv2
/textures/
+alt_gfx/back_board_sample_snow.jpg Poul Sander
back_board.png qubodup
background.png qubodup
background_sixteen_nine.png Poul Sander (based of qubodup's background.png)
diff --git a/source/code/BlockGameSdl.inc b/source/code/BlockGameSdl.inc
index 73561e0..c1d2880 100644
--- a/source/code/BlockGameSdl.inc
+++ b/source/code/BlockGameSdl.inc
@@ -26,6 +26,7 @@ https://blockattack.net
#include "sago/SagoTextField.hpp"
#include "mainVars.inc"
+
static void setScoreboardFont(const sago::SagoDataHolder* holder, sago::SagoTextField& field, const char* text){
field.SetHolder(holder);
field.SetFont("penguinattack");
@@ -64,7 +65,7 @@ public:
}
void DrawImgBoardBounded(const sago::SagoSprite& img, int x, int y) const {
- DrawIMG_Bounded(img, globalData.screen, x+topx, y+topy, topx, topy, topx + backBoard.GetWidth(), topy + backBoard.GetHeight());
+ DrawIMG_Bounded(img, globalData.screen, x+topx, y+topy, topx, topy, topx + BOARD_WIDTH, topy + BOARD_HEIGHT);
}
void PrintTextCenteredBoard(int x, int y, sago::SagoTextField& field) {
@@ -221,7 +222,7 @@ private:
SDL_Texture* CreateGarbageTexture(int x, int y, int size_x, int size_y, SDL_Rect& dstrect, SDL_Rect& srcrect) const {
dstrect = { x, y, size_x*bsize, size_y*bsize };
srcrect = { 0, 0, size_x*bsize, size_y*bsize };
- SDL_Rect bound = {topx, topy, backBoard.GetWidth(), backBoard.GetHeight()};
+ SDL_Rect bound = {topx, topy, BOARD_WIDTH, BOARD_HEIGHT};
CropTexture (dstrect, srcrect, bound);
SDL_Texture* mTexture = SDL_CreateTexture( globalData.screen, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, size_x*bsize, size_y*bsize );
SDL_SetRenderTarget( globalData.screen, mTexture );
@@ -409,7 +410,7 @@ public:
this->timeLabel.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()-68+197);
this->chainLabel.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()-68+246);
this->speedLabel.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()-68+295);
- DrawImgBoard(backBoard, 0, 0);
+ backBoard.DrawScaled(globalData.screen, SDL_GetTicks(), this->GetTopX(),this->GetTopY(), BOARD_WIDTH, BOARD_HEIGHT);
PaintBricks();
if (stageClear) {
diff --git a/source/code/global.hpp b/source/code/global.hpp
index 4dbbbdd..4d74aee 100644
--- a/source/code/global.hpp
+++ b/source/code/global.hpp
@@ -69,6 +69,9 @@ const int SIXTEEN_NINE_WIDTH = 1364;
const int FOUR_THREE_WIDTH = 1024;
const int SCREEN_HIGHT = 768;
+const int BOARD_WIDTH = 300;
+const int BOARD_HEIGHT = 600;
+
struct GlobalData {
sago::SagoSprite bHighScore;
sago::SagoSprite bBack;
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 43c8326..37c1c33 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -181,7 +181,7 @@ static int InitImages(sago::SagoSpriteHolder& holder) {
globalData.bNext = holder.GetSprite("b_blank");
bRetry = holder.GetSprite("b_blank");
globalData.mouse = holder.GetSprite("mouse");
- backBoard = holder.GetSprite("back_board");
+ backBoard = holder.GetSprite("back_board"); // Can also be "back_board_sample_snow"
sagoTextSetBlueFont(player1name);
sagoTextSetBlueFont(player2name);
@@ -546,7 +546,7 @@ void DrawEverything(int xsize, int ysize,BlockGameSdl* theGame, BlockGameSdl* th
*/
if (!twoPlayers && !theGame->isGameOver()) {
//Blank player2's board:
- DrawIMG(backBoard,globalData.screen,theGame2->GetTopX(),theGame2->GetTopY());
+ backBoard.DrawScaled(globalData.screen, SDL_GetTicks(), theGame2->GetTopX(),theGame2->GetTopY(), BOARD_WIDTH, BOARD_HEIGHT);
//Write a description:
std::string gametypeName;
std::string infostring;
diff --git a/source/code/sago/SagoDataHolder.cpp b/source/code/sago/SagoDataHolder.cpp
index cb2ce7f..ce79a31 100644
--- a/source/code/sago/SagoDataHolder.cpp
+++ b/source/code/sago/SagoDataHolder.cpp
@@ -114,7 +114,12 @@ SDL_Texture* SagoDataHolder::getTexturePtr(const std::string& textureName) const
printFileWeLoad(path);
}
if (!PHYSFS_exists(path.c_str())) {
- sago::SagoFatalErrorF("getTextureFailed - Texture does not exist: %s", path.c_str());
+ // We did not find the png file. Try to see if there are a jpg file.
+ std::string jpg_path = "textures/"+textureName+".jpg";
+ if (!PHYSFS_exists(jpg_path.c_str())) {
+ sago::SagoFatalErrorF("getTextureFailed - Texture does not exist: %s", path.c_str());
+ }
+ path = jpg_path;
}
unsigned int m_size = 0;
std::unique_ptr<char[]> m_data;