Merge branch 'master' into MusicalProgrammer
This commit is contained in:
@@ -32,7 +32,6 @@ void AudioPlayer::init()
|
||||
/* Open the audio device and start playing sound! */
|
||||
if ( SDL_OpenAudio(&fmt, NULL) < 0 ) {
|
||||
fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
SDL_PauseAudio(0);
|
||||
}
|
||||
@@ -58,7 +57,7 @@ void mixaudio(void *unused, Uint8 *stream, int len)
|
||||
}
|
||||
}
|
||||
|
||||
void AudioPlayer::PlaySound(std::string fileString)
|
||||
void AudioPlayer::playSound(std::string fileString)
|
||||
{
|
||||
|
||||
if(initiated)
|
||||
|
||||
@@ -6,6 +6,6 @@ class AudioPlayer
|
||||
public:
|
||||
AudioPlayer(void);
|
||||
~AudioPlayer(void);
|
||||
static void PlaySound(std::string);
|
||||
static void playSound(std::string);
|
||||
static void init();
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "BaseButtonInstance.h"
|
||||
#include "Globals.h"
|
||||
|
||||
bool floatBottom = false;
|
||||
bool floatRight = false;
|
||||
@@ -12,6 +13,14 @@ BaseButtonInstance::BaseButtonInstance(void)
|
||||
listener = NULL;
|
||||
}
|
||||
|
||||
void BaseButtonInstance::render(RenderDevice* rd)
|
||||
{
|
||||
DataModelInstance* dataModel = Globals::dataModel;
|
||||
Vector2 pos = Vector2(dataModel->mousex,dataModel->mousey);
|
||||
drawObj(rd, pos, dataModel->mouseButton1Down);
|
||||
Instance::render(rd);
|
||||
}
|
||||
|
||||
BaseButtonInstance::~BaseButtonInstance(void)
|
||||
{
|
||||
delete listener;
|
||||
|
||||
@@ -8,6 +8,7 @@ class BaseButtonInstance : public Instance
|
||||
public:
|
||||
BaseButtonInstance(void);
|
||||
virtual ~BaseButtonInstance(void);
|
||||
virtual void render(RenderDevice* rd);
|
||||
virtual void drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown);
|
||||
virtual bool mouseInButton(float, float, RenderDevice* rd);
|
||||
virtual void onMouseClick();
|
||||
|
||||
34
DataModelInstance.cpp
Normal file
34
DataModelInstance.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "DataModelInstance.h"
|
||||
|
||||
|
||||
WorkspaceInstance* workspace;
|
||||
Instance* guiRoot;
|
||||
float mousex;
|
||||
float mousey;
|
||||
bool mouseButton1Down;
|
||||
|
||||
|
||||
DataModelInstance::DataModelInstance(void)
|
||||
{
|
||||
workspace = new WorkspaceInstance();
|
||||
guiRoot = new Instance();
|
||||
children.push_back(workspace);
|
||||
className = "dataModel";
|
||||
mousex = 0;
|
||||
mousey = 0;
|
||||
mouseButton1Down = false;
|
||||
}
|
||||
|
||||
DataModelInstance::~DataModelInstance(void)
|
||||
{
|
||||
}
|
||||
|
||||
WorkspaceInstance* DataModelInstance::getWorkspace()
|
||||
{
|
||||
return workspace;
|
||||
}
|
||||
|
||||
Instance* DataModelInstance::getGuiRoot()
|
||||
{
|
||||
return guiRoot;
|
||||
}
|
||||
16
DataModelInstance.h
Normal file
16
DataModelInstance.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "instance.h"
|
||||
#include "WorkspaceInstance.h"
|
||||
|
||||
class DataModelInstance :
|
||||
public Instance
|
||||
{
|
||||
public:
|
||||
DataModelInstance(void);
|
||||
~DataModelInstance(void);
|
||||
WorkspaceInstance* getWorkspace();
|
||||
Instance* getGuiRoot();
|
||||
float mousex;
|
||||
float mousey;
|
||||
bool mouseButton1Down;
|
||||
};
|
||||
11
Globals.cpp
Normal file
11
Globals.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "Globals.h"
|
||||
|
||||
DataModelInstance* Globals::dataModel = NULL;
|
||||
int const Globals::gen = 0;
|
||||
int const Globals::major = 0;
|
||||
int const Globals::minor = 4;
|
||||
int const Globals::patch = 2;
|
||||
|
||||
Globals::Globals(void){}
|
||||
|
||||
Globals::~Globals(void){}
|
||||
14
Globals.h
Normal file
14
Globals.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "DataModelInstance.h"
|
||||
|
||||
class Globals
|
||||
{
|
||||
public:
|
||||
Globals(void);
|
||||
~Globals(void);
|
||||
static DataModelInstance* dataModel;
|
||||
static const int gen;
|
||||
static const int major;
|
||||
static const int minor;
|
||||
static const int patch;
|
||||
};
|
||||
91
Instance.cpp
91
Instance.cpp
@@ -3,20 +3,103 @@
|
||||
#include "Instance.h"
|
||||
|
||||
std::string name;
|
||||
Instance* parent;
|
||||
static std::string className = "DataModel";
|
||||
Instance* parent = NULL;
|
||||
std::vector<Instance* > children;
|
||||
static std::string className = "BaseInstance";
|
||||
|
||||
Instance::Instance(void)
|
||||
{
|
||||
parent = NULL;
|
||||
name = "Default Game Instance";
|
||||
className = "DataModel";
|
||||
className = "BaseInstance";
|
||||
}
|
||||
|
||||
void Instance::render(RenderDevice* rd)
|
||||
{
|
||||
for(size_t i = 0; i < children.size(); i++)
|
||||
{
|
||||
children.at(i)->render(rd);
|
||||
}
|
||||
}
|
||||
|
||||
Instance::~Instance(void)
|
||||
{
|
||||
name = "Default Game Instance";
|
||||
for(size_t i = 0; i < children.size(); i++)
|
||||
{
|
||||
delete children.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
std::string Instance::getClassName()
|
||||
{
|
||||
return className;
|
||||
}
|
||||
|
||||
std::vector<Instance* > Instance::getChildren()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
std::vector<Instance* > Instance::getAllChildren()
|
||||
{
|
||||
if(!children.empty())
|
||||
{
|
||||
std::vector<Instance* > totalchildren = children;
|
||||
for(size_t i = 0; i < children.size(); i++)
|
||||
{
|
||||
std::vector<Instance* > subchildren = children.at(i)->getAllChildren();
|
||||
if(!subchildren.empty())
|
||||
totalchildren.insert(totalchildren.end(), subchildren.begin(), subchildren.end());
|
||||
}
|
||||
return totalchildren;
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
void Instance::setParent(Instance* newParent)
|
||||
{
|
||||
if(parent != NULL)
|
||||
{
|
||||
parent->removeChild(this);
|
||||
}
|
||||
parent = newParent;
|
||||
if(newParent != NULL)
|
||||
{
|
||||
newParent->addChild(this);
|
||||
}
|
||||
}
|
||||
|
||||
Instance* Instance::getParent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
void Instance::addChild(Instance* newChild)
|
||||
{
|
||||
children.push_back(newChild);
|
||||
}
|
||||
|
||||
void Instance::removeChild(Instance* oldChild)
|
||||
{
|
||||
for(size_t i = 0; i < children.size(); i++)
|
||||
{
|
||||
if(children.at(i) == oldChild)
|
||||
{
|
||||
children.erase(children.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Instance* Instance::findFirstChild(std::string name)
|
||||
{
|
||||
Instance* child = NULL;
|
||||
for(size_t i = 0; i < children.size(); i++)
|
||||
{
|
||||
if(children.at(i)->name == name)
|
||||
{
|
||||
child = children.at(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
13
Instance.h
13
Instance.h
@@ -7,6 +7,17 @@ public:
|
||||
Instance(void);
|
||||
virtual ~Instance(void);
|
||||
std::string name;
|
||||
Instance* parent; // Another pointer.
|
||||
virtual void render(RenderDevice*);
|
||||
std::vector<Instance*> children; // All children.
|
||||
std::string getClassName();
|
||||
Instance* findFirstChild(std::string);
|
||||
std::vector<Instance* > getChildren();
|
||||
std::vector<Instance* > getAllChildren();
|
||||
void setParent(Instance*);
|
||||
void addChild(Instance*);
|
||||
void removeChild(Instance*);
|
||||
Instance* getParent();
|
||||
protected:
|
||||
std::string className;
|
||||
Instance* parent; // Another pointer.
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@ Color3 color;
|
||||
bool changed = true;
|
||||
Box itemBox = Box();
|
||||
|
||||
|
||||
PhysicalInstance::PhysicalInstance(void)
|
||||
{
|
||||
name = "Default PhysicalInstance";
|
||||
@@ -23,7 +24,38 @@ PhysicalInstance::PhysicalInstance(void)
|
||||
velocity = Vector3(0,0,0);
|
||||
rotVelocity = Vector3(0,0,0);
|
||||
}
|
||||
void PhysicalInstance::setSize(Vector3 newSize)
|
||||
{
|
||||
int minsize = 1;
|
||||
int maxsize = 512;
|
||||
changed = true;
|
||||
int sizex = (int)newSize.x;
|
||||
if(sizex <= 0)
|
||||
sizex = 1;
|
||||
if(sizex > 512)
|
||||
sizex = 512;
|
||||
|
||||
int sizey = (int)newSize.y;
|
||||
if(sizey <= 0)
|
||||
sizey = 1;
|
||||
if(sizey > 512)
|
||||
sizey = 512;
|
||||
|
||||
int sizez = (int)newSize.z;
|
||||
if(sizez <= 0)
|
||||
sizez = 1;
|
||||
if(sizez > 512)
|
||||
sizez = 512;
|
||||
|
||||
size = Vector3(sizex, sizey, sizez);
|
||||
|
||||
|
||||
|
||||
}
|
||||
Vector3 PhysicalInstance::getSize()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
Vector3 PhysicalInstance::getPosition()
|
||||
{
|
||||
return position;
|
||||
@@ -61,6 +93,19 @@ Box PhysicalInstance::getBox()
|
||||
return itemBox;
|
||||
}
|
||||
|
||||
void PhysicalInstance::render(RenderDevice* rd)
|
||||
{
|
||||
Draw::box(getBox(), rd, color, Color4::clear());
|
||||
if(!children.empty())
|
||||
{
|
||||
for(size_t i = 0; i < children.size(); i++)
|
||||
{
|
||||
children.at(i)->render(rd);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PhysicalInstance::~PhysicalInstance(void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class PhysicalInstance :
|
||||
public:
|
||||
PhysicalInstance(void);
|
||||
~PhysicalInstance(void);
|
||||
Vector3 size;
|
||||
virtual void render(RenderDevice*);
|
||||
Vector3 velocity;
|
||||
Vector3 rotvelocity;
|
||||
CoordinateFrame cFrame;
|
||||
@@ -18,6 +18,9 @@ public:
|
||||
void setCFrame(CoordinateFrame);
|
||||
Box getBox();
|
||||
CoordinateFrame getCFrameRenderBased();
|
||||
Vector3 getSize();
|
||||
void setSize(Vector3);
|
||||
private:
|
||||
Vector3 position;
|
||||
Vector3 size;
|
||||
};
|
||||
|
||||
14
WorkspaceInstance.cpp
Normal file
14
WorkspaceInstance.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "WorkspaceInstance.h"
|
||||
float timer = 60.0F;
|
||||
int score = 0;
|
||||
|
||||
WorkspaceInstance::WorkspaceInstance(void)
|
||||
{
|
||||
className = "Workspace";
|
||||
timer = 60.0F;
|
||||
score = 0;
|
||||
}
|
||||
|
||||
WorkspaceInstance::~WorkspaceInstance(void)
|
||||
{
|
||||
}
|
||||
12
WorkspaceInstance.h
Normal file
12
WorkspaceInstance.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "instance.h"
|
||||
|
||||
class WorkspaceInstance :
|
||||
public Instance
|
||||
{
|
||||
public:
|
||||
float timer;
|
||||
int score;
|
||||
WorkspaceInstance(void);
|
||||
~WorkspaceInstance(void);
|
||||
};
|
||||
Reference in New Issue
Block a user