migrate to TES-engine
This commit is contained in:
1 parent
b4c58abee4
commit
d97dab0ecc
8 files changed
+569
-381
No files matched your search
+43
-16
@@ -58,35 +58,60 @@ struct TOnClickTest
|
||||
void TMyApplication::InnerInit()
|
||||
{
|
||||
#ifdef TARGET_ANDROID
|
||||
ResourceManager->PathToResources = "";
|
||||
SE::ST::PathToResources = "";
|
||||
#endif
|
||||
#ifdef TARGET_WIN32
|
||||
#ifdef DEBUG
|
||||
ResourceManager->PathToResources = "../../assets/";
|
||||
SE::ST::PathToResources = "../../assets/";
|
||||
#else
|
||||
ResourceManager->PathToResources = "res/";
|
||||
SE::ST::PathToResources = "res/";
|
||||
#endif
|
||||
#endif
|
||||
#ifdef TARGET_IOS
|
||||
ResourceManager->PathToResources = "assets/";
|
||||
SE::ST::PathToResources = "assets/";
|
||||
#endif
|
||||
|
||||
if (SE::Console != nullptr) {
|
||||
*SE::Console << "APP INIT\n";
|
||||
}
|
||||
|
||||
boost::shared_ptr<boost::property_tree::ptree> px = FileToPropertyTree("function_info_list.xml");
|
||||
SE::ResourceManager->ShaderManager.AddShader("DefaultShader", "shader1vertex.txt", "shader1fragment.txt");
|
||||
SE::ResourceManager->ShaderManager.AddShader("FrameShader", "frameshader_vertex.txt", "frameshader_fragment.txt");
|
||||
SE::ResourceManager->ShaderManager.AddShader("BrickShader", "brickshader_vertex.txt", "brickshader_fragment.txt");
|
||||
SE::Renderer->PushShader("DefaultShader");
|
||||
|
||||
const std::string CONST_LOADING_BACKGROUND_BLACK = "loading_background_black";
|
||||
const std::string CONST_LOADING_TEXTURE = "loading";
|
||||
const std::string CONST_LOGO_SMALL_TEXTURE = "logo_small";
|
||||
|
||||
SE::ResourceManager->TexList.AddTexture(CONST_LOADING_BACKGROUND_BLACK + ".png", CONST_LOADING_BACKGROUND_BLACK);
|
||||
SE::ResourceManager->TexList.AddTexture(CONST_LOADING_TEXTURE + ".png", CONST_LOADING_TEXTURE);
|
||||
SE::ResourceManager->TexList.AddTexture(CONST_LOGO_SMALL_TEXTURE + ".png", CONST_LOGO_SMALL_TEXTURE);
|
||||
|
||||
SE::ResourceManager->TexList.AddTexture("console_bkg.bmp");
|
||||
|
||||
SE::ResourceManager->FrameManager.AddFrameRenderBuffer("LevelBuffer", 512, 512);
|
||||
|
||||
Inited = true;
|
||||
|
||||
SE::Renderer->SetOrthoProjection();
|
||||
|
||||
SE::Renderer->SetFullScreenViewport();
|
||||
|
||||
ResourceManager->ScriptManager.Serialize(*px);
|
||||
|
||||
px = FileToPropertyTree("shaders.xml");
|
||||
ResourceManager->ShaderManager.Serialize(*px);
|
||||
auto px = SE::FileToPropertyTree("shaders.xml");
|
||||
SE::ResourceManager->ShaderManager.Serialize(*px);
|
||||
|
||||
HalibutRender->PushShader("DefaultShader");
|
||||
px = SE::FileToPropertyTree("textures.xml");
|
||||
SE::ResourceManager->TexList.Serialize(*px);
|
||||
|
||||
px = FileToPropertyTree("textures.xml");
|
||||
ResourceManager->TexList.Serialize(*px);
|
||||
|
||||
px = FileToPropertyTree("fonts.xml");
|
||||
ResourceManager->FontManager.Serialize(*px);
|
||||
ResourceManager->FontManager.PushFont("droid_sans14");
|
||||
//this cause exception
|
||||
//px = SE::FileToPropertyTree("fonts.xml");
|
||||
//SE::ResourceManager->FontManager.Serialize(*px);
|
||||
//SE::ResourceManager->FontManager.PushFont("droid_sans14");
|
||||
|
||||
|
||||
/*
|
||||
|
||||
ResourceManager->GUIManager.AddWidgetAndFill(boost::shared_ptr<TInstancingWidgetAncestor>(new TSquareButton),
|
||||
"ololo", "group1",
|
||||
@@ -104,6 +129,8 @@ void TMyApplication::InnerInit()
|
||||
ResourceManager->GUIManager.MoveWidget("ololo", vec2(-100, 0));
|
||||
|
||||
TOnClickTest OnClickTest;
|
||||
*/
|
||||
|
||||
|
||||
//ResourceManager->GUIManager.GetOnClickSignal("ololo").connect(OnClickTest);
|
||||
|
||||
@@ -136,6 +163,6 @@ void TMyApplication::InnerDraw()
|
||||
}
|
||||
|
||||
//What to do on update. timer means how many ms passed since last update
|
||||
void TMyApplication::InnerUpdate(cardinal timer)
|
||||
void TMyApplication::InnerUpdate(size_t timer)
|
||||
{
|
||||
}
|
||||
+3
-2
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "match3/match3field.h"
|
||||
|
||||
class TMatch3Field;
|
||||
|
||||
class TMatch3Controller
|
||||
{
|
||||
@@ -35,7 +36,7 @@ public:
|
||||
|
||||
|
||||
//Application class
|
||||
class TMyApplication : public TApplication
|
||||
class TMyApplication : public SE::TApplication
|
||||
{
|
||||
public:
|
||||
bool Inited;
|
||||
@@ -53,7 +54,7 @@ public:
|
||||
virtual void InnerDraw();
|
||||
//What to do on draw
|
||||
|
||||
virtual void InnerUpdate(cardinal timer);
|
||||
virtual void InnerUpdate(size_t timer);
|
||||
//What to do on update. timer means how many ms passed since last update
|
||||
};
|
||||
|
||||
|
||||
+277
-266
File diff suppressed because it is too large.
Load diff
+76
-78
@@ -2,11 +2,12 @@
|
||||
#define MATCH3FIELD_H_INCLUDED
|
||||
|
||||
#include "include/Engine.h"
|
||||
#include <Eigen/src/Core/Matrix.h>
|
||||
|
||||
|
||||
|
||||
const cardinal CONST_MAX_FIELD_WIDTH = 11;
|
||||
const cardinal CONST_MAX_FIELD_HEIGHT = 11;
|
||||
const size_t CONST_MAX_FIELD_WIDTH = 11;
|
||||
const size_t CONST_MAX_FIELD_HEIGHT = 11;
|
||||
|
||||
|
||||
const float CONST_MATCH3_CELL_WIDTH = 42.f;
|
||||
@@ -20,7 +21,7 @@ const float CONST_MATCH3_CELL_HEIGHT = 32.f;
|
||||
const float CONST_CHIP_LOWEST_SPEED = -0.3f;
|
||||
const float CONST_CHIP_ACCELERATION = -0.001f;
|
||||
*/
|
||||
const cardinal CONST_MATCH_TIME = 150;
|
||||
const size_t CONST_MATCH_TIME = 150;
|
||||
|
||||
const float CONST_CHIP_POSITION_EPSILON = 1.f;
|
||||
const float CONST_CHIP_VELOCITY_EPSILON = 0.3f;
|
||||
@@ -28,25 +29,24 @@ const float CONST_CHIP_VELOCITY_EPSILON = 0.3f;
|
||||
|
||||
const float CONST_CHIP_K = 0.4f;
|
||||
|
||||
const cardinal CONST_CHIP_TYPE_COUNT = 4;
|
||||
const size_t CONST_CHIP_TYPE_COUNT = 4;
|
||||
|
||||
|
||||
struct TChipTemplateParams : public TSerializeInterface
|
||||
struct TChipTemplateParams : public SE::TSerializeInterface
|
||||
{
|
||||
THalibutExternalAnimObject SelectedTemplateAnimObject;
|
||||
THalibutExternalAnimObject FinishingTemplateAnimObject;
|
||||
TRenderParams SelectedRenderParams;
|
||||
TRenderParams FinishingRenderParams;
|
||||
SE::THalibutExternalAnimObject SelectedTemplateAnimObject;
|
||||
SE::THalibutExternalAnimObject FinishingTemplateAnimObject;
|
||||
SE::TRenderParams SelectedRenderParams;
|
||||
SE::TRenderParams FinishingRenderParams;
|
||||
|
||||
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct TMatch3FieldParams : public TSerializeInterface
|
||||
struct TMatch3FieldParams : public SE::TSerializeInterface
|
||||
{
|
||||
cardinal FieldWidth;
|
||||
cardinal FieldHeight;
|
||||
size_t FieldWidth;
|
||||
size_t FieldHeight;
|
||||
float CellWidth;
|
||||
float CellHeight;
|
||||
float ChipLowestSpeed;
|
||||
@@ -55,9 +55,9 @@ struct TMatch3FieldParams : public TSerializeInterface
|
||||
float ChipPositionEpsilon;
|
||||
float ChipVelocityEpsilon;
|
||||
float ChipK;
|
||||
cardinal ChipMatchTime;
|
||||
size_t ChipMatchTime;
|
||||
|
||||
cardinal ChipTypeCount;
|
||||
size_t ChipTypeCount;
|
||||
|
||||
std::vector<TChipTemplateParams> ChipTemplateParamsArr;
|
||||
|
||||
@@ -82,15 +82,14 @@ struct TMatch3FieldParams : public TSerializeInterface
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct TChip
|
||||
{
|
||||
int ChipType; // -1 means empty field
|
||||
std::string AnimName; //Generated automatically
|
||||
|
||||
TRenderPairList::iterator RenderPair;
|
||||
SE::TRenderPairList::iterator RenderPair;
|
||||
|
||||
cardinal VertexListShift;
|
||||
size_t VertexListShift;
|
||||
|
||||
float Velocity;
|
||||
|
||||
@@ -104,31 +103,32 @@ struct TChip
|
||||
CS_X,
|
||||
} ChipState;
|
||||
|
||||
TChip(int chipType, TRenderPairList::iterator renderPair, cardinal vertexListShift, TChipState chipState = CS_FALLING);
|
||||
TChip(int chipType, SE::TRenderPairList::iterator renderPair, size_t vertexListShift, TChipState chipState = CS_FALLING);
|
||||
|
||||
~TChip();
|
||||
|
||||
vec2 GetLeftBottomPos();
|
||||
void SetLeftBottomPos(vec2 newPos);
|
||||
void MoveLeftBottomPos(vec2 shift);
|
||||
Eigen::Vector2f GetLeftBottomPos();
|
||||
void SetLeftBottomPos(Eigen::Vector2f newPos);
|
||||
void MoveLeftBottomPos(Eigen::Vector2f shift);
|
||||
|
||||
static int StaticAnimationIndex;
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct TChipSwappingPair
|
||||
{
|
||||
float T;
|
||||
ivec2 Chip1;
|
||||
ivec2 Chip2;
|
||||
Eigen::Vector2i Chip1;
|
||||
Eigen::Vector2i Chip2;
|
||||
|
||||
vec2 Chip1RealPosFrom;
|
||||
vec2 Chip2RealPosFrom;
|
||||
Eigen::Vector2f Chip1RealPosFrom;
|
||||
Eigen::Vector2f Chip2RealPosFrom;
|
||||
|
||||
bool IsReturning;
|
||||
|
||||
|
||||
TChipSwappingPair(ivec2 chip1, ivec2 chip2, vec2 chip1PosFrom, vec2 chip2PosFrom)
|
||||
TChipSwappingPair(Eigen::Vector2i chip1, Eigen::Vector2i chip2, Eigen::Vector2f chip1PosFrom, Eigen::Vector2f chip2PosFrom)
|
||||
: Chip1(chip1)
|
||||
, Chip2(chip2)
|
||||
, T(0)
|
||||
@@ -143,10 +143,10 @@ struct TChipSwappingPair
|
||||
struct TChipDeletingData
|
||||
{
|
||||
float T;
|
||||
ivec2 Chip;
|
||||
vec2 Pos;
|
||||
Eigen::Vector2i Chip;
|
||||
Eigen::Vector2f Pos;
|
||||
|
||||
TChipDeletingData(ivec2 chip, vec2 pos)
|
||||
TChipDeletingData(Eigen::Vector2i chip, Eigen::Vector2f pos)
|
||||
: T(0.f)
|
||||
, Chip(chip)
|
||||
, Pos(pos)
|
||||
@@ -154,97 +154,100 @@ struct TChipDeletingData
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class TMatch3Logic
|
||||
{
|
||||
protected:
|
||||
|
||||
cardinal ChipTypeCount;
|
||||
size_t ChipTypeCount;
|
||||
|
||||
std::vector<std::vector<TChip> > ChipMatrix;
|
||||
std::vector<TChipSwappingPair> ChipSwappingPairVector;
|
||||
std::vector<TChipDeletingData> ChipDeletingVector;
|
||||
|
||||
std::vector<TRenderPairList::iterator> RenderPairIteratorVector;
|
||||
std::vector<SE::TRenderPairList::iterator> RenderPairIteratorVector;
|
||||
|
||||
ivec2 selectedChip;
|
||||
Eigen::Vector2i selectedChip;
|
||||
|
||||
vec2 LeftBottomPosField;
|
||||
Eigen::Vector2f LeftBottomPosField;
|
||||
|
||||
TMatch3FieldParams Match3FieldParams;
|
||||
|
||||
void FillRandomChipMatrix(std::vector<TRenderPairList::iterator> renderPairIteratorVector, vec2 leftBottomPos);
|
||||
void FillRandomChipMatrix(std::vector<SE::TRenderPairList::iterator> renderPairIteratorVector, Eigen::Vector2f leftBottomPos);
|
||||
|
||||
vec2 GetExpectedLeftBottomPos(cardinal x, cardinal y);
|
||||
Eigen::Vector2f GetExpectedLeftBottomPos(size_t x, size_t y);
|
||||
|
||||
void StartAnimateChip(cardinal x, cardinal y);
|
||||
void StopAnimateChip(cardinal x, cardinal y);
|
||||
void StartAnimateChip(size_t x, size_t y);
|
||||
void StopAnimateChip(size_t x, size_t y);
|
||||
|
||||
bool ChipIsLocked(ivec2 chip);
|
||||
bool ChipIsFinishing(ivec2 chip);
|
||||
bool ChipIsStable(ivec2 chip);
|
||||
bool ChipCanBeSelected(ivec2 chip);
|
||||
bool ChipsCanBeSwapped(ivec2 p1, ivec2 p2);
|
||||
bool ChipIsLocked(Eigen::Vector2i chip);
|
||||
bool ChipIsFinishing(Eigen::Vector2i chip);
|
||||
bool ChipIsStable(Eigen::Vector2i chip);
|
||||
bool ChipCanBeSelected(Eigen::Vector2i chip);
|
||||
bool ChipsCanBeSwapped(Eigen::Vector2i p1, Eigen::Vector2i p2);
|
||||
|
||||
bool ChipCanBeMatchedUp(ivec2 chip);
|
||||
bool ChipCanBeMatchedDown(ivec2 chip);
|
||||
bool ChipCanBeMatchedLeft(ivec2 chip);
|
||||
bool ChipCanBeMatchedRight(ivec2 chip);
|
||||
bool ChipCanBeMatchedUp(Eigen::Vector2i chip);
|
||||
bool ChipCanBeMatchedDown(Eigen::Vector2i chip);
|
||||
bool ChipCanBeMatchedLeft(Eigen::Vector2i chip);
|
||||
bool ChipCanBeMatchedRight(Eigen::Vector2i chip);
|
||||
|
||||
void UnmatchChips(std::vector<ivec2> chipList);
|
||||
void UpdateChipPosition(cardinal dt);
|
||||
void UnmatchChips(std::vector<Eigen::Vector2i> chipList);
|
||||
void UpdateChipPosition(size_t dt);
|
||||
void RemoveBubbles();
|
||||
|
||||
void ReplaceAnimation(ivec2 p);
|
||||
void ReplaceAnimation(Eigen::Vector2i p);
|
||||
|
||||
void MoveVertexListShiftBack(TRenderPairList::iterator renderPairItr, cardinal moveFrom);
|
||||
void MoveVertexCoordDown(TRenderPairList::iterator renderPairItr, cardinal moveFrom, float value);
|
||||
void MoveVertexListShiftBack(SE::TRenderPairList::iterator renderPairItr, size_t moveFrom);
|
||||
void MoveVertexCoordDown(SE::TRenderPairList::iterator renderPairItr, size_t moveFrom, float value);
|
||||
|
||||
void AddChipToUp(cardinal colNum, int chipType, vec2 spawnPos, TChip::TChipState chipState = TChip::CS_FALLING);
|
||||
void InsertEmptyChip(cardinal colNum, cardinal rowNum, int chipType);
|
||||
void AddChipToUp(size_t colNum, int chipType, Eigen::Vector2f spawnPos, TChip::TChipState chipState = TChip::CS_FALLING);
|
||||
void InsertEmptyChip(size_t colNum, size_t rowNum, int chipType);
|
||||
|
||||
void UpdateChipSwapping(cardinal dt);
|
||||
void UpdateChipSwapping(size_t dt);
|
||||
void TryMatchAllChips();
|
||||
|
||||
void DestroyChip(ivec2 p);
|
||||
void DestroyChip(Eigen::Vector2i p);
|
||||
|
||||
void ChangeChipType(ivec2 p);
|
||||
void ChangeChipType(Eigen::Vector2i p);
|
||||
|
||||
public:
|
||||
|
||||
TMatch3Logic();
|
||||
virtual ~TMatch3Logic();
|
||||
|
||||
void SelectChip(ivec2 pos);
|
||||
void SelectChip(Eigen::Vector2i pos);
|
||||
void UnselectChip();
|
||||
ivec2 GetSelectedChip();
|
||||
Eigen::Vector2i GetSelectedChip();
|
||||
|
||||
std::vector<ivec2> GetAvailableMatchingChips();
|
||||
std::vector<Eigen::Vector2i> GetAvailableMatchingChips();
|
||||
|
||||
void SwapChips(ivec2 p1, ivec2 p2, bool isReturning = false);
|
||||
void SwapChips(Eigen::Vector2i p1, Eigen::Vector2i p2, bool isReturning = false);
|
||||
|
||||
void ResetChipPos(ivec2 p);
|
||||
void ResetChipPos(Eigen::Vector2i p);
|
||||
|
||||
void UpdateLogic(cardinal dt);
|
||||
void UpdateLogic(size_t dt);
|
||||
|
||||
void HitFieldWithPattern(ivec2 pos, std::vector<std::vector<char> > pattern, std::vector<std::vector<char> > jumpingPattern);
|
||||
void HitFieldWithPattern(Eigen::Vector2i pos, std::vector<std::vector<char> > pattern, std::vector<std::vector<char> > jumpingPattern);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class TMatch3Controller;
|
||||
|
||||
class TMatch3Field : public TMatch3Logic, public TInstancingWidgetAncestor
|
||||
class TMatch3Field : public TMatch3Logic
|
||||
{
|
||||
protected:
|
||||
void FillBasicChipMatrixAndTriangleList();
|
||||
|
||||
//TMatch3Controller& Match3Controller;
|
||||
|
||||
vec2 LastTappedPos;
|
||||
vec2 LastMovePos;
|
||||
Eigen::Vector2f LastTappedPos;
|
||||
Eigen::Vector2f LastMovePos;
|
||||
|
||||
ivec2 PosToChip(vec2 pos);
|
||||
Eigen::Vector2i PosToChip(Eigen::Vector2f pos);
|
||||
|
||||
public:
|
||||
TMatch3Field();
|
||||
@@ -254,11 +257,11 @@ public:
|
||||
TMatch3Field(TMatch3Controller& match3Controller);
|
||||
~TMatch3Field();
|
||||
|
||||
virtual void Update(cardinal dt);
|
||||
virtual void OnTapDown(vec2 pos);
|
||||
virtual void OnTapUp(vec2 pos);
|
||||
virtual void OnMove(vec2 shift);
|
||||
virtual bool CheckClick(vec2 mousePos);
|
||||
virtual void Update(size_t dt);
|
||||
virtual void OnTapDown(Eigen::Vector2f pos);
|
||||
virtual void OnTapUp(Eigen::Vector2f pos);
|
||||
virtual void OnMove(Eigen::Vector2f shift);
|
||||
virtual bool CheckClick(Eigen::Vector2f mousePos);
|
||||
|
||||
void HighlightMatch3();
|
||||
|
||||
@@ -268,9 +271,4 @@ public:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user