aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/Jin.exebin846848 -> 2342912 bytes
-rw-r--r--bin/SDL2.dllbin771072 -> 1279488 bytes
-rw-r--r--build/vc++/examples/ParticleSystem/ParticleSystem.vcxproj15
-rw-r--r--build/vc++/examples/StateMachine/StateMachine.vcxproj141
-rw-r--r--build/vc++/examples/StateMachine/StateMachine.vcxproj.filters6
-rw-r--r--build/vc++/examples/StateMachine/StateMachine.vcxproj.user4
-rw-r--r--build/vc++/jin.sln15
-rw-r--r--build/vc++/jin/jin.vcxproj4
-rw-r--r--build/vc++/libjin/libjin.vcxproj1
-rw-r--r--build/vc++/libjin/libjin.vcxproj.filters3
-rw-r--r--examples/particle_system/main.cpp51
-rw-r--r--examples/state_machine/main.cpp102
-rw-r--r--src/3rdparty/buildvm/buildvm.exebin62976 -> 123392 bytes
-rw-r--r--src/3rdparty/minilua/minilua.exebin112640 -> 219136 bytes
-rw-r--r--src/jin/main.cpp25
-rw-r--r--src/libjin/Common/je_pool.hpp168
-rw-r--r--src/libjin/Graphics/animations/je_animation.cpp14
-rw-r--r--src/libjin/Graphics/animations/je_animator.cpp14
-rw-r--r--src/libjin/Graphics/animations/je_animator.h5
-rw-r--r--src/libjin/Graphics/je_color.cpp5
-rw-r--r--src/libjin/Graphics/je_color.h5
-rw-r--r--src/libjin/Graphics/je_graphics.h1
-rw-r--r--src/libjin/Graphics/je_window.cpp22
-rw-r--r--src/libjin/Graphics/je_window.h11
-rw-r--r--src/libjin/Graphics/particles/je_particle.cpp14
-rw-r--r--src/libjin/Graphics/particles/je_particle.h21
-rw-r--r--src/libjin/Graphics/particles/je_particle_pool.cpp0
-rw-r--r--src/libjin/Graphics/particles/je_particle_pool.h36
-rw-r--r--src/libjin/Graphics/particles/je_particle_system.h5
-rw-r--r--src/libjin/Time/je_timer.cpp78
-rw-r--r--src/libjin/Time/je_timer.h73
-rw-r--r--src/libjin/ai/je_behavior_tree.h2
-rw-r--r--src/libjin/ai/je_state_machine.cpp96
-rw-r--r--src/libjin/ai/je_state_machine.h38
-rw-r--r--src/lua/embed/boot.lua.h8
-rw-r--r--src/lua/modules/graphics/je_lua_graphics.cpp21
36 files changed, 806 insertions, 198 deletions
diff --git a/bin/Jin.exe b/bin/Jin.exe
index e937e5b..e7d4cf7 100644
--- a/bin/Jin.exe
+++ b/bin/Jin.exe
Binary files differ
diff --git a/bin/SDL2.dll b/bin/SDL2.dll
index cb9ed5d..efa2f27 100644
--- a/bin/SDL2.dll
+++ b/bin/SDL2.dll
Binary files differ
diff --git a/build/vc++/examples/ParticleSystem/ParticleSystem.vcxproj b/build/vc++/examples/ParticleSystem/ParticleSystem.vcxproj
index 7c11e29..ab310c9 100644
--- a/build/vc++/examples/ParticleSystem/ParticleSystem.vcxproj
+++ b/build/vc++/examples/ParticleSystem/ParticleSystem.vcxproj
@@ -69,7 +69,12 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
- <PropertyGroup />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <OutDir>$(SolutionDir)..\..\bin</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <OutDir>$(SolutionDir)..\..\bin</OutDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
@@ -78,14 +83,14 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
- <AdditionalIncludeDirectories>D:\Documents\VisualStudio2017\Projects\Jin\jin\Jin\src\libjin;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(SolutionDir)..\..\src\;$(SolutionDir)..\..\src\3rdparty\SDL2\include;$(SolutionDir)..\..\src\3rdparty\LuaJIT-2.0.5\include;$(SolutionDir)..\..\src\3rdparty\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>$(SolutionDir)libs\SDL2-2.0.5\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>SDL2.lib;SDL2main.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@@ -94,12 +99,12 @@
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
- <AdditionalIncludeDirectories>D:\Jin\Jin\Jin\src\libjin;$(SolutionDir)libs\SDL2-2.0.5\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>$(SolutionDir)..\..\src\;$(SolutionDir)..\..\src\3rdparty\SDL2\include;$(SolutionDir)..\..\src\3rdparty\LuaJIT-2.0.5\include;$(SolutionDir)..\..\src\3rdparty\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>$(SolutionDir)libs\SDL2-2.0.5\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <AdditionalDependencies>SDL2.lib;SDL2main.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
diff --git a/build/vc++/examples/StateMachine/StateMachine.vcxproj b/build/vc++/examples/StateMachine/StateMachine.vcxproj
new file mode 100644
index 0000000..90821de
--- /dev/null
+++ b/build/vc++/examples/StateMachine/StateMachine.vcxproj
@@ -0,0 +1,141 @@
+<?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>{C70BFD61-6462-49D2-9F54-F16D77FF434A}</ProjectGuid>
+ <RootNamespace>StateMachine</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0.17134.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>v141</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</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|Win32'">
+ <OutDir>$(SolutionDir)..\..\bin</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <OutDir>$(SolutionDir)..\..\bin</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ <AdditionalIncludeDirectories>$(SolutionDir)..\..\src\;$(SolutionDir)..\..\src\3rdparty\SDL2\include;$(SolutionDir)..\..\src\3rdparty\LuaJIT-2.0.5\include;$(SolutionDir)..\..\src\3rdparty\</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <AdditionalDependencies>opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </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>
+ <AdditionalIncludeDirectories>$(SolutionDir)..\..\src\;$(SolutionDir)..\..\src\3rdparty\SDL2\include;$(SolutionDir)..\..\src\3rdparty\LuaJIT-2.0.5\include;$(SolutionDir)..\..\src\3rdparty\</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <SubSystem>Console</SubSystem>
+ <AdditionalDependencies>opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </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="..\..\..\..\examples\state_machine\main.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\libjin\libjin.vcxproj">
+ <Project>{9ee02090-c15e-4520-9c05-c435e45ef2fc}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/build/vc++/examples/StateMachine/StateMachine.vcxproj.filters b/build/vc++/examples/StateMachine/StateMachine.vcxproj.filters
new file mode 100644
index 0000000..3a52c98
--- /dev/null
+++ b/build/vc++/examples/StateMachine/StateMachine.vcxproj.filters
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="..\..\..\..\examples\state_machine\main.cpp" />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/build/vc++/examples/StateMachine/StateMachine.vcxproj.user b/build/vc++/examples/StateMachine/StateMachine.vcxproj.user
new file mode 100644
index 0000000..be25078
--- /dev/null
+++ b/build/vc++/examples/StateMachine/StateMachine.vcxproj.user
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup />
+</Project> \ No newline at end of file
diff --git a/build/vc++/jin.sln b/build/vc++/jin.sln
index fd022a4..b15527a 100644
--- a/build/vc++/jin.sln
+++ b/build/vc++/jin.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2047
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "luaport", "jin.vcxproj", "{A3E35ECA-62EB-45CE-8152-674FBC7F7A3B}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jin", "jin.vcxproj", "{A3E35ECA-62EB-45CE-8152-674FBC7F7A3B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjin", "libjin\libjin.vcxproj", "{9EE02090-C15E-4520-9C05-C435E45EF2FC}"
EndProject
@@ -27,7 +27,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Library", "Library", "{60F3
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Runner", "Runner", "{2D5BA0D9-04A7-43BB-BD30-000D39317B07}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jin", "jin\jin.vcxproj", "{05128A0C-74E2-43EF-B5F4-B0DA70D47940}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runner", "jin\jin.vcxproj", "{05128A0C-74E2-43EF-B5F4-B0DA70D47940}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2", "3rdparty\SDL2\SDL2.vcxproj", "{8658F91C-9AAE-4819-9005-77D09C61D97F}"
EndProject
@@ -43,6 +43,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SDL", "SDL", "{CD378AC6-A4F
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2main", "3rdparty\SDL2main\SDL2main.vcxproj", "{5522BDBA-3F18-4EDD-B6E4-CE6A70D9D794}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StateMachine", "examples\StateMachine\StateMachine.vcxproj", "{C70BFD61-6462-49D2-9F54-F16D77FF434A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -163,6 +165,14 @@ Global
{5522BDBA-3F18-4EDD-B6E4-CE6A70D9D794}.Release|x64.Build.0 = Release|x64
{5522BDBA-3F18-4EDD-B6E4-CE6A70D9D794}.Release|x86.ActiveCfg = Release|Win32
{5522BDBA-3F18-4EDD-B6E4-CE6A70D9D794}.Release|x86.Build.0 = Release|Win32
+ {C70BFD61-6462-49D2-9F54-F16D77FF434A}.Debug|x64.ActiveCfg = Debug|x64
+ {C70BFD61-6462-49D2-9F54-F16D77FF434A}.Debug|x64.Build.0 = Debug|x64
+ {C70BFD61-6462-49D2-9F54-F16D77FF434A}.Debug|x86.ActiveCfg = Debug|Win32
+ {C70BFD61-6462-49D2-9F54-F16D77FF434A}.Debug|x86.Build.0 = Debug|Win32
+ {C70BFD61-6462-49D2-9F54-F16D77FF434A}.Release|x64.ActiveCfg = Release|x64
+ {C70BFD61-6462-49D2-9F54-F16D77FF434A}.Release|x64.Build.0 = Release|x64
+ {C70BFD61-6462-49D2-9F54-F16D77FF434A}.Release|x86.ActiveCfg = Release|Win32
+ {C70BFD61-6462-49D2-9F54-F16D77FF434A}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -184,6 +194,7 @@ Global
{C87C5B2F-4088-4BBC-8BEE-C6A2BB22F9A0} = {2A2F610D-E42B-426F-8DC8-79E0C6FCCDD2}
{CD378AC6-A4FE-48F7-984A-EB68C60A211B} = {65DFFFA6-F434-47FB-9DB2-DCF019060B92}
{5522BDBA-3F18-4EDD-B6E4-CE6A70D9D794} = {CD378AC6-A4FE-48F7-984A-EB68C60A211B}
+ {C70BFD61-6462-49D2-9F54-F16D77FF434A} = {6FC112F9-B317-4444-B4FB-2E0BF70328F1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {633D8D43-3349-43F7-8835-7D7F58BAD2A8}
diff --git a/build/vc++/jin/jin.vcxproj b/build/vc++/jin/jin.vcxproj
index 489f35d..ac3cec8 100644
--- a/build/vc++/jin/jin.vcxproj
+++ b/build/vc++/jin/jin.vcxproj
@@ -23,6 +23,7 @@
<ProjectGuid>{05128A0C-74E2-43EF-B5F4-B0DA70D47940}</ProjectGuid>
<RootNamespace>jin</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ <ProjectName>runner</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -71,10 +72,11 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)..\..\bin</OutDir>
+ <TargetName>$(SolutionName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)..\..\bin</OutDir>
- <TargetName>$(ProjectName)</TargetName>
+ <TargetName>$(SolutionName)</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
diff --git a/build/vc++/libjin/libjin.vcxproj b/build/vc++/libjin/libjin.vcxproj
index 7339e02..892229f 100644
--- a/build/vc++/libjin/libjin.vcxproj
+++ b/build/vc++/libjin/libjin.vcxproj
@@ -255,7 +255,6 @@
<ClCompile Include="..\..\..\src\libjin\Graphics\je_window.cpp" />
<ClCompile Include="..\..\..\src\libjin\graphics\particles\je_particle.cpp" />
<ClCompile Include="..\..\..\src\libjin\graphics\particles\je_particle_emitter.cpp" />
- <ClCompile Include="..\..\..\src\libjin\graphics\particles\je_particle_pool.cpp" />
<ClCompile Include="..\..\..\src\libjin\graphics\particles\je_particle_system.cpp" />
<ClCompile Include="..\..\..\src\libjin\graphics\shaders\je_jsl_compiler.cpp" />
<ClCompile Include="..\..\..\src\libjin\graphics\shaders\je_shader.cpp" />
diff --git a/build/vc++/libjin/libjin.vcxproj.filters b/build/vc++/libjin/libjin.vcxproj.filters
index 31230e0..88717b9 100644
--- a/build/vc++/libjin/libjin.vcxproj.filters
+++ b/build/vc++/libjin/libjin.vcxproj.filters
@@ -445,9 +445,6 @@
<ClCompile Include="..\..\..\src\libjin\graphics\particles\je_particle_emitter.cpp">
<Filter>source\graphics\particles</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\src\libjin\graphics\particles\je_particle_pool.cpp">
- <Filter>source\graphics\particles</Filter>
- </ClCompile>
<ClCompile Include="..\..\..\src\libjin\graphics\particles\je_particle_system.cpp">
<Filter>source\graphics\particles</Filter>
</ClCompile>
diff --git a/examples/particle_system/main.cpp b/examples/particle_system/main.cpp
index 1477a20..0b7e191 100644
--- a/examples/particle_system/main.cpp
+++ b/examples/particle_system/main.cpp
@@ -1,24 +1,55 @@
-#include "jin.h"
+#include <iostream>
+#include "libjin/jin.h"
+
+using namespace std;
using namespace JinEngine::AI;
using namespace JinEngine::Game;
using namespace JinEngine::Input;
using namespace JinEngine::Graphics;
using namespace JinEngine::Graphics::Particles;
+using namespace JinEngine::Filesystem;
+using namespace JinEngine::Time;
ParticleSystem* p;
-
+StateMachine sm;
+Timer timer;
+Timer::Handler* hnd;
void onLoad()
{
- StateMachine sm;
sm.addState("Run");
sm.addState("Idle");
sm.addState("Sleep");
sm.addState("Jump");
- sm.addParameteri("run");
- sm.addParameteri("idle");
- sm.addTransitioni("Empty", "Idle", "run", 1);
- sm.addTransitioni("Run", "Idle", "run", 1);
+ sm.addParametert("run");
+ sm.addParameterb("idle");
+ /*sm.addTransitionb("Empty", "Idle", "run", StateMachine::BOOL_IS, true);
+ sm.addTransitionb("Idle", "Run", "run", StateMachine::BOOL_IS, false);
+ */
+ sm.addTransitiont("Empty", "Idle", "run");
+ sm.addTransitiont("Idle", "Run", "run");
+ sm.setEnterListener([](const string& state, void* p) {
+ cout << "Enter: " << state << endl;
+ });
+ sm.addEnterListener("Run", [](void* p) {
+ cout << "A Run state enter callback" << endl;
+ });
+ sm.addTranslateListener("Idle", "Run", [](void* p) {
+ cout << "From Idle to Run" << endl;
+ });
+ Window::get()->show();
+ hnd = timer.every(500, [](void*) {
+ cout << sm.getCurrentState() << endl;
+ }, NULL);
+ timer.after(2500, [](void*) {
+ //sm.setParameterb("run", true);
+ sm.setParametert("run");
+ //timer.cancel(hnd);
+ }, NULL);
+ timer.after(5000, [](void*) {
+ sm.setParametert("run");
+ //sm.setParameterb("run", false);
+ }, NULL);
}
void onEvent(Event* e)
@@ -30,11 +61,12 @@ void onEvent(Event* e)
void onUpdate(int ms)
{
+ timer.update(ms);
+ sm.update();
}
void onDraw()
{
-
}
int main(int argc, char* argv[])
@@ -47,6 +79,8 @@ int main(int argc, char* argv[])
setting.drawer = onDraw;
Application->init(&setting);
+ AssetDatabase::get()->mount(".");
+
Window* wnd = Window::get();
Window::Setting wndSetting;
wndSetting.width = 600;
@@ -56,6 +90,7 @@ int main(int argc, char* argv[])
wndSetting.vsync = false;
wndSetting.fullscreen = false;
wndSetting.resizable = false;
+ wndSetting.icon = ".";
wnd->init(&wndSetting);
Application->run();
diff --git a/examples/state_machine/main.cpp b/examples/state_machine/main.cpp
new file mode 100644
index 0000000..0b7e191
--- /dev/null
+++ b/examples/state_machine/main.cpp
@@ -0,0 +1,102 @@
+#include <iostream>
+
+#include "libjin/jin.h"
+
+using namespace std;
+using namespace JinEngine::AI;
+using namespace JinEngine::Game;
+using namespace JinEngine::Input;
+using namespace JinEngine::Graphics;
+using namespace JinEngine::Graphics::Particles;
+using namespace JinEngine::Filesystem;
+using namespace JinEngine::Time;
+
+ParticleSystem* p;
+StateMachine sm;
+Timer timer;
+Timer::Handler* hnd;
+void onLoad()
+{
+ sm.addState("Run");
+ sm.addState("Idle");
+ sm.addState("Sleep");
+ sm.addState("Jump");
+ sm.addParametert("run");
+ sm.addParameterb("idle");
+ /*sm.addTransitionb("Empty", "Idle", "run", StateMachine::BOOL_IS, true);
+ sm.addTransitionb("Idle", "Run", "run", StateMachine::BOOL_IS, false);
+ */
+ sm.addTransitiont("Empty", "Idle", "run");
+ sm.addTransitiont("Idle", "Run", "run");
+ sm.setEnterListener([](const string& state, void* p) {
+ cout << "Enter: " << state << endl;
+ });
+ sm.addEnterListener("Run", [](void* p) {
+ cout << "A Run state enter callback" << endl;
+ });
+ sm.addTranslateListener("Idle", "Run", [](void* p) {
+ cout << "From Idle to Run" << endl;
+ });
+ Window::get()->show();
+ hnd = timer.every(500, [](void*) {
+ cout << sm.getCurrentState() << endl;
+ }, NULL);
+ timer.after(2500, [](void*) {
+ //sm.setParameterb("run", true);
+ sm.setParametert("run");
+ //timer.cancel(hnd);
+ }, NULL);
+ timer.after(5000, [](void*) {
+ sm.setParametert("run");
+ //sm.setParameterb("run", false);
+ }, NULL);
+}
+
+void onEvent(Event* e)
+{
+ static Application* Application = Application::get();
+ if (e->type == EventType::QUIT)
+ Application->stop();
+}
+
+void onUpdate(int ms)
+{
+ timer.update(ms);
+ sm.update();
+}
+
+void onDraw()
+{
+}
+
+int main(int argc, char* argv[])
+{
+ Application* Application = Application::get();
+ Application::Setting setting;
+ setting.loader = onLoad;
+ setting.eventHandler = onEvent;
+ setting.updater = onUpdate;
+ setting.drawer = onDraw;
+ Application->init(&setting);
+
+ AssetDatabase::get()->mount(".");
+
+ Window* wnd = Window::get();
+ Window::Setting wndSetting;
+ wndSetting.width = 600;
+ wndSetting.height = 512;
+ wndSetting.title = "Jin v0.1.1";
+ wndSetting.fps = 60;
+ wndSetting.vsync = false;
+ wndSetting.fullscreen = false;
+ wndSetting.resizable = false;
+ wndSetting.icon = ".";
+ wnd->init(&wndSetting);
+
+ Application->run();
+
+ Application->quit();
+ wnd->quit();
+
+ return 0;
+} \ No newline at end of file
diff --git a/src/3rdparty/buildvm/buildvm.exe b/src/3rdparty/buildvm/buildvm.exe
index 17459f4..c1e069e 100644
--- a/src/3rdparty/buildvm/buildvm.exe
+++ b/src/3rdparty/buildvm/buildvm.exe
Binary files differ
diff --git a/src/3rdparty/minilua/minilua.exe b/src/3rdparty/minilua/minilua.exe
index e6cd530..09b1820 100644
--- a/src/3rdparty/minilua/minilua.exe
+++ b/src/3rdparty/minilua/minilua.exe
Binary files differ
diff --git a/src/jin/main.cpp b/src/jin/main.cpp
index 2f0f9b3..da5b5e7 100644
--- a/src/jin/main.cpp
+++ b/src/jin/main.cpp
@@ -4,13 +4,13 @@
#ifdef _WIN32
#include <Windows.h>
- #include <SDL2/SDL_Main.h>
#include <direct.h>
#include <shlobj.h>
#include <wchar.h>
#endif
#define EXECUTABLE_DIR "./"
+#define DIALOG_TITLE L"Open existing game"
using namespace std;
using namespace JinEngine::Filesystem;
@@ -58,16 +58,17 @@ std::string wstrtostr(const std::wstring &wstr)
std::string BrowseFolder()
{
- string path = EXECUTABLE_DIR;
#ifdef _WIN32
- IFileDialog *pfd = NULL;
+ string path = EXECUTABLE_DIR;
+ IFileDialog* pfd = NULL;
DWORD dwFlags;
- IShellItem *pShellItem = NULL;
+ IShellItem* pItem = NULL;
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr)) goto End;
hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL,
IID_IFileOpenDialog, reinterpret_cast<void**>(&pfd));
if (FAILED(hr)) goto End;
+ pfd->SetTitle(DIALOG_TITLE);
hr = pfd->GetOptions(&dwFlags);
if (FAILED(hr)) goto End;
hr = pfd->SetOptions(dwFlags | FOS_PICKFOLDERS);
@@ -75,19 +76,19 @@ std::string BrowseFolder()
hr = pfd->Show(NULL);
if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED))
goto End;
- hr = pfd->GetResult(&pShellItem);
+ hr = pfd->GetResult(&pItem);
if (FAILED(hr)) goto End;
LPWSTR filePath;
- hr = pShellItem->GetDisplayName(SIGDN_FILESYSPATH, &filePath);
- if (FAILED(hr))
- {
- goto End;
- }
+ hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &filePath);
+ if (FAILED(hr)) goto End;
path = wstrtostr(filePath);
CoTaskMemFree(filePath);
-#endif
+ pItem->Release();
+ pfd->Release();
+ CoUninitialize();
End:
return path;
+#endif
}
int main(int argc, char* args[])
@@ -95,9 +96,7 @@ int main(int argc, char* args[])
string cwd = EXECUTABLE_DIR;
#ifdef _WIN32
if (argc > 1)
- {
cwd = args[1];
- }
#endif
else
cwd = BrowseFolder();
diff --git a/src/libjin/Common/je_pool.hpp b/src/libjin/Common/je_pool.hpp
index 1c74eaf..cb96c5b 100644
--- a/src/libjin/Common/je_pool.hpp
+++ b/src/libjin/Common/je_pool.hpp
@@ -1,11 +1,177 @@
+///
+/// An O(1) Object Pool. Original from https://www.codeproject.com/Articles/746630/O-Object-Pool-in-Cplusplus
+///
#ifndef __JE_POOL_H__
#define __JE_POOL_H__
+#include <stdlib.h>
+#include <iostream>
+
+#include "je_types.h"
+
namespace JinEngine
{
+ class DefaultMemoryAllocator
+ {
+ public:
+ static inline void *Allocate(size_t size)
+ {
+ return ::operator new(size, ::std::nothrow);
+ }
+ static inline void Deallocate(void *pointer, size_t size)
+ {
+ ::operator delete(pointer);
+ }
+ };
+
+ template<typename T, class TMemoryAllocator = DefaultMemoryAllocator>
+ class Pool
+ {
+ private:
+ struct _Node
+ {
+ void *_memory;
+ size_t _capacity;
+ _Node *_nextNode;
+
+ _Node(size_t capacity)
+ {
+ if (capacity < 1)
+ throw std::invalid_argument("capacity must be at least 1.");
+
+ _memory = TMemoryAllocator::Allocate(_itemSize * capacity);
+ if (_memory == NULL)
+ throw std::bad_alloc();
+
+ _capacity = capacity;
+ _nextNode = NULL;
+ }
+ ~_Node()
+ {
+ TMemoryAllocator::Deallocate(_memory, _itemSize * _capacity);
+ }
+ };
+
+ void *_nodeMemory;
+ T *_firstDeleted;
+ size_t _countInNode;
+ size_t _nodeCapacity;
+ _Node _firstNode;
+ _Node *_lastNode;
+ size_t _maxBlockLength;
+
+ static const size_t _itemSize;
+
+ Pool(const Pool<T, TMemoryAllocator> &source);
+ void operator = (const Pool<T, TMemoryAllocator> &source);
+
+ void _AllocateNewNode()
+ {
+ size_t size = _countInNode;
+ if (size >= _maxBlockLength)
+ size = _maxBlockLength;
+ else
+ {
+ size *= 2;
+
+ if (size < _countInNode)
+ throw std::overflow_error("size became too big.");
+
+ if (size >= _maxBlockLength)
+ size = _maxBlockLength;
+ }
+
+ _Node *newNode = new _Node(size);
+ _lastNode->_nextNode = newNode;
+ _lastNode = newNode;
+ _nodeMemory = newNode->_memory;
+ _countInNode = 0;
+ _nodeCapacity = size;
+ }
+
+ public:
+ explicit Pool(size_t initialCapacity = 32, size_t maxBlockLength = 1000000)
+ : _firstDeleted(NULL)
+ , _countInNode(0)
+ , _nodeCapacity(initialCapacity)
+ , _firstNode(initialCapacity)
+ , _maxBlockLength(maxBlockLength)
+ {
+ if (maxBlockLength < 1)
+ throw std::invalid_argument("maxBlockLength must be at least 1.");
+
+ _nodeMemory = _firstNode._memory;
+ _lastNode = &_firstNode;
+ }
+ ~Pool()
+ {
+ _Node *node = _firstNode._nextNode;
+ while (node)
+ {
+ _Node *nextNode = node->_nextNode;
+ delete node;
+ node = nextNode;
+ }
+ }
+
+ T *New()
+ {
+ if (_firstDeleted)
+ {
+ T *result = _firstDeleted;
+ _firstDeleted = *((T **)_firstDeleted);
+ new(result) T();
+ return result;
+ }
+
+ if (_countInNode >= _nodeCapacity)
+ _AllocateNewNode();
+
+ char *address = (char *)_nodeMemory;
+ address += _countInNode * _itemSize;
+ T *result = new(address) T();
+ _countInNode++;
+ return result;
+ }
+
+ // This method is useful if you want to call a non-default constructor.
+ // It should be used like this:
+ // new (pool.GetNextWithoutInitializing()) ObjectType(... parameters ...);
+ T *GetNextWithoutInitializing()
+ {
+ if (_firstDeleted)
+ {
+ T *result = (T *)_firstDeleted;
+ _firstDeleted = *((T **)_firstDeleted);
+ return result;
+ }
+
+ if (_countInNode >= _nodeCapacity)
+ _AllocateNewNode();
+
+ char *address = (char *)_nodeMemory;
+ address += _countInNode * _itemSize;
+ _countInNode++;
+ return (T *)address;
+ }
+ void Delete(T *content)
+ {
+ content->~T();
+
+ *((T **)content) = _firstDeleted;
+ _firstDeleted = content;
+ }
+ void DeleteWithoutDestroying(T *content)
+ {
+ *((T **)content) = _firstDeleted;
+ _firstDeleted = content;
+ }
+ };
+ template<typename T, class TMemoryAllocator>
+ const size_t Pool<T, TMemoryAllocator>::_itemSize = ((sizeof(T) + sizeof(void *) - 1) / sizeof(void *)) * sizeof(void *);
-}
+} // namespace JinEngine
#endif \ No newline at end of file
diff --git a/src/libjin/Graphics/animations/je_animation.cpp b/src/libjin/Graphics/animations/je_animation.cpp
index e69de29..4fe673a 100644
--- a/src/libjin/Graphics/animations/je_animation.cpp
+++ b/src/libjin/Graphics/animations/je_animation.cpp
@@ -0,0 +1,14 @@
+#include "je_animation.h"
+
+namespace JinEngine
+{
+ namespace Graphics
+ {
+ namespace Animations
+ {
+
+
+
+ }
+ }
+} \ No newline at end of file
diff --git a/src/libjin/Graphics/animations/je_animator.cpp b/src/libjin/Graphics/animations/je_animator.cpp
index e69de29..360bd5d 100644
--- a/src/libjin/Graphics/animations/je_animator.cpp
+++ b/src/libjin/Graphics/animations/je_animator.cpp
@@ -0,0 +1,14 @@
+#include "je_animator.h"
+
+namespace JinEngine
+{
+ namespace Graphics
+ {
+ namespace Animations
+ {
+
+
+
+ }
+ }
+} \ No newline at end of file
diff --git a/src/libjin/Graphics/animations/je_animator.h b/src/libjin/Graphics/animations/je_animator.h
index 84b0385..6510a7d 100644
--- a/src/libjin/Graphics/animations/je_animator.h
+++ b/src/libjin/Graphics/animations/je_animator.h
@@ -24,8 +24,7 @@ namespace JinEngine
bool hasKey(const std::string& key);
void play();
- void switchAnimationByKey(const std::string& key);
- void switchAnimation(const Animation* clip);
+ void switchAnimation(const std::string& key);
///
/// Control clips.
@@ -44,7 +43,7 @@ namespace JinEngine
};
- }
+ } // namespace Animations
} // namespace Graphics
} // namespace JinEngine
diff --git a/src/libjin/Graphics/je_color.cpp b/src/libjin/Graphics/je_color.cpp
index da48162..c939a1d 100644
--- a/src/libjin/Graphics/je_color.cpp
+++ b/src/libjin/Graphics/je_color.cpp
@@ -13,5 +13,10 @@ namespace JinEngine
const Color Color::MAGENTA = Color(255, 0, 255);
const Color Color::YELLOW = Color(255, 255, 0);
+ const uint32 Color::RMASK = 0x000000ff;
+ const uint32 Color::GMASK = 0x0000ff00;
+ const uint32 Color::BMASK = 0x00ff0000;
+ const uint32 Color::AMASK = 0xff000000;
+
}
} \ No newline at end of file
diff --git a/src/libjin/Graphics/je_color.h b/src/libjin/Graphics/je_color.h
index 9195e48..06b8f61 100644
--- a/src/libjin/Graphics/je_color.h
+++ b/src/libjin/Graphics/je_color.h
@@ -30,6 +30,11 @@ namespace JinEngine
static const Color MAGENTA;
static const Color YELLOW;
+ static const uint32 RMASK;
+ static const uint32 GMASK;
+ static const uint32 BMASK;
+ static const uint32 AMASK;
+
///
/// Get lerp color with given factor.
///
diff --git a/src/libjin/Graphics/je_graphics.h b/src/libjin/Graphics/je_graphics.h
index d9e0c0a..52bfbda 100644
--- a/src/libjin/Graphics/je_graphics.h
+++ b/src/libjin/Graphics/je_graphics.h
@@ -32,6 +32,5 @@
// int64 textureMemory;
//};
-
#endif // defined(jin_graphics)
#endif // __JE_GRAPHICS_H__ \ No newline at end of file
diff --git a/src/libjin/Graphics/je_window.cpp b/src/libjin/Graphics/je_window.cpp
index 86ccd29..c14d290 100644
--- a/src/libjin/Graphics/je_window.cpp
+++ b/src/libjin/Graphics/je_window.cpp
@@ -3,6 +3,7 @@
#include <iostream>
+#include "../common/je_exception.h"
#include "../utils/je_utils.h"
#include "../audio/sdl/je_sdl_audio.h"
#include "../utils/je_log.h"
@@ -30,8 +31,9 @@ namespace JinEngine
mSize.w = setting->width;
mSize.h = setting->height;
mFps = setting->fps;
- bool vsync = setting->vsync;
- const char* title = setting->title;
+ bool vsync = setting->vsync;
+ const char* title = setting->title;
+ const char* icon = setting->icon;
if (mWnd)
{
@@ -58,13 +60,27 @@ namespace JinEngine
int wx = SDL_WINDOWPOS_UNDEFINED,
wy = SDL_WINDOWPOS_UNDEFINED;
- int flag = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
+ int flag = SDL_WINDOW_HIDDEN | SDL_WINDOW_OPENGL;
if (setting->fullscreen) flag |= SDL_WINDOW_FULLSCREEN;
if (setting->resizable) flag |= SDL_WINDOW_RESIZABLE;
mWnd = SDL_CreateWindow(title, wx, wy, mSize.w, mSize.h, flag);
if (mWnd == NULL)
return false;
+
+ // Set window icon
+ try
+ {
+ Bitmap* bitmap = Bitmap::createBitmap(icon);
+ SDL_Surface *surface;
+ Color* pixels = const_cast<Color*>(bitmap->getPixels());
+ uint w = bitmap->getWidth(), h = bitmap->getHeight();
+ surface = SDL_CreateRGBSurfaceFrom(
+ pixels, w, h, 32, w * 4, Color::RMASK, Color::GMASK, Color::BMASK, Color::AMASK);
+ SDL_SetWindowIcon(mWnd, surface);
+ SDL_FreeSurface(surface);
+ } catch (...) {}
+
ctx = SDL_GL_CreateContext(mWnd);
if (ctx == NULL)
return false;
diff --git a/src/libjin/Graphics/je_window.h b/src/libjin/Graphics/je_window.h
index 7ca1e5e..436fd24 100644
--- a/src/libjin/Graphics/je_window.h
+++ b/src/libjin/Graphics/je_window.h
@@ -26,6 +26,7 @@ namespace JinEngine
{
public:
const char* title; ///< window title
+ const char* icon; ///< window icon
bool fullscreen; ///< full screen
int width, height; ///< window size
bool vsync; ///< vsync
@@ -58,6 +59,16 @@ namespace JinEngine
///
void swapBuffers();
+ ///
+ ///
+ ///
+ inline void hide() { SDL_HideWindow(mWnd); };
+
+ ///
+ ///
+ ///
+ void show() { SDL_ShowWindow(mWnd); };
+
private:
// declare a singleton
diff --git a/src/libjin/Graphics/particles/je_particle.cpp b/src/libjin/Graphics/particles/je_particle.cpp
index e69de29..9179093 100644
--- a/src/libjin/Graphics/particles/je_particle.cpp
+++ b/src/libjin/Graphics/particles/je_particle.cpp
@@ -0,0 +1,14 @@
+#include "je_particle.h"
+
+namespace JinEngine
+{
+ namespace Graphics
+ {
+ namespace Particles
+ {
+
+
+
+ }
+ }
+} \ No newline at end of file
diff --git a/src/libjin/Graphics/particles/je_particle.h b/src/libjin/Graphics/particles/je_particle.h
index 3dd480e..73803e8 100644
--- a/src/libjin/Graphics/particles/je_particle.h
+++ b/src/libjin/Graphics/particles/je_particle.h
@@ -2,6 +2,7 @@
#define __JE_PARTICLE_H__
#include "../../math/je_vector2.hpp"
+#include "../je_color.h"
namespace JinEngine
{
@@ -12,6 +13,9 @@ namespace JinEngine
class ParticleEmitter;
+ ///
+ ///
+ ///
struct LifeTimeDef
{
bool enableRandom = false;
@@ -25,11 +29,17 @@ namespace JinEngine
} life;
};
+ ///
+ ///
+ ///
struct LinearAccelaration
{
};
+ ///
+ ///
+ ///
struct SpeedOverTimeDef
{
bool enable = false;
@@ -100,7 +110,16 @@ namespace JinEngine
///
struct Particle
{
- Particle(const ParticleDef& particleDef);
+ ///
+ /// Default constructor.
+ ///
+ Particle();
+
+ ///
+ /// Initialize with given definition.
+ ///
+ void initialize(const ParticleDef& particleDef);
+
///
/// Whole life time.
///
diff --git a/src/libjin/Graphics/particles/je_particle_pool.cpp b/src/libjin/Graphics/particles/je_particle_pool.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/Graphics/particles/je_particle_pool.cpp
+++ /dev/null
diff --git a/src/libjin/Graphics/particles/je_particle_pool.h b/src/libjin/Graphics/particles/je_particle_pool.h
index 6bd41e0..46cd73a 100644
--- a/src/libjin/Graphics/particles/je_particle_pool.h
+++ b/src/libjin/Graphics/particles/je_particle_pool.h
@@ -1,7 +1,7 @@
#ifndef __JE_PARTICLE_BATCH_H__
#define __JE_PARTICLE_BATCH_H__
-#include <list>
+#include "../../common/je_pool.hpp"
#include "je_particle.h"
@@ -15,39 +15,7 @@ namespace JinEngine
///
/// Particle pool for reducing memory fragmentation.
///
- class ParticlePool
- {
- public:
-
- ///
- /// Particle pool constructor.
- ///
- /// @param count Max count of particles.
- ///
- ParticlePool(uint count);
-
- ///
- /// Particle pool destructor.
- ///
- ~ParticlePool();
-
- ///
- /// Claim a particle if available.
- ///
- Particle* claim();
-
- ///
- /// Recycle particle if the particle is no more alive.
- ///
- void recycle(Particle* particle);
-
- private:
- ///
- /// All particles include available and inavailable particles.
- ///
- std::list<Particle> particles;
-
- };
+ typedef Pool<Particle> ParticlePool;
} // namespace Particles
} // namespace Graphics
diff --git a/src/libjin/Graphics/particles/je_particle_system.h b/src/libjin/Graphics/particles/je_particle_system.h
index 32123a6..fa050f7 100644
--- a/src/libjin/Graphics/particles/je_particle_system.h
+++ b/src/libjin/Graphics/particles/je_particle_system.h
@@ -63,7 +63,10 @@ namespace JinEngine
///
/// Release particle and make it available in particle pool.
///
- void releaseParticle();
+ void releaseParticle()
+ {
+ Particle*p = mParticlePool.New();
+ }
private:
// Disable default constructor.
diff --git a/src/libjin/Time/je_timer.cpp b/src/libjin/Time/je_timer.cpp
index a2f2486..94ab747 100644
--- a/src/libjin/Time/je_timer.cpp
+++ b/src/libjin/Time/je_timer.cpp
@@ -9,52 +9,55 @@ namespace JinEngine
{
- Timers::Timers()
- : timers()
+ Timer::Timer()
+ : mHandlers()
{
}
- Timers::~Timers()
+ Timer::~Timer()
{
- for (int i = 0; i < timers.size(); ++i)
- delete timers[i];
+ for (int i = 0; i < mHandlers.size(); ++i)
+ delete mHandlers[i];
}
- void Timers::update(int ms)
+ void Timer::update(int ms)
{
- std::vector<Timer*>::iterator it = timers.begin();
- for (; it != timers.end(); )
- {
- if (!(*it)->process(ms))
- {
- Timer* t = *it;
- timers.erase(it);
- delete t;
- return;
- }
- ++it;
- }
+ // Process handler.
+ std::vector<Handler*>::iterator it = mHandlers.begin();
+ for (; it != mHandlers.end(); ++it)
+ (*it)->process(ms);
+ // Erase canceled handler.
+ for (it = mHandlers.begin(); it != mHandlers.end();)
+ {
+ if ((*it)->canceled)
+ it = mHandlers.erase(it);
+ else
+ ++it;
+ }
}
- void Timers::every(int ms, timer_callback callback, void* p)
+ Timer::Handler* Timer::every(int ms, TimerCallback callback, void* p)
{
- Timer* t = new Timer(Timer::EVERY, ms, 0, callback, p);
- timers.push_back(t);
+ Handler* t = new Handler(Handler::EVERY, ms, 0, callback, p);
+ mHandlers.push_back(t);
+ return t;
}
- void Timers::after(int ms, timer_callback callback, void* p)
+ Timer::Handler* Timer::after(int ms, TimerCallback callback, void* p)
{
- Timer* t = new Timer(Timer::AFTER, ms, 0, callback, p);
- timers.push_back(t);
+ Handler* t = new Handler(Handler::AFTER, ms, 0, callback, p);
+ mHandlers.push_back(t);
+ return t;
}
- void Timers::repeat(int ms, int count, timer_callback callback, void* p)
+ Timer::Handler* Timer::repeat(int ms, int count, TimerCallback callback, void* p)
{
- Timer* t = new Timer(Timer::REPEAT, ms, count, callback, p);
- timers.push_back(t);
+ Handler* t = new Handler(Handler::REPEAT, ms, count, callback, p);
+ mHandlers.push_back(t);
+ return t;
}
- Timers::Timer::Timer(Type t, int d, int c, timer_callback f, void* p)
+ Timer::Handler::Handler(Type t, int d, int c, TimerCallback f, void* p)
: type(t)
, duration(d)
, count(c)
@@ -62,14 +65,15 @@ namespace JinEngine
, countdown(c)
, callback(f)
, paramters(p)
+ , canceled(false)
{
}
- Timers::Timer::~Timer()
+ Timer::Handler::~Handler()
{
}
- bool Timers::Timer::process(int ms)
+ void Timer::Handler::process(int ms)
{
tickdown -= ms;
if (tickdown <= 0)
@@ -82,19 +86,23 @@ namespace JinEngine
}
else if (type == AFTER)
{
- return false;
+ canceled = true;
}
else if (type == REPEAT)
{
--countdown;
- if (countdown <= 0)
- return false;
+ if (countdown <= 0)
+ canceled = true;
}
}
- return true;
}
+ void Timer::cancel(Handler* handler)
+ {
+ handler->canceled = true;
+ }
+
} // namespace Time
} // namespace JinEngine
-#endif // defined(jin_time)
+#endif // defined(jin_time) \ No newline at end of file
diff --git a/src/libjin/Time/je_timer.h b/src/libjin/Time/je_timer.h
index b558a55..d0e5513 100644
--- a/src/libjin/Time/je_timer.h
+++ b/src/libjin/Time/je_timer.h
@@ -14,68 +14,77 @@ namespace JinEngine
///
///
///
- class Timers
+ class Timer
{
public:
- typedef void(*timer_callback)(void* prameters);
+
+ typedef void(*TimerCallback)(void* prameters);
///
///
///
- Timers();
+ class Handler
+ {
+ private:
+ friend class Timer;
+ enum Type
+ {
+ EVERY,
+ AFTER,
+ REPEAT,
+ };
+ Handler(Type type, int duration, int count = 0, TimerCallback callback = nullptr, void* paramters = nullptr);
+ virtual ~Handler();
+ void process(int ms);
+
+ int duration;
+ int count;
+ int tickdown;
+ int countdown;
+ Type type;
+ TimerCallback callback;
+ void* paramters;
+ bool canceled;
+ };
///
///
///
- ~Timers();
+ Timer();
///
///
///
- void update(int ms);
+ ~Timer();
///
///
///
- void every(int ms, timer_callback callback, void* paramters);
+ void update(int ms);
///
///
///
- void after(int ms, timer_callback callback, void* paramters);
+ Handler* every(int ms, TimerCallback callback, void* paramters);
///
///
///
- void repeat(int ms, int count, timer_callback callback, void* paramters);
+ Handler* after(int ms, TimerCallback callback, void* paramters);
- private:
+ ///
+ ///
+ ///
+ Handler* repeat(int ms, int count, TimerCallback callback, void* paramters);
///
///
///
- class Timer
- {
- public:
- enum Type
- {
- EVERY,
- AFTER,
- REPEAT,
- };
- Timer(Type type, int duration, int count = 0, timer_callback callback = nullptr, void* paramters = nullptr);
- virtual ~Timer();
- bool process(int ms);
- private:
- int duration;
- int count;
- int tickdown;
- int countdown;
- Type type;
- timer_callback callback;
- void* paramters;
- };
- std::vector<Timer*> timers;
+ void cancel(Handler* handler = nullptr);
+
+ private:
+
+ std::vector<Handler*> mHandlers;
};
@@ -114,4 +123,4 @@ namespace JinEngine
#endif // defined(jin_time)
-#endif // __JE_TIMER_H__
+#endif // __JE_TIMER_H__ \ No newline at end of file
diff --git a/src/libjin/ai/je_behavior_tree.h b/src/libjin/ai/je_behavior_tree.h
index cb518f0..8621696 100644
--- a/src/libjin/ai/je_behavior_tree.h
+++ b/src/libjin/ai/je_behavior_tree.h
@@ -9,8 +9,6 @@ namespace JinEngine
namespace AI
{
-
-
///
///
///
diff --git a/src/libjin/ai/je_state_machine.cpp b/src/libjin/ai/je_state_machine.cpp
index 8f8bd81..9b766b5 100644
--- a/src/libjin/ai/je_state_machine.cpp
+++ b/src/libjin/ai/je_state_machine.cpp
@@ -88,7 +88,6 @@ namespace JinEngine
mMode = mode;
}
- //ģʽ״̬
void StateMachine::update()
{
switch (mMode)
@@ -109,10 +108,42 @@ namespace JinEngine
Parameter& p = it->second;
switch (p.type)
{
- case ParameterType::Int: return p.value._int == condition.value._int;
- case ParameterType::Float: return p.value._float == condition.value._float;
- case ParameterType::Bool: return p.value._bool == condition.value._bool;
- case ParameterType::Trigger: return p.value._trigger == true;
+ case ParameterType::Int:
+ {
+ int value = p.value._int;
+ int cvalue = condition.value._int;
+ bool is = false;
+ is |= ((condition.expression & ParameterExpression::INT_BIGGER) ? value > cvalue : false);
+ is |= ((condition.expression & ParameterExpression::INT_EQUAL) ? value == cvalue : false);
+ is |= ((condition.expression & ParameterExpression::INT_SMALLER) ? value < cvalue : false);
+ return is;
+ }
+ case ParameterType::Float:
+ {
+ float value = p.value._float;
+ float cvalue = condition.value._float;
+ bool is = false;
+ is |= ((condition.expression & ParameterExpression::FLOAT_BIGGER) ? value > cvalue : false);
+ is |= ((condition.expression & ParameterExpression::FLOAT_EQUAL) ? value == cvalue : false);
+ is |= ((condition.expression & ParameterExpression::FLOAT_SMALLER) ? value < cvalue : false);
+ return is;
+ }
+ case ParameterType::Bool:
+ {
+ bool value = p.value._bool;
+ bool cvalue = condition.value._bool;
+ bool is = false;
+ is |= ((condition.expression & ParameterExpression::BOOL_IS) ? value == cvalue : false);
+ is |= ((condition.expression & ParameterExpression::BOOL_NOT) ? value != cvalue : false);
+ return is;
+ }
+ case ParameterType::Trigger:
+ {
+ bool is = p.value._trigger;
+ // Close trigger.
+ p.value._trigger = false;
+ return is;
+ }
}
return false;
}
@@ -197,7 +228,7 @@ namespace JinEngine
}
}
- void StateMachine::addTransitioni(const std::string& stateFrom, const std::string& stateTo, const std::string& name, int value)
+ void StateMachine::addTransitioni(const std::string& stateFrom, const std::string& stateTo, const std::string& name, ParameterExpression expression, int value)
{
map<string, State>::iterator it;
it = mStates.find(stateFrom);
@@ -224,17 +255,18 @@ namespace JinEngine
Parameter& parameter = itp->second;
if (parameter.type != ParameterType::Int)
{
- jin_log_error("The type of parameter called %s is %s, but the transition gives a int value.", name, parameterTypeString(parameter.type));
+ jin_log_error("The type of parameter %s is %s, but the transition gives a int value.", name, parameterTypeString(parameter.type));
return;
}
- Transition trasition;
- trasition.condition.parameter = name;
- trasition.condition.value._int = value;
- trasition.state = stateTo;
- from.transitions.push_back(trasition);
+ Transition transition;
+ transition.condition.parameter = name;
+ transition.condition.expression = expression;
+ transition.condition.value._int = value;
+ transition.state = stateTo;
+ from.transitions.push_back(transition);
}
- void StateMachine::addTransitionf(const std::string& stateFrom, const std::string& stateTo, const std::string& name, float value)
+ void StateMachine::addTransitionf(const std::string& stateFrom, const std::string& stateTo, const std::string& name, ParameterExpression expression, float value)
{
map<string, State>::iterator it;
it = mStates.find(stateFrom);
@@ -261,17 +293,18 @@ namespace JinEngine
Parameter& parameter = itp->second;
if (parameter.type != ParameterType::Float)
{
- jin_log_error("The type of parameter called %s is %s, but the transition gives a float value.", name, parameterTypeString(parameter.type));
+ jin_log_error("The type of parameter %s is %s, but the transition gives a float value.", name, parameterTypeString(parameter.type));
return;
}
- Transition trasition;
- trasition.condition.parameter = name;
- trasition.condition.value._float = value;
- trasition.state = stateTo;
- from.transitions.push_back(trasition);
+ Transition transition;
+ transition.condition.parameter = name;
+ transition.condition.expression = expression;
+ transition.condition.value._float = value;
+ transition.state = stateTo;
+ from.transitions.push_back(transition);
}
- void StateMachine::addTransitionb(const std::string& stateFrom, const std::string& stateTo, const std::string& name, bool value)
+ void StateMachine::addTransitionb(const std::string& stateFrom, const std::string& stateTo, const std::string& name, ParameterExpression expression, bool value)
{
map<string, State>::iterator it;
it = mStates.find(stateFrom);
@@ -298,14 +331,15 @@ namespace JinEngine
Parameter& parameter = itp->second;
if (parameter.type != ParameterType::Bool)
{
- jin_log_error("The type of parameter called %s is %s, but the transition gives a bool value.", name, parameterTypeString(parameter.type));
+ jin_log_error("The type of parameter %s is %s, but the transition gives a bool value.", name, parameterTypeString(parameter.type));
return;
}
- Transition trasition;
- trasition.condition.parameter = name;
- trasition.condition.value._bool = value;
- trasition.state = stateTo;
- from.transitions.push_back(trasition);
+ Transition transition;
+ transition.condition.parameter = name;
+ transition.condition.expression = expression;
+ transition.condition.value._bool = value;
+ transition.state = stateTo;
+ from.transitions.push_back(transition);
}
void StateMachine::addTransitiont(const std::string& stateFrom, const std::string& stateTo, const std::string& name)
@@ -335,7 +369,7 @@ namespace JinEngine
Parameter& parameter = itp->second;
if (parameter.type != ParameterType::Trigger)
{
- jin_log_error("The type of parameter called %s is %s, but the transition gives a trigger value.", name, parameterTypeString(parameter.type));
+ jin_log_error("The type of parameter %s is %s, but the transition gives a trigger value.", name, parameterTypeString(parameter.type));
return;
}
Transition trasition;
@@ -356,7 +390,7 @@ namespace JinEngine
Parameter& p = it->second;
if (p.type != ParameterType::Int)
{
- jin_log_error("The type of parameter called %s is %s, but try to assign a int value to it", name, parameterTypeString(p.type));
+ jin_log_error("The type of parameter %s is %s, but try to assign a int value to it", name, parameterTypeString(p.type));
return;
}
p.value._int = value;
@@ -373,7 +407,7 @@ namespace JinEngine
Parameter& p = it->second;
if (p.type != ParameterType::Float)
{
- jin_log_error("The type of parameter called %s is %s, but try to assign a float value to it", name, parameterTypeString(p.type));
+ jin_log_error("The type of parameter %s is %s, but try to assign a float value to it", name, parameterTypeString(p.type));
return;
}
p.value._float = value;
@@ -390,7 +424,7 @@ namespace JinEngine
Parameter& p = it->second;
if (p.type != ParameterType::Bool)
{
- jin_log_error("The type of parameter called %s is %s, but try to assign a bool value to it", name, parameterTypeString(p.type));
+ jin_log_error("The type of parameter %s is %s, but try to assign a bool value to it", name, parameterTypeString(p.type));
return;
}
p.value._bool = value;
@@ -407,7 +441,7 @@ namespace JinEngine
Parameter& p = it->second;
if (p.type != ParameterType::Trigger)
{
- jin_log_error("The type of parameter called %s is %s, but try to assign a trigger value to it", name, parameterTypeString(p.type));
+ jin_log_error("The type of parameter %s is %s, but try to assign a trigger value to it", name, parameterTypeString(p.type));
return;
}
p.value._trigger = true;
diff --git a/src/libjin/ai/je_state_machine.h b/src/libjin/ai/je_state_machine.h
index 7d638c4..1765e97 100644
--- a/src/libjin/ai/je_state_machine.h
+++ b/src/libjin/ai/je_state_machine.h
@@ -34,6 +34,23 @@ namespace JinEngine
///
///
///
+ enum ParameterExpression
+ {
+ INT_BIGGER = 0x02,
+ INT_SMALLER = 0x04,
+ INT_EQUAL = 0x08,
+
+ FLOAT_BIGGER = 0x10,
+ FLOAT_SMALLER = 0x20,
+ FLOAT_EQUAL = 0x40,
+
+ BOOL_IS = 0x80,
+ BOOL_NOT = 0x100,
+ };
+
+ ///
+ ///
+ ///
typedef void(StateChangeCallback)(void* userdata);
///
@@ -104,17 +121,17 @@ namespace JinEngine
///
///
///
- void addTransitioni(const std::string& stateFrom, const std::string& stateTo, const std::string& name, int value);
+ void addTransitioni(const std::string& stateFrom, const std::string& stateTo, const std::string& name, ParameterExpression condition, int value);
///
///
///
- void addTransitionf(const std::string& stateFrom, const std::string& stateTo, const std::string& name, float value);
+ void addTransitionf(const std::string& stateFrom, const std::string& stateTo, const std::string& name, ParameterExpression condition, float value);
///
///
///
- void addTransitionb(const std::string& stateFrom, const std::string& stateTo, const std::string& name, bool value);
+ void addTransitionb(const std::string& stateFrom, const std::string& stateTo, const std::string& name, ParameterExpression condition, bool value);
///
///
@@ -200,21 +217,6 @@ namespace JinEngine
ParameterValue value;
};
- enum ParameterExpression
- {
- //
- INT_BIGGER = 0x02,
- INT_SMALLER = 0x04,
- INT_EQUAL = 0x08,
- //
- FLOAT_BIGGER = 0x10,
- FLOAT_SMALLER = 0x20,
- FLOAT_EQUAL = 0x40,
- //
- BOOL_IS = 0x80,
- BOOL_NOT = 0x100,
- };
-
///
/// Traslation's condition.
///
diff --git a/src/lua/embed/boot.lua.h b/src/lua/embed/boot.lua.h
index 2369b0f..0884188 100644
--- a/src/lua/embed/boot.lua.h
+++ b/src/lua/embed/boot.lua.h
@@ -19,6 +19,7 @@ jin.config.title = jin.config.title or ("jin v" .. jin.version)
jin.config.resizable = jin.config.resizable or false
jin.config.fullscreen = jin.config.fullscreen or false
jin.config.fps = jin.config.fps or 60
+jin.config.icon = jin.config.icon or ""
-------------------------------------------------------------------------
-- Default game loop
@@ -62,6 +63,7 @@ end
-- Display error message.
local function onError(msg)
+ jin.graphics.showWindow()
local err = "Error:\n" .. msg .. "\n" .. debug.traceback()
jin.graphics.reset()
jin.graphics.setClearColor(100, 100, 100, 255)
@@ -80,7 +82,7 @@ end
-- No game screen.
local function noGame()
- jin.graphics.reset()
+ jin.graphics.showWindow()
jin.graphics.reset()
jin.graphics.setClearColor(100, 100, 100, 255)
jin.graphics.clear()
@@ -114,6 +116,10 @@ end
jin.audio.init()
jin.graphics.init(jin.config)
+-------------------------------------------------------------------------
+-- Boot game
+-------------------------------------------------------------------------
+
xpcall(boot, onError)
-------------------------------------------------------------------------
diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp
index 7efb2e7..c45a939 100644
--- a/src/lua/modules/graphics/je_lua_graphics.cpp
+++ b/src/lua/modules/graphics/je_lua_graphics.cpp
@@ -42,6 +42,7 @@ namespace JinEngine
setting.width = luax_getfieldinteger(L, 1, "width");
setting.height = luax_getfieldinteger(L, 1, "height");
setting.title = luax_getfieldstring(L, 1, "title");
+ setting.icon = luax_getfieldstring(L, 1, "icon");
setting.vsync = luax_getfieldbool(L, 1, "vsync");
setting.fullscreen = luax_getfieldbool(L, 1, "fullscreen");
setting.resizable = luax_getfieldbool(L, 1, "resizable");
@@ -77,7 +78,21 @@ namespace JinEngine
wnd->quit();
return 0;
}
-
+
+ LUA_IMPLEMENT int l_showWindow(lua_State* L)
+ {
+ Window* wnd = Window::get();
+ wnd->show();
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_hideWindow(lua_State* L)
+ {
+ Window* wnd = Window::get();
+ wnd->hide();
+ return 0;
+ }
+
LUA_IMPLEMENT int l_getSize(lua_State* L)
{
Window* wnd = Window::get();
@@ -742,7 +757,9 @@ namespace JinEngine
{ "getSize", l_getSize },
{ "getWidth", l_getWidth },
{ "getHeight", l_getHeight },
- { "destroy", l_destroy },
+ { "destroy", l_destroy },
+ { "hideWindow", l_hideWindow },
+ { "showWindow", l_showWindow },
/* creators */
{ "newBitmap", l_newBitmap },
{ "newTexture", l_newTexture },