Start OnTouch

This commit is contained in:
Modnark
2022-10-10 20:01:30 -04:00
parent 7e9f34e1ac
commit adade066cc
3 changed files with 120 additions and 27 deletions

View File

@@ -24,13 +24,24 @@ public:
Enum::SurfaceType::Value back; Enum::SurfaceType::Value back;
Enum::SurfaceType::Value left; Enum::SurfaceType::Value left;
Enum::SurfaceType::Value bottom; Enum::SurfaceType::Value bottom;
//Shapes
Enum::Shape::Value shape; Enum::Shape::Value shape;
//OnTocuh
Enum::ActionType::Value OnTouchAction;
Enum::Sound::Value OnTouchSound;
//Variables //Variables
Color3 color; Color3 color;
bool canCollide; bool canCollide;
dBodyID physBody; dBodyID physBody;
dGeomID physGeom[3]; dGeomID physGeom[3];
bool singleShot;
int touchesToTrigger;
int uniqueObjectsToTrigger;
int changeScore;
int changeTimer;
//Getters //Getters
Vector3 getPosition(); Vector3 getPosition();

View File

@@ -32,4 +32,10 @@ namespace Enum
NoChange = 0, Increase = 1, Decrease = 2 NoChange = 0, Increase = 1, Decrease = 2
}; };
} }
namespace Sound
{
enum Value {
NoSound = 0, Victory = 1, Boing = 2
};
}
} }

View File

@@ -27,6 +27,13 @@ PartInstance::PartInstance(void)
left = Enum::SurfaceType::Smooth; left = Enum::SurfaceType::Smooth;
bottom = Enum::SurfaceType::Smooth; bottom = Enum::SurfaceType::Smooth;
shape = Enum::Shape::Block; shape = Enum::Shape::Block;
// OnTouch
singleShot = true;
touchesToTrigger = 1;
uniqueObjectsToTrigger = 1;
changeScore = 0;
changeTimer = 0;
} }
bool PartInstance::isDragging() bool PartInstance::isDragging()
@@ -164,8 +171,6 @@ PartInstance::PartInstance(const PartInstance &oinst)
PVInstance::PVInstance(oinst); PVInstance::PVInstance(oinst);
physBody = NULL; physBody = NULL;
glList = glGenLists(1); glList = glGenLists(1);
//name = oinst.name;
//className = "Part";
name = oinst.name; name = oinst.name;
canCollide = oinst.canCollide; canCollide = oinst.canCollide;
setParent(oinst.parent); setParent(oinst.parent);
@@ -183,6 +188,15 @@ PartInstance::PartInstance(const PartInstance &oinst)
bottom = oinst.bottom; bottom = oinst.bottom;
shape = oinst.shape; shape = oinst.shape;
changed = true; changed = true;
// OnTouch
singleShot = oinst.singleShot;
touchesToTrigger = oinst.touchesToTrigger;
uniqueObjectsToTrigger = oinst.uniqueObjectsToTrigger;
changeScore = oinst.changeScore;
changeTimer = oinst.changeTimer;
OnTouchAction = oinst.OnTouchAction;
OnTouchSound = oinst.OnTouchSound;
} }
void PartInstance::setSize(Vector3 newSize) void PartInstance::setSize(Vector3 newSize)
@@ -363,6 +377,7 @@ char pto[512];
char pto2[512]; char pto2[512];
#include <sstream> #include <sstream>
// Shape
static Enum::Shape::Value strEnum(TCHAR* shape) static Enum::Shape::Value strEnum(TCHAR* shape)
{ {
if(strcmp("Block", shape) == 0) if(strcmp("Block", shape) == 0)
@@ -386,6 +401,64 @@ static TCHAR* enumStr(int shape)
return "Block"; return "Block";
} }
// ActionType
static TCHAR* strActionType(int option)
{
switch(option)
{
case Enum::ActionType::Nothing:
return "Nothing";
case Enum::ActionType::Pause:
return "Pause";
case Enum::ActionType::Lose:
return "Lose";
case Enum::ActionType::Draw:
return "Draw";
case Enum::ActionType::Win:
return "Win";
}
return "Nothing";
}
static Enum::ActionType::Value EnumOnTouchActionType(TCHAR* option)
{
if(strcmp("Nothing", option) == 0)
return Enum::ActionType::Nothing;
if(strcmp("Pause", option) == 0)
return Enum::ActionType::Pause;
if(strcmp("Lose", option) == 0)
return Enum::ActionType::Lose;
if(strcmp("Draw", option) == 0)
return Enum::ActionType::Draw;
return Enum::ActionType::Win;
}
// SoundType
static TCHAR* strSoundType(int option)
{
switch(option)
{
case Enum::Sound::NoSound:
return "NoSound";
case Enum::Sound::Victory:
return "Victory";
case Enum::Sound::Boing:
return "Boing";
}
return "NoSound";
}
static Enum::Sound::Value EnumOnTouchSoundType(TCHAR* option)
{
if(strcmp("Nothing", option) == 0)
return Enum::Sound::NoSound;
if(strcmp("Victory", option) == 0)
return Enum::Sound::Victory;
if(strcmp("Boing", option) == 0)
return Enum::Sound::Boing;
return Enum::Sound::NoSound;
}
void PartInstance::PropUpdate(LPPROPGRIDITEM &item) void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
{ {
setChanged(); setChanged();
@@ -412,13 +485,6 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
ss.ignore(); ss.ignore();
} }
//if(vect.size() != 3)
//{
//sprintf(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z, "what");
//LPCSTR str = LPCSTR(pto);
//item->lpCurValue = (LPARAM)str;
//}
//else
if(vect.size() == 3) if(vect.size() == 3)
{ {
Vector3 pos(vect.at(0),vect.at(1),vect.at(2)); Vector3 pos(vect.at(0),vect.at(1),vect.at(2));
@@ -441,13 +507,6 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
ss.ignore(); ss.ignore();
} }
/*if(vect.size() != 3)
{
sprintf(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z, "what");
LPCSTR str = LPCSTR(pto);
item->lpCurValue = (LPARAM)str;
}
else*/
if(vect.size() == 3) if(vect.size() == 3)
{ {
Vector3 size(vect.at(0),vect.at(1),vect.at(2)); Vector3 size(vect.at(0),vect.at(1),vect.at(2));
@@ -459,6 +518,14 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
printf("%s", enumStr(strEnum((TCHAR*)item->lpCurValue))); printf("%s", enumStr(strEnum((TCHAR*)item->lpCurValue)));
setShape(strEnum((TCHAR*)item->lpCurValue)); setShape(strEnum((TCHAR*)item->lpCurValue));
} }
else if(strcmp(item->lpszPropName, "Action") == 0)
{
OnTouchAction = EnumOnTouchActionType((TCHAR*)item->lpCurValue);
}
else if (strcmp(item->lpszPropName, "Sound") == 0)
{
OnTouchSound = EnumOnTouchSoundType((TCHAR*)item->lpCurValue);
}
else PVInstance::PropUpdate(item); else PVInstance::PropUpdate(item);
} }
@@ -467,44 +534,53 @@ std::vector<PROPGRIDITEM> PartInstance::getProperties()
std::vector<PROPGRIDITEM> properties = PVInstance::getProperties(); std::vector<PROPGRIDITEM> properties = PVInstance::getProperties();
properties.push_back(createPGI( properties.push_back(createPGI("Properties",
"Properties",
"Color3", "Color3",
"The color of the selected part", "The color of the selected part",
RGB((color.r*255),(color.g*255),(color.b*255)), RGB((color.r*255),(color.g*255),(color.b*255)),
PIT_COLOR PIT_COLOR
)); ));
properties.push_back(createPGI( properties.push_back(createPGI("Item",
"Item",
"Anchored", "Anchored",
"Whether the block can move or not", "Whether the block can move or not",
(LPARAM)anchored, (LPARAM)anchored,
PIT_CHECK PIT_CHECK
)); ));
sprintf_s(pto, "%g, %g, %g", position.x, position.y, position.z); sprintf_s(pto, "%g, %g, %g", position.x, position.y, position.z);
properties.push_back(createPGI( properties.push_back(createPGI("Item",
"Item",
"Offset", "Offset",
"The position of the object in the workspace", "The position of the object in the workspace",
(LPARAM)pto, (LPARAM)pto,
PIT_EDIT PIT_EDIT
)); ));
sprintf_s(pto2, "%g, %g, %g", size.x, size.y, size.z); sprintf_s(pto2, "%g, %g, %g", size.x, size.y, size.z);
properties.push_back(createPGI( properties.push_back(createPGI("Item",
"Item",
"Size", "Size",
"The position of the object in the workspace", "The size of the object in the workspace",
(LPARAM)pto2, (LPARAM)pto2,
PIT_EDIT PIT_EDIT
)); ));
properties.push_back(createPGI( properties.push_back(createPGI("Item",
"Item",
"Shape", "Shape",
"The shape of the object in the workspace", "The shape of the object in the workspace",
(LPARAM)enumStr(shape), (LPARAM)enumStr(shape),
PIT_COMBO, PIT_COMBO,
TEXT("Ball\0Block\0Cylinder\0") TEXT("Ball\0Block\0Cylinder\0")
)); ));
properties.push_back(createPGI("OnTouch",
"Action",
"What action is taken when touched",
(LPARAM)strActionType(OnTouchAction),
PIT_COMBO,
TEXT("Nothing\0Pause\0Lose\0Draw\0Win\0")
));
properties.push_back(createPGI("OnTouch",
"Sound",
"What sound plays when touched",
(LPARAM)strSoundType(OnTouchSound),
PIT_COMBO,
TEXT("NoSound\0Victory\0Boing\0")
));
return properties; return properties;
} }