new engine
This commit is contained in:
1 parent
59f74b3826
commit
450e80b278
20 files changed
+586865
-661
No files matched your search
+13
-9
@@ -19,32 +19,33 @@ TGameCredits::TGameCredits()
|
||||
|
||||
void TGameCredits::Draw()
|
||||
{
|
||||
|
||||
//*SE::Console << "TGameCredits::Draw";
|
||||
float transparency = StateTimer/CONST_APPEAR_TIME;
|
||||
|
||||
|
||||
RenderUniform1f("Transparency", transparency);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList["main_menu_bkg_left"]);
|
||||
Renderer->DrawRect(vec2(0, 0.f), vec2(480.f, 320.f));
|
||||
Renderer->DrawRect(Vector2f(0, 0.f), Vector2f(480.f, 320.f));
|
||||
|
||||
const vec2 creditsPos(140.f, 130.f);
|
||||
const Vector2f creditsPos(140.f, 130.f);
|
||||
|
||||
const vec2 creditsHalfSize(128.f, 128.f);
|
||||
const Vector2f creditsHalfSize(128.f, 128.f);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_CREDITS_TEXTURE]);
|
||||
Renderer->DrawRect(creditsPos-creditsHalfSize, creditsPos+creditsHalfSize);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_LOGO_SMALL_TEXTURE]);
|
||||
Renderer->DrawRect(vec2(240.f-128.f+15.f, 320.f-64.f), vec2(240.f+128.f+15.f, 320.f));
|
||||
Renderer->DrawRect(Vector2f(240.f-128.f+15.f, 320.f-64.f), Vector2f(240.f+128.f+15.f, 320.f));
|
||||
|
||||
CheckGlError("Draw TGameCredits");
|
||||
}
|
||||
|
||||
void TGameCredits::Update(cardinal dt)
|
||||
void TGameCredits::Update(size_t dt)
|
||||
{
|
||||
if (State == CONST_STATE_APPEARING)
|
||||
{
|
||||
{
|
||||
*SE::Console << "TGameCredits::Update - CONST_STATE_APPEARING";
|
||||
StateTimer += dt;
|
||||
if (StateTimer >= CONST_APPEAR_TIME)
|
||||
{
|
||||
@@ -53,7 +54,7 @@ void TGameCredits::Update(cardinal dt)
|
||||
}
|
||||
}
|
||||
else if (State == CONST_STATE_DISAPPEARING)
|
||||
{
|
||||
{
|
||||
StateTimer -= dt;
|
||||
if (StateTimer <= 0.f)
|
||||
{
|
||||
@@ -63,17 +64,20 @@ void TGameCredits::Update(cardinal dt)
|
||||
}
|
||||
}
|
||||
|
||||
void TGameCredits::OnTapDown(vec2 p)
|
||||
void TGameCredits::OnTapDown(Vector2f p)
|
||||
{
|
||||
*SE::Console << "TGameCredits::OnTapDown";
|
||||
Application->GoFromCreditsToMenu();
|
||||
}
|
||||
|
||||
void TGameCredits::StartAppear()
|
||||
{
|
||||
*SE::Console << "TGameCredits::StartAppear";
|
||||
State = CONST_STATE_APPEARING;
|
||||
}
|
||||
|
||||
void TGameCredits::StartDisappear()
|
||||
{
|
||||
*SE::Console << "TGameCredits::StartDisappear";
|
||||
State = CONST_STATE_DISAPPEARING;
|
||||
}
|
||||
+2
-2
@@ -23,8 +23,8 @@ public:
|
||||
TGameCredits();
|
||||
|
||||
virtual void Draw();
|
||||
virtual void Update(cardinal dt);
|
||||
virtual void OnTapDown(vec2 p);
|
||||
virtual void Update(size_t dt);
|
||||
virtual void OnTapDown(Vector2f p);
|
||||
|
||||
void StartAppear();
|
||||
void StartDisappear();
|
||||
|
||||
@@ -10,13 +10,13 @@ class TGameAreaAncestor
|
||||
{
|
||||
public:
|
||||
virtual void Draw() { }
|
||||
virtual void Update(cardinal) { }
|
||||
virtual void OnTapUp(vec2) { }
|
||||
virtual void OnTapUpAfterMove(vec2) { }
|
||||
virtual void Update(size_t) { }
|
||||
virtual void OnTapUp(Vector2f) { }
|
||||
virtual void OnTapUpAfterMove(Vector2f) { }
|
||||
|
||||
virtual void OnTapDown(vec2) { }
|
||||
virtual void OnFling(vec2) { }
|
||||
virtual void OnScroll(vec2) { }
|
||||
virtual void OnTapDown(Vector2f) { }
|
||||
virtual void OnFling(Vector2f) { }
|
||||
virtual void OnScroll(Vector2f) { }
|
||||
|
||||
virtual ~TGameAreaAncestor() { } //By default destructor is not virtual
|
||||
};
|
||||
|
||||
+263
-195
File diff suppressed because it is too large.
Load diff
+34
-34
@@ -45,16 +45,16 @@ protected:
|
||||
int Locked; //0, 1 or 2
|
||||
int State;
|
||||
float StateTimer;
|
||||
vec4 Color;
|
||||
Vector4f Color;
|
||||
public:
|
||||
TBrick();
|
||||
void SetVisible(vec4 color, int locked);
|
||||
void SetVisible(Vector4f color, int locked);
|
||||
void SetInvisible();
|
||||
void TryDrawAppear(int ipos, int jpos);
|
||||
void Update(cardinal dt);
|
||||
vec2 GetPosFrom(int ipos, int jpos);
|
||||
vec4 GetColor();
|
||||
void Appear(vec4 color, int locked);
|
||||
void Update(size_t dt);
|
||||
Vector2f GetPosFrom(int ipos, int jpos);
|
||||
Vector4f GetColor();
|
||||
void Appear(Vector4f color, int locked);
|
||||
void Appear();
|
||||
void Hit();
|
||||
void Disappear();
|
||||
@@ -66,30 +66,30 @@ class TBonusFalling
|
||||
{
|
||||
protected:
|
||||
float Lifetime;
|
||||
vec2 Pos;
|
||||
Vector2f Pos;
|
||||
std::string TexName;
|
||||
int BonusType; //0 - multiplier, 1 - Go-through, 2 - floor
|
||||
public:
|
||||
TBonusFalling(vec2 pos);
|
||||
vec2 GetPos();
|
||||
TBonusFalling(Vector2f pos);
|
||||
Vector2f GetPos();
|
||||
int GetType();
|
||||
void Draw();
|
||||
void Update(cardinal dt);
|
||||
void Update(size_t dt);
|
||||
};
|
||||
|
||||
struct TBall
|
||||
{
|
||||
vec2 Pos;
|
||||
vec2 Velocity;
|
||||
vec4 Color;
|
||||
std::list<vec2> TalePos;
|
||||
Vector2f Pos;
|
||||
Vector2f Velocity;
|
||||
Vector4f Color;
|
||||
std::list<Vector2f> TalePos;
|
||||
|
||||
vec2 BallInBlock;
|
||||
vec2 PrevBallInBlock;
|
||||
Vector2f BallInBlock;
|
||||
Vector2f PrevBallInBlock;
|
||||
|
||||
TBall(vec2 pos, vec2 velocity, vec4 color);
|
||||
vec2 GetPos();
|
||||
vec2 GetVelocityVector();
|
||||
TBall(Vector2f pos, Vector2f velocity, Vector4f color);
|
||||
Vector2f GetPos();
|
||||
Vector2f GetVelocityVector();
|
||||
|
||||
void Go();
|
||||
|
||||
@@ -98,12 +98,12 @@ struct TBall
|
||||
void ReflectToUp();
|
||||
void ReflectToDown();
|
||||
|
||||
void TryReflectOnReflector(vec2 refPos);
|
||||
void TryReflectOnReflector(Vector2f refPos);
|
||||
|
||||
void Update(cardinal dt);
|
||||
void Update(size_t dt);
|
||||
};
|
||||
|
||||
typedef std::pair<vec4, std::string> PairColorTexture;
|
||||
typedef std::pair<Vector4f, std::string> PairColorTexture;
|
||||
|
||||
struct TBlockInstansingList
|
||||
{
|
||||
@@ -124,7 +124,7 @@ protected:
|
||||
std::string LevelScreenTexture;
|
||||
std::string LevelFileName;
|
||||
|
||||
vec2 ReflectorPos;
|
||||
Vector2f ReflectorPos;
|
||||
|
||||
int LevelState;
|
||||
bool PrevLevelStateIsStandby;
|
||||
@@ -133,7 +133,7 @@ protected:
|
||||
TBrick BlockMatrix[CONST_BRICKMATRIX_WIDTH][CONST_BRICKMATRIX_HEIGHT];
|
||||
TBlockInstansingList BlockInstansingList;
|
||||
|
||||
bool TapInBackBtnArea(const vec2& pos);
|
||||
bool TapInBackBtnArea(const Vector2f& pos);
|
||||
|
||||
void ReloadBlockInstansingList();
|
||||
void SetFinished();
|
||||
@@ -158,23 +158,23 @@ protected:
|
||||
|
||||
TBallInstancingList BallInstancingList;
|
||||
|
||||
vec4 BallColor;
|
||||
Vector4f BallColor;
|
||||
|
||||
void ReloadBallInstancingList();
|
||||
void RefreshBallInstancingList();
|
||||
|
||||
|
||||
void UpdateBallList(cardinal dt);
|
||||
void MultiplyBalls(vec2 pos, vec2 velocity);
|
||||
void UpdateBallList(size_t dt);
|
||||
void MultiplyBalls(Vector2f pos, Vector2f velocity);
|
||||
|
||||
vec2 GetBlock(const vec2& pos);
|
||||
Vector2f GetBlock(const Vector2f& pos);
|
||||
void InitLevel();
|
||||
|
||||
float BonusGothroughTimer;
|
||||
float BonusFloorTimer;
|
||||
float BonusFloorPosY;
|
||||
|
||||
vec4 ParseColor(const std::string& s);
|
||||
Vector4f ParseColor(const std::string& s);
|
||||
void ReloadLevel();
|
||||
|
||||
public:
|
||||
@@ -193,11 +193,11 @@ public:
|
||||
bool IsPaused();
|
||||
void ReleasePause();
|
||||
|
||||
virtual void Update(cardinal dt);
|
||||
virtual void OnTapDown(vec2 pos);
|
||||
virtual void OnTapUp(vec2 pos);
|
||||
virtual void OnFling(vec2 slideSpeed);
|
||||
virtual void OnScroll(vec2 shift);
|
||||
virtual void Update(size_t dt);
|
||||
virtual void OnTapDown(Vector2f pos);
|
||||
virtual void OnTapUp(Vector2f pos);
|
||||
virtual void OnFling(Vector2f slideSpeed);
|
||||
virtual void OnScroll(Vector2f shift);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -4,12 +4,16 @@
|
||||
|
||||
void TGameLoading::Draw()
|
||||
{
|
||||
//*SE::Console << "TGameLoading::Draw";
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList[CONST_LOADING_BACKGROUND_BLACK]);
|
||||
Renderer->DrawRect(Vector2f(0.f, 0.f), Vector2f(Renderer->GetMatrixWidth(), Renderer->GetMatrixHeight()));
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_LOADING_TEXTURE]);
|
||||
Renderer->DrawRect(vec2(240.f - 128.f, 10.f), vec2(240.f + 128.f, 10.f + 64.f));
|
||||
Renderer->DrawRect(Vector2f(240.f - 128.f, 10.f), Vector2f(240.f + 128.f, 10.f + 64.f));
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D,ResourceManager->TexList[CONST_LOGO_SMALL_TEXTURE]);
|
||||
Renderer->DrawRect(vec2(480.f - 256.f+50.f, 320.f - 64.f), vec2(480.f+50.f, 320.f));
|
||||
Renderer->DrawRect(Vector2f(480.f - 256.f+50.f, 320.f - 64.f), Vector2f(480.f+50.f, 320.f));
|
||||
|
||||
CheckGlError();
|
||||
|
||||
|
||||
+69
-62
@@ -11,11 +11,11 @@
|
||||
|
||||
#include "main_code.h"
|
||||
|
||||
boost::signals2::signal<void (vec2)> OnTapUpSignal;
|
||||
boost::signals2::signal<void (vec2)> OnTapUpAfterMoveSignal;
|
||||
boost::signals2::signal<void (vec2)> OnTapDownSignal;
|
||||
boost::signals2::signal<void (vec2)> OnFlingSignal;
|
||||
boost::signals2::signal<void (vec2)> OnScrollSignal;
|
||||
boost::signals2::signal<void (Vector2f)> OnTapUpSignal;
|
||||
boost::signals2::signal<void (Vector2f)> OnTapUpAfterMoveSignal;
|
||||
boost::signals2::signal<void (Vector2f)> OnTapDownSignal;
|
||||
boost::signals2::signal<void (Vector2f)> OnFlingSignal;
|
||||
boost::signals2::signal<void (Vector2f)> OnScrollSignal;
|
||||
|
||||
boost::signals2::signal<void ()> OnDrawSignal;
|
||||
|
||||
@@ -43,13 +43,15 @@ const std::string CONST_SLIDE_UP_BTN_TEXTURE = "slide_up_btn";
|
||||
const std::string CONST_TAP_TO_CONTINUE_BTN_TEXTURE = "tap_to_continue_btn";
|
||||
const std::string CONST_LOADING_TEXTURE = "loading";
|
||||
const std::string CONST_LOGO_SMALL_TEXTURE = "logo_small";
|
||||
const std::string CONST_LOADING_BACKGROUND_BLACK = "loading_background_black";
|
||||
const std::string CONST_CREDITS_TEXTURE = "credits";
|
||||
|
||||
const float CONST_CREDITS_SHOW_TIME = 150.f;
|
||||
|
||||
TAndroidApplication* Application;
|
||||
TMyApplication* Application;
|
||||
|
||||
void TAndroidApplication::InnerInit()
|
||||
|
||||
void TMyApplication::InnerInit()
|
||||
{
|
||||
|
||||
Application = this;
|
||||
@@ -70,35 +72,34 @@ void TAndroidApplication::InnerInit()
|
||||
{
|
||||
*Console<<"APP INIT\n";
|
||||
}
|
||||
srand (static_cast<cardinal>(time(NULL)));
|
||||
srand (static_cast<size_t>(time(NULL)));
|
||||
GameState = CONST_GAMESTATE_PRELOADING;
|
||||
StateTimer = 0.f;
|
||||
|
||||
|
||||
|
||||
ResourceManager->ShaderManager.AddShader("DefaultShader", "shader1vertex.txt", "shader1fragment.txt");
|
||||
ResourceManager->ShaderManager.AddShader("FrameShader", "frameshader_vertex.txt", "frameshader_fragment.txt");
|
||||
ResourceManager->ShaderManager.AddShader("BrickShader", "brickshader_vertex.txt", "brickshader_fragment.txt");
|
||||
Renderer->PushShader("DefaultShader");
|
||||
|
||||
|
||||
ResourceManager->TexList.AddTexture(CONST_LOADING_BACKGROUND_BLACK + ".png", CONST_LOADING_BACKGROUND_BLACK);
|
||||
ResourceManager->TexList.AddTexture(CONST_LOADING_TEXTURE + ".png", CONST_LOADING_TEXTURE);
|
||||
ResourceManager->TexList.AddTexture(CONST_LOGO_SMALL_TEXTURE + ".png", CONST_LOGO_SMALL_TEXTURE);
|
||||
|
||||
ResourceManager->TexList.AddTexture("console_bkg.bmp");
|
||||
|
||||
|
||||
ResourceManager->FrameManager.AddFrameRenderBuffer("LevelBuffer", 512, 512);
|
||||
|
||||
|
||||
OnDrawSignal.connect(boost::bind(&TGameLoading::Draw, boost::ref(GameLoading)));
|
||||
Inited = true;
|
||||
|
||||
Renderer->SetOrthoProjection();
|
||||
|
||||
Renderer->SetFullScreenViewport();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void TAndroidApplication::InnerDeinit()
|
||||
void TMyApplication::InnerDeinit()
|
||||
{
|
||||
Inited = false;
|
||||
Loaded = false;
|
||||
@@ -131,32 +132,33 @@ void TAndroidApplication::InnerDeinit()
|
||||
|
||||
}
|
||||
|
||||
void TAndroidApplication::InnerOnTapDown(vec2 p)
|
||||
{
|
||||
OnTapDownSignal(vec2(p.v[0], p.v[1]));
|
||||
}
|
||||
|
||||
void TAndroidApplication::InnerOnTapUp(vec2 p)
|
||||
{
|
||||
OnTapUpSignal(vec2(p.v[0], p.v[1]));
|
||||
void TMyApplication::InnerOnTapDown(Vector2f p)
|
||||
{
|
||||
//-OnTapDownSignal(Vector2f(p.v[0], p.v[1]));
|
||||
OnTapDownSignal(Vector2f(p(0), p(1)));
|
||||
}
|
||||
|
||||
void TAndroidApplication::InnerOnTapUpAfterMove(vec2 p)
|
||||
void TMyApplication::InnerOnTapUp(Vector2f p)
|
||||
{
|
||||
OnTapUpAfterMoveSignal(vec2(p.v[0], p.v[1]));
|
||||
OnTapUpSignal(Vector2f(p(0), p(1)));
|
||||
}
|
||||
|
||||
void TMyApplication::InnerOnTapUpAfterMove(Vector2f p)
|
||||
{
|
||||
OnTapUpAfterMoveSignal(Vector2f(p(0), p(1)));
|
||||
}
|
||||
|
||||
void TMyApplication::InnerOnMove(Vector2f p, Vector2f shift)
|
||||
{
|
||||
OnScrollSignal(Vector2f(shift(0), shift(1)));
|
||||
}
|
||||
|
||||
void TAndroidApplication::InnerOnMove(vec2 shift)
|
||||
{
|
||||
OnScrollSignal(shift);
|
||||
}
|
||||
|
||||
void TAndroidApplication::OnFling(vec2 v)
|
||||
void TMyApplication::OnFling(Vector2f v)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void TAndroidApplication::ApplySignalsToMenu()
|
||||
void TMyApplication::ApplySignalsToMenu()
|
||||
{
|
||||
|
||||
OnTapUpSignal.connect(boost::bind(&TGameMenu::OnTapUp, boost::ref(Menu), _1));
|
||||
@@ -168,7 +170,7 @@ void TAndroidApplication::ApplySignalsToMenu()
|
||||
}
|
||||
|
||||
|
||||
void TAndroidApplication::DisapplySignalsToMenu()
|
||||
void TMyApplication::DisapplySignalsToMenu()
|
||||
{
|
||||
OnTapUpSignal.disconnect(boost::bind(&TGameMenu::OnTapUp, boost::ref(Menu), _1));
|
||||
OnTapUpAfterMoveSignal.disconnect(boost::bind(&TGameMenu::OnTapUpAfterMove, boost::ref(Menu), _1));
|
||||
@@ -177,17 +179,16 @@ void TAndroidApplication::DisapplySignalsToMenu()
|
||||
OnTapDownSignal.disconnect(boost::bind(&TGameMenu::OnTapDown, boost::ref(Menu), _1));
|
||||
}
|
||||
|
||||
void TAndroidApplication::ApplySignalsToGame()
|
||||
void TMyApplication::ApplySignalsToGame()
|
||||
{
|
||||
|
||||
OnTapUpSignal.connect(boost::bind(&TGameLevel::OnTapUp, boost::ref(GameLevel), _1));
|
||||
OnFlingSignal.connect(boost::bind(&TGameLevel::OnFling, boost::ref(GameLevel), _1));
|
||||
OnScrollSignal.connect(boost::bind(&TGameLevel::OnScroll, boost::ref(GameLevel), _1));
|
||||
OnScrollSignal.connect(boost::bind(&TGameLevel::OnScroll, boost::ref(GameLevel), _1));
|
||||
OnTapDownSignal.connect(boost::bind(&TGameLevel::OnTapDown, boost::ref(GameLevel), _1));
|
||||
|
||||
}
|
||||
|
||||
void TAndroidApplication::DisapplySignalsToGame()
|
||||
void TMyApplication::DisapplySignalsToGame()
|
||||
{
|
||||
OnTapUpSignal.disconnect(boost::bind(&TGameLevel::OnTapUp, boost::ref(GameLevel), _1));
|
||||
OnFlingSignal.disconnect(boost::bind(&TGameLevel::OnFling, boost::ref(GameLevel), _1));
|
||||
@@ -196,18 +197,18 @@ void TAndroidApplication::DisapplySignalsToGame()
|
||||
|
||||
}
|
||||
|
||||
void TAndroidApplication::ApplySignalsToCredits()
|
||||
void TMyApplication::ApplySignalsToCredits()
|
||||
{
|
||||
OnTapDownSignal.connect(boost::bind(&TGameCredits::OnTapDown, boost::ref(GameCredits), _1));
|
||||
}
|
||||
|
||||
|
||||
void TAndroidApplication::DisapplySignalsToCredits()
|
||||
void TMyApplication::DisapplySignalsToCredits()
|
||||
{
|
||||
OnTapDownSignal.disconnect(boost::bind(&TGameCredits::OnTapDown, boost::ref(GameCredits), _1));
|
||||
}
|
||||
|
||||
void TAndroidApplication::LoadResources()
|
||||
void TMyApplication::LoadResources()
|
||||
{
|
||||
|
||||
TextureNamesToLoad.clear();
|
||||
@@ -273,7 +274,7 @@ void TAndroidApplication::LoadResources()
|
||||
|
||||
}
|
||||
|
||||
void TAndroidApplication::TryLoadSavedGame()
|
||||
void TMyApplication::TryLoadSavedGame()
|
||||
{
|
||||
|
||||
std::string fileName = GetFilePathUserData("progress.txt");
|
||||
@@ -292,7 +293,7 @@ void TAndroidApplication::TryLoadSavedGame()
|
||||
}
|
||||
}
|
||||
|
||||
void TAndroidApplication::TrySaveGame()
|
||||
void TMyApplication::TrySaveGame()
|
||||
{
|
||||
|
||||
std::string fileName = GetFilePathUserData("progress.txt");
|
||||
@@ -310,23 +311,22 @@ void TAndroidApplication::TrySaveGame()
|
||||
|
||||
|
||||
|
||||
void TAndroidApplication::InnerDraw()
|
||||
void TMyApplication::InnerDraw()
|
||||
{
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
|
||||
OnDrawSignal();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TAndroidApplication::InnerUpdate(cardinal dt)
|
||||
void TMyApplication::InnerUpdate(size_t dt)
|
||||
{
|
||||
|
||||
if (GameState == CONST_GAMESTATE_PRELOADING)
|
||||
{
|
||||
*SE::Console << "1CONST_GAMESTATE_PRELOADING";
|
||||
StateTimer += dt/1000.f;
|
||||
if (StateTimer >= 1.f)
|
||||
{
|
||||
@@ -337,6 +337,7 @@ void TAndroidApplication::InnerUpdate(cardinal dt)
|
||||
}
|
||||
else if (GameState == CONST_GAMESTATE_LOADING)
|
||||
{
|
||||
*SE::Console << "2CONST_GAMESTATE_LOADING";
|
||||
StateTimer += dt/1000.f;
|
||||
if (StateTimer >= 1.f)
|
||||
{
|
||||
@@ -360,17 +361,21 @@ void TAndroidApplication::InnerUpdate(cardinal dt)
|
||||
}
|
||||
else if (GameState == CONST_GAMESTATE_LEVEL)
|
||||
{
|
||||
*SE::Console << "3CONST_GAMESTATE_LEVEL";
|
||||
GameLevel.Update(dt);
|
||||
}
|
||||
else if (GameState == CONST_GAMESTATE_MENU)
|
||||
{
|
||||
//*SE::Console << "4CONST_GAMESTATE_MENU";
|
||||
Menu.Update(dt);
|
||||
}
|
||||
else if (GameState == CONST_GAMESTATE_FROM_MENU_TO_LEVEL)
|
||||
{
|
||||
{
|
||||
*SE::Console << "5CONST_GAMESTATE_FROM_MENU_TO_LEVEL";
|
||||
GameLevel.Update(dt);
|
||||
if (GameLevel.IsLoaded())
|
||||
{
|
||||
//*SE::Console << "5CONST_GAMESTATE_FROM_MENU_TO_LEVEL";
|
||||
GameState = CONST_GAMESTATE_LEVEL;
|
||||
OnDrawSignal.disconnect(boost::bind(&TGameMenu::Draw, boost::ref(Menu)));
|
||||
//CONNECT SLOT
|
||||
@@ -379,7 +384,8 @@ void TAndroidApplication::InnerUpdate(cardinal dt)
|
||||
}
|
||||
}
|
||||
else if (GameState == CONST_GAMESTATE_FROM_MENU_TO_CREDITS)
|
||||
{
|
||||
{
|
||||
*SE::Console << "6CONST_GAMESTATE_FROM_MENU_TO_CREDITS";
|
||||
Menu.Update(dt);
|
||||
GameCredits.Update(dt);
|
||||
StateTimer -= dt;
|
||||
@@ -392,7 +398,8 @@ void TAndroidApplication::InnerUpdate(cardinal dt)
|
||||
}
|
||||
}
|
||||
else if (GameState == CONST_GAMESTATE_CREDITS)
|
||||
{
|
||||
{
|
||||
//*SE::Console << "7CONST_GAMESTATE_CREDITS";
|
||||
GameCredits.Update(dt);
|
||||
}
|
||||
else if (GameState == CONST_GAMESTATE_FROM_CREDITS_TO_MENU)
|
||||
@@ -411,12 +418,12 @@ void TAndroidApplication::InnerUpdate(cardinal dt)
|
||||
}
|
||||
|
||||
|
||||
void TAndroidApplication::GoFromMenuToGame(int level)
|
||||
void TMyApplication::GoFromMenuToGame(int level)
|
||||
{
|
||||
//#ifndef TARGET_IOS
|
||||
ResourceManager->SoundManager.PlayMusicLooped("level1ogg.ogg");
|
||||
|
||||
//#ifndef TARGET_IOS
|
||||
// ResourceManager->SoundManager.PlayMusicLooped("level1ogg.ogg");
|
||||
//#endif
|
||||
|
||||
GameLevel.FillWithFile(ST::PathToResources + "level"+tostr(level+1)+".txt");
|
||||
GameLevel.SetLoading("shutterstock" + tostr(level+1), "levelshot"+tostr(level+1));
|
||||
GameState = CONST_GAMESTATE_FROM_MENU_TO_LEVEL;
|
||||
@@ -426,10 +433,10 @@ void TAndroidApplication::GoFromMenuToGame(int level)
|
||||
|
||||
}
|
||||
|
||||
void TAndroidApplication::GoFromGameToMenu()
|
||||
void TMyApplication::GoFromGameToMenu()
|
||||
{
|
||||
//#ifndef TARGET_IOS
|
||||
ResourceManager->SoundManager.StopMusic("level1ogg.ogg");
|
||||
// ResourceManager->SoundManager.StopMusic("level1ogg.ogg");
|
||||
//#endif
|
||||
TrySaveGame();
|
||||
DisapplySignalsToGame();
|
||||
@@ -438,7 +445,7 @@ void TAndroidApplication::GoFromGameToMenu()
|
||||
OnDrawSignal.disconnect(boost::bind(&TGameLevel::Draw, boost::ref(GameLevel)));
|
||||
}
|
||||
|
||||
void TAndroidApplication::GoFromMenuToCredits()
|
||||
void TMyApplication::GoFromMenuToCredits()
|
||||
{
|
||||
GameState = CONST_GAMESTATE_FROM_MENU_TO_CREDITS;
|
||||
StateTimer = CONST_CREDITS_SHOW_TIME;
|
||||
@@ -448,7 +455,7 @@ void TAndroidApplication::GoFromMenuToCredits()
|
||||
|
||||
}
|
||||
|
||||
void TAndroidApplication::GoFromCreditsToMenu()
|
||||
void TMyApplication::GoFromCreditsToMenu()
|
||||
{
|
||||
|
||||
GameState = CONST_GAMESTATE_FROM_CREDITS_TO_MENU;
|
||||
@@ -459,28 +466,28 @@ void TAndroidApplication::GoFromCreditsToMenu()
|
||||
DisapplySignalsToCredits();
|
||||
}
|
||||
|
||||
void TAndroidApplication::MarkSetGameLevelPause()
|
||||
void TMyApplication::MarkSetGameLevelPause()
|
||||
{
|
||||
OnDrawSignal.connect(0, boost::bind(&TGameMenu::Draw, boost::ref(Menu)));
|
||||
}
|
||||
|
||||
void TAndroidApplication::MarkReleaseGameLevelPause()
|
||||
void TMyApplication::MarkReleaseGameLevelPause()
|
||||
{
|
||||
OnDrawSignal.disconnect(boost::bind(&TGameMenu::Draw, boost::ref(Menu)));
|
||||
}
|
||||
|
||||
|
||||
void TAndroidApplication::OpenNextLevel()
|
||||
void TMyApplication::OpenNextLevel()
|
||||
{
|
||||
Menu.OpenNextLevel();
|
||||
}
|
||||
|
||||
bool TAndroidApplication::IsLoaded()
|
||||
bool TMyApplication::IsLoaded()
|
||||
{
|
||||
return Loaded;
|
||||
}
|
||||
|
||||
bool TAndroidApplication::IsInited()
|
||||
bool TMyApplication::IsInited()
|
||||
{
|
||||
return Inited;
|
||||
}
|
||||
+49
-48
@@ -32,14 +32,14 @@
|
||||
using namespace SE;
|
||||
|
||||
|
||||
extern boost::signals2::signal<void (vec2)> OnTapUpSignal;
|
||||
extern boost::signals2::signal<void (vec2)> OnTapUpAfterMoveSignal;
|
||||
extern boost::signals2::signal<void(Vector2f)> OnTapUpSignal;
|
||||
extern boost::signals2::signal<void(Vector2f)> OnTapUpAfterMoveSignal;
|
||||
|
||||
extern boost::signals2::signal<void (vec2)> OnTapDownSignal;
|
||||
extern boost::signals2::signal<void (vec2)> OnFlingSignal;
|
||||
extern boost::signals2::signal<void (vec2)> OnScrollSignal;
|
||||
extern boost::signals2::signal<void(Vector2f)> OnTapDownSignal;
|
||||
extern boost::signals2::signal<void(Vector2f)> OnFlingSignal;
|
||||
extern boost::signals2::signal<void(Vector2f)> OnScrollSignal;
|
||||
|
||||
extern boost::signals2::signal<void ()> OnDrawSignal;
|
||||
extern boost::signals2::signal<void()> OnDrawSignal;
|
||||
|
||||
extern const std::string CONST_BLOCK_TEXTURE1;
|
||||
extern const std::string CONST_BLOCK_TEXTURE2;
|
||||
@@ -70,6 +70,7 @@ extern const std::string CONST_SLIDE_UP_BTN_TEXTURE;
|
||||
extern const std::string CONST_TAP_TO_CONTINUE_BTN_TEXTURE;
|
||||
extern const std::string CONST_LOADING_TEXTURE;
|
||||
extern const std::string CONST_LOGO_SMALL_TEXTURE;
|
||||
extern const std::string CONST_LOADING_BACKGROUND_BLACK;
|
||||
extern const std::string CONST_CREDITS_TEXTURE;
|
||||
|
||||
|
||||
@@ -84,73 +85,73 @@ const int CONST_GAMESTATE_LOADING = 6;
|
||||
const int CONST_GAMESTATE_PRELOADING = 7;
|
||||
|
||||
|
||||
class TAndroidApplication : public TApplication
|
||||
class TMyApplication : public TApplication
|
||||
{
|
||||
protected:
|
||||
TGameMenu Menu;
|
||||
TGameLevel GameLevel;
|
||||
TGameCredits GameCredits;
|
||||
TGameLoading GameLoading;
|
||||
|
||||
int GameState;
|
||||
|
||||
int GameState;
|
||||
float StateTimer;
|
||||
|
||||
void TryLoadSavedGame();
|
||||
void TrySaveGame();
|
||||
|
||||
bool Inited;
|
||||
|
||||
std::vector<std::pair<std::string, std::string> > TextureNamesToLoad;
|
||||
|
||||
void ApplySignalsToMenu();
|
||||
void DisapplySignalsToMenu();
|
||||
void ApplySignalsToGame();
|
||||
void DisapplySignalsToGame();
|
||||
void ApplySignalsToCredits();
|
||||
void DisapplySignalsToCredits();
|
||||
|
||||
void TryLoadSavedGame();
|
||||
void TrySaveGame();
|
||||
|
||||
bool Inited;
|
||||
|
||||
std::vector<std::pair<std::string, std::string> > TextureNamesToLoad;
|
||||
|
||||
void ApplySignalsToMenu();
|
||||
void DisapplySignalsToMenu();
|
||||
void ApplySignalsToGame();
|
||||
void DisapplySignalsToGame();
|
||||
void ApplySignalsToCredits();
|
||||
void DisapplySignalsToCredits();
|
||||
|
||||
public:
|
||||
bool Loaded;
|
||||
|
||||
TAndroidApplication() : TApplication(), Loaded(false), Inited(false) { }
|
||||
bool Loaded;
|
||||
|
||||
TMyApplication() : TApplication(), Loaded(false), Inited(false) { }
|
||||
|
||||
virtual void InnerInit();
|
||||
|
||||
virtual void InnerDeinit();
|
||||
|
||||
virtual void InnerInit();
|
||||
|
||||
virtual void InnerDeinit();
|
||||
|
||||
virtual void InnerDraw();
|
||||
|
||||
virtual void InnerUpdate(cardinal dt);
|
||||
|
||||
|
||||
virtual void InnerUpdate(size_t dt);
|
||||
|
||||
void GoFromMenuToGame(int level);
|
||||
void GoFromGameToMenu();
|
||||
void GoFromMenuToCredits();
|
||||
void GoFromCreditsToMenu();
|
||||
void MarkSetGameLevelPause();
|
||||
void MarkReleaseGameLevelPause();
|
||||
|
||||
|
||||
void OpenNextLevel();
|
||||
|
||||
|
||||
bool IsLoaded();
|
||||
|
||||
|
||||
bool IsInited();
|
||||
|
||||
|
||||
void LoadResources();
|
||||
|
||||
virtual void InnerOnTapDown(vec2 p);
|
||||
|
||||
virtual void InnerOnTapUp(vec2 p);
|
||||
|
||||
virtual void InnerOnTapUpAfterMove(vec2 p);
|
||||
|
||||
virtual void InnerOnMove(vec2 shift);
|
||||
|
||||
virtual void OnFling(vec2 v);
|
||||
|
||||
virtual void InnerOnTapDown(Vector2f p);
|
||||
|
||||
virtual void InnerOnTapUp(Vector2f p);
|
||||
|
||||
virtual void InnerOnTapUpAfterMove(Vector2f p);
|
||||
|
||||
virtual void InnerOnMove(Vector2f p, Vector2f shift);
|
||||
|
||||
virtual void OnFling(Vector2f v);
|
||||
|
||||
};
|
||||
|
||||
|
||||
extern TAndroidApplication* Application;
|
||||
extern TMyApplication* Application;
|
||||
|
||||
|
||||
|
||||
|
||||
+29
-23
@@ -21,14 +21,15 @@ TGameMenu::TGameMenu()
|
||||
|
||||
void TGameMenu::Draw()
|
||||
{
|
||||
// *SE::Console << "TGameMenu::Draw";
|
||||
CheckGlError("Draw TGameMenu");
|
||||
RenderUniform1i("sel", 0);
|
||||
RenderUniform1f("Transparency", 1.f);
|
||||
float bkgShift = MenuPos*0.1f - 100.f;
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["main_menu_bkg_left"]);
|
||||
Renderer->DrawRect(vec2(bkgShift,0.f), vec2(480.f+bkgShift,320.f));
|
||||
Renderer->DrawRect(Vector2f(bkgShift,0.f), Vector2f(480.f+bkgShift,320.f));
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["main_menu_bkg_right"]);
|
||||
Renderer->DrawRect(vec2(480.f+bkgShift,0.f), vec2(960.f+bkgShift,320.f));
|
||||
Renderer->DrawRect(Vector2f(480.f+bkgShift,0.f), Vector2f(960.f+bkgShift,320.f));
|
||||
|
||||
|
||||
if (SelectedGame == 0)
|
||||
@@ -43,38 +44,38 @@ void TGameMenu::Draw()
|
||||
for (int i=0; i<MenuItemCount; i++)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["levelshot"+tostr(i+1)]);
|
||||
Renderer->DrawRect(vec2(160.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*i,80.f), vec2(160.f+240.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*i, 240.f));
|
||||
Renderer->DrawRect(Vector2f(160.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*i,80.f), Vector2f(160.f+240.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*i, 240.f));
|
||||
}
|
||||
|
||||
if (MenuItemCount == 12)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["game_end"]);
|
||||
Renderer->DrawRect(vec2(160.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*12,160.f - 64.f), vec2(160.f+256.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*12, 160.f + 64.f));
|
||||
Renderer->DrawRect(Vector2f(160.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*12,160.f - 64.f), Vector2f(160.f+256.f+MenuPos+CONST_MENU_WINDOW_DISTANCE*12, 160.f + 64.f));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["select_level"]);
|
||||
Renderer->DrawRect(vec2(240.f-128.f, 241.f), vec2(240.f+128.f, 305.f));
|
||||
Renderer->DrawRect(Vector2f(240.f-128.f, 241.f), Vector2f(240.f+128.f, 305.f));
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, ResourceManager->TexList["logo_small"]);
|
||||
Renderer->DrawRect(vec2(240.f-128.f+15.f, 0.f), vec2(240.f+128.f+15.f, 64.f));
|
||||
Renderer->DrawRect(Vector2f(240.f-128.f+15.f, 0.f), Vector2f(240.f+128.f+15.f, 64.f));
|
||||
|
||||
CheckGlError("Draw TGameMenu 2");
|
||||
|
||||
|
||||
}
|
||||
|
||||
void TGameMenu::Update(cardinal dt)
|
||||
void TGameMenu::Update(size_t dt)
|
||||
{
|
||||
if (HoldToTap)
|
||||
return;
|
||||
|
||||
// åñëè êíîïêà íå íàæàòà
|
||||
float k;
|
||||
|
||||
MenuPos = MenuPos + MenuSpeed*dt/1000.f;
|
||||
|
||||
|
||||
int menuItemToShowCount;
|
||||
|
||||
if (MenuItemCount == 12)
|
||||
@@ -130,22 +131,22 @@ void TGameMenu::Update(cardinal dt)
|
||||
|
||||
}
|
||||
|
||||
void TGameMenu::OnTapDown(vec2 pos)
|
||||
void TGameMenu::OnTapDown(Vector2f pos)
|
||||
{
|
||||
|
||||
*SE::Console << "TGameMenu::OnTapDown";
|
||||
HoldToTap = true;
|
||||
|
||||
if (pos.v[1]<64.f && pos.v[0]>=265.f-128.f && pos.v[0]<=265.f+128.f)
|
||||
|
||||
if (pos(1)<64.f && pos(0)>=265.f-128.f && pos(0)<=265.f+128.f)
|
||||
{
|
||||
Application->GoFromMenuToCredits();
|
||||
return;
|
||||
}
|
||||
|
||||
vec2 realPos = pos - vec2(MenuPos, 0);
|
||||
|
||||
Vector2f realPos = pos - Vector2f(MenuPos, 0);
|
||||
|
||||
if (realPos.v[1] >= 80.f && realPos.v[1] <= 240.f)
|
||||
if (realPos(1) >= 80.f && realPos(1) <= 240.f)
|
||||
{
|
||||
float x = realPos.v[0] - 160.f;
|
||||
float x = realPos(0) - 160.f;
|
||||
|
||||
int p = 0;
|
||||
while (x >280.f)
|
||||
@@ -166,8 +167,9 @@ void TGameMenu::OnTapDown(vec2 pos)
|
||||
|
||||
}
|
||||
|
||||
void TGameMenu::OnTapUp(vec2 pos)
|
||||
void TGameMenu::OnTapUp(Vector2f pos)
|
||||
{
|
||||
*SE::Console << "TGameMenu::OnTapUp";
|
||||
HoldToTap = false;
|
||||
|
||||
if (SelectedGame != -1)
|
||||
@@ -178,25 +180,27 @@ void TGameMenu::OnTapUp(vec2 pos)
|
||||
}
|
||||
}
|
||||
|
||||
void TGameMenu::OnTapUpAfterMove(vec2 pos)
|
||||
void TGameMenu::OnTapUpAfterMove(Vector2f pos)
|
||||
{
|
||||
HoldToTap = false;
|
||||
}
|
||||
|
||||
|
||||
void TGameMenu::OnFling(vec2 slideSpeed)
|
||||
void TGameMenu::OnFling(Vector2f slideSpeed)
|
||||
{
|
||||
*SE::Console << "TGameMenu::OnFling";
|
||||
HoldToTap = false;
|
||||
MenuSpeed = slideSpeed.v[0];
|
||||
MenuSpeed = slideSpeed(0);
|
||||
}
|
||||
|
||||
void TGameMenu::OnScroll(vec2 shift)
|
||||
void TGameMenu::OnScroll(Vector2f shift)
|
||||
{
|
||||
MenuPos = MenuPos - shift.v[0];
|
||||
MenuPos = MenuPos - shift(0);
|
||||
}
|
||||
|
||||
void TGameMenu::OpenNextLevel()
|
||||
{
|
||||
*SE::Console << "TGameMenu::OpenNextLevel";
|
||||
if (MenuItemCount < 12)
|
||||
{
|
||||
MenuItemCount++;
|
||||
@@ -205,10 +209,12 @@ void TGameMenu::OpenNextLevel()
|
||||
|
||||
int TGameMenu::GetMenuItemCount()
|
||||
{
|
||||
*SE::Console << "TGameMenu::GetMenuItemCount";
|
||||
return MenuItemCount;
|
||||
}
|
||||
|
||||
void TGameMenu::SetMenuItemCount(int menuItemCount)
|
||||
{
|
||||
*SE::Console << "TGameMenu::SetMenuItemCount";
|
||||
MenuItemCount = menuItemCount;
|
||||
}
|
||||
+6
-6
@@ -23,12 +23,12 @@ protected:
|
||||
public:
|
||||
TGameMenu();
|
||||
virtual void Draw();
|
||||
virtual void Update(cardinal dt);
|
||||
virtual void OnTapDown(vec2 pos);
|
||||
virtual void OnTapUp(vec2 pos);
|
||||
virtual void OnTapUpAfterMove(vec2 pos);
|
||||
virtual void OnFling(vec2 slideSpeed);
|
||||
virtual void OnScroll(vec2 shift);
|
||||
virtual void Update(size_t dt);
|
||||
virtual void OnTapDown(Vector2f pos);
|
||||
virtual void OnTapUp(Vector2f pos);
|
||||
virtual void OnTapUpAfterMove(Vector2f pos);
|
||||
virtual void OnFling(Vector2f slideSpeed);
|
||||
virtual void OnScroll(Vector2f shift);
|
||||
|
||||
void OpenNextLevel();
|
||||
int GetMenuItemCount();
|
||||
|
||||
Reference in new issue
Block a user