Compare commits
37 Commits
cb3
...
DataModelR
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b580ef5ad | ||
|
|
5232d5e97f | ||
|
|
011d817321 | ||
|
|
60c7a386f0 | ||
|
|
3ee06b6c62 | ||
|
|
57b407c894 | ||
|
|
9999eb62e4 | ||
|
|
930aee06dc | ||
|
|
e6ca1cd502 | ||
|
|
c875454b40 | ||
|
|
388962a5e7 | ||
|
|
9986f2ee5f | ||
|
|
529821ab9f | ||
|
|
d72d09f95d | ||
|
|
d810c213f6 | ||
|
|
ce66ec6f5d | ||
|
|
faaa59f58b | ||
|
|
8dff73d5f5 | ||
|
|
4bdb1d6939 | ||
|
|
f0f16a3a69 | ||
|
|
09c6a73e80 | ||
|
|
3108021007 | ||
|
|
fa3a0f9aa4 | ||
|
|
f45e8afb37 | ||
|
|
739f116895 | ||
|
|
f281103ca1 | ||
|
|
b7d14dcf2a | ||
|
|
5659a1e13c | ||
|
|
fb48c4d85d | ||
|
|
ce3ca419e8 | ||
|
|
c3b9e1f6c8 | ||
|
|
9ba0db1ab9 | ||
|
|
70d9aded42 | ||
|
|
a99f58b62f | ||
|
|
fcb1ad05fd | ||
|
|
50f8c7ec10 | ||
|
|
4094631f30 |
@@ -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();
|
||||
};
|
||||
|
||||
27
DataModelInstance.cpp
Normal file
27
DataModelInstance.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "DataModelInstance.h"
|
||||
|
||||
|
||||
WorkspaceInstance* workspace;
|
||||
Instance* guiRoot;
|
||||
|
||||
DataModelInstance::DataModelInstance(void)
|
||||
{
|
||||
workspace = new WorkspaceInstance();
|
||||
guiRoot = new Instance();
|
||||
children.push_back(workspace);
|
||||
className = "dataModel";
|
||||
}
|
||||
|
||||
DataModelInstance::~DataModelInstance(void)
|
||||
{
|
||||
}
|
||||
|
||||
WorkspaceInstance* DataModelInstance::getWorkspace()
|
||||
{
|
||||
return workspace;
|
||||
}
|
||||
|
||||
Instance* DataModelInstance::getGuiRoot()
|
||||
{
|
||||
return guiRoot;
|
||||
}
|
||||
13
DataModelInstance.h
Normal file
13
DataModelInstance.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "instance.h"
|
||||
#include "WorkspaceInstance.h"
|
||||
|
||||
class DataModelInstance :
|
||||
public Instance
|
||||
{
|
||||
public:
|
||||
DataModelInstance(void);
|
||||
~DataModelInstance(void);
|
||||
WorkspaceInstance* getWorkspace();
|
||||
Instance* getGuiRoot();
|
||||
};
|
||||
100
G3DTest.vcproj
100
G3DTest.vcproj
@@ -234,10 +234,6 @@
|
||||
RelativePath=".\AudioPlayer.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\BaseButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ButtonListener.cpp"
|
||||
>
|
||||
@@ -246,14 +242,6 @@
|
||||
RelativePath=".\Dialogs.rc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ImageButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Instance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="main.cpp"
|
||||
>
|
||||
@@ -274,14 +262,38 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\PhysicalInstance.cpp"
|
||||
<Filter
|
||||
Name="Instances"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TextButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\BaseButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DataModelInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ImageButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Instance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\PhysicalInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TextButtonInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\WorkspaceInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
@@ -291,34 +303,46 @@
|
||||
RelativePath=".\AudioPlayer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\BaseButtonInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ButtonListener.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ImageButtonInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Instance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\PhysicalInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TextButtonInstance.h"
|
||||
<Filter
|
||||
Name="Instances"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\BaseButtonInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DataModelInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ImageButtonInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Instance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\PhysicalInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TextButtonInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\WorkspaceInstance.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
|
||||
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.
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "PhysicalInstance.h"
|
||||
|
||||
bool canCollide = true;
|
||||
bool anchored = false;
|
||||
Vector3 size;
|
||||
@@ -8,6 +7,9 @@ Vector3 velocity;
|
||||
Vector3 rotVelocity;
|
||||
CoordinateFrame cFrame;
|
||||
Color3 color;
|
||||
bool changed = true;
|
||||
Box itemBox = Box();
|
||||
|
||||
|
||||
PhysicalInstance::PhysicalInstance(void)
|
||||
{
|
||||
@@ -22,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;
|
||||
@@ -31,6 +64,7 @@ void PhysicalInstance::setPosition(Vector3 pos)
|
||||
{
|
||||
position = pos;
|
||||
cFrame = CoordinateFrame(pos);
|
||||
changed = true;
|
||||
}
|
||||
CoordinateFrame PhysicalInstance::getCFrame()
|
||||
{
|
||||
@@ -40,8 +74,37 @@ void PhysicalInstance::setCFrame(CoordinateFrame coordinateFrame)
|
||||
{
|
||||
cFrame = coordinateFrame;
|
||||
position = coordinateFrame.translation;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
CoordinateFrame PhysicalInstance::getCFrameRenderBased()
|
||||
{
|
||||
return CoordinateFrame(getCFrame().rotation,Vector3(getCFrame().translation.x/2, getCFrame().translation.y/2, getCFrame().translation.z/2));
|
||||
}
|
||||
|
||||
Box PhysicalInstance::getBox()
|
||||
{
|
||||
if(changed)
|
||||
{
|
||||
Box box = Box(Vector3(0+size.x/4, 0+size.y/4, 0+size.z/4) ,Vector3(0-size.x/4,0-size.y/4,0-size.z/4));
|
||||
CoordinateFrame c = getCFrameRenderBased();
|
||||
itemBox = c.toWorldSpace(box);
|
||||
}
|
||||
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;
|
||||
@@ -16,6 +16,11 @@ public:
|
||||
void setPosition(Vector3);
|
||||
CoordinateFrame getCFrame();
|
||||
void setCFrame(CoordinateFrame);
|
||||
Box getBox();
|
||||
CoordinateFrame getCFrameRenderBased();
|
||||
Vector3 getSize();
|
||||
void setSize(Vector3);
|
||||
private:
|
||||
Vector3 position;
|
||||
Vector3 size;
|
||||
};
|
||||
|
||||
14
README.md
Normal file
14
README.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# G3D-Fun
|
||||
|
||||
Despite its name, this is actually a recreation of ROBLOX as it was in 2005. Early development. Uses roughly time-accurate development tools.
|
||||
|
||||
# COMPILE WITH
|
||||
|
||||
Graphics3D 6.10 (Released July 21, 2006)
|
||||
SDL 1.2.7 (1.2.9 could work as well)
|
||||
Visual Studio 2005 Professional or Visual Studio 2005 Express with Platform SDK
|
||||
|
||||
# NOTE
|
||||
|
||||
Please know that there currently is no documentation and minimal commenting. As such, it may be confusing to follow the code.
|
||||
Code for this project is written quickly at random intervals, where each individual thinks of a solution to a problem and adds it.
|
||||
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);
|
||||
};
|
||||
75
building.md
Normal file
75
building.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# Building Setup
|
||||
|
||||
##### G3D is super delicate, meaning that you have to go about building in a special way
|
||||
|
||||
#### Skip to steps 7-13 if you have already built this program
|
||||
|
||||
1. Install Visual Studio 2005. Google where to find it. Make note of which version you downloaded.
|
||||
|
||||
2. Download and install G3D from [this link here](https://sourceforge.net/projects/g3d/files/g3d-cpp/6.10/g3d-6_10_win32.exe/download).
|
||||
|
||||
3. Make sure G3D is included under your build directories by going under Tools -> Options -> Projects and Solutions -> VC++ Directories and check and see if:
|
||||
|
||||
* `g3d-6_10\bin` is under executable files
|
||||
|
||||
* `g3d-6_10\include` is under include files
|
||||
|
||||
* `g3d-6_10\bin` is under executable files
|
||||
|
||||
* `g3d-6_10\win32-vc8-lib` is under library files
|
||||
|
||||
* Ex: `C:\libraries\g3d-6_10\bin`
|
||||
|
||||
4. Download SDL version 1.2.7 from [this link](http://www.libsdl.org/release/SDL-devel-1.2.7-VC6.zip)
|
||||
|
||||
5. Extract the file to a folder on your computer. Keep note of this folder.
|
||||
|
||||
6. Include the extracted files by going to Tools -> Options -> Projects and Solutions -> VC++ Directories and adding the following links:
|
||||
|
||||
* Include files - extractpath\`include`
|
||||
|
||||
* Library files - extractpath\`lib`
|
||||
|
||||
* Ex: `C:\libraries\SDL-1.2.7\bin`
|
||||
|
||||
#### Steps 7-11 are optional if you are using Visual Studio Professional. Check the Error stuff section if it doesn't work, most reference steps from here.
|
||||
|
||||
7. Download and install the [platform SDK](https://www.microsoft.com/en-us/download/details.aspx?id=6510).
|
||||
|
||||
8. Put the platform SDK into your directories (Tools -> Options -> Projects and Solutions -> VC++ Directories) by replacing all mentions of $(VCInstallDir)PlatformSDK with the actual path.
|
||||
Ex: `$(VCInstallDir)PlatformSDK\include` -> `C:\Program Files\Microsoft Platform SDK\Include`
|
||||
|
||||
9. Right click Source files -> Dialogs.rc -> View Code
|
||||
|
||||
10. Edit line 10 to say
|
||||
```cpp
|
||||
#include "WinResrc.h"
|
||||
#define IDC_STATIC -1
|
||||
```
|
||||
|
||||
instead of
|
||||
|
||||
```cpp
|
||||
#include "afxres.h"
|
||||
```
|
||||
|
||||
11. Right click the project -> Properties -> Configuration Properties -> Linker -> Input, and add `AdvAPI32.lib` under Additional Dependencies.
|
||||
|
||||
### Continue back here if you're skipping steps 7-11
|
||||
|
||||
12. Right click the project -> Properties -> Configuration Properties -> Linker -> General, and make sure Additional Library Directories is blank.
|
||||
|
||||
13. Try building using Build -> Build G3DTest.
|
||||
|
||||
|
||||
## Error stuff
|
||||
|
||||
```c:\libraries\g3d-6_10\include\G3D/platform.h(235) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory``` > Download and install platform SDK (lines 7-8)
|
||||
|
||||
```G3D-debug.lib(RegistryUtil.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function "public: static bool __cdecl G3D::RegistryUtil::keyExists(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?keyExists@RegistryUtil@G3D@@SA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)``` > Add AdvAPI32.lib under Additional Dependencies (step 11)
|
||||
|
||||
```.\Dialogs.rc(10) : fatal error RC1015: cannot open include file 'afxres.h'.``` > Perform steps 9-10
|
||||
|
||||
Enjoy!
|
||||
|
||||
please report unfriendliness of this page
|
||||
BIN
content/sounds/electronicpingshort.wav
Normal file
BIN
content/sounds/electronicpingshort.wav
Normal file
Binary file not shown.
BIN
content/sounds/switch.wav
Normal file
BIN
content/sounds/switch.wav
Normal file
Binary file not shown.
Reference in New Issue
Block a user