working with screen resizing

This commit is contained in:
Emil Kabirov 2018-10-17 08:59:08 +05:00
parent ce905daa85
commit a9f6a9be2b
8 changed files with 284 additions and 157 deletions

View File

@ -7,7 +7,7 @@
"y_coord": 0.0 "y_coord": 0.0
}, },
"texture": "galaxy_0.png", "texture": "galaxy_0.png",
"scale": 1.2, "scale": 1,
"Stars": [ "Stars": [
{ {
"name": "star2", "name": "star2",
@ -157,7 +157,7 @@
"y_coord": 0.55 "y_coord": 0.55
}, },
"texture": "levels/star3/star-flare-3.png", "texture": "levels/star3/star-flare-3.png",
"scale": 0.3, "scale": 0.15,
"levels": [ "levels": [
{ {
"name": "levels/star3/star3_level1" "name": "levels/star3/star3_level1"
@ -204,7 +204,7 @@
"y_coord": 0.0 "y_coord": 0.0
}, },
"texture": "levels/star4/star-flare-4.png", "texture": "levels/star4/star-flare-4.png",
"scale": 0.3, "scale": 0.15,
"levels": [ "levels": [
{ {
"name": "levels/star4/star4_level1" "name": "levels/star4/star4_level1"
@ -247,11 +247,11 @@
{ {
"name": "star_0_5", "name": "star_0_5",
"position": { "position": {
"x_coord": 0.5, "x_coord": 0.6,
"y_coord": -0.25 "y_coord": -0.25
}, },
"texture": "levels/star5/star-flare-5.png", "texture": "levels/star5/star-flare-5.png",
"scale": 0.3, "scale": 0.15,
"levels": [ "levels": [
{ {
"name": "levels/star5/star5_level1" "name": "levels/star5/star5_level1"
@ -298,7 +298,7 @@
"y_coord": -0.55 "y_coord": -0.55
}, },
"texture": "levels/star6/star-flare-6.png", "texture": "levels/star6/star-flare-6.png",
"scale": 0.3, "scale": 0.15,
"levels": [ "levels": [
{ {
"name": "levels/star6/star6_level1" "name": "levels/star6/star6_level1"
@ -345,7 +345,7 @@
"y_coord": -0.5 "y_coord": -0.5
}, },
"texture": "levels/star7/star-flare-7.png", "texture": "levels/star7/star-flare-7.png",
"scale": 0.3, "scale": 0.15,
"levels": [ "levels": [
{ {
"name": "levels/star7/star7_level1" "name": "levels/star7/star7_level1"
@ -392,7 +392,7 @@
"y_coord": -0.26 "y_coord": -0.26
}, },
"texture": "levels/star8/star-flare-8.png", "texture": "levels/star8/star-flare-8.png",
"scale": 0.3, "scale": 0.15,
"levels": [ "levels": [
{ {
"name": "levels/star8/star8_level1" "name": "levels/star8/star8_level1"
@ -439,7 +439,7 @@
"y_coord": 0.15 "y_coord": 0.15
}, },
"texture": "levels/star9/star-flare-9.png", "texture": "levels/star9/star-flare-9.png",
"scale": 0.3, "scale": 0.15,
"levels": [ "levels": [
{ {
"name": "levels/star9/star9_level1" "name": "levels/star9/star9_level1"
@ -486,7 +486,7 @@
"y_coord": 0.35 "y_coord": 0.35
}, },
"texture": "levels/star10/star-flare-10.png", "texture": "levels/star10/star-flare-10.png",
"scale": 0.3, "scale": 0.15,
"levels": [ "levels": [
{ {
"name": "levels/star10/star10_level1" "name": "levels/star10/star10_level1"
@ -533,7 +533,7 @@
"y_coord": 0.09 "y_coord": 0.09
}, },
"texture": "levels/star11/star-flare-11.png", "texture": "levels/star11/star-flare-11.png",
"scale": 0.3, "scale": 0.15,
"levels": [ "levels": [
{ {
"name": "levels/star11/star11_level1" "name": "levels/star11/star11_level1"
@ -580,7 +580,7 @@
"y_coord": -0.05 "y_coord": -0.05
}, },
"texture": "levels/star12/star-flare-12.png", "texture": "levels/star12/star-flare-12.png",
"scale": 0.3, "scale": 0.15,
"levels": [ "levels": [
{ {
"name": "levels/star12/star12_level1" "name": "levels/star12/star12_level1"
@ -627,7 +627,7 @@
"y_coord": -0.14 "y_coord": -0.14
}, },
"texture": "levels/star13/star-flare-13.png", "texture": "levels/star13/star-flare-13.png",
"scale": 0.3, "scale": 0.15,
"levels": [ "levels": [
{ {
"name": "levels/star13/star13_level1" "name": "levels/star13/star13_level1"
@ -674,7 +674,7 @@
"y_coord": -0.0 "y_coord": -0.0
}, },
"texture": "levels/star14/star-flare-14.png", "texture": "levels/star14/star-flare-14.png",
"scale": 0.3, "scale": 0.15,
"levels": [ "levels": [
{ {
"name": "levels/star14/star14_level1" "name": "levels/star14/star14_level1"
@ -721,7 +721,7 @@
"y_coord": 0.3 "y_coord": 0.3
}, },
"texture": "levels/star15/star-flare-15.png", "texture": "levels/star15/star-flare-15.png",
"scale": 0.3, "scale": 0.15,
"levels": [ "levels": [
{ {
"name": "levels/star15/star15_level1" "name": "levels/star15/star15_level1"
@ -735,7 +735,7 @@
"y_coord": 0.07 "y_coord": 0.07
}, },
"texture": "levels/star16/star-flare-16.png", "texture": "levels/star16/star-flare-16.png",
"scale": 0.3, "scale": 0.15,
"levels": [ "levels": [
{ {
"name": "levels/star16/star16_level1" "name": "levels/star16/star16_level1"

View File

@ -92,6 +92,15 @@ bool GalaxyMenu::InitGalaxyMenu(std::string config_json, float scale) {
void GalaxyMenu::UpdateGalaxyMenu(float s_width, float s_height, size_t dt) { void GalaxyMenu::UpdateGalaxyMenu(float s_width, float s_height, size_t dt) {
/*..Reset..*/ /*..Reset..*/
if (s_width == currentWindowWidth && s_height == currentWindowHeight)
{
return;
}
currentWindowWidth = s_width;
currentWindowHeight = s_height;
galaxies_params.clear(); galaxies_params.clear();
stars_params.clear(); stars_params.clear();
@ -111,6 +120,7 @@ void GalaxyMenu::UpdateGalaxyMenu(float s_width, float s_height, size_t dt) {
);*/ );*/
/*..Menu geometry..*/ /*..Menu geometry..*/
xDimension = menuScale * gameScreenWidth; xDimension = menuScale * gameScreenWidth;
yDimension = menuScale * gameScreenHeight; yDimension = menuScale * gameScreenHeight;
Eigen::Vector2f currentMenuPos = Eigen::Vector2f(gameScreenCenter(0) + (gameScreenWidth/2/*relative to the screen x-dimension*/)*(menuPosition(0) - menu_offset(0)), gameScreenCenter(1) + (gameScreenHeight/2/*relative to the screen y-dimension*/)*(menuPosition(1) - menu_offset(1))); Eigen::Vector2f currentMenuPos = Eigen::Vector2f(gameScreenCenter(0) + (gameScreenWidth/2/*relative to the screen x-dimension*/)*(menuPosition(0) - menu_offset(0)), gameScreenCenter(1) + (gameScreenHeight/2/*relative to the screen y-dimension*/)*(menuPosition(1) - menu_offset(1)));
@ -158,34 +168,24 @@ void GalaxyMenu::UpdateGalaxyMenu(float s_width, float s_height, size_t dt) {
} }
Eigen::Vector2f GalaxyMenu::textureSizeNormalize(Eigen::Vector2f texVec, int t_type) { Eigen::Vector2f GalaxyMenu::textureSizeNormalize(Eigen::Vector2f texVec, int t_type)
float tex_ratio = texVec(0)/texVec(1); {
float x_dim, y_dim; float x_dim, y_dim;
float Xmax; // Max normalized texture width
float Xmin;
float Ymax; // Max normalized texture height
float Ymin;
if (t_type == 0) {
Xmax = SE::Renderer->GetScreenWidth();
Xmin = Xmax;
Ymax = SE::Renderer->GetScreenHeight();
Ymin = Ymax;
}
else { // temp for star textures
Xmax = (((float)SE::Renderer->GetScreenWidth())/2);
Xmin = Xmax;
Ymax = (((float)SE::Renderer->GetScreenHeight())/2);
Ymin = Ymax;
}
if (texVec(0) > texVec(1)) { float tex_ratio = texVec(0) / texVec(1);
x_dim = val_clamp(texVec(0), Xmin, Xmax);
float screenRatio = SE::Renderer->GetScreenWidth() / (float)SE::Renderer->GetScreenHeight();
if (tex_ratio > screenRatio)
{
y_dim = SE::Renderer->GetScreenHeight();
x_dim = y_dim * tex_ratio;
}
else
{
x_dim = SE::Renderer->GetScreenWidth();
y_dim = x_dim / tex_ratio; y_dim = x_dim / tex_ratio;
} }
else {
y_dim = val_clamp(texVec(1), Ymin, Ymax);
x_dim = y_dim * tex_ratio;
}
return Eigen::Vector2f(x_dim, y_dim); return Eigen::Vector2f(x_dim, y_dim);
} }
@ -201,6 +201,10 @@ float GalaxyMenu::val_clamp(float val, float min, float max) {
void GalaxyMenu::DrawGalaxyMenu() { void GalaxyMenu::DrawGalaxyMenu() {
Renderer->PushOrthoProjection();
Renderer->PushMatrix();
Renderer->LoadIdentity();
for (int i = 0; i < galaxies_params.size(); i++) { for (int i = 0; i < galaxies_params.size(); i++) {
glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["galaxy_" + std::to_string(i)]); glBindTexture(GL_TEXTURE_2D, SE::ResourceManager->TexList["galaxy_" + std::to_string(i)]);
@ -246,6 +250,9 @@ void GalaxyMenu::DrawGalaxyMenu() {
} }
Renderer->PopMatrix();
Renderer->PopProjectionMatrix();
} }
void GalaxyMenu::InteractWithGalaxy(size_t dt) { void GalaxyMenu::InteractWithGalaxy(size_t dt) {

View File

@ -36,6 +36,8 @@ public:
// ::#Params#:: // ::#Params#::
Eigen::Vector2f menuPosition = Eigen::Vector2f(0.f, 0.f); // relative to the screen center(0.f,0.f means center) (not const!!) Eigen::Vector2f menuPosition = Eigen::Vector2f(0.f, 0.f); // relative to the screen center(0.f,0.f means center) (not const!!)
float menuScale = 1.f; // (not const!!) float menuScale = 1.f; // (not const!!)
int currentWindowWidth;
int currentWindowHeight;
float xDimension; float xDimension;
float yDimension; float yDimension;
float anchorSize = 1.f; float anchorSize = 1.f;

View File

@ -89,12 +89,28 @@ void TBrick::SetInvisible()
void TBrick::TryDrawAppear(int ipos, int jpos, int screenWidth) void TBrick::TryDrawAppear(int ipos, int jpos, int screenWidth)
{ {
float screenRatio = Renderer->GetMatrixWidth() / (float)Renderer->GetMatrixHeight();
float screenRatioToFixedRatio = screenRatio / 1.6f;
Vector2f offset;
float scale;
if (screenRatioToFixedRatio > 1.f)
{
offset[0] = (Renderer->GetMatrixWidth() - Renderer->GetMatrixWidth() / screenRatioToFixedRatio) / 2.f;
offset[1] = 0;
scale = Renderer->GetMatrixHeight() / 480.f;
}
else
{
offset[0] = 0;
offset[1] = 0;// (screenHeight - screenHeight * screenRatioToFixedRatio) / 2.f;
scale = Renderer->GetMatrixWidth() / 768.f;
}
Vector2f centerPos = GetPosFrom(ipos, jpos, screenWidth); Vector2f centerPos = GetPosFrom(ipos, jpos, screenWidth);
float LEVEL_VIEWPORT_WIDTH = Application->GetGameLevelScreenWidth(); //float LEVEL_VIEWPORT_WIDTH = Application->GetGameLevelScreenWidth();
float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight(); //float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight();
Vector2f blockHalfSize = Vector2f(0.5f*CONST_BRICK_WIDTH * (LEVEL_VIEWPORT_WIDTH/480.f), 0.5f*CONST_BRICK_HEIGHT * (LEVEL_VIEWPORT_HEIGHT/320.f)); Vector2f blockHalfSize = Vector2f(0.5f*CONST_BRICK_WIDTH * (768/480.f), 0.5f*CONST_BRICK_HEIGHT * (480/320.f));
std::string texName; std::string texName;
if (Locked == 2) if (Locked == 2)
@ -109,6 +125,9 @@ void TBrick::TryDrawAppear(int ipos, int jpos, int screenWidth)
{ {
texName = CONST_BLOCK_TEXTURE1; texName = CONST_BLOCK_TEXTURE1;
} }
//Vector2f offset = { (Renderer->GetMatrixWidth() - 768) / 2.f,
// (Renderer->GetMatrixHeight() - 480) / 2.f };
if (State == CONST_BRICKSTATE_DISAPPEAR) if (State == CONST_BRICKSTATE_DISAPPEAR)
{ {
@ -116,7 +135,7 @@ void TBrick::TryDrawAppear(int ipos, int jpos, int screenWidth)
RenderUniform1f("Transparency", StateTimer/CONST_BRICK_DISAPPEAR_TIME); RenderUniform1f("Transparency", StateTimer/CONST_BRICK_DISAPPEAR_TIME);
RenderUniform4fv("BrickColor", (Color.data())); RenderUniform4fv("BrickColor", (Color.data()));
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[texName]); glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[texName]);
Renderer->DrawRect(centerPos - blockHalfSize, centerPos + blockHalfSize); Renderer->DrawRect((centerPos - blockHalfSize) * scale + offset, (centerPos + blockHalfSize) * scale + offset);
} }
else if (State == CONST_BRICKSTATE_APPEAR) else if (State == CONST_BRICKSTATE_APPEAR)
{ {
@ -124,7 +143,7 @@ void TBrick::TryDrawAppear(int ipos, int jpos, int screenWidth)
RenderUniform1f("Transparency", 1.f - StateTimer/CONST_BRICK_APPEAR_TIME); RenderUniform1f("Transparency", 1.f - StateTimer/CONST_BRICK_APPEAR_TIME);
RenderUniform4fv("BrickColor", Color.data()); RenderUniform4fv("BrickColor", Color.data());
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[texName]); glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[texName]);
Renderer->DrawRect(centerPos - blockHalfSize, centerPos + blockHalfSize); Renderer->DrawRect((centerPos - blockHalfSize) * scale + offset, (centerPos + blockHalfSize) * scale + offset);
} }
} }
@ -160,14 +179,15 @@ Vector4f TBrick::GetColor()
Vector2f TBrick::GetPosFrom(int ipos, int jpos, int screenWidth) Vector2f TBrick::GetPosFrom(int ipos, int jpos, int screenWidth)
{ {
float LEVEL_VIEWPORT_WIDTH = Application->GetGameLevelScreenWidth(); //float LEVEL_VIEWPORT_WIDTH = Application->GetGameLevelScreenWidth();
float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight(); //float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight();
const Vector2f BorderShift(CONST_BRICK_SHIFT_X * (LEVEL_VIEWPORT_WIDTH/480.f), CONST_BRICK_SHIFT_Y * (LEVEL_VIEWPORT_HEIGHT/320.f)); const Vector2f BorderShift(CONST_BRICK_SHIFT_X * (768/480.f), CONST_BRICK_SHIFT_Y * (480 /320.f));
Vector2f outlineShift = Vector2f(((screenWidth - LEVEL_VIEWPORT_WIDTH)*0.5f),0.f); //Vector2f outlineShift = Vector2f(((screenWidth - LEVEL_VIEWPORT_WIDTH)*0.5f),0.f);
return outlineShift+BorderShift+Vector2f(CONST_BRICK_WIDTH*(LEVEL_VIEWPORT_WIDTH/480.f)*ipos + 0.5f*CONST_BRICK_WIDTH*(LEVEL_VIEWPORT_WIDTH/480.f), LEVEL_VIEWPORT_HEIGHT - CONST_BRICK_HEIGHT*(LEVEL_VIEWPORT_HEIGHT/320.f)*(jpos)-0.5f*CONST_BRICK_HEIGHT*(LEVEL_VIEWPORT_HEIGHT/320.f)); return BorderShift+Vector2f(CONST_BRICK_WIDTH*(768 /480.f)*ipos + 0.5f*CONST_BRICK_WIDTH*(768 /480.f),
480 - CONST_BRICK_HEIGHT*(480 /320.f)*(jpos)-0.5f*CONST_BRICK_HEIGHT*(480.f /320.f));
} }
void TBrick::Disappear() void TBrick::Disappear()
@ -257,6 +277,22 @@ int TBonusFalling::GetType()
void TBonusFalling::Draw() void TBonusFalling::Draw()
{ {
float screenRatio = Renderer->GetMatrixWidth() / (float)Renderer->GetMatrixHeight();
float screenRatioToFixedRatio = screenRatio / 1.6f;
Vector2f offset;
float scale;
if (screenRatioToFixedRatio > 1.f)
{
offset[0] = (Renderer->GetMatrixWidth() - Renderer->GetMatrixWidth() / screenRatioToFixedRatio) / 2.f;
offset[1] = 0;
scale = Renderer->GetMatrixHeight() / 480.f;
}
else
{
offset[0] = 0;
offset[1] = 0;// (screenHeight - screenHeight * screenRatioToFixedRatio) / 2.f;
scale = Renderer->GetMatrixWidth() / 768.f;
}
Vector2f BonusHalfSize = Vector2f(16.f, 16.f); Vector2f BonusHalfSize = Vector2f(16.f, 16.f);
@ -266,7 +302,7 @@ void TBonusFalling::Draw()
RenderUniform1f("Transparency", transparency); RenderUniform1f("Transparency", transparency);
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[TexName]); glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[TexName]);
Renderer->DrawRect(Pos - BonusHalfSize, Pos + BonusHalfSize); Renderer->DrawRect((Pos - BonusHalfSize) * scale + offset, (Pos + BonusHalfSize) * scale + offset);
} }
@ -310,12 +346,11 @@ void TBall::Go()
{ {
// Velocity = Normalize(Vector2f(2.f, 1.f)); // Velocity = Normalize(Vector2f(2.f, 1.f));
Velocity = Vector2f(2.f, 1.f).normalized(); Velocity = { 0, 1 }; // Vector2f(2.f, 1.f).normalized();
} }
void TBall::ReflectToLeft() void TBall::ReflectToLeft()
{ {
Application->hitSpark("left",Pos); Application->hitSpark("left",Pos);
if (Velocity(0) > 0.f) if (Velocity(0) > 0.f)
@ -326,7 +361,6 @@ void TBall::ReflectToLeft()
void TBall::ReflectToRight() void TBall::ReflectToRight()
{ {
Application->hitSpark("right", Pos); Application->hitSpark("right", Pos);
if (Velocity(0) < 0.f) if (Velocity(0) < 0.f)
@ -337,7 +371,6 @@ void TBall::ReflectToRight()
void TBall::ReflectToUp() void TBall::ReflectToUp()
{ {
Application->hitSpark("up", Pos); Application->hitSpark("up", Pos);
if (Velocity(1) < 0.f) if (Velocity(1) < 0.f)
@ -348,7 +381,6 @@ void TBall::ReflectToUp()
void TBall::ReflectToDown() void TBall::ReflectToDown()
{ {
Application->hitSpark("down", Pos); Application->hitSpark("down", Pos);
if (Velocity(1) > 0.f) if (Velocity(1) > 0.f)
@ -367,11 +399,11 @@ float ReflectorPlaneFunction(float shift)
Something like this Something like this
*/ */
float LEVEL_VIEWPORT_WIDTH = Application->GetGameLevelScreenWidth(); //float LEVEL_VIEWPORT_WIDTH = Application->GetGameLevelScreenWidth();
float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight(); //float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight();
float hRW = (CONST_REFLECTOR_WIDTH*LEVEL_VIEWPORT_WIDTH / 700.f)*0.5f; // Half Reflector width float hRW = (CONST_REFLECTOR_WIDTH*768 / 700.f)*0.5f; // Half Reflector width
float hRPW = hRW*0.594f; // Half Reflector plane width float hRPW = hRW*0.594f; // Half Reflector plane width
float cRH = CONST_REFLECTOR_HEIGHT*LEVEL_VIEWPORT_HEIGHT / 480.f; // Current Reflector Height float cRH = CONST_REFLECTOR_HEIGHT*480 / 480.f; // Current Reflector Height
if (shift >= -(hRW) && shift < -(hRPW)) { if (shift >= -(hRW) && shift < -(hRPW)) {
float t = (shift+ hRW)/cRH; float t = (shift+ hRW)/cRH;
@ -390,9 +422,9 @@ float ReflectorPlaneFunction(float shift)
void TBall::TryReflectOnReflector(Vector2f refPos) void TBall::TryReflectOnReflector(Vector2f refPos)
{ {
float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight(); //float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight();
const float reflectionShiftY = 13.f; const float reflectionShiftY = 13.f;
const float reflectionMaxHeight = CONST_REFLECTOR_HEIGHT*LEVEL_VIEWPORT_HEIGHT/480.f; const float reflectionMaxHeight = CONST_REFLECTOR_HEIGHT*480/480.f;
@ -437,7 +469,8 @@ void TBall::Update(size_t dt)
//=========================================== //===========================================
//=========================================== //===========================================
//=========================================== //===========================================
bool TGameLevel::XXX = true;
TGameLevel::TGameLevel(int levelStar, int levelIndex) TGameLevel::TGameLevel(int levelStar, int levelIndex)
{ {
@ -480,8 +513,8 @@ int TGameLevel::getLevelIndex()
void TGameLevel::ReloadBlockInstansingList(int screenWidth) void TGameLevel::ReloadBlockInstansingList(int screenWidth)
{ {
float LEVEL_VIEWPORT_WIDTH = Application->GetGameLevelScreenWidth(); //float LEVEL_VIEWPORT_WIDTH = Application->GetGameLevelScreenWidth();
float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight(); //float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight();
std::map<int, std::string> ConstTextureBlockMap = boost::assign::map_list_of (0,CONST_BLOCK_TEXTURE1) (1,CONST_BLOCK_TEXTURE2) (2,CONST_BLOCK_TEXTURE3); std::map<int, std::string> ConstTextureBlockMap = boost::assign::map_list_of (0,CONST_BLOCK_TEXTURE1) (1,CONST_BLOCK_TEXTURE2) (2,CONST_BLOCK_TEXTURE3);
@ -515,8 +548,8 @@ void TGameLevel::ReloadBlockInstansingList(int screenWidth)
itr--; itr--;
} }
Vector2f posFrom = BlockMatrix[i][j].GetPosFrom(i,j, screenWidth) + Vector2f(-0.5f*CONST_BRICK_WIDTH*(LEVEL_VIEWPORT_WIDTH/480.f), -0.5f*CONST_BRICK_HEIGHT*(LEVEL_VIEWPORT_HEIGHT/320.f)); Vector2f posFrom = BlockMatrix[i][j].GetPosFrom(i,j, screenWidth) + Vector2f(-0.5f*CONST_BRICK_WIDTH*(768/480.f), -0.5f*CONST_BRICK_HEIGHT*(480/320.f));
Vector2f posTo = BlockMatrix[i][j].GetPosFrom(i,j, screenWidth) + Vector2f(+0.5f*CONST_BRICK_WIDTH*(LEVEL_VIEWPORT_WIDTH/480.f), +0.5f*CONST_BRICK_HEIGHT*(LEVEL_VIEWPORT_HEIGHT/320.f)); Vector2f posTo = BlockMatrix[i][j].GetPosFrom(i,j, screenWidth) + Vector2f(+0.5f*CONST_BRICK_WIDTH*(768 /480.f), +0.5f*CONST_BRICK_HEIGHT*(480 /320.f));
itr->second.Data += MakeDataTriangleList(posFrom, posTo); itr->second.Data += MakeDataTriangleList(posFrom, posTo);
@ -534,10 +567,10 @@ void TGameLevel::ReloadBlockInstansingList(int screenWidth)
Vector2f TGameLevel::GetBlock(const Vector2f& pos) Vector2f TGameLevel::GetBlock(const Vector2f& pos)
{ {
float LEVEL_VIEWPORT_WIDTH = Application->GetGameLevelScreenWidth(); //float LEVEL_VIEWPORT_WIDTH = Application->GetGameLevelScreenWidth();
float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight(); //float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight();
int x = static_cast<int>((pos(0) - CONST_BRICK_SHIFT_X*(LEVEL_VIEWPORT_WIDTH /480.f) - ((Renderer->GetScreenWidth() - LEVEL_VIEWPORT_WIDTH)*0.5f)) / (CONST_BRICK_WIDTH*(LEVEL_VIEWPORT_WIDTH /480.f))); int x = static_cast<int>((pos(0) - CONST_BRICK_SHIFT_X*(768 /480.f)) / (CONST_BRICK_WIDTH*(768 /480.f)));
int y = static_cast<int>((LEVEL_VIEWPORT_HEIGHT + CONST_BRICK_SHIFT_Y*(LEVEL_VIEWPORT_HEIGHT/320.f) - pos(1)) / (CONST_BRICK_HEIGHT*(LEVEL_VIEWPORT_HEIGHT/320.f))); int y = static_cast<int>((480 + CONST_BRICK_SHIFT_Y*(480/320.f) - pos(1)) / (CONST_BRICK_HEIGHT*(480/320.f)));
if (x < 0) if (x < 0)
@ -692,7 +725,7 @@ void TGameLevel::ReloadLevel()
rowColorIterator++; rowColorIterator++;
} }
ReloadBlockInstansingList(Renderer->GetScreenWidth()); ReloadBlockInstansingList(Application->GetGameLevelScreenHeight());
} }
@ -722,7 +755,7 @@ void TGameLevel::SetStandBy()
void TGameLevel::SetLoading() void TGameLevel::SetLoading()
{ {
InitLevel(Renderer->GetScreenWidth(), Renderer->GetScreenHeight()); InitLevel(Application->GetGameLevelScreenWidth(), Application->GetGameLevelScreenHeight());
StateTimer = CONST_TIMER_LOADING; StateTimer = CONST_TIMER_LOADING;
LevelState = CONST_LEVELSTATE_LOADING; LevelState = CONST_LEVELSTATE_LOADING;
} }
@ -730,10 +763,10 @@ void TGameLevel::SetLoading()
void TGameLevel::InitLevel(int screenWidth, int screenHeight) void TGameLevel::InitLevel(int screenWidth, int screenHeight)
{ {
float LEVEL_VIEWPORT_WIDTH = Application->GetGameLevelScreenWidth(); //float LEVEL_VIEWPORT_WIDTH = Application->GetGameLevelScreenWidth();
float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight(); //float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight();
ReflectorPos = Vector2f(screenWidth*0.5f, 16* LEVEL_VIEWPORT_HEIGHT/320.f + 13 * LEVEL_VIEWPORT_HEIGHT / 320.f); ReflectorPos = { 0.5f, 43.5 / Application->GetGameLevelScreenHeight() }; // Vector2f(screenWidth*0.5f, 16 * LEVEL_VIEWPORT_HEIGHT / 320.f + 13 * LEVEL_VIEWPORT_HEIGHT / 320.f);
Vector2f ballPos = Vector2f(screenWidth*0.5f, 80* LEVEL_VIEWPORT_HEIGHT/320.f); Vector2f ballPos = Vector2f(screenWidth*0.5f, 80* 480/320.f);
BallList.clear(); BallList.clear();
BallList.push_back(TBall(ballPos, Vector2f(0, 0), BallColor)); BallList.push_back(TBall(ballPos, Vector2f(0, 0), BallColor));
@ -834,11 +867,14 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
CheckGlError(); CheckGlError();
return; return;
} }
Renderer->PushProjectionMatrix(screenWidth, screenHeight);
Renderer->PushMatrix();
Renderer->LoadIdentity();
if (LevelState == CONST_LEVELSTATE_LOADING) if (LevelState == CONST_LEVELSTATE_LOADING)
{ {
Renderer->PushMatrix();
float scale = 1.f - 0.5f*StateTimer/CONST_TIMER_LOADING; float scale = 1.f - 0.5f*StateTimer/CONST_TIMER_LOADING;
if (scale < 0.5f) if (scale < 0.5f)
scale = 0.5f; scale = 0.5f;
@ -846,13 +882,13 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
if (scale > 1.f) if (scale > 1.f)
scale = 1.f; scale = 1.f;
Renderer->TranslateMatrix(Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0)); glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[levelName + "_prerender"]);
Renderer->ScaleMatrix(scale);
Renderer->TranslateMatrix(-Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0));
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[levelName + "_prerendered"]);
Renderer->DrawRect(Vector2f(xlOffset, ylOffset), Vector2f(xlOffset+tSW, ylOffset+tSH), Vector2f (0.f,0.f), Vector2f(1.f,1.f)); // Game Screen Scale Renderer->DrawRect(Vector2f(xlOffset, ylOffset), Vector2f(xlOffset+tSW, ylOffset+tSH), Vector2f (0.f,0.f), Vector2f(1.f,1.f)); // Game Screen Scale
Renderer->PopMatrix();
CheckGlError(); CheckGlError();
Renderer->PopMatrix();
Renderer->PopProjectionMatrix();
return; return;
} }
@ -869,20 +905,24 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
{ {
//See also below (same method) //See also below (same method)
Renderer->PushMatrix(); // Renderer->PushMatrix();
Renderer->TranslateMatrix(Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0)); //Renderer->TranslateMatrix(Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0));
Renderer->ScaleMatrix(OutScale); // Renderer->ScaleMatrix(OutScale);
Renderer->TranslateMatrix(-Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0)); //Renderer->TranslateMatrix(-Vector3f(matrixWidth * 0.5f, matrixHeight * 0.5f, 0));
DrawBuffer(); DrawBuffer();
if (mustShowButtons) if (mustShowButtons)
{ {
DrawPauseButtons(); DrawPauseButtons();
} }
Renderer->PopMatrix(); //Renderer->PopMatrix();
CheckGlError(); CheckGlError();
drawOutline(screenWidth, screenHeight); drawOutline(screenWidth, screenHeight);
Renderer->PopMatrix();
Renderer->PopProjectionMatrix();
return; return;
} }
@ -926,19 +966,42 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
std::list<TBall>::iterator iBall; std::list<TBall>::iterator iBall;
float screenRatio = screenWidth / (float)screenHeight;
float screenRatioToFixedRatio = screenRatio / 1.6f;
Vector2f offset;
float scale;
if (screenRatioToFixedRatio > 1.f)
{
offset[0] = (screenWidth - screenWidth / screenRatioToFixedRatio) / 2.f;
offset[1] = 0;
scale = matrixHeight / 480.f;
}
else
{
offset[0] = 0;
offset[1] = 0;// (screenHeight - screenHeight * screenRatioToFixedRatio) / 2.f;
scale = matrixWidth / 768.f;
}
Renderer->PushShader("BrickShader"); Renderer->PushShader("BrickShader");
for (int i=0; i<CONST_BRICKMATRIX_WIDTH; i++) for (int i = 0; i < CONST_BRICKMATRIX_WIDTH; i++)
{ {
for (int j=0; j<CONST_BRICKMATRIX_HEIGHT; j++) for (int j = 0; j < CONST_BRICKMATRIX_HEIGHT; j++)
{ {
BlockMatrix[i][j].TryDrawAppear(i,j, screenWidth); //Draws only appearing/disappearing blocks BlockMatrix[i][j].TryDrawAppear(i, j, screenWidth); //Draws only appearing/disappearing blocks
} }
} }
RenderUniform1f("Transparency", 1.f); RenderUniform1f("Transparency", 1.f);
//Vector2f outlineShift = Vector2f(((screenWidth - Application->GetGameLevelScreenWidth())*0.5f), 0.f);
Renderer->PushMatrix();
Renderer->TranslateMatrix(Vector3f(offset[0], offset[1], 0));
Renderer->ScaleMatrix(scale);
std::list<std::pair<PairColorTexture, TTriangleList>>::iterator colorBlockIterator; std::list<std::pair<PairColorTexture, TTriangleList>>::iterator colorBlockIterator;
for (colorBlockIterator = BlockInstansingList.ColorBlockList.begin(); colorBlockIterator != BlockInstansingList.ColorBlockList.end(); ++colorBlockIterator) for (colorBlockIterator = BlockInstansingList.ColorBlockList.begin(); colorBlockIterator != BlockInstansingList.ColorBlockList.end(); ++colorBlockIterator)
@ -957,28 +1020,32 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
Renderer->DrawTriangleList(colorBlockIterator->second); Renderer->DrawTriangleList(colorBlockIterator->second);
} }
DrawBallInstancingList(blackAndWhite);
std::list<TBonusFalling>::iterator iBonus;
Renderer->PopMatrix();
for (iBonus = BonusFallingList.begin(); iBonus != BonusFallingList.end(); ++iBonus)
{
iBonus->Draw(); std::list<TBonusFalling>::iterator iBonus;
}
for (iBonus = BonusFallingList.begin(); iBonus != BonusFallingList.end(); ++iBonus)
{
iBonus->Draw();
}
Application->EffectsDraw(); Application->EffectsDraw();
DrawBallInstancingList(blackAndWhite);
Renderer->PopShader(); Renderer->PopShader();
//float LEVEL_VIEWPORT_WIDTH = Application->GetGameLevelScreenWidth();
//float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight();
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_REFLECTOR_TEXTURE]); glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_REFLECTOR_TEXTURE]);
float xRW = 210.f * tSW/700.f; // x Reflector Width float xRW = 210.f * tSW/700.f; // x Reflector Width
float yRH = 45.f * tSH/480.f; // y Reflector Height float yRH = 45.f * tSH/480.f; // y Reflector Height
Renderer->DrawRect(Vector2f(-xRW*0.5f, -yRH*0.5f)+ReflectorPos, Vector2f(xRW*0.5f, yRH*0.5f)+ReflectorPos, Vector2f(0.f, 0.f), Vector2f(1.f, 1.f)); Vector2f matrixSize = ReflectorPos.cwiseProduct(Vector2f(Application->GetGameLevelScreenWidth(), Application->GetGameLevelScreenHeight()));
Renderer->DrawRect(Vector2f(-xRW * 0.5f, -yRH * 0.5f) + matrixSize + offset,
Vector2f(xRW*0.5f, yRH*0.5f) + matrixSize + offset, Vector2f(0.f, 0.f), Vector2f(1.f, 1.f));
const Vector2f wallUpPos1(xlOffset, tSH-ylOffset-uWTW); const Vector2f wallUpPos1(xlOffset, tSH-ylOffset-uWTW);
const Vector2f wallUpPos2(tSW + xlOffset, tSH-ylOffset); const Vector2f wallUpPos2(tSW + xlOffset, tSH-ylOffset);
@ -1048,7 +1115,9 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
Renderer->PopMatrix();
Renderer->PopProjectionMatrix();
CheckGlError(); CheckGlError();
} }
@ -1056,11 +1125,14 @@ void TGameLevel::InnerDraw(int screenWidth, int screenHeight, int matrixWidth, i
void TGameLevel::DrawPauseButtons() //continue from void TGameLevel::DrawPauseButtons() //continue from
{ {
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_SLIDE_UP_BTN_TEXTURE]); float x_levelScreenCenter = Renderer->GetScreenWidth()*0.5f;
Renderer->DrawRect(Vector2f(-128.f, -64.f)+CONST_SLIDE_UP_POS, Vector2f(128.f, 64.f)+CONST_SLIDE_UP_POS); float y_levelScreenCenter = Renderer->GetScreenHeight()*0.5f;
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_SLIDE_UP_BTN_TEXTURE]);
Renderer->DrawRect(Vector2f(x_levelScreenCenter - 128.f, y_levelScreenCenter - 64.f) + CONST_SLIDE_UP_POS, Vector2f(x_levelScreenCenter + 128.f, y_levelScreenCenter + 64.f) + CONST_SLIDE_UP_POS);
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_TAP_TO_CONTINUE_BTN_TEXTURE]); glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_TAP_TO_CONTINUE_BTN_TEXTURE]);
Renderer->DrawRect(Vector2f(-128.f, -128.f)+CONST_TAP_TO_CONTINUE_POS, Vector2f(128.f, 128.f)+CONST_TAP_TO_CONTINUE_POS); Renderer->DrawRect(Vector2f(x_levelScreenCenter - 128.f, y_levelScreenCenter - 128.f) + CONST_TAP_TO_CONTINUE_POS, Vector2f(x_levelScreenCenter + 128.f, y_levelScreenCenter + 128.f) + CONST_TAP_TO_CONTINUE_POS);
} }
@ -1162,7 +1234,6 @@ bool TGameLevel::IsPaused()
void TGameLevel::Update(size_t dt) void TGameLevel::Update(size_t dt)
{ {
if (LevelState == CONST_LEVELSTATE_NODRAW) if (LevelState == CONST_LEVELSTATE_NODRAW)
{ {
return; return;
@ -1259,8 +1330,8 @@ void TGameLevel::Update(size_t dt)
{ {
iBonus->Update(dt); iBonus->Update(dt);
if ((fabs(ReflectorPos(0) - iBonus->GetPos()(0))<CONST_BONUS_CATCH_DISTANCE_X) && if ((fabs(ReflectorPos(0) * 768 - iBonus->GetPos()(0))<CONST_BONUS_CATCH_DISTANCE_X) &&
(fabs(ReflectorPos(1) - iBonus->GetPos()(1))<CONST_BONUS_CATCH_DISTANCE_Y)) (fabs(ReflectorPos(1) * 480 - iBonus->GetPos()(1))<CONST_BONUS_CATCH_DISTANCE_Y))
{ {
int bonusType = iBonus->GetType(); int bonusType = iBonus->GetType();
iBonus = BonusFallingList.erase(iBonus); iBonus = BonusFallingList.erase(iBonus);
@ -1555,8 +1626,8 @@ void TGameLevel::UpdateBallList(size_t dt)
std::list<TBall>::iterator iBall; std::list<TBall>::iterator iBall;
float LEVEL_VIEWOPRT_WIDTH = Application->GetGameLevelScreenWidth(); //float LEVEL_VIEWOPRT_WIDTH = Application->GetGameLevelScreenWidth();
float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight(); //float LEVEL_VIEWPORT_HEIGHT = Application->GetGameLevelScreenHeight();
bool mustReloadBalls = false; bool mustReloadBalls = false;
@ -1602,33 +1673,34 @@ void TGameLevel::UpdateBallList(size_t dt)
Vector2f ballPos = iBall->GetPos(); Vector2f ballPos = iBall->GetPos();
float xWO = (Renderer->GetScreenWidth()-LEVEL_VIEWOPRT_WIDTH)*0.5f; // x Wall Offest // float xWO = (Renderer->GetScreenWidth()-LEVEL_VIEWOPRT_WIDTH)*0.5f; // x Wall Offest
float yWO = (Renderer->GetScreenHeight()-LEVEL_VIEWPORT_HEIGHT)*0.5f; // y Wall Offset //float yWO = (Renderer->GetScreenHeight()-LEVEL_VIEWPORT_HEIGHT)*0.5f; // y Wall Offset
if (ballPos(0) > (xWO + LEVEL_VIEWOPRT_WIDTH)-15.f*(LEVEL_VIEWOPRT_WIDTH/480.f)) if (ballPos(0) > (768)-15.f*(768 /480.f))
{ {
iBall->ReflectToLeft(); iBall->ReflectToLeft();
} }
if (ballPos(0) < xWO + 15.f) if (ballPos(0) < 15.f)
{ {
iBall->ReflectToRight(); iBall->ReflectToRight();
} }
if (ballPos(1) > (yWO+LEVEL_VIEWPORT_HEIGHT)-16.f * (LEVEL_VIEWPORT_HEIGHT/320.f)) if (ballPos(1) > (480)-16.f * (480 /320.f))
{ {
iBall->ReflectToDown(); iBall->ReflectToDown();
} }
if (BonusFloorTimer > 0.f) if (BonusFloorTimer > 0.f)
{ {
if (ballPos(1) < yWO+13.0f*(LEVEL_VIEWPORT_HEIGHT/320.f)) if (ballPos(1) < 13.0f*(480 /320.f))
{ {
iBall->ReflectToUp(); iBall->ReflectToUp();
} }
} }
iBall->TryReflectOnReflector(ReflectorPos); Vector2f matrixSize = { 768, 480 };
iBall->TryReflectOnReflector(ReflectorPos.cwiseProduct(matrixSize));
Vector2f ipos = GetBlock(ballPos); Vector2f ipos = GetBlock(ballPos);
if (!(ipos == iBall->BallInBlock)) if (!(ipos == iBall->BallInBlock))
@ -1703,7 +1775,7 @@ void TGameLevel::UpdateBallList(size_t dt)
if (blockListChanged) if (blockListChanged)
{ {
ReloadBlockInstansingList(Renderer->GetScreenWidth()); ReloadBlockInstansingList(Application->GetGameLevelScreenWidth());
} }
if (mustReloadBalls) if (mustReloadBalls)
@ -1745,10 +1817,15 @@ void TGameLevel::MultiplyBalls(Vector2f pos, Vector2f velocity)
void TGameLevel::OnTapDown(Vector2f pos) void TGameLevel::OnTapDown(Vector2f pos)
{ {
float xOffset = (Renderer->GetMatrixWidth() - Application->GetGameLevelScreenWidth()) / 2.f;
float yOffset = (Renderer->GetMatrixHeight() - Application->GetGameLevelScreenHeight()) / 2.f;
float xPos = pos(0) - xOffset;
float yPos = pos(1) - yOffset;
if (LevelState == CONST_LEVELSTATE_STANDBY) if (LevelState == CONST_LEVELSTATE_STANDBY)
{ {
if (TapInBackBtnArea(pos)) if (TapInBackBtnArea({ xPos, yPos }))
{ {
SetPause(); SetPause();
PrevLevelStateIsStandby = true; PrevLevelStateIsStandby = true;
@ -1761,22 +1838,20 @@ void TGameLevel::OnTapDown(Vector2f pos)
} }
} }
else if (LevelState == CONST_LEVELSTATE_PLAYING) else if (LevelState == CONST_LEVELSTATE_PLAYING)
{ {
if (TapInBackBtnArea({ xPos, yPos }))
if (TapInBackBtnArea(pos))
{ {
SetPause(); SetPause();
} }
else if (fabs(ReflectorPos(0) - pos(0))>64.f) else// if (fabs(ReflectorPos(0) - xPos / Application->GetGameLevelScreenWidth()) > 64.f / Application->GetGameLevelScreenWidth())
{ {
ReflectorPos(0) = pos(0); ReflectorPos(0) = xPos / Application->GetGameLevelScreenWidth();
} }
} }
else if (LevelState == CONST_LEVELSTATE_PAUSE) else if (LevelState == CONST_LEVELSTATE_PAUSE)
{ {
if (pos(1) > 128.f) if (yPos > 128.f)
{ {
ReleasePause(); ReleasePause();
} }
@ -1803,7 +1878,7 @@ void TGameLevel::OnScroll(Vector2f shift)
const float CONST_SCROLL_SCALE = 1.1f; const float CONST_SCROLL_SCALE = 1.1f;
if (LevelState == CONST_LEVELSTATE_PLAYING || LevelState == CONST_LEVELSTATE_STANDBY) if (LevelState == CONST_LEVELSTATE_PLAYING || LevelState == CONST_LEVELSTATE_STANDBY)
{ {
ReflectorPos(0) -= CONST_SCROLL_SCALE*shift(0); ReflectorPos(0) -= CONST_SCROLL_SCALE * shift(0) / Application->GetGameLevelScreenWidth();
} }
else if (LevelState == CONST_LEVELSTATE_PAUSE) else if (LevelState == CONST_LEVELSTATE_PAUSE)
{ {

View File

@ -195,6 +195,8 @@ protected:
public: public:
TGameLevel(int levelStar, int levelIndex); TGameLevel(int levelStar, int levelIndex);
~TGameLevel(); ~TGameLevel();
static bool XXX;
void FillWithFile(const std::string& filename); void FillWithFile(const std::string& filename);
//void setBackground(const std::string& assignedShutterstock); //void setBackground(const std::string& assignedShutterstock);

View File

@ -129,7 +129,12 @@ void TMyApplication::SaveUserProgress(int levelStar, int levelIndex)
SaveFileToAndroid("user_progress.json", ss.str()); SaveFileToAndroid("user_progress.json", ss.str());
#endif #endif
} }
void TMyApplication::InnerChangeWidthHeight(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight)
{
Menu.GalaxMenu.UpdateGalaxyMenu(matrixWidth, matrixHeight, 0);
SetGameLevelScreenScale();
}
void TMyApplication::InnerInit() void TMyApplication::InnerInit()
{ {
@ -154,10 +159,8 @@ void TMyApplication::InnerInit()
LoadUserProgress(); LoadUserProgress();
if (Console != NULL) GetConsole() <<"APP INIT\n";
{
*Console<<"APP INIT\n";
}
srand (static_cast<size_t>(time(NULL))); srand (static_cast<size_t>(time(NULL)));
GameState = CONST_GAMESTATE_PRELOADING; GameState = CONST_GAMESTATE_PRELOADING;
StateTimer = 0.f; StateTimer = 0.f;
@ -221,10 +224,8 @@ void TMyApplication::InnerDeinit()
{ {
Inited = false; Inited = false;
Loaded = false; Loaded = false;
if (Console != NULL)
{ GetConsole() << "APP DEINIT\n";
*Console<<"APP DEINIT\n";
}
OnTapUpSignal.disconnect(boost::bind(&TGameLevel::OnTapUp, boost::ref(GameLevel), _1)); OnTapUpSignal.disconnect(boost::bind(&TGameLevel::OnTapUp, boost::ref(GameLevel), _1));
OnTapUpSignal.disconnect(boost::bind(&TGameMenu::OnTapUp, boost::ref(Menu), _1)); OnTapUpSignal.disconnect(boost::bind(&TGameMenu::OnTapUp, boost::ref(Menu), _1));
@ -474,7 +475,10 @@ void TMyApplication::TrySaveGame()
} }
void TMyApplication::OnKeyPress(size_t key)
{
TGameLevel::XXX = !TGameLevel::XXX;
}
void TMyApplication::InnerDraw() void TMyApplication::InnerDraw()
{ {
@ -519,8 +523,6 @@ void TMyApplication::InnerUpdate(size_t dt)
Renderer->SwitchToFrameBuffer("LevelBuffer"); Renderer->SwitchToFrameBuffer("LevelBuffer");
Renderer->SetProjectionMatrix(768, 480);
Renderer->LoadIdentity(); Renderer->LoadIdentity();
for (auto &star : Menu.GalaxMenu.galaxies[0].Stars) for (auto &star : Menu.GalaxMenu.galaxies[0].Stars)
@ -544,7 +546,9 @@ void TMyApplication::InnerUpdate(size_t dt)
GameState = CONST_GAMESTATE_MENU; GameState = CONST_GAMESTATE_MENU;
ApplySignalsToMenu(); ApplySignalsToMenu();
LoadGalaxyUi(); LoadGalaxyUi();
Menu.GalaxMenu.UpdateGalaxyMenu(Renderer->GetMatrixWidth(), Renderer->GetMatrixHeight(), 0);
OnDrawSignal.connect(0, boost::bind(&TGameMenu::Draw, boost::ref(Menu))); OnDrawSignal.connect(0, boost::bind(&TGameMenu::Draw, boost::ref(Menu)));
StateTimer = 0.f; StateTimer = 0.f;
@ -895,14 +899,47 @@ void TMyApplication::EffectsUpdate(size_t dt) {
lvlFirework.update(dt / 1000.f); lvlFirework.update(dt / 1000.f);
} }
void TMyApplication::EffectsDraw() { void TMyApplication::EffectsDraw() {
float screenRatio = Renderer->GetMatrixWidth() / (float)Renderer->GetMatrixHeight();
float screenRatioToFixedRatio = screenRatio / 1.6f;
Vector2f offset;
float scale;
if (screenRatioToFixedRatio > 1.f)
{
offset[0] = (Renderer->GetMatrixWidth() - Renderer->GetMatrixWidth() / screenRatioToFixedRatio) / 2.f;
offset[1] = 0;
scale = Renderer->GetMatrixHeight() / 480.f;
}
else
{
offset[0] = 0;
offset[1] = 0;// (screenHeight - screenHeight * screenRatioToFixedRatio) / 2.f;
scale = Renderer->GetMatrixWidth() / 768.f;
}
Renderer->PushMatrix();
Renderer->TranslateMatrix(Vector3f(offset[0], offset[1], 0));
Renderer->ScaleMatrix(scale);
glPushAttrib(GL_ALL_ATTRIB_BITS);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
lsparkler.draw(); lsparkler.draw();
rsparkler.draw(); rsparkler.draw();
tsparkler.draw(); tsparkler.draw();
bsparkler.draw(); bsparkler.draw();
lvlFirework.draw(); lvlFirework.draw();
Renderer->PopMatrix();
glPopAttrib();
} }
void TMyApplication::hitSpark(std::string direct,Vector2f Pos) { void TMyApplication::hitSpark(std::string direct,Vector2f Pos) {
if (direct == "left") { if (direct == "left") {
lsparkler.setCoords({ Pos(0),Pos(1),0 }); lsparkler.setCoords({ Pos(0),Pos(1),0 });
lsparkler.stopSpawn(); lsparkler.stopSpawn();

View File

@ -141,6 +141,10 @@ public:
void LoadUserProgress(); void LoadUserProgress();
void SaveUserProgress(int levelStar, int levelIndex); void SaveUserProgress(int levelStar, int levelIndex);
void InnerChangeWidthHeight(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight) override;
virtual void OnKeyPress(size_t key);
virtual void InnerInit(); virtual void InnerInit();
virtual void InnerDeinit(); virtual void InnerDeinit();

View File

@ -90,7 +90,7 @@ void TGameMenu::Update(size_t dt)
#ifdef GALAX_MENU_UPDATE #ifdef GALAX_MENU_UPDATE
/*..Galaxy Menu..*/ /*..Galaxy Menu..*/
GalaxMenu.InteractWithGalaxy(dt); GalaxMenu.InteractWithGalaxy(dt);
GalaxMenu.UpdateGalaxyMenu((float)SE::Renderer->GetScreenWidth(), (float)SE::Renderer->GetScreenHeight(), dt); //GalaxMenu.UpdateGalaxyMenu((float)SE::Renderer->GetScreenWidth(), (float)SE::Renderer->GetScreenHeight(), dt);
#else #else
if (HoldToTap) if (HoldToTap)
return; return;