2017-01-10 12:43:06 +00:00
|
|
|
#ifndef GAMECODE_H_INCLUDED
|
|
|
|
#define GAMECODE_H_INCLUDED
|
|
|
|
|
|
|
|
#include "include/Engine.h"
|
|
|
|
#include "game_area_interface.h"
|
2018-06-01 11:45:16 +00:00
|
|
|
//#include "galaxy_menu.h"
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
#include <list>
|
|
|
|
|
|
|
|
using namespace SE;
|
|
|
|
|
|
|
|
|
|
|
|
const int CONST_BRICKSTATE_VISIBLE = 3;
|
|
|
|
const int CONST_BRICKSTATE_DISAPPEAR = 2;
|
|
|
|
const int CONST_BRICKSTATE_INVISIBLE = 1;
|
|
|
|
const int CONST_BRICKSTATE_APPEAR = 0;
|
|
|
|
|
|
|
|
const float CONST_BRICK_DISAPPEAR_TIME = 200.f;
|
|
|
|
const float CONST_BRICK_APPEAR_TIME = 200.f;
|
|
|
|
|
2018-04-03 09:47:08 +00:00
|
|
|
const int CONST_BRICKMATRIX_WIDTH = 12; // 12
|
|
|
|
const int CONST_BRICKMATRIX_HEIGHT = 13; // 13
|
2018-03-21 12:55:54 +00:00
|
|
|
const float CONST_BRICK_WIDTH = 38.65f;
|
2017-01-10 12:43:06 +00:00
|
|
|
const float CONST_BRICK_HEIGHT = 0.5f*CONST_BRICK_WIDTH;
|
2018-03-21 12:55:54 +00:00
|
|
|
const float CONST_BRICK_SHIFT_X = 8.2f;
|
2017-01-10 12:43:06 +00:00
|
|
|
const float CONST_BRICK_SHIFT_Y = -16.f;
|
|
|
|
|
|
|
|
const float CONST_BONUS_APPEAR_TIME = 400.f;
|
|
|
|
const float CONST_BONUS_FALL_SPEED = 100.f;
|
|
|
|
const float CONST_BONUS_GOTHROUGH_TIME = 8000.f;
|
|
|
|
const float CONST_BONUS_CATCH_DISTANCE_X = 65.f;
|
|
|
|
const float CONST_BONUS_CATCH_DISTANCE_Y = 20.f;
|
|
|
|
|
|
|
|
const float CONST_BONUS_FLOOR_TIME = 8000.f;
|
|
|
|
const float CONST_BONUS_FLOOR_APPEAR_SPEED = 50.f;
|
|
|
|
|
|
|
|
const int CONST_BONUS_TYPE_MULTIPLIER = 0;
|
|
|
|
const int CONST_BONUS_TYPE_GOTHROUGH = 1;
|
|
|
|
const int CONST_BONUS_TYPE_FLOOR = 2;
|
|
|
|
|
|
|
|
|
|
|
|
class TBrick
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
int InitialLocked;
|
|
|
|
int Locked; //0, 1 or 2
|
|
|
|
int State;
|
|
|
|
float StateTimer;
|
2017-11-14 17:04:04 +00:00
|
|
|
Vector4f Color;
|
2017-01-10 12:43:06 +00:00
|
|
|
public:
|
|
|
|
TBrick();
|
2017-11-14 17:04:04 +00:00
|
|
|
void SetVisible(Vector4f color, int locked);
|
2017-01-10 12:43:06 +00:00
|
|
|
void SetInvisible();
|
|
|
|
void TryDrawAppear(int ipos, int jpos);
|
2017-11-14 17:04:04 +00:00
|
|
|
void Update(size_t dt);
|
|
|
|
Vector2f GetPosFrom(int ipos, int jpos);
|
|
|
|
Vector4f GetColor();
|
|
|
|
void Appear(Vector4f color, int locked);
|
2017-01-10 12:43:06 +00:00
|
|
|
void Appear();
|
|
|
|
void Hit();
|
|
|
|
void Disappear();
|
|
|
|
int GetLocked();
|
|
|
|
bool CanReact();
|
2018-06-01 11:45:16 +00:00
|
|
|
bool IsAppear();
|
2017-01-10 12:43:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class TBonusFalling
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
float Lifetime;
|
2017-11-14 17:04:04 +00:00
|
|
|
Vector2f Pos;
|
2017-01-10 12:43:06 +00:00
|
|
|
std::string TexName;
|
|
|
|
int BonusType; //0 - multiplier, 1 - Go-through, 2 - floor
|
|
|
|
public:
|
2017-11-14 17:04:04 +00:00
|
|
|
TBonusFalling(Vector2f pos);
|
|
|
|
Vector2f GetPos();
|
2017-01-10 12:43:06 +00:00
|
|
|
int GetType();
|
|
|
|
void Draw();
|
2017-11-14 17:04:04 +00:00
|
|
|
void Update(size_t dt);
|
2017-01-10 12:43:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TBall
|
|
|
|
{
|
2017-11-14 17:04:04 +00:00
|
|
|
Vector2f Pos;
|
|
|
|
Vector2f Velocity;
|
|
|
|
Vector4f Color;
|
|
|
|
std::list<Vector2f> TalePos;
|
2017-01-10 12:43:06 +00:00
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
Vector2f BallInBlock;
|
|
|
|
Vector2f PrevBallInBlock;
|
2017-01-10 12:43:06 +00:00
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
TBall(Vector2f pos, Vector2f velocity, Vector4f color);
|
|
|
|
Vector2f GetPos();
|
|
|
|
Vector2f GetVelocityVector();
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
void Go();
|
|
|
|
|
|
|
|
void ReflectToLeft();
|
|
|
|
void ReflectToRight();
|
|
|
|
void ReflectToUp();
|
|
|
|
void ReflectToDown();
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
void TryReflectOnReflector(Vector2f refPos);
|
2017-01-10 12:43:06 +00:00
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
void Update(size_t dt);
|
2017-01-10 12:43:06 +00:00
|
|
|
};
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
typedef std::pair<Vector4f, std::string> PairColorTexture;
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
struct TBlockInstansingList
|
|
|
|
{
|
|
|
|
//color-texture ---> and list of triangles for this color
|
|
|
|
std::list<std::pair<PairColorTexture, TTriangleList>> ColorBlockList;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct TBallInstancingList
|
|
|
|
{
|
|
|
|
std::map<int, TTriangleList> BallAndGlowList;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TGameLevel : public TGameAreaAncestor
|
|
|
|
{
|
2018-04-05 04:35:49 +00:00
|
|
|
friend class TMyApplication;
|
2018-06-01 11:45:16 +00:00
|
|
|
friend class GalaxyMenu;
|
2017-01-10 12:43:06 +00:00
|
|
|
protected:
|
2018-03-23 12:22:07 +00:00
|
|
|
float lvlWidth;
|
|
|
|
float lvlHeight;
|
2017-01-10 12:43:06 +00:00
|
|
|
std::string BkgTexture;
|
|
|
|
std::string LevelScreenTexture;
|
|
|
|
std::string LevelFileName;
|
2018-06-09 19:29:55 +00:00
|
|
|
|
|
|
|
GLuint prerenderedImage;
|
2017-01-10 12:43:06 +00:00
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
Vector2f ReflectorPos;
|
2018-06-09 19:29:55 +00:00
|
|
|
|
|
|
|
std::string levelName;
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
int LevelState;
|
|
|
|
bool PrevLevelStateIsStandby;
|
|
|
|
float StateTimer;
|
|
|
|
|
|
|
|
TBrick BlockMatrix[CONST_BRICKMATRIX_WIDTH][CONST_BRICKMATRIX_HEIGHT];
|
|
|
|
TBlockInstansingList BlockInstansingList;
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
bool TapInBackBtnArea(const Vector2f& pos);
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
void ReloadBlockInstansingList();
|
|
|
|
void SetFinished();
|
|
|
|
void SetFinishFreeze();
|
|
|
|
|
|
|
|
void DrawBuffer();
|
|
|
|
void DrawPauseButtons();
|
|
|
|
|
|
|
|
void DrawBallInstancingList();
|
2018-05-31 11:47:18 +00:00
|
|
|
|
|
|
|
void drawOutline();
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
bool RenderBufferReady;
|
|
|
|
|
|
|
|
float OutScale;
|
|
|
|
|
|
|
|
float OutScaleVelocity;
|
|
|
|
|
|
|
|
void TryGoToMenu();
|
|
|
|
|
|
|
|
std::list<TBonusFalling> BonusFallingList;
|
|
|
|
|
|
|
|
std::list<TBall> BallList;
|
|
|
|
|
|
|
|
TBallInstancingList BallInstancingList;
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
Vector4f BallColor;
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
void ReloadBallInstancingList();
|
|
|
|
void RefreshBallInstancingList();
|
|
|
|
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
void UpdateBallList(size_t dt);
|
|
|
|
void MultiplyBalls(Vector2f pos, Vector2f velocity);
|
2017-01-10 12:43:06 +00:00
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
Vector2f GetBlock(const Vector2f& pos);
|
2017-01-10 12:43:06 +00:00
|
|
|
void InitLevel();
|
|
|
|
|
|
|
|
float BonusGothroughTimer;
|
|
|
|
float BonusFloorTimer;
|
|
|
|
float BonusFloorPosY;
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
Vector4f ParseColor(const std::string& s);
|
2017-01-10 12:43:06 +00:00
|
|
|
void ReloadLevel();
|
|
|
|
|
|
|
|
public:
|
|
|
|
TGameLevel();
|
|
|
|
~TGameLevel();
|
|
|
|
|
|
|
|
void FillWithFile(const std::string& filename);
|
2018-06-09 19:51:32 +00:00
|
|
|
void setBackground(const std::string& assignedShutterstock);
|
2017-01-10 12:43:06 +00:00
|
|
|
|
2018-03-26 11:42:25 +00:00
|
|
|
//void SetLevelScale();
|
|
|
|
//Vector2f GetLevelScale();
|
2018-03-23 12:22:07 +00:00
|
|
|
|
2017-01-10 12:43:06 +00:00
|
|
|
void SetStandBy();
|
2018-06-09 19:51:32 +00:00
|
|
|
void SetLoading();
|
2017-01-10 12:43:06 +00:00
|
|
|
bool IsLoaded();
|
|
|
|
|
|
|
|
virtual void Draw();
|
2018-06-09 19:51:32 +00:00
|
|
|
void DrawSnapshot(const std::string& assignedSnapshotFrameBuffer);
|
2017-01-10 12:43:06 +00:00
|
|
|
|
|
|
|
void SetPause();
|
|
|
|
bool IsPaused();
|
|
|
|
void ReleasePause();
|
|
|
|
|
2017-11-14 17:04:04 +00:00
|
|
|
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);
|
2017-01-10 12:43:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|