"On tap" does not work properly
This commit is contained in:
parent
d80637e343
commit
cfd1a0a062
@ -20,33 +20,6 @@ boost::shared_ptr<TMyApplication> App(new TMyApplication);
|
|||||||
bool animPaused = false;
|
bool animPaused = false;
|
||||||
|
|
||||||
|
|
||||||
Eigen::Matrix3f quatToMatrix(Eigen::Vector4f q) {
|
|
||||||
using namespace Eigen;
|
|
||||||
Matrix3f result;
|
|
||||||
double sqw = q(3)*q(3);
|
|
||||||
double sqx = q(0)*q(0);
|
|
||||||
double sqy = q(1)*q(1);
|
|
||||||
double sqz = q(2)*q(2);
|
|
||||||
// invs (inverse square length) is only required if quaternion is not already normalised
|
|
||||||
double invs = 1 / (sqx + sqy + sqz + sqw);
|
|
||||||
result(0, 0) = (sqx - sqy - sqz + sqw)*invs; // since sqw + sqx + sqy + sqz =1/invs*invs
|
|
||||||
result(1, 1) = (-sqx + sqy - sqz + sqw)*invs;
|
|
||||||
result(2, 2) = (-sqx - sqy + sqz + sqw)*invs;
|
|
||||||
double tmp1 = q(0)*q(1);
|
|
||||||
double tmp2 = q(2)*q(3);
|
|
||||||
result(1, 0) = 2.0 * (tmp1 + tmp2)*invs;
|
|
||||||
result(0, 1) = 2.0 * (tmp1 - tmp2)*invs;
|
|
||||||
tmp1 = q(0)*q(2);
|
|
||||||
tmp2 = q(1)*q(3);
|
|
||||||
result(2, 0) = 2.0 * (tmp1 - tmp2)*invs;
|
|
||||||
result(0, 2) = 2.0 * (tmp1 + tmp2)*invs;
|
|
||||||
tmp1 = q(1)*q(2);
|
|
||||||
tmp2 = q(0)*q(3);
|
|
||||||
result(2, 1) = 2.0 * (tmp1 + tmp2)*invs;
|
|
||||||
result(1, 2) = 2.0 * (tmp1 - tmp2)*invs;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct TOnClickTest
|
struct TOnClickTest
|
||||||
{
|
{
|
||||||
void operator()()
|
void operator()()
|
||||||
@ -80,8 +53,6 @@ struct TOnClickTest
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//What to do on init
|
//What to do on init
|
||||||
void TMyApplication::InnerInit()
|
void TMyApplication::InnerInit()
|
||||||
{
|
{
|
||||||
@ -133,32 +104,19 @@ void TMyApplication::InnerInit()
|
|||||||
px = SE::FileToPropertyTree("textures.xml");
|
px = SE::FileToPropertyTree("textures.xml");
|
||||||
SE::ResourceManager->TexList.Serialize(*px);
|
SE::ResourceManager->TexList.Serialize(*px);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//test
|
|
||||||
SE::ResourceManager->TexList.AddTexture("levelshot1.png");
|
|
||||||
|
|
||||||
testPair.second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].emplace_back(Eigen::Vector3f(-100, -100, 0));
|
|
||||||
testPair.second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].emplace_back(Eigen::Vector3f(100, 0, 0));
|
|
||||||
testPair.second.Data.Vec3CoordArr[SE::CONST_STRING_POSITION_ATTRIB].emplace_back(Eigen::Vector3f(0, 100, 0));
|
|
||||||
|
|
||||||
testPair.second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].emplace_back(Eigen::Vector2f(0, 0));
|
|
||||||
testPair.second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].emplace_back(Eigen::Vector2f(1, 0));
|
|
||||||
testPair.second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].emplace_back(Eigen::Vector2f(0, 1));
|
|
||||||
|
|
||||||
testPair.first.ShaderName = "DefaultShader";
|
|
||||||
|
|
||||||
testPair.first.SamplerMap[SE::CONST_STRING_TEXTURE_UNIFORM] = "levelshot1.png";
|
|
||||||
testPair.second.RefreshBuffer();
|
|
||||||
//end
|
|
||||||
|
|
||||||
|
|
||||||
//this cause exception
|
//this cause exception
|
||||||
//px = SE::FileToPropertyTree("fonts.xml");
|
//px = SE::FileToPropertyTree("fonts.xml");
|
||||||
//SE::ResourceManager->FontManager.Serialize(*px);
|
//SE::ResourceManager->FontManager.Serialize(*px);
|
||||||
//SE::ResourceManager->FontManager.PushFont("droid_sans14");
|
//SE::ResourceManager->FontManager.PushFont("droid_sans14");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Match3Controller.Match3Field = std::make_shared<TMatch3Field>(Match3Controller);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
ResourceManager->GUIManager.AddWidgetAndFill(boost::shared_ptr<TInstancingWidgetAncestor>(new TSquareButton),
|
ResourceManager->GUIManager.AddWidgetAndFill(boost::shared_ptr<TInstancingWidgetAncestor>(new TSquareButton),
|
||||||
@ -197,6 +155,8 @@ void TMyApplication::InnerInit()
|
|||||||
ResourceManager->FontManager.AddFont("droid_sans14", "droid_sans14_font_bitmap.bmp32", "droid_sans14_font_charmap.txt");
|
ResourceManager->FontManager.AddFont("droid_sans14", "droid_sans14_font_bitmap.bmp32", "droid_sans14_font_charmap.txt");
|
||||||
ResourceManager->FontManager.PushFont("droid_sans14");*/
|
ResourceManager->FontManager.PushFont("droid_sans14");*/
|
||||||
|
|
||||||
|
//glDisable(GL_CULL_FACE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//What to do on deinit
|
//What to do on deinit
|
||||||
@ -208,42 +168,42 @@ void TMyApplication::InnerDeinit()
|
|||||||
//What to do on draw
|
//What to do on draw
|
||||||
void TMyApplication::InnerDraw()
|
void TMyApplication::InnerDraw()
|
||||||
{
|
{
|
||||||
using namespace SE;
|
auto &list = Match3Controller.Match3Field.get()->TriangleListVector;
|
||||||
Renderer->SetPerspectiveProjection(pi / 6, 10.f, 10000.f);
|
|
||||||
Renderer->SetFullScreenViewport();
|
|
||||||
Renderer->PushMatrix();
|
|
||||||
float phi = pi / 6;
|
|
||||||
float alpha = 0;
|
|
||||||
float distance = 2000;
|
|
||||||
Renderer->TranslateMatrix(Vector3f(0, 0, -distance));
|
|
||||||
Vector4f quat1 = Vector4f(sin(phi / 2), 0, 0, cos(phi / 2));
|
|
||||||
Vector4f quat2 = Vector4f(0, sin(alpha / 2), 0, cos(alpha / 2));
|
|
||||||
Renderer->RotateMatrix(quat1);
|
|
||||||
Renderer->RotateMatrix(quat2);
|
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
|
||||||
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
CheckGlError("");
|
|
||||||
auto mat1 = quatToMatrix(quat1);
|
|
||||||
auto mat2 = quatToMatrix(quat2);
|
|
||||||
Vector3f lightPos = { 0.f, 1.f, 1.f };
|
|
||||||
Vector3f eye = mat2 * mat1 * Vector3f(0.0f, 0.f, -distance);
|
|
||||||
{
|
|
||||||
TRenderParamsSetter params(testPair.first);
|
|
||||||
RenderUniform3fv("eye", eye.data());
|
|
||||||
RenderUniform3fv("lightPos", lightPos.data());
|
|
||||||
Matrix3f normMatrix = Renderer->GetModelviewMatrix().inverse().transpose().block<3, 3>(0, 0);
|
|
||||||
RenderUniformMatrix3fv("NormalMatrix", false, normMatrix.data());
|
|
||||||
RenderUniformMatrix4fv("ModelViewMatrix", false, Renderer->GetModelviewMatrix().data());
|
|
||||||
RenderUniformMatrix3fv("ModelViewMatrix3x3", false, Renderer->GetModelviewMatrix().block<3, 3>(0, 0).data());
|
|
||||||
Renderer->DrawTriangleList(testPair.second);
|
|
||||||
}
|
|
||||||
Renderer->PopMatrix();
|
|
||||||
CheckGlError("");
|
|
||||||
|
|
||||||
|
for (auto j = list.begin(); j != list.end(); ++j)
|
||||||
|
{
|
||||||
|
SE::TRenderParamsSetter paramSetter(j->first);
|
||||||
|
SE::Renderer->DrawTriangleList(j->second);
|
||||||
|
SE::CheckGlError("TMyApplication::InnerDraw()");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//What to do on update. timer means how many ms passed since last update
|
//What to do on update. timer means how many ms passed since last update
|
||||||
void TMyApplication::InnerUpdate(size_t timer)
|
void TMyApplication::InnerUpdate(size_t timer)
|
||||||
{
|
{
|
||||||
|
Match3Controller.Match3Field.get()->Update(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TMyApplication::InnerOnTapDown(Eigen::Vector2f p) {
|
||||||
|
if (!Match3Controller.Match3Field.get()->CheckClick(p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Match3Controller.Match3Field.get()->OnTapDown(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TMyApplication::InnerOnTapUp(Eigen::Vector2f p) {
|
||||||
|
if (!Match3Controller.Match3Field.get()->CheckClick(p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Match3Controller.Match3Field.get()->OnTapUp(p);
|
||||||
|
}
|
||||||
|
void TMyApplication::InnerOnTapUpAfterMove(Eigen::Vector2f p) {
|
||||||
|
//Match3Controller.Match3Field.get()->
|
||||||
|
}
|
||||||
|
|
||||||
|
void TMyApplication::InnerOnMove(Eigen::Vector2f pos, Eigen::Vector2f shift) {
|
||||||
|
if (!Match3Controller.Match3Field.get()->CheckClick(pos)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Match3Controller.Match3Field.get()->OnMove(pos);
|
||||||
|
}
|
@ -8,6 +8,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "boost/shared_ptr.hpp"
|
#include "boost/shared_ptr.hpp"
|
||||||
/*#include "boost/thread/thread.hpp"
|
/*#include "boost/thread/thread.hpp"
|
||||||
@ -24,12 +25,11 @@ class TMatch3Field;
|
|||||||
class TMatch3Controller
|
class TMatch3Controller
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TMatch3Field* Match3Field;
|
std::shared_ptr<TMatch3Field> Match3Field;
|
||||||
|
|
||||||
|
|
||||||
TMatch3Controller()
|
TMatch3Controller()
|
||||||
: Match3Field(NULL)
|
{
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -58,6 +58,15 @@ public:
|
|||||||
|
|
||||||
virtual void InnerUpdate(size_t timer);
|
virtual void InnerUpdate(size_t timer);
|
||||||
//What to do on update. timer means how many ms passed since last update
|
//What to do on update. timer means how many ms passed since last update
|
||||||
|
|
||||||
|
|
||||||
|
virtual void InnerOnTapDown(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;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef TARGET_IOS
|
#ifndef TARGET_IOS
|
||||||
|
@ -13,14 +13,16 @@ void TChipTemplateParams::Serialize(boost::property_tree::ptree& propertyTree)
|
|||||||
std::string selectedNormTexName = propertyTree.get<std::string>("SelectedNormTexName");
|
std::string selectedNormTexName = propertyTree.get<std::string>("SelectedNormTexName");
|
||||||
std::string finishingTexName = propertyTree.get<std::string>("FinishingTexName");
|
std::string finishingTexName = propertyTree.get<std::string>("FinishingTexName");
|
||||||
|
|
||||||
//SelectedRenderParams.ShaderName = selectedShaderName;
|
SelectedRenderParams.ShaderName = selectedShaderName;
|
||||||
//SelectedRenderParams.TexName = selectedTexName;
|
SelectedRenderParams.SamplerMap[SE::CONST_STRING_TEXTURE_UNIFORM] = selectedTexName;
|
||||||
//SelectedRenderParams.NormTexName = selectedNormTexName;
|
SelectedRenderParams.SamplerMap[SE::CONST_STRING_NORMALMAP_UNIFORM] = selectedNormTexName;
|
||||||
|
SelectedRenderParams.transparencyFlag = SE::TRenderParams::opaque;
|
||||||
//SelectedRenderParams.Transparency = 1.f;
|
//SelectedRenderParams.Transparency = 1.f;
|
||||||
//
|
|
||||||
//FinishingRenderParams.ShaderName = "";
|
FinishingRenderParams.ShaderName = "";
|
||||||
//FinishingRenderParams.TexName = finishingTexName;
|
FinishingRenderParams.SamplerMap[SE::CONST_STRING_TEXTURE_UNIFORM] = finishingTexName;
|
||||||
//FinishingRenderParams.NormTexName = "";
|
FinishingRenderParams.SamplerMap[SE::CONST_STRING_NORMALMAP_UNIFORM] = "";
|
||||||
|
SelectedRenderParams.transparencyFlag = SE::TRenderParams::opaque;
|
||||||
//FinishingRenderParams.Transparency = 1.f;
|
//FinishingRenderParams.Transparency = 1.f;
|
||||||
|
|
||||||
std::string selectedAnimFileName = propertyTree.get<std::string>("SelectedAnimFileName");
|
std::string selectedAnimFileName = propertyTree.get<std::string>("SelectedAnimFileName");
|
||||||
@ -141,23 +143,29 @@ void TMatch3Logic::FillRandomChipMatrix(std::vector<SE::TRenderPairList::iterato
|
|||||||
if (i == 0 && j == 6)
|
if (i == 0 && j == 6)
|
||||||
{
|
{
|
||||||
//AddChipToUp(i, chipType, GetExpectedLeftBottomPos(i, j), TChip::CS_LOCKED);
|
//AddChipToUp(i, chipType, GetExpectedLeftBottomPos(i, j), TChip::CS_LOCKED);
|
||||||
AddChipToUp(i, chipType, GetExpectedLeftBottomPos(i, j), TChip::CS_STANDBY);
|
InnerAddChipToUp(i, chipType, GetExpectedLeftBottomPos(i, j), TChip::CS_STANDBY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddChipToUp(i, chipType, GetExpectedLeftBottomPos(i, j), TChip::CS_STANDBY);
|
InnerAddChipToUp(i, chipType, GetExpectedLeftBottomPos(i, j), TChip::CS_STANDBY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<Eigen::Vector2i> chipList;
|
||||||
|
|
||||||
std::vector<Eigen::Vector2i> chipList = GetAvailableMatchingChips();
|
do {
|
||||||
|
|
||||||
while (chipList.size() != 0)
|
|
||||||
{
|
|
||||||
UnmatchChips(chipList);
|
|
||||||
chipList = GetAvailableMatchingChips();
|
chipList = GetAvailableMatchingChips();
|
||||||
|
UnmatchChips(chipList);
|
||||||
|
} while (!chipList.empty());
|
||||||
|
|
||||||
|
|
||||||
|
for (size_t i = 0; i < ChipMatrix.size(); i++) {
|
||||||
|
for (size_t j = 0; j < ChipMatrix[i].size(); j++) {
|
||||||
|
ReplaceAnimation(Eigen::Vector2i(i, j));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -384,7 +392,26 @@ void TMatch3Logic::MoveVertexListShiftBack(SE::TRenderPairList::iterator renderP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TMatch3Logic::AddChipToUp(size_t colNum, int chipType, Eigen::Vector2f spawnPos, TChip::TChipState chipState)
|
void TMatch3Logic::MoveVertexListShiftBackWithoutAnimation(SE::TRenderPairList::iterator renderPairItr, size_t moveFrom)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < ChipMatrix.size(); i++)
|
||||||
|
{
|
||||||
|
for (size_t j = 0; j < ChipMatrix[i].size(); j++)
|
||||||
|
{
|
||||||
|
if (ChipMatrix[i][j].RenderPair == renderPairItr)
|
||||||
|
{
|
||||||
|
if (ChipMatrix[i][j].VertexListShift > moveFrom)
|
||||||
|
{
|
||||||
|
ChipMatrix[i][j].VertexListShift -= 6;
|
||||||
|
|
||||||
|
//ReplaceAnimation(Eigen::Vector2i(i, j));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TMatch3Logic::InnerAddChipToUp(size_t colNum, int chipType, Eigen::Vector2f spawnPos, TChip::TChipState chipState)
|
||||||
{
|
{
|
||||||
size_t yPos = ChipMatrix[colNum].size();
|
size_t yPos = ChipMatrix[colNum].size();
|
||||||
|
|
||||||
@ -416,11 +443,19 @@ void TMatch3Logic::AddChipToUp(size_t colNum, int chipType, Eigen::Vector2f spaw
|
|||||||
|
|
||||||
ChipMatrix[colNum].push_back(TChip(chipType, RenderPairIteratorVector[renderPairIndex], vertexListShift, chipState));
|
ChipMatrix[colNum].push_back(TChip(chipType, RenderPairIteratorVector[renderPairIndex], vertexListShift, chipState));
|
||||||
|
|
||||||
ReplaceAnimation(Eigen::Vector2i(colNum, yPos));
|
//triangleList.NeedRefreshBuffer = true;
|
||||||
|
|
||||||
triangleList.NeedRefreshBuffer = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() - 1; //?
|
||||||
|
|
||||||
|
ReplaceAnimation(Eigen::Vector2i(colNum, yPos));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void TMatch3Logic::InsertEmptyChip(size_t colNum, size_t rowNum, int chipType)
|
void TMatch3Logic::InsertEmptyChip(size_t colNum, size_t rowNum, int chipType)
|
||||||
{
|
{
|
||||||
@ -692,7 +727,7 @@ void TMatch3Logic::DestroyChip(Eigen::Vector2i p)
|
|||||||
ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].begin() + ChipMatrix[p[0]][p[1]].VertexListShift,
|
ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].begin() + ChipMatrix[p[0]][p[1]].VertexListShift,
|
||||||
ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].begin() + ChipMatrix[p[0]][p[1]].VertexListShift + 6);
|
ChipMatrix[p[0]][p[1]].RenderPair->second.Data.Vec2CoordArr[SE::CONST_STRING_TEXCOORD_ATTRIB].begin() + ChipMatrix[p[0]][p[1]].VertexListShift + 6);
|
||||||
|
|
||||||
MoveVertexListShiftBack(ChipMatrix[p[0]][p[1]].RenderPair, ChipMatrix[p[0]][p[1]].VertexListShift);
|
MoveVertexListShiftBackWithoutAnimation(ChipMatrix[p[0]][p[1]].RenderPair, ChipMatrix[p[0]][p[1]].VertexListShift);
|
||||||
|
|
||||||
ChipMatrix[p[0]].erase(ChipMatrix[p[0]].begin() + p[1]);
|
ChipMatrix[p[0]].erase(ChipMatrix[p[0]].begin() + p[1]);
|
||||||
/*
|
/*
|
||||||
@ -1088,14 +1123,11 @@ void TMatch3Field::FillBasicChipMatrixAndTriangleList()
|
|||||||
auto px = SE::FileToPropertyTree("match3params.xml");
|
auto px = SE::FileToPropertyTree("match3params.xml");
|
||||||
Match3FieldParams.Serialize(*px);
|
Match3FieldParams.Serialize(*px);
|
||||||
|
|
||||||
std::vector<SE::TRenderPairList::iterator> triangleListVec;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < Match3FieldParams.ChipTypeCount; i++)
|
for (size_t i = 0; i < Match3FieldParams.ChipTypeCount; i++)
|
||||||
{
|
{
|
||||||
TriangleListVector.push_back(SE::TRenderPair(Match3FieldParams.ChipTemplateParamsArr[i].SelectedRenderParams, SE::TTriangleList()));
|
TriangleListVector.push_back(SE::TRenderPair(Match3FieldParams.ChipTemplateParamsArr[i].SelectedRenderParams, SE::TTriangleList()));
|
||||||
}
|
}
|
||||||
auto x = RenderPairIteratorVector.front()->first;
|
|
||||||
auto y = RenderPairIteratorVector.front()->second;
|
|
||||||
|
|
||||||
renderParams.SamplerMap[SE::CONST_STRING_TEXTURE_UNIFORM] = "chip1locked";
|
renderParams.SamplerMap[SE::CONST_STRING_TEXTURE_UNIFORM] = "chip1locked";
|
||||||
TriangleListVector.push_back(SE::TRenderPair(renderParams, SE::TTriangleList()));
|
TriangleListVector.push_back(SE::TRenderPair(renderParams, SE::TTriangleList()));
|
||||||
@ -1117,6 +1149,9 @@ void TMatch3Field::FillBasicChipMatrixAndTriangleList()
|
|||||||
TriangleListVector.push_back(SE::TRenderPair(Match3FieldParams.ChipTemplateParamsArr[i].FinishingRenderParams, SE::TTriangleList()));
|
TriangleListVector.push_back(SE::TRenderPair(Match3FieldParams.ChipTemplateParamsArr[i].FinishingRenderParams, SE::TTriangleList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<SE::TRenderPairList::iterator> triangleListVec;
|
||||||
|
|
||||||
for (SE::TRenderPairList::iterator i = TriangleListVector.begin(); i != TriangleListVector.end(); ++i)
|
for (SE::TRenderPairList::iterator i = TriangleListVector.begin(); i != TriangleListVector.end(); ++i)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1124,16 +1159,16 @@ void TMatch3Field::FillBasicChipMatrixAndTriangleList()
|
|||||||
triangleListVec.push_back(i);
|
triangleListVec.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
LeftBottomPosField = Eigen::Vector2f(150, 0);
|
LeftBottomPos = Eigen::Vector2f(150, 0);
|
||||||
|
|
||||||
FillRandomChipMatrix(triangleListVec, LeftBottomPosField);
|
FillRandomChipMatrix(triangleListVec, LeftBottomPos);
|
||||||
|
|
||||||
//Init everything
|
//Init everything
|
||||||
selectedChip = Eigen::Vector2i(-1, -1);
|
selectedChip = Eigen::Vector2i(-1, -1);
|
||||||
|
|
||||||
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.RefreshBuffer();
|
i->second.RefreshBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1144,7 +1179,7 @@ Eigen::Vector2i TMatch3Field::PosToChip(Eigen::Vector2f pos)
|
|||||||
{
|
{
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
Eigen::Vector2f fieldPos = pos - LeftBottomPosField;
|
Eigen::Vector2f fieldPos = pos - LeftBottomPos;
|
||||||
x = static_cast<int>(fieldPos[0] / Match3FieldParams.CellWidth);
|
x = static_cast<int>(fieldPos[0] / Match3FieldParams.CellWidth);
|
||||||
y = static_cast<int>(fieldPos[1] / Match3FieldParams.CellHeight);
|
y = static_cast<int>(fieldPos[1] / Match3FieldParams.CellHeight);
|
||||||
|
|
||||||
@ -1311,7 +1346,7 @@ void TMatch3Field::OnMove(Eigen::Vector2f shift)
|
|||||||
bool TMatch3Field::CheckClick(Eigen::Vector2f mousePos)
|
bool TMatch3Field::CheckClick(Eigen::Vector2f mousePos)
|
||||||
{
|
{
|
||||||
|
|
||||||
Eigen::Vector2f fieldPos = mousePos - LeftBottomPosField;
|
Eigen::Vector2f fieldPos = mousePos - LeftBottomPos;
|
||||||
if (fieldPos[0] >= 0 && fieldPos[0] <= Match3FieldParams.FieldWidth*Match3FieldParams.CellWidth)
|
if (fieldPos[0] >= 0 && fieldPos[0] <= Match3FieldParams.FieldWidth*Match3FieldParams.CellWidth)
|
||||||
{
|
{
|
||||||
if (fieldPos[1] >= 0 && fieldPos[1] <= Match3FieldParams.FieldHeight*Match3FieldParams.CellHeight)
|
if (fieldPos[1] >= 0 && fieldPos[1] <= Match3FieldParams.FieldHeight*Match3FieldParams.CellHeight)
|
||||||
|
@ -199,9 +199,12 @@ protected:
|
|||||||
void ReplaceAnimation(Eigen::Vector2i p);
|
void ReplaceAnimation(Eigen::Vector2i p);
|
||||||
|
|
||||||
void MoveVertexListShiftBack(SE::TRenderPairList::iterator renderPairItr, size_t moveFrom);
|
void MoveVertexListShiftBack(SE::TRenderPairList::iterator renderPairItr, size_t moveFrom);
|
||||||
|
void MoveVertexListShiftBackWithoutAnimation(SE::TRenderPairList::iterator renderPairItr, size_t moveFrom);
|
||||||
void MoveVertexCoordDown(SE::TRenderPairList::iterator renderPairItr, size_t moveFrom, float value);
|
void MoveVertexCoordDown(SE::TRenderPairList::iterator renderPairItr, size_t moveFrom, float value);
|
||||||
|
|
||||||
void AddChipToUp(size_t colNum, int chipType, Eigen::Vector2f spawnPos, TChip::TChipState chipState = TChip::CS_FALLING);
|
void AddChipToUp(size_t colNum, int chipType, Eigen::Vector2f spawnPos, TChip::TChipState chipState = TChip::CS_FALLING);
|
||||||
|
void InnerAddChipToUp(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 InsertEmptyChip(size_t colNum, size_t rowNum, int chipType);
|
||||||
|
|
||||||
void UpdateChipSwapping(size_t dt);
|
void UpdateChipSwapping(size_t dt);
|
||||||
@ -237,7 +240,7 @@ public:
|
|||||||
|
|
||||||
class TMatch3Controller;
|
class TMatch3Controller;
|
||||||
|
|
||||||
class TMatch3Field : public TMatch3Logic
|
class TMatch3Field : protected TMatch3Logic
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
void FillBasicChipMatrixAndTriangleList();
|
void FillBasicChipMatrixAndTriangleList();
|
||||||
@ -249,9 +252,13 @@ protected:
|
|||||||
|
|
||||||
Eigen::Vector2i PosToChip(Eigen::Vector2f pos);
|
Eigen::Vector2i PosToChip(Eigen::Vector2f pos);
|
||||||
|
|
||||||
SE::TRenderPairList TriangleListVector;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//should be in protected
|
||||||
|
Eigen::Vector2f LeftBottomPos;
|
||||||
|
SE::TRenderPairList TriangleListVector;
|
||||||
|
|
||||||
|
|
||||||
TMatch3Field();
|
TMatch3Field();
|
||||||
TMatch3Field(const TMatch3Field& m);
|
TMatch3Field(const TMatch3Field& m);
|
||||||
TMatch3Field& operator=(const TMatch3Field& m);
|
TMatch3Field& operator=(const TMatch3Field& m);
|
||||||
|
@ -12,9 +12,14 @@ extern boost::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)
|
||||||
{
|
{
|
||||||
int height = 480;
|
|
||||||
|
//480x320
|
||||||
|
int height = 600;
|
||||||
int width = 800;
|
int width = 800;
|
||||||
|
|
||||||
|
//int height = 480;
|
||||||
|
//int width = 800;
|
||||||
|
|
||||||
if (SE::CreateEngine(width, height)) {
|
if (SE::CreateEngine(width, height)) {
|
||||||
|
|
||||||
App->OuterInit(width, height, width, height);
|
App->OuterInit(width, height, width, height);
|
||||||
|
Loading…
Reference in New Issue
Block a user