Initial commit
@@ -0,0 +1,7 @@
|
||||
irrKlang-64bit-1.6.0/
|
||||
irrlicht-1.8.4/
|
||||
.vs/
|
||||
irrKlang.dll
|
||||
Irrlicht.dll
|
||||
assets/sounds/*.wav
|
||||
*.exe
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.852
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Privateer", "Privateer\Privateer.vcxproj", "{F93360D2-3EB8-4F4D-B225-1162B440D4D1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F93360D2-3EB8-4F4D-B225-1162B440D4D1}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F93360D2-3EB8-4F4D-B225-1162B440D4D1}.Debug|x64.Build.0 = Debug|x64
|
||||
{F93360D2-3EB8-4F4D-B225-1162B440D4D1}.Release|x64.ActiveCfg = Release|x64
|
||||
{F93360D2-3EB8-4F4D-B225-1162B440D4D1}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {0A47AA10-53E1-46A2-83DA-B1F719439FCC}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,139 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{F93360D2-3EB8-4F4D-B225-1162B440D4D1}</ProjectGuid>
|
||||
<RootNamespace>Privateer</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>$(SolutionDir)irrKlang-64bit-1.6.0\include;$(SolutionDir)irrlicht-1.8.4\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)irrlicht-1.8.4\lib\Win64-visualStudio;$(SolutionDir)irrKlang-64bit-1.6.0\lib\Winx64-visualStudio;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>$(SolutionDir)irrKlang-64bit-1.6.0\include;$(SolutionDir)irrlicht-1.8.4\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)irrlicht-1.8.4\lib\Win64-visualStudio;$(SolutionDir)irrKlang-64bit-1.6.0\lib\Winx64-visualStudio;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Resource.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="p2.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Resource.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="p2.ico">
|
||||
<Filter>Resource Files</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LocalDebuggerWorkingDirectory>$(SolutionDir)</LocalDebuggerWorkingDirectory>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,578 @@
|
||||
#include <irrlicht.h>
|
||||
#include <irrKlang.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
using namespace irr;
|
||||
using namespace irrklang;
|
||||
using namespace core;
|
||||
using namespace scene;
|
||||
using namespace video;
|
||||
using namespace io;
|
||||
using namespace gui;
|
||||
|
||||
#ifdef _IRR_WINDOWS_
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
#pragma comment(lib, "irrKlang.lib")
|
||||
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
|
||||
#endif
|
||||
|
||||
|
||||
//--- set camera to behave as cockpit camera of ship ---
|
||||
void makeCockpit(irr::scene::ICameraSceneNode *camera, //camera
|
||||
irr::scene::ISceneNode *node, //scene node (ship)
|
||||
irr::core::vector3df offset) //relative position of camera to node (ship)
|
||||
{
|
||||
//get rotation matrix of node - Zeuss must be getRotation not getRelativeTransformation
|
||||
irr::core::matrix4 m;
|
||||
m.setRotationDegrees(node->getRotation());
|
||||
|
||||
// transform forward vector of camera
|
||||
irr::core::vector3df frv = irr::core::vector3df(0.0f, 0.0f, 1.0f);
|
||||
m.transformVect(frv);
|
||||
|
||||
// transform upvector of camera
|
||||
irr::core::vector3df upv = irr::core::vector3df(0.0f, 1.0f, 0.0f);
|
||||
m.transformVect(upv);
|
||||
|
||||
// transform camera offset (thanks to Zeuss for finding it was missing)
|
||||
m.transformVect(offset);
|
||||
|
||||
// set camera
|
||||
camera->setPosition(node->getPosition() + offset); //position camera in front of the ship
|
||||
camera->setUpVector(upv); //set up vector of camera >> Zeuss - tested with +node->getPostion() and it didnt work, but this works fine.
|
||||
camera->setTarget(node->getPosition() + frv); //set target of camera (look at point) >> Zeuss - Dont forget to add the node positiob
|
||||
}
|
||||
|
||||
void rotate(irr::scene::ISceneNode *node, irr::core::vector3df rot)
|
||||
{
|
||||
irr::core::matrix4 m;
|
||||
m.setRotationDegrees(node->getRotation());
|
||||
irr::core::matrix4 n;
|
||||
n.setRotationDegrees(rot);
|
||||
m *= n;
|
||||
node->setRotation(m.getRotationDegrees());
|
||||
node->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
//--- turn ship left or right ---
|
||||
void turn(irr::scene::ISceneNode *node, irr::f32 rot)
|
||||
{
|
||||
rotate(node, irr::core::vector3df(0.0f, rot, 0.0f));
|
||||
}
|
||||
|
||||
//--- pitch ship up or down ---
|
||||
void pitch(irr::scene::ISceneNode *node, irr::f32 rot)
|
||||
{
|
||||
rotate(node, irr::core::vector3df(rot, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
//--- roll ship left or right ---
|
||||
void roll(irr::scene::ISceneNode *node, irr::f32 rot)
|
||||
{
|
||||
rotate(node, irr::core::vector3df(0.0f, 0.0f, rot));
|
||||
}
|
||||
|
||||
void move(irr::scene::ISceneNode *node, irr::core::vector3df vel)
|
||||
{
|
||||
irr::core::matrix4 m;
|
||||
m.setRotationDegrees(node->getRotation());
|
||||
m.transformVect(vel);
|
||||
node->setPosition(node->getPosition() + vel);
|
||||
node->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
class MyEventReceiver : public IEventReceiver
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
// We'll create a struct to record info on the mouse state
|
||||
struct SMouseState
|
||||
{
|
||||
core::position2di Position;
|
||||
bool LeftButtonDown;
|
||||
SMouseState() : LeftButtonDown(false) { }
|
||||
} MouseState;
|
||||
|
||||
|
||||
// This is the one method that we have to implement
|
||||
virtual bool OnEvent(const SEvent& event)
|
||||
{
|
||||
// Remember whether each key is down or up
|
||||
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
|
||||
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
|
||||
|
||||
|
||||
|
||||
|
||||
if (event.EventType == irr::EET_MOUSE_INPUT_EVENT)
|
||||
{
|
||||
switch (event.MouseInput.Event)
|
||||
{
|
||||
case EMIE_LMOUSE_PRESSED_DOWN:
|
||||
MouseState.LeftButtonDown = true;
|
||||
break;
|
||||
|
||||
case EMIE_LMOUSE_LEFT_UP:
|
||||
MouseState.LeftButtonDown = false;
|
||||
break;
|
||||
|
||||
case EMIE_MOUSE_MOVED:
|
||||
MouseState.Position.X = event.MouseInput.X;
|
||||
MouseState.Position.Y = event.MouseInput.Y;
|
||||
break;
|
||||
|
||||
default:
|
||||
// We won't use the wheel
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
const SMouseState & GetMouseState(void) const
|
||||
{
|
||||
return MouseState;
|
||||
}
|
||||
// This is used to check whether a key is being held down
|
||||
virtual bool IsKeyDown(EKEY_CODE keyCode) const
|
||||
{
|
||||
return KeyIsDown[keyCode];
|
||||
}
|
||||
|
||||
MyEventReceiver()
|
||||
{
|
||||
for (u32 i = 0; i < KEY_KEY_CODES_COUNT; ++i)
|
||||
KeyIsDown[i] = false;
|
||||
}
|
||||
|
||||
private:
|
||||
// We use this array to store the current state of each key
|
||||
bool KeyIsDown[KEY_KEY_CODES_COUNT];
|
||||
};
|
||||
|
||||
// This is the movement speed in units per second.
|
||||
f32 MOVEMENT_SPEED = 0.f;
|
||||
f32 MOVEMENT_SPEED_TARGET = 0.f;
|
||||
|
||||
f32 MOVEMENT_SPEED_INCREMENT = 80.f;
|
||||
|
||||
f32 MOVEMENT_SPEED_DECEL = 60.f;
|
||||
|
||||
f32 MOVEMENT_SPEED_MAX_STANDARD = 288.f;
|
||||
f32 MOVEMENT_SPEED_MAX_AFTERBURN = 576.f;
|
||||
|
||||
f32 MOVEMENT_SPEED_ACCEL = 50.f;
|
||||
f32 MOVEMENT_SPEED_ACCEL_STANDARD = 50.f;
|
||||
f32 MOVEMENT_SPEED_ACCEL_AFTERBRUN = 100.f;
|
||||
|
||||
f32 MOVEMENT_TURN = 0.f;
|
||||
f32 MOVEMENT_TURN_MAX = 100.0f;
|
||||
|
||||
f32 MOVEMENT_PITCH = 0.f;
|
||||
f32 MOVEMENT_PITCH_MAX = 100.0f;
|
||||
|
||||
u16 DISPLAY_WIDTH = 800;
|
||||
u16 DISPLAY_HEIGHT = 600;
|
||||
u16 MOUSE_DEAD = 10;
|
||||
u16 MOUSE_MAX = 100;
|
||||
u16 MOUSE_BOUNCE = 1;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create device
|
||||
MyEventReceiver receiver;
|
||||
|
||||
|
||||
IrrlichtDevice *device =
|
||||
createDevice( video::EDT_OPENGL, dimension2d<u32>(DISPLAY_WIDTH, DISPLAY_HEIGHT), 32,
|
||||
false, false, false, &receiver);
|
||||
|
||||
/*IrrlichtDevice *device =
|
||||
createDevice(video::EDT_DIRECT3D9, dimension2d<u32>(1920, 1080), 32,
|
||||
true, false, false, &receiver);*/
|
||||
|
||||
if (!device)
|
||||
{
|
||||
printf("Could not start graphics engine\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ISoundEngine* snddevice = createIrrKlangDevice(ESOD_AUTO_DETECT);
|
||||
|
||||
if (!snddevice)
|
||||
{
|
||||
printf("Could not start sound engine\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
device->setWindowCaption(L"Privateer");
|
||||
|
||||
IVideoDriver* driver = device->getVideoDriver();
|
||||
ISceneManager* smgr = device->getSceneManager();
|
||||
IGUIEnvironment* guienv = device->getGUIEnvironment();
|
||||
|
||||
snddevice->setSoundVolume(0.3f);
|
||||
snddevice->play2D("assets/sounds/startup1.ogg", false);
|
||||
|
||||
ISound* shipengine = snddevice->play2D("assets/sounds/engine1.ogg", true,true);
|
||||
ISound* shipengineafterburn = snddevice->play2D("assets/sounds/engine2.ogg", true,true);
|
||||
|
||||
//set other font
|
||||
guienv->getSkin()->setFont(guienv->getFont("assets/arial10.bmp"));
|
||||
guienv->getSkin()->setColor(gui::EGDC_BUTTON_TEXT,
|
||||
video::SColor(255, 217, 206, 56));
|
||||
IGUIStaticText* textTargetSpeed = guienv->addStaticText(L"XXX", rect<s32>(0, 0, 150, 20), false);
|
||||
IGUIStaticText* textSpeed = guienv->addStaticText(L"XXX", rect<s32>(0, 20, 150, 40), false);
|
||||
|
||||
/* Sky Dome */
|
||||
/**********************************************************************************************/
|
||||
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
|
||||
scene::ISceneNode* skydome = smgr->addSkyDomeSceneNode(driver->getTexture("assets/space/default.jpg"), 16, 8, 0.95f, 2.0f);
|
||||
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
|
||||
/**********************************************************************************************/
|
||||
|
||||
/* Test Planet */
|
||||
/**********************************************************************************************/
|
||||
IAnimatedMesh* planet = smgr->getMesh("assets/models/planets/planet.obj");
|
||||
if (!planet)
|
||||
{
|
||||
device->drop();
|
||||
return 1;
|
||||
}
|
||||
IAnimatedMeshSceneNode* planetnode = smgr->addAnimatedMeshSceneNode(planet,skydome);
|
||||
if (planetnode)
|
||||
{
|
||||
core::vector3df scale;
|
||||
scale.X = 5000;
|
||||
scale.Y = 5000;
|
||||
scale.Z = 5000;
|
||||
planetnode->setScale(scale);
|
||||
planetnode->setPosition(core::vector3df(0, 0, 50000));
|
||||
planetnode->setMaterialFlag(EMF_LIGHTING, false);
|
||||
planetnode->setMaterialTexture(0, driver->getTexture("assets/models/planets/pbex.png"));
|
||||
}
|
||||
/**********************************************************************************************/
|
||||
|
||||
/* Test Asteroid */
|
||||
/**********************************************************************************************/
|
||||
IAnimatedMesh* asteroid = smgr->getMesh("assets/models/junk/asteroid.obj");
|
||||
if (!asteroid)
|
||||
{
|
||||
device->drop();
|
||||
return 1;
|
||||
}
|
||||
IAnimatedMeshSceneNode* asteroidnode = smgr->addAnimatedMeshSceneNode(asteroid,skydome);
|
||||
if (asteroidnode)
|
||||
{
|
||||
core::vector3df scale;
|
||||
scale.X = 2;
|
||||
scale.Y = 2;
|
||||
scale.Z = 2;
|
||||
asteroidnode->setScale(scale);
|
||||
asteroidnode->setPosition(core::vector3df(200, 0, 500));
|
||||
asteroidnode->setMaterialFlag(EMF_LIGHTING, false);
|
||||
asteroidnode->setMaterialTexture(0, driver->getTexture("assets/models/junk/asteroid.png"));
|
||||
}
|
||||
/**********************************************************************************************/
|
||||
// smgr->saveScene("recent.irr", 0, skydome);
|
||||
|
||||
|
||||
|
||||
// smgr->loadScene("assets/scenes/recent.irr");
|
||||
|
||||
video::ITexture* sightimages = driver->getTexture("assets/sight_all.png");
|
||||
|
||||
// Space dust model TODO: Planet mesh is way overkill!
|
||||
IAnimatedMesh* dust = smgr->getMesh("assets/models/junk/dust.obj");
|
||||
if (!dust)
|
||||
{
|
||||
device->drop();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create 500 dust nodes
|
||||
std::vector<IAnimatedMeshSceneNode*> dustnodes;
|
||||
for (u16 i = 0; i < 500; ++i)
|
||||
{
|
||||
dustnodes.push_back(smgr->addAnimatedMeshSceneNode(dust));
|
||||
}
|
||||
|
||||
// Scatter dust in a radius around the player
|
||||
for (size_t i = 0; i < dustnodes.size(); ++i)
|
||||
{
|
||||
core::vector3df scale;
|
||||
scale.X = 0.2f;
|
||||
scale.Y = 0.2f;
|
||||
scale.Z = 0.2f;
|
||||
dustnodes[i]->setScale(scale);
|
||||
dustnodes[i]->setPosition(core::vector3df((float)(rand() % 500)-250, (float)(rand() % 500) - 250, (float)(rand() % 500) - 150));
|
||||
dustnodes[i]->setMaterialFlag(EMF_LIGHTING, false);
|
||||
dustnodes[i]->setMaterialTexture(0, driver->getTexture("assets/models/junk/asteroid.png"));
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Player ship*/
|
||||
/**********************************************************************************************/
|
||||
IAnimatedMesh* mesh = smgr->getMesh("assets/models/warhawk.obj");
|
||||
if (!mesh)
|
||||
{
|
||||
device->drop();
|
||||
return 1;
|
||||
}
|
||||
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
|
||||
if (node)
|
||||
{
|
||||
core::vector3df scale;
|
||||
scale.X = 2;
|
||||
scale.Y = 2;
|
||||
scale.Z = 2;
|
||||
node->setScale(scale);
|
||||
node->setMaterialFlag(EMF_LIGHTING, false);
|
||||
node->setMaterialTexture( 0, driver->getTexture("assets/models/warhawk.png") );
|
||||
}
|
||||
/**********************************************************************************************/
|
||||
#endif
|
||||
/* Player shield*/
|
||||
/**********************************************************************************************/
|
||||
IAnimatedMesh* shieldmesh = smgr->getMesh("assets/models/shield.obj");
|
||||
if (!shieldmesh)
|
||||
{
|
||||
device->drop();
|
||||
return 1;
|
||||
}
|
||||
IAnimatedMeshSceneNode* shieldnode = smgr->addAnimatedMeshSceneNode(shieldmesh);
|
||||
if (shieldnode)
|
||||
{
|
||||
core::vector3df scale;
|
||||
scale.X = 4;
|
||||
scale.Y = 4;
|
||||
scale.Z = 4;
|
||||
shieldnode->setScale(scale);
|
||||
shieldnode->setMaterialFlag(EMF_LIGHTING, false);
|
||||
shieldnode->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
|
||||
shieldnode->setMaterialTexture(0, driver->getTexture("assets/models/shield.png"));
|
||||
|
||||
|
||||
}
|
||||
/**********************************************************************************************/
|
||||
|
||||
|
||||
scene::ICameraSceneNode* camera = smgr->addCameraSceneNode(0, vector3df(0,0,0), vector3df(0,0,1));
|
||||
camera->setFarValue(50000.0f);
|
||||
scene::ISceneNode* test = smgr->addSceneNode("empty");
|
||||
test->setPosition(vector3df(0, 0, 0));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Store last FPS so we can show it if enabled*/
|
||||
u16 lastFPS = -1;
|
||||
|
||||
device->getCursorControl()->setPosition(DISPLAY_WIDTH/2, DISPLAY_HEIGHT/2);
|
||||
device->getCursorControl()->setVisible(false);
|
||||
|
||||
// In order to do framerate independent movement, we have to know
|
||||
// how long it was since the last frame
|
||||
u32 then = device->getTimer()->getTime();
|
||||
|
||||
while (device->run())
|
||||
{
|
||||
|
||||
|
||||
for (size_t i = 0; i < dustnodes.size(); ++i)
|
||||
{
|
||||
core::vector3df dustpos = dustnodes[i]->getPosition();
|
||||
if (dustpos.getDistanceFrom(test->getPosition()) > (1.42 * 250))
|
||||
{
|
||||
core::vector3df newrandom = core::vector3df((float)(rand() % 500) - 250, (float)(rand() % 500) - 250, (float)(rand() % 500) - 250);
|
||||
dustnodes[i]->setPosition(test->getPosition());
|
||||
move(dustnodes[i], newrandom);
|
||||
}
|
||||
}
|
||||
|
||||
// Work out a frame delta time.
|
||||
const u32 now = device->getTimer()->getTime();
|
||||
const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // Time in seconds
|
||||
then = now;
|
||||
|
||||
core::vector3df target = (camera->getTarget() - camera->getAbsolutePosition());
|
||||
core::vector3df relativeRotation = target.getHorizontalAngle();
|
||||
|
||||
if (receiver.IsKeyDown(irr::KEY_PLUS))
|
||||
{
|
||||
MOVEMENT_SPEED_TARGET += MOVEMENT_SPEED_INCREMENT * frameDeltaTime;
|
||||
MOVEMENT_SPEED_TARGET = (MOVEMENT_SPEED_TARGET > MOVEMENT_SPEED_MAX_STANDARD) ? MOVEMENT_SPEED_MAX_STANDARD : MOVEMENT_SPEED_TARGET;
|
||||
|
||||
}
|
||||
else if (receiver.IsKeyDown(irr::KEY_MINUS))
|
||||
{
|
||||
MOVEMENT_SPEED_TARGET -= MOVEMENT_SPEED_INCREMENT * frameDeltaTime;
|
||||
MOVEMENT_SPEED_TARGET = (MOVEMENT_SPEED_TARGET < 0) ? 0 : MOVEMENT_SPEED_TARGET;
|
||||
}
|
||||
else if (receiver.IsKeyDown(irr::KEY_OEM_4))
|
||||
{
|
||||
MOVEMENT_SPEED_TARGET = 0;
|
||||
}
|
||||
else if (receiver.IsKeyDown(irr::KEY_OEM_6))
|
||||
{
|
||||
MOVEMENT_SPEED_TARGET = MOVEMENT_SPEED_MAX_STANDARD;
|
||||
}
|
||||
else if (receiver.IsKeyDown(irr::KEY_TAB))
|
||||
{
|
||||
MOVEMENT_SPEED_ACCEL = MOVEMENT_SPEED_ACCEL_AFTERBRUN;
|
||||
MOVEMENT_SPEED_TARGET = MOVEMENT_SPEED_MAX_AFTERBURN;
|
||||
shipengine->setIsPaused(true);
|
||||
shipengineafterburn->setIsPaused(false);
|
||||
}
|
||||
else {
|
||||
MOVEMENT_SPEED_ACCEL = MOVEMENT_SPEED_ACCEL_STANDARD;
|
||||
MOVEMENT_SPEED_TARGET = (MOVEMENT_SPEED_TARGET > MOVEMENT_SPEED_MAX_STANDARD) ? MOVEMENT_SPEED_MAX_STANDARD : MOVEMENT_SPEED_TARGET;
|
||||
shipengine->setIsPaused(false);
|
||||
shipengineafterburn->setIsPaused(true);
|
||||
}
|
||||
|
||||
if (device->getCursorControl()->getPosition().X > ((DISPLAY_WIDTH/2)+MOUSE_DEAD))
|
||||
{
|
||||
MOVEMENT_TURN = ((device->getCursorControl()->getPosition().X - ((DISPLAY_WIDTH / 2) + MOUSE_DEAD))*1.1f);
|
||||
if((receiver.GetMouseState().Position.X > ((DISPLAY_WIDTH/2) + MOUSE_MAX)))
|
||||
device->getCursorControl()->setPosition((DISPLAY_WIDTH/2)+MOUSE_MAX-MOUSE_BOUNCE, device->getCursorControl()->getPosition().Y);
|
||||
|
||||
}
|
||||
else if (device->getCursorControl()->getPosition().X < (DISPLAY_WIDTH/2)-MOUSE_DEAD)
|
||||
{
|
||||
MOVEMENT_TURN = 0 -(((DISPLAY_WIDTH/2)-MOUSE_DEAD) - device->getCursorControl()->getPosition().X)*1.1f;
|
||||
if ((receiver.GetMouseState().Position.X < (DISPLAY_WIDTH/2)-MOUSE_MAX))
|
||||
device->getCursorControl()->setPosition((DISPLAY_WIDTH / 2)-MOUSE_MAX+MOUSE_BOUNCE, device->getCursorControl()->getPosition().Y);
|
||||
}
|
||||
else {
|
||||
MOVEMENT_TURN = 0;
|
||||
}
|
||||
|
||||
if (device->getCursorControl()->getPosition().Y < ((DISPLAY_HEIGHT/2)/*-MOUSE_DEAD*/))
|
||||
{
|
||||
MOVEMENT_PITCH = (((DISPLAY_HEIGHT/2)/*-MOUSE_DEAD*/) - device->getCursorControl()->getPosition().Y);
|
||||
if ((receiver.GetMouseState().Position.Y < (DISPLAY_HEIGHT / 2)-MOUSE_MAX))
|
||||
device->getCursorControl()->setPosition(device->getCursorControl()->getPosition().X, (DISPLAY_HEIGHT/2)-MOUSE_MAX+MOUSE_BOUNCE);
|
||||
}
|
||||
else if (device->getCursorControl()->getPosition().Y > (DISPLAY_HEIGHT/2)/*+MOUSE_DEAD*/)
|
||||
{
|
||||
MOVEMENT_PITCH = 0-((device->getCursorControl()->getPosition().Y - (DISPLAY_HEIGHT / 2) /*+ MOUSE_DEAD*/));
|
||||
if ((receiver.GetMouseState().Position.Y > (DISPLAY_HEIGHT/2)+MOUSE_MAX))
|
||||
device->getCursorControl()->setPosition(device->getCursorControl()->getPosition().X, (DISPLAY_HEIGHT/2)+MOUSE_MAX-MOUSE_BOUNCE);
|
||||
}
|
||||
else {
|
||||
MOVEMENT_PITCH = 0;
|
||||
}
|
||||
if (MOVEMENT_SPEED > 0)
|
||||
{
|
||||
pitch(test, ((MOVEMENT_PITCH / MOUSE_MAX * MOVEMENT_PITCH_MAX)) * frameDeltaTime);
|
||||
turn(test, ((MOVEMENT_TURN / MOUSE_MAX * MOVEMENT_TURN_MAX)) * frameDeltaTime);
|
||||
}
|
||||
else {
|
||||
device->getCursorControl()->setPosition((DISPLAY_WIDTH/2), (DISPLAY_HEIGHT/2));
|
||||
|
||||
}
|
||||
|
||||
/* Tend towards desired speed */
|
||||
if (MOVEMENT_SPEED > MOVEMENT_SPEED_TARGET)
|
||||
MOVEMENT_SPEED -= MOVEMENT_SPEED_DECEL * frameDeltaTime;
|
||||
if (MOVEMENT_SPEED < MOVEMENT_SPEED_TARGET)
|
||||
MOVEMENT_SPEED += MOVEMENT_SPEED_ACCEL * frameDeltaTime;
|
||||
move(test, vector3df(0, 0,MOVEMENT_SPEED * frameDeltaTime));
|
||||
|
||||
stringw strspeed = L"Current velocity: ";
|
||||
strspeed += (int)round(MOVEMENT_SPEED);
|
||||
strspeed += L" m/s";
|
||||
textSpeed->setText(strspeed.c_str());
|
||||
|
||||
stringw strtargetspeed = L"Target velocity: ";
|
||||
strtargetspeed += (int)round(MOVEMENT_SPEED_TARGET);
|
||||
strtargetspeed += L" m/s";
|
||||
textTargetSpeed->setText(strtargetspeed.c_str());
|
||||
|
||||
/*stringw strpitch = L"Pitch: ";
|
||||
strpitch += (int)round((MOVEMENT_PITCH / MOUSE_MAX * MOVEMENT_PITCH_MAX));
|
||||
strpitch += L" deg/s";
|
||||
textPitch->setText(strpitch.c_str());
|
||||
makeCockpit(camera, test, vector3df(0, 0, 0));
|
||||
|
||||
stringw strturn = L"Turn: ";
|
||||
strturn += (int)round(0 - (MOVEMENT_TURN / MOUSE_MAX * MOVEMENT_TURN_MAX));
|
||||
strturn += L" deg/s";
|
||||
textTurn->setText(strturn.c_str());*/
|
||||
|
||||
|
||||
makeCockpit(camera, test, vector3df(0, 0, 0));
|
||||
|
||||
/* Render */
|
||||
/**********************************************************************************************/
|
||||
driver->beginScene(true, true, SColor(100, 100, 100, 100));
|
||||
|
||||
|
||||
|
||||
|
||||
smgr->drawAll();
|
||||
guienv->drawAll();
|
||||
driver->draw2DImage(sightimages, core::position2d<s32>((DISPLAY_WIDTH/2) - 41, (DISPLAY_HEIGHT / 2) - 41), core::rect<s32>(1, 1, 88, 74), 0, SColor(255, 255, 255, 255), true);
|
||||
|
||||
// H
|
||||
driver->draw2DImage(sightimages, core::position2d<s32>((DISPLAY_WIDTH / 2) - (54/2), (DISPLAY_HEIGHT / 2) - 50), core::rect<s32>(126, 1, 179, 7), 0, SColor(255, 255, 255, 255), true);
|
||||
driver->draw2DImage(sightimages, core::position2d<s32>((DISPLAY_WIDTH / 2) + ((MOVEMENT_TURN / MOUSE_MAX) * 26) - 2, (DISPLAY_HEIGHT / 2) - 40), core::rect<s32>(120, 1, 123, 6), 0, SColor(255, 255, 255, 255), true);
|
||||
|
||||
// V
|
||||
driver->draw2DImage(sightimages, core::position2d<s32>((DISPLAY_WIDTH / 2) - 50, (DISPLAY_HEIGHT / 2) - (52/2)), core::rect<s32>(126, 10, 132, 63), 0, SColor(255, 255, 255, 255), true);
|
||||
driver->draw2DImage(sightimages, core::position2d<s32>((DISPLAY_WIDTH / 2) - 41, (DISPLAY_HEIGHT / 2) + ((MOVEMENT_PITCH / MOUSE_MAX) * 26)), core::rect<s32>(112, 1, 117, 4), 0, SColor(255, 255, 255, 255), true);
|
||||
|
||||
// Throttle
|
||||
|
||||
driver->endScene();
|
||||
/**********************************************************************************************/
|
||||
|
||||
/* FPS Counter - TODO: Add cvar*/
|
||||
/**********************************************************************************************/
|
||||
u16 fps = driver->getFPS();
|
||||
if (lastFPS != fps)
|
||||
{
|
||||
core::stringw tmp(L"Privateer [");
|
||||
tmp += L"] fps: ";
|
||||
tmp += fps;
|
||||
|
||||
device->setWindowCaption(tmp.c_str());
|
||||
lastFPS = fps;
|
||||
}
|
||||
/**********************************************************************************************/
|
||||
|
||||
|
||||
|
||||
shieldnode->setPosition(camera->getAbsolutePosition());
|
||||
|
||||
/*asteroidnode->setDebugDataVisible(scene::EDS_BBOX | scene::EDS_MESH_WIRE_OVERLAY);
|
||||
planetnode->setDebugDataVisible(scene::EDS_BBOX | scene::EDS_MESH_WIRE_OVERLAY);
|
||||
shieldnode->setDebugDataVisible(scene::EDS_BBOX | scene::EDS_MESH_WIRE_OVERLAY);*/
|
||||
if (asteroidnode->getTransformedBoundingBox().intersectsWithBox(shieldnode->getTransformedBoundingBox()))
|
||||
{
|
||||
snddevice->play2D("assets/sounds/shldhit.ogg", false);
|
||||
for (unsigned int i = 0; i < shieldnode->getMaterialCount(); i++) {
|
||||
shieldnode->getMaterial(i).BackfaceCulling = false;
|
||||
shieldnode->getMaterial(i).FrontfaceCulling = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (unsigned int i = 0; i < shieldnode->getMaterialCount(); i++) {
|
||||
shieldnode->getMaterial(i).BackfaceCulling = true;
|
||||
shieldnode->getMaterial(i).FrontfaceCulling = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
device->drop();
|
||||
snddevice->drop(); // delete engine
|
||||
return 0;
|
||||
}
|
||||
|
After Width: | Height: | Size: 115 KiB |
@@ -0,0 +1,16 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by Resource.rc
|
||||
//
|
||||
#define IDI_ICON1 102
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 103
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
# Privateer
|
||||
|
||||
Back in 2019 I was playing with a graphics engine called irrlicht (and the associated sound system called irrklang). This was a quick play around with that to immitate the flying system from Privateer 2: The Darkening.
|
||||
|
||||
Many of the assets for the game have been placed in public domain and have been used. All other models/textures are from free online asset stores. It was so long ago I'm not sure I can fairly credit, but if anything here is yours then let me know and I'll credit (or remove) as required.
|
||||
|
||||
- \+ = increase speed
|
||||
- \- = decrease speed
|
||||
- \[ = minimum speed
|
||||
- \] = maximum speed
|
||||
- tab = afterburner
|
||||
|
||||
Flight direction is controlled with the mouse. It's every bit as un-controllable as the original game at first - look at the arrows around the crosshairs to get a feel if you're struggling. It's a game much more suited to a joystick
|
||||
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 257 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 317 KiB |
|
After Width: | Height: | Size: 2.9 MiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
After Width: | Height: | Size: 364 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 41 KiB |
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<ship>
|
||||
<movement>
|
||||
<setting name="speed_increment" value="80" />
|
||||
|
||||
<setting name="speed_max_standard" value="288" />
|
||||
<setting name="speed_max_afterburn" value="576" />
|
||||
|
||||
<setting name="speed_decel" value="60" />
|
||||
|
||||
<setting name="speed_accel_standard" value="50" />
|
||||
<setting name="speed_accel_afterburn" value="100" />
|
||||
|
||||
<setting name="turn_max" value="100" />
|
||||
<setting name="pitch_max" value="100" />
|
||||
</movement>
|
||||
</ship>
|
||||