animation doesn't work

This commit is contained in:
Samat Agishev 2018-02-05 19:53:52 +05:00
parent cfd1a0a062
commit 992befeb45
5 changed files with 33 additions and 78 deletions

View File

@ -14,7 +14,7 @@
#include "main_code.h" #include "main_code.h"
#ifndef TARGET_IOS #ifndef TARGET_IOS
boost::shared_ptr<TMyApplication> App(new TMyApplication); std::shared_ptr<TMyApplication> App = std::make_shared<TMyApplication>();
#endif #endif
bool animPaused = false; bool animPaused = false;
@ -115,48 +115,6 @@ void TMyApplication::InnerInit()
Match3Controller.Match3Field = std::make_shared<TMatch3Field>(Match3Controller); Match3Controller.Match3Field = std::make_shared<TMatch3Field>(Match3Controller);
/*
ResourceManager->GUIManager.AddWidgetAndFill(boost::shared_ptr<TInstancingWidgetAncestor>(new TSquareButton),
"ololo", "group1",
boost::shared_ptr<TTriangleListFillerAncestor>(new TSquareButtonTriangleListFiller(vec2(100, 100), vec2(200, 200), "button_normal", "button_pressed")));
ResourceManager->GUIManager.AddWidgetAndFill(boost::shared_ptr<TInstancingWidgetAncestor>(new TSquareStatic),
"Background", "group1",
boost::shared_ptr<TSquareStaticTriangleListFiller>(new TSquareStaticTriangleListFiller(vec2(0, 0), vec2(800, 480), "cave_hd")));
ResourceManager->GUIManager.AddWidget(boost::shared_ptr<TInstancingWidgetAncestor>(new TMatch3Field(Match3Controller)),
"match3", "group1");
ResourceManager->GUIManager.MoveWidget("ololo", vec2(-100, 0));
TOnClickTest OnClickTest;
*/
//ResourceManager->GUIManager.GetOnClickSignal("ololo").connect(OnClickTest);
//testAnimObject.Serialize(FileToPropertyTree("test_animation_xml.xml"));
//ResourceManager->HalibutAnimationManager.AddAnimationObject("test_anim", testAnimObject);
//ResourceManager->HalibutAnimationManager.StartAnimation("test_anim");
//ResourceManager->ShaderManager.AddShader("DefaultShader", "shader_vertex.txt", "shader_fragment.txt");
/*HalibutRender->PushShader("DefaultShader");
ResourceManager->TexList.AddTexture(CONST_CONSOLE_TEX_NAME);
ResourceManager->FontManager.AddFont("droid_sans14", "droid_sans14_font_bitmap.bmp32", "droid_sans14_font_charmap.txt");
ResourceManager->FontManager.PushFont("droid_sans14");*/
//glDisable(GL_CULL_FACE);
} }
//What to do on deinit //What to do on deinit
@ -197,13 +155,10 @@ void TMyApplication::InnerOnTapUp(Eigen::Vector2f p) {
} }
Match3Controller.Match3Field.get()->OnTapUp(p); Match3Controller.Match3Field.get()->OnTapUp(p);
} }
void TMyApplication::InnerOnTapUpAfterMove(Eigen::Vector2f p) {
//Match3Controller.Match3Field.get()->
}
void TMyApplication::InnerOnMove(Eigen::Vector2f pos, Eigen::Vector2f shift) { void TMyApplication::InnerOnMove(Eigen::Vector2f pos, Eigen::Vector2f shift) {
if (!Match3Controller.Match3Field.get()->CheckClick(pos)) { // if (!Match3Controller.Match3Field.get()->CheckClick(pos)) {
return; // return;
} // }
Match3Controller.Match3Field.get()->OnMove(pos); // Match3Controller.Match3Field.get()->OnMove(pos);
} }

View File

@ -64,13 +64,11 @@ public:
virtual void InnerOnTapUp(Eigen::Vector2f p) override; virtual void InnerOnTapUp(Eigen::Vector2f p) override;
virtual void InnerOnTapUpAfterMove(Eigen::Vector2f p) override;
virtual void InnerOnMove(Eigen::Vector2f pos, Eigen::Vector2f shift) override; virtual void InnerOnMove(Eigen::Vector2f pos, Eigen::Vector2f shift) override;
}; };
#ifndef TARGET_IOS #ifndef TARGET_IOS
extern boost::shared_ptr<TMyApplication> App; extern std::shared_ptr<TMyApplication> App;
#endif #endif
#endif #endif

View File

@ -54,7 +54,7 @@ void TMatch3FieldParams::Serialize(boost::property_tree::ptree& propertyTree)
ChipMatchTime = propertyTree.get<size_t>("Match3Params.ChipMatchTime"); ChipMatchTime = propertyTree.get<size_t>("Match3Params.ChipMatchTime");
ChipTypeCount = propertyTree.get<size_t>("Match3Params.ChipTypeCount"); ChipTypeCount = propertyTree.get<size_t>("Match3Params.ChipTypeCount");
BOOST_FOREACH(boost::property_tree::ptree::value_type &v, propertyTree.get_child("Match3Params.ChipList")) for (boost::property_tree::ptree::value_type &v : propertyTree.get_child("Match3Params.ChipList"))
{ {
boost::property_tree::ptree& p = v.second.get_child(""); boost::property_tree::ptree& p = v.second.get_child("");
chipTemplateParams.Serialize(p); chipTemplateParams.Serialize(p);
@ -181,14 +181,14 @@ Eigen::Vector2f TMatch3Logic::GetExpectedLeftBottomPos(size_t x, size_t y)
void TMatch3Logic::StartAnimateChip(size_t x, size_t y) void TMatch3Logic::StartAnimateChip(size_t x, size_t y)
{ {
//return;
SE::ResourceManager->HalibutAnimationManager.StartAnimation(ChipMatrix[x][y].AnimName); SE::ResourceManager->HalibutAnimationManager.StartAnimation(ChipMatrix[x][y].AnimName);
} }
void TMatch3Logic::StopAnimateChip(size_t x, size_t y) void TMatch3Logic::StopAnimateChip(size_t x, size_t y)
{ {
//return;
SE::ResourceManager->HalibutAnimationManager.StopAnimation(ChipMatrix[x][y].AnimName); SE::ResourceManager->HalibutAnimationManager.StopAnimation(ChipMatrix[x][y].AnimName);
} }
@ -413,8 +413,6 @@ void TMatch3Logic::MoveVertexListShiftBackWithoutAnimation(SE::TRenderPairList::
void TMatch3Logic::InnerAddChipToUp(size_t colNum, int chipType, Eigen::Vector2f spawnPos, TChip::TChipState chipState) void TMatch3Logic::InnerAddChipToUp(size_t colNum, int chipType, Eigen::Vector2f spawnPos, TChip::TChipState chipState)
{ {
size_t yPos = ChipMatrix[colNum].size();
Eigen::Vector2f posFrom = spawnPos; Eigen::Vector2f posFrom = spawnPos;
Eigen::Vector2f posTo = posFrom + Eigen::Vector2f(Match3FieldParams.CellWidth, Match3FieldParams.CellHeight); Eigen::Vector2f posTo = posFrom + Eigen::Vector2f(Match3FieldParams.CellWidth, Match3FieldParams.CellHeight);
@ -448,9 +446,9 @@ void TMatch3Logic::InnerAddChipToUp(size_t colNum, int chipType, Eigen::Vector2f
void TMatch3Logic::AddChipToUp(size_t colNum, int chipType, Eigen::Vector2f spawnPos, TChip::TChipState chipState) void TMatch3Logic::AddChipToUp(size_t colNum, int chipType, Eigen::Vector2f spawnPos, TChip::TChipState chipState)
{ {
InnerAddChipToUp(colNum, chipType, spawnPos, chipState); size_t yPos = ChipMatrix[colNum].size();
size_t yPos = ChipMatrix[colNum].size() - 1; //? InnerAddChipToUp(colNum, chipType, spawnPos, chipState);
ReplaceAnimation(Eigen::Vector2i(colNum, yPos)); ReplaceAnimation(Eigen::Vector2i(colNum, yPos));
@ -484,7 +482,7 @@ void TMatch3Logic::InsertEmptyChip(size_t colNum, size_t rowNum, int chipType)
ReplaceAnimation(Eigen::Vector2i(colNum, rowNum)); ReplaceAnimation(Eigen::Vector2i(colNum, rowNum));
triangleList.NeedRefreshBuffer = true; //triangleList.NeedRefreshBuffer = true;
Eigen::Vector2f pos = GetExpectedLeftBottomPos(colNum, rowNum); Eigen::Vector2f pos = GetExpectedLeftBottomPos(colNum, rowNum);
@ -565,8 +563,8 @@ void TMatch3Logic::UpdateChipSwapping(size_t dt)
chip2.RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB][chip2.VertexListShift + k] += shiftChip2; chip2.RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB][chip2.VertexListShift + k] += shiftChip2;
} }
chip1.RenderPair->second.NeedRefreshBuffer = true; //chip1.RenderPair->second.NeedRefreshBuffer = true;
chip2.RenderPair->second.NeedRefreshBuffer = true; //chip2.RenderPair->second.NeedRefreshBuffer = true;
} }
@ -655,7 +653,7 @@ void TMatch3Logic::UpdateChipPosition(size_t dt)
} }
chip.RenderPair->second.NeedRefreshBuffer = true; //chip.RenderPair->second.NeedRefreshBuffer = true;
for (size_t k = j + 1; k < ChipMatrix[i].size(); k++) for (size_t k = j + 1; k < ChipMatrix[i].size(); k++)
{ {
@ -671,7 +669,7 @@ void TMatch3Logic::UpdateChipPosition(size_t dt)
chipAbove.ChipState = TChip::CS_FALLING; chipAbove.ChipState = TChip::CS_FALLING;
chipAbove.SetLeftBottomPos(chip.GetLeftBottomPos() + Eigen::Vector2f(0, Match3FieldParams.CellHeight)); chipAbove.SetLeftBottomPos(chip.GetLeftBottomPos() + Eigen::Vector2f(0, Match3FieldParams.CellHeight));
chipAbove.Velocity = chip.Velocity; chipAbove.Velocity = chip.Velocity;
chipAbove.RenderPair->second.NeedRefreshBuffer = true; //chipAbove.RenderPair->second.NeedRefreshBuffer = true;
} }
} }
} }
@ -715,10 +713,11 @@ void TMatch3Logic::TryMatchAllChips()
void TMatch3Logic::DestroyChip(Eigen::Vector2i p) void TMatch3Logic::DestroyChip(Eigen::Vector2i p)
{ {
ChipMatrix[p[0]][p[1]].RenderPair->second.NeedRefreshBuffer = true; //ChipMatrix[p[0]][p[1]].RenderPair->second.NeedRefreshBuffer = true;
SE::ResourceManager->HalibutAnimationManager.DeleteAnimationObject(ChipMatrix[p[0]][p[1]].AnimName); SE::ResourceManager->HalibutAnimationManager.DeleteAnimationObject(ChipMatrix[p[0]][p[1]].AnimName);
ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].erase( ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].erase(
ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].begin() + ChipMatrix[p[0]][p[1]].VertexListShift, ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].begin() + ChipMatrix[p[0]][p[1]].VertexListShift,
ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].begin() + ChipMatrix[p[0]][p[1]].VertexListShift + 6); ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].begin() + ChipMatrix[p[0]][p[1]].VertexListShift + 6);
@ -761,14 +760,14 @@ void TMatch3Logic::ChangeChipType(Eigen::Vector2i p)
MoveVertexListShiftBack(chip.RenderPair, chip.VertexListShift); MoveVertexListShiftBack(chip.RenderPair, chip.VertexListShift);
chip.RenderPair->second.NeedRefreshBuffer = true; //chip.RenderPair->second.NeedRefreshBuffer = true;
chip.ChipType = newChipType; chip.ChipType = newChipType;
RenderPairIteratorVector[newChipType]->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].insert(RenderPairIteratorVector[newChipType]->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].end(), vertexCoordSubVec.begin(), vertexCoordSubVec.end()); RenderPairIteratorVector[newChipType]->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].insert(RenderPairIteratorVector[newChipType]->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].end(), vertexCoordSubVec.begin(), vertexCoordSubVec.end());
RenderPairIteratorVector[newChipType]->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].insert(RenderPairIteratorVector[newChipType]->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].end(), texCoordSubVec.begin(), texCoordSubVec.end()); RenderPairIteratorVector[newChipType]->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].insert(RenderPairIteratorVector[newChipType]->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].end(), texCoordSubVec.begin(), texCoordSubVec.end());
RenderPairIteratorVector[newChipType]->second.NeedRefreshBuffer = true; //RenderPairIteratorVector[newChipType]->second.NeedRefreshBuffer = true;
chip.RenderPair = RenderPairIteratorVector[newChipType]; chip.RenderPair = RenderPairIteratorVector[newChipType];
chip.VertexListShift = RenderPairIteratorVector[newChipType]->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].size() - 6; chip.VertexListShift = RenderPairIteratorVector[newChipType]->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].size() - 6;
@ -910,7 +909,7 @@ void TMatch3Logic::SwapChips(Eigen::Vector2i p1, Eigen::Vector2i p2, bool isRetu
Eigen::Vector2f chip2PosFrom(LeftBottomPosField[0] + p2[0]*Match3FieldParams.CellWidth, LeftBottomPosField[1] + p2[1]*Match3FieldParams.CellHeight); Eigen::Vector2f chip2PosFrom(LeftBottomPosField[0] + p2[0]*Match3FieldParams.CellWidth, LeftBottomPosField[1] + p2[1]*Match3FieldParams.CellHeight);
ChipSwappingPairVector.push_back(TChipSwappingPair(p1, p2, chip1PosFrom, chip2PosFrom)); ChipSwappingPairVector.push_back(TChipSwappingPair(p1, p2, chip1PosFrom, chip2PosFrom));
(ChipSwappingPairVector.end() - 1)->IsReturning = isReturning; ChipSwappingPairVector.back().IsReturning = isReturning;
ChipMatrix[p1[0]][p1[1]].ChipState = TChip::CS_SWAPPING; ChipMatrix[p1[0]][p1[1]].ChipState = TChip::CS_SWAPPING;
ChipMatrix[p2[0]][p2[1]].ChipState = TChip::CS_SWAPPING; ChipMatrix[p2[0]][p2[1]].ChipState = TChip::CS_SWAPPING;
@ -932,7 +931,7 @@ void TMatch3Logic::ResetChipPos(Eigen::Vector2i p)
chip.RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB][chip.VertexListShift + i] = vertexCoordVec[i]; chip.RenderPair->second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB][chip.VertexListShift + i] = vertexCoordVec[i];
} }
chip.RenderPair->second.NeedRefreshBuffer = true; //chip.RenderPair->second.NeedRefreshBuffer = true;
} }
@ -994,6 +993,7 @@ void TMatch3Logic::UpdateLogic(size_t dt)
} }
} }
RemoveBubbles(); RemoveBubbles();
} }
@ -1168,7 +1168,7 @@ void TMatch3Field::FillBasicChipMatrixAndTriangleList()
for (SE::TRenderPairList::iterator i = TriangleListVector.begin(); i != TriangleListVector.end(); ++i) for (SE::TRenderPairList::iterator i = TriangleListVector.begin(); i != TriangleListVector.end(); ++i)
{ {
i->second.NeedRefreshBuffer = false; //i->second.NeedRefreshBuffer = false;
i->second.RefreshBuffer(); i->second.RefreshBuffer();
} }
@ -1192,14 +1192,11 @@ void TMatch3Field::Update(size_t dt)
TMatch3Logic::UpdateLogic(dt); TMatch3Logic::UpdateLogic(dt);
SE::TRenderPairList::iterator i; SE::TRenderPairList::iterator i;
for (i = TriangleListVector.begin(); i != TriangleListVector.end(); ++i) for (i = TriangleListVector.begin(); i != TriangleListVector.end(); ++i)
{ {
if (i->second.NeedRefreshBuffer) i->second.RefreshBuffer();
{
i->second.RefreshBuffer();
}
} }
int y = 6; int y = 6;

View File

@ -4,6 +4,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 14.0.25123.0 VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Crystal of Rhylil", "Crystal of Rhylil\Crystal of Rhylil.vcxproj", "{0080A3E1-DFBF-4557-B198-E6D5D7724393}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Crystal of Rhylil", "Crystal of Rhylil\Crystal of Rhylil.vcxproj", "{0080A3E1-DFBF-4557-B198-E6D5D7724393}"
ProjectSection(ProjectDependencies) = postProject
{534F100C-E611-43BF-B6F3-AD9F9925F703} = {534F100C-E611-43BF-B6F3-AD9F9925F703}
{03736B28-58F6-4AEA-9D37-B6AC4F5F853B} = {03736B28-58F6-4AEA-9D37-B6AC4F5F853B}
{A05BADE1-D792-4620-9928-13A7AFD0F195} = {A05BADE1-D792-4620-9928-13A7AFD0F195}
EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Engine", "..\..\tes-engine\windows\Engine\Engine.vcxproj", "{534F100C-E611-43BF-B6F3-AD9F9925F703}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Engine", "..\..\tes-engine\windows\Engine\Engine.vcxproj", "{534F100C-E611-43BF-B6F3-AD9F9925F703}"
EndProject EndProject

View File

@ -7,7 +7,7 @@
#include "boost/foreach.hpp" #include "boost/foreach.hpp"
extern boost::shared_ptr<TMyApplication> App; extern std::shared_ptr<TMyApplication> App;
int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst, int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst,
LPSTR lpszCmdLine, int nCmdShow) LPSTR lpszCmdLine, int nCmdShow)