Forráskód Böngészése

Fixed event handling broken by class system change, added equality operator to Lua classes that uses __ptr equality, changed Lua examples to use IDE project filenames, fixed old code so all examples work in the IDE, fixed positional ScreenSounds, added static constructor for ScreenLines to use in Lua

Ivan Safrin 13 éve
szülő
commit
ae751ec28f
91 módosított fájl, 540 hozzáadás és 451 törlés
  1. 6 0
      Bindings/Contents/LUA/API/class.lua
  2. 7 9
      Bindings/Scripts/create_lua_library/create_lua_library.py
  3. 2 0
      Core/Contents/Include/PolyEntity.h
  4. 1 0
      Core/Contents/Include/PolyScreenLine.h
  5. 6 2
      Core/Contents/Source/PolyEntity.cpp
  6. 5 0
      Core/Contents/Source/PolyScreenLine.cpp
  7. 4 3
      Core/Contents/Source/PolyScreenSound.cpp
  8. 8 0
      Examples/Lua/2D_Graphics/2DParticles/2DParticles.polyproject
  9. 0 7
      Examples/Lua/2D_Graphics/2DParticles/2DParticles.xml
  10. 0 0
      Examples/Lua/2D_Graphics/2DParticles/Resources/particle.png
  11. 6 3
      Examples/Lua/2D_Graphics/2DParticles/Scripts/2DParticles.lua
  12. 0 9
      Examples/Lua/2D_Graphics/2DTransforms/2DTransforms.lua
  13. 8 0
      Examples/Lua/2D_Graphics/2DTransforms/2DTransforms.polyproject
  14. 0 7
      Examples/Lua/2D_Graphics/2DTransforms/2DTransforms.xml
  15. 0 0
      Examples/Lua/2D_Graphics/2DTransforms/Resources/polycode_logo.png
  16. 22 0
      Examples/Lua/2D_Graphics/2DTransforms/Scripts/2DTransforms.lua
  17. 0 3
      Examples/Lua/2D_Graphics/BasicImage/BasicImage.lua
  18. 8 0
      Examples/Lua/2D_Graphics/BasicImage/BasicImage.polyproject
  19. 0 7
      Examples/Lua/2D_Graphics/BasicImage/BasicImage.xml
  20. 0 0
      Examples/Lua/2D_Graphics/BasicImage/Resources/polycode_logo.png
  21. 5 0
      Examples/Lua/2D_Graphics/BasicImage/Scripts/BasicImage.lua
  22. 7 0
      Examples/Lua/2D_Graphics/BasicText/BasicText.polyproject
  23. 0 4
      Examples/Lua/2D_Graphics/BasicText/BasicText.xml
  24. 2 0
      Examples/Lua/2D_Graphics/BasicText/Scripts/BasicText.lua
  25. 7 0
      Examples/Lua/2D_Graphics/ScreenEntities/ScreenEntities.polyproject
  26. 0 4
      Examples/Lua/2D_Graphics/ScreenEntities/ScreenEntities.xml
  27. 10 4
      Examples/Lua/2D_Graphics/ScreenEntities/Scripts/ScreenEntities.lua
  28. 0 12
      Examples/Lua/2D_Physics/2DPhysics_Basic/2DPhysics_Basic.lua
  29. 10 0
      Examples/Lua/2D_Physics/2DPhysics_Basic/2DPhysics_Basic.polyproject
  30. 0 7
      Examples/Lua/2D_Physics/2DPhysics_Basic/2DPhysics_Basic.xml
  31. 20 0
      Examples/Lua/2D_Physics/2DPhysics_Basic/Scripts/2DPhysics_Basic.lua
  32. 10 0
      Examples/Lua/2D_Physics/2DPhysics_CollisionOnly/2DPhysics_CollisionOnly.polyproject
  33. 0 7
      Examples/Lua/2D_Physics/2DPhysics_CollisionOnly/2DPhysics_CollisionOnly.xml
  34. 14 13
      Examples/Lua/2D_Physics/2DPhysics_CollisionOnly/Scripts/2DPhysics_CollisionOnly.lua
  35. 11 0
      Examples/Lua/2D_Physics/2DPhysics_Contacts/2DPhysics_Contacts.polyproject
  36. 0 10
      Examples/Lua/2D_Physics/2DPhysics_Contacts/2DPhysics_Contacts.xml
  37. 0 0
      Examples/Lua/2D_Physics/2DPhysics_Contacts/Resources/collision.wav
  38. 9 8
      Examples/Lua/2D_Physics/2DPhysics_Contacts/Scripts/2DPhysics_Contacts.lua
  39. 10 0
      Examples/Lua/2D_Physics/2DPhysics_Joints/2DPhysics_Joints.polyproject
  40. 0 7
      Examples/Lua/2D_Physics/2DPhysics_Joints/2DPhysics_Joints.xml
  41. 10 10
      Examples/Lua/2D_Physics/2DPhysics_Joints/Scripts/2DPhysics_Joints.lua
  42. 0 20
      Examples/Lua/2D_Physics/2DPhysics_PointCollision/2DPhysics_PointCollision.lua
  43. 10 0
      Examples/Lua/2D_Physics/2DPhysics_PointCollision/2DPhysics_PointCollision.polyproject
  44. 0 7
      Examples/Lua/2D_Physics/2DPhysics_PointCollision/2DPhysics_PointCollision.xml
  45. 18 0
      Examples/Lua/2D_Physics/2DPhysics_PointCollision/Scripts/2DPhysics_PointCollision.lua
  46. 0 13
      Examples/Lua/3D_Graphics/3DBasics/3DBasics.lua
  47. 8 0
      Examples/Lua/3D_Graphics/3DBasics/3DBasics.polyproject
  48. 0 8
      Examples/Lua/3D_Graphics/3DBasics/3DBasics.xml
  49. 0 0
      Examples/Lua/3D_Graphics/3DBasics/Resources/green_texture.png
  50. 0 0
      Examples/Lua/3D_Graphics/3DBasics/Resources/pink_texture.png
  51. 15 0
      Examples/Lua/3D_Graphics/3DBasics/Scripts/3DBasics.lua
  52. 8 0
      Examples/Lua/3D_Graphics/AdvancedLighting/AdvancedLighting.polyproject
  53. 0 7
      Examples/Lua/3D_Graphics/AdvancedLighting/AdvancedLighting.xml
  54. 38 25
      Examples/Lua/3D_Graphics/AdvancedLighting/Resources/example.mat
  55. 23 9
      Examples/Lua/3D_Graphics/AdvancedLighting/Scripts/AdvancedLighting.lua
  56. 0 18
      Examples/Lua/3D_Graphics/BasicLighting/BasicLighting.lua
  57. 8 0
      Examples/Lua/3D_Graphics/BasicLighting/BasicLighting.polyproject
  58. 0 7
      Examples/Lua/3D_Graphics/BasicLighting/BasicLighting.xml
  59. 38 25
      Examples/Lua/3D_Graphics/BasicLighting/Resources/example.mat
  60. 27 0
      Examples/Lua/3D_Graphics/BasicLighting/Scripts/BasicLighting.lua
  61. 8 0
      Examples/Lua/Audio/2DAudio/2DAudio.polyproject
  62. 0 7
      Examples/Lua/Audio/2DAudio/2DAudio.xml
  63. 0 0
      Examples/Lua/Audio/2DAudio/Resources/test.wav
  64. 7 4
      Examples/Lua/Audio/2DAudio/Scripts/2DAudio.lua
  65. 8 0
      Examples/Lua/Audio/3DAudio/3DAudio.polyproject
  66. 0 7
      Examples/Lua/Audio/3DAudio/3DAudio.xml
  67. 0 0
      Examples/Lua/Audio/3DAudio/Resources/test.wav
  68. 6 3
      Examples/Lua/Audio/3DAudio/Scripts/3DAudio.lua
  69. 0 17
      Examples/Lua/Audio/PlayingSounds/PlayingSounds.lua
  70. 8 0
      Examples/Lua/Audio/PlayingSounds/PlayingSounds.polyproject
  71. 0 7
      Examples/Lua/Audio/PlayingSounds/PlayingSounds.xml
  72. 0 0
      Examples/Lua/Audio/PlayingSounds/Resources/test.wav
  73. 8 0
      Examples/Lua/Audio/PlayingSounds/Scripts/PlayingSounds.lua
  74. 0 22
      Examples/Lua/Events_And_Input/EventHandling/EventHandling.lua
  75. 0 7
      Examples/Lua/Events_And_Input/EventHandling/EventHandling.xml
  76. 0 46
      Examples/Lua/Events_And_Input/KeyboardInput/KeyboardInput.lua
  77. 0 7
      Examples/Lua/Events_And_Input/KeyboardInput/KeyboardInput.xml
  78. 0 33
      Examples/Lua/Events_And_Input/MouseInput/MouseInput.lua
  79. 0 7
      Examples/Lua/Events_And_Input/MouseInput/MouseInput.xml
  80. BIN
      Examples/Lua/Events_And_Input/MouseInput/polycode_logo.png
  81. 8 0
      Examples/Lua/Input/KeyboardInput/KeyboardInput.polyproject
  82. 0 0
      Examples/Lua/Input/KeyboardInput/Resources/polycode_logo.png
  83. 29 0
      Examples/Lua/Input/KeyboardInput/Scripts/KeyboardInput.lua
  84. 8 0
      Examples/Lua/Input/MouseInput/MouseInput.polyproject
  85. 0 0
      Examples/Lua/Input/MouseInput/Resources/polycode_logo.png
  86. 27 0
      Examples/Lua/Input/MouseInput/Scripts/MouseInput.lua
  87. 2 0
      IDE/Contents/Include/PolycodeRemoteDebugger.h
  88. 1 1
      IDE/Contents/Source/ExampleBrowserWindow.cpp
  89. 3 1
      IDE/Contents/Source/PolycodeProject.cpp
  90. 15 6
      IDE/Contents/Source/PolycodeRemoteDebugger.cpp
  91. 1 1
      Modules/Contents/2DPhysics/Source/PolyPhysicsScreen.cpp

+ 6 - 0
Bindings/Contents/LUA/API/class.lua

@@ -1,3 +1,7 @@
+function __areclassesequal(a,b)
+	return a.__ptr == b.__ptr
+end
+
 function class(name)
 function class(name)
 	local cls = {}
 	local cls = {}
 	cls.__classname = name
 	cls.__classname = name
@@ -16,6 +20,8 @@ function class(name)
 		end
 		end
 	end
 	end
 
 
+	cls.__eq = __areclassesequal
+
 	cls.__index = function(t,k)
 	cls.__index = function(t,k)
 		local prototype = rawget(t,"__prototype")
 		local prototype = rawget(t,"__prototype")
 		if prototype ~= nil then
 		if prototype ~= nil then

+ 7 - 9
Bindings/Scripts/create_lua_library/create_lua_library.py

@@ -103,16 +103,14 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 		wrappersHeaderOut += "public:\n"
 		wrappersHeaderOut += "public:\n"
 		wrappersHeaderOut += "	LuaEventHandler() : EventHandler() {}\n"
 		wrappersHeaderOut += "	LuaEventHandler() : EventHandler() {}\n"
 		wrappersHeaderOut += "	void handleEvent(Event *e) {\n"
 		wrappersHeaderOut += "	void handleEvent(Event *e) {\n"
-		wrappersHeaderOut += "		lua_rawgeti( L, LUA_REGISTRYINDEX, wrapperIndex );\n"
+		wrappersHeaderOut += "		lua_getfield(L, LUA_GLOBALSINDEX, \"EventHandler\" );\n"
 		wrappersHeaderOut += "		lua_getfield(L, -1, \"__handleEvent\");\n"
 		wrappersHeaderOut += "		lua_getfield(L, -1, \"__handleEvent\");\n"
 		wrappersHeaderOut += "		lua_rawgeti( L, LUA_REGISTRYINDEX, wrapperIndex );\n"
 		wrappersHeaderOut += "		lua_rawgeti( L, LUA_REGISTRYINDEX, wrapperIndex );\n"
 		wrappersHeaderOut += "		lua_pushlightuserdata(L, e);\n"
 		wrappersHeaderOut += "		lua_pushlightuserdata(L, e);\n"
-		wrappersHeaderOut += "		if(lua_pcall(L, 2, 0, 0) != 0) {\n"
-		wrappersHeaderOut += "			const char *msg = lua_tostring(L, -1);\n"
-		wrappersHeaderOut += "			lua_getfield(L, LUA_GLOBALSINDEX, \"__customError\");\n"
-		wrappersHeaderOut += "			lua_pushstring(L, msg);\n"
-		wrappersHeaderOut += "			lua_call(L, 1, 0);\n"
-		wrappersHeaderOut += "		}\n"
+#		wrappersHeaderOut += "		lua_getfield (L, LUA_GLOBALSINDEX, \"__customError\");\n"
+#		wrappersHeaderOut += "		int errH = lua_gettop(L);\n"
+#		wrappersHeaderOut += "		lua_pcall(L, 2, 0, errH);\n"
+		wrappersHeaderOut += "		lua_pcall(L, 2, 0, 0);\n"
 		wrappersHeaderOut += "	}\n"
 		wrappersHeaderOut += "	}\n"
 		wrappersHeaderOut += "	int wrapperIndex;\n"
 		wrappersHeaderOut += "	int wrapperIndex;\n"
 		wrappersHeaderOut += "	lua_State *L;\n"
 		wrappersHeaderOut += "	lua_State *L;\n"
@@ -497,7 +495,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 						luaClassBindingOut += "function %s:%s(...)\n" % (ckey, ckey)
 						luaClassBindingOut += "function %s:%s(...)\n" % (ckey, ckey)
 						if inherits:
 						if inherits:
 							luaClassBindingOut += "\tif type(arg[1]) == \"table\" and count(arg) == 1 then\n"
 							luaClassBindingOut += "\tif type(arg[1]) == \"table\" and count(arg) == 1 then\n"
-							luaClassBindingOut += "\t\tif \"\"..arg[1]:class() == \"%s\" then\n" % (c["inherits"][0]["class"])
+							luaClassBindingOut += "\t\tif \"\"..arg[1].__classname == \"%s\" then\n" % (c["inherits"][0]["class"])
 							luaClassBindingOut += "\t\t\tself.__ptr = arg[1].__ptr\n"
 							luaClassBindingOut += "\t\t\tself.__ptr = arg[1].__ptr\n"
 							luaClassBindingOut += "\t\t\treturn\n"
 							luaClassBindingOut += "\t\t\treturn\n"
 							luaClassBindingOut += "\t\tend\n"
 							luaClassBindingOut += "\t\tend\n"
@@ -566,7 +564,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 				if ckey == "EventHandler": # See LuaEventHandler above
 				if ckey == "EventHandler": # See LuaEventHandler above
 					luaClassBindingOut += "\n\n"
 					luaClassBindingOut += "\n\n"
 					luaClassBindingOut += "function EventHandler:__handleEvent(event)\n"
 					luaClassBindingOut += "function EventHandler:__handleEvent(event)\n"
-					luaClassBindingOut += "\tevt = Event(\"__skip_ptr__\")\n"
+					luaClassBindingOut += "\tevt = _G[\"Event\"](\"__skip_ptr__\")\n"
 					luaClassBindingOut += "\tevt.__ptr = event\n"
 					luaClassBindingOut += "\tevt.__ptr = event\n"
 					luaClassBindingOut += "\tself:handleEvent(evt)\n"
 					luaClassBindingOut += "\tself:handleEvent(evt)\n"
 					#luaClassBindingOut += "\tself:handleEvent(event)\n"
 					#luaClassBindingOut += "\tself:handleEvent(event)\n"

+ 2 - 0
Core/Contents/Include/PolyEntity.h

@@ -617,6 +617,8 @@ namespace Polycode {
 	
 	
 		protected:
 		protected:
 		
 		
+			void checkTransformSetters();
+		
 			void *userData;
 			void *userData;
 		
 		
 			std::vector<Entity*> children;
 			std::vector<Entity*> children;

+ 1 - 0
Core/Contents/Include/PolyScreenLine.h

@@ -48,6 +48,7 @@ namespace Polycode {
 			ScreenLine(ScreenEntity* target1, ScreenEntity* target2);
 			ScreenLine(ScreenEntity* target1, ScreenEntity* target2);
 			virtual ~ScreenLine();
 			virtual ~ScreenLine();
 			
 			
+			static ScreenLine *ScreenLineBetweenEntities(ScreenEntity* target1, ScreenEntity* target2);			
 
 
 			void Update();
 			void Update();
 			void Render();
 			void Render();

+ 6 - 2
Core/Contents/Source/PolyEntity.cpp

@@ -236,8 +236,7 @@ void Entity::doUpdates() {
 	}	
 	}	
 }
 }
 
 
-void Entity::updateEntityMatrix() {	
-
+void Entity::checkTransformSetters() {
 	if(_position != position) {
 	if(_position != position) {
 		_position = position;
 		_position = position;
 		matrixDirty = true;
 		matrixDirty = true;
@@ -253,6 +252,10 @@ void Entity::updateEntityMatrix() {
 		rebuildRotation();
 		rebuildRotation();
 		matrixDirty = true;
 		matrixDirty = true;
 	}
 	}
+}
+
+void Entity::updateEntityMatrix() {	
+	checkTransformSetters();
 
 
 	if(matrixDirty)
 	if(matrixDirty)
 		rebuildTransformMatrix();
 		rebuildTransformMatrix();
@@ -404,6 +407,7 @@ Vector3 Entity::getScale() const {
 }
 }
 
 
 Matrix4 Entity::getConcatenatedMatrix() {
 Matrix4 Entity::getConcatenatedMatrix() {
+	checkTransformSetters();
 	if(matrixDirty)
 	if(matrixDirty)
 		rebuildTransformMatrix();
 		rebuildTransformMatrix();
 
 

+ 5 - 0
Core/Contents/Source/PolyScreenLine.cpp

@@ -40,6 +40,11 @@ ScreenLine::ScreenLine(Vector2* start, Vector2* end) : ScreenMesh(Mesh::LINE_MES
 	mesh->arrayDirtyMap[RenderDataArray::VERTEX_DATA_ARRAY] = true;	
 	mesh->arrayDirtyMap[RenderDataArray::VERTEX_DATA_ARRAY] = true;	
 }
 }
 
 
+ScreenLine *ScreenLine::ScreenLineBetweenEntities(ScreenEntity* target1, ScreenEntity* target2) {
+	return new ScreenLine(target1, target2);
+}	
+
+
 ScreenLine::ScreenLine(ScreenEntity* target1, ScreenEntity* target2) : ScreenMesh(Mesh::LINE_MESH) {
 ScreenLine::ScreenLine(ScreenEntity* target1, ScreenEntity* target2) : ScreenMesh(Mesh::LINE_MESH) {
 	initMesh();	
 	initMesh();	
 	this->target1 = target1;
 	this->target1 = target1;

+ 4 - 3
Core/Contents/Source/PolyScreenSound.cpp

@@ -38,13 +38,14 @@ void ScreenSoundListener::Update() {
 	Matrix4 finalMatrix = getConcatenatedMatrix();
 	Matrix4 finalMatrix = getConcatenatedMatrix();
 	CoreServices::getInstance()->getSoundManager()->setListenerPosition(finalMatrix.getPosition());
 	CoreServices::getInstance()->getSoundManager()->setListenerPosition(finalMatrix.getPosition());
 
 
-	Vector3 upVector = Vector3(0.0, 0.0, 1.0);
+	Vector3 upVector = Vector3(0.0, 1.0, 0.0);
 		
 		
 	Vector3 direction;
 	Vector3 direction;
 	direction.x = 0;		
 	direction.x = 0;		
 	direction.y = 0;
 	direction.y = 0;
 	direction.z = -1;
 	direction.z = -1;
-	direction = finalMatrix.rotateVector(direction);
+//	direction = finalMatrix.rotateVector(direction);	
+
 	CoreServices::getInstance()->getSoundManager()->setListenerOrientation(direction, upVector);
 	CoreServices::getInstance()->getSoundManager()->setListenerOrientation(direction, upVector);
 
 
 }
 }
@@ -68,7 +69,7 @@ void ScreenSound::Update() {
 	direction.x = 0;		
 	direction.x = 0;		
 	direction.y = 0;
 	direction.y = 0;
 	direction.z = -1;
 	direction.z = -1;
-	direction = finalMatrix.rotateVector(direction);
+//	direction = finalMatrix.rotateVector(direction);
 	sound->setSoundDirection(direction);
 	sound->setSoundDirection(direction);
 	
 	
 }
 }

+ 8 - 0
Examples/Lua/2D_Graphics/2DParticles/2DParticles.polyproject

@@ -0,0 +1,8 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/2DParticles.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <polyarray:packedItems>
+        <item type="folder" path="Resources" />
+        <item type="folder" path="Scripts" />
+    </polyarray:packedItems>
+</PolycodeProject>

+ 0 - 7
Examples/Lua/2D_Graphics/2DParticles/2DParticles.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>2DParticles.lua</entryPoint>
-	<packedItems>
-		<item path="particle.png" type="file"/>
-        </packedItems>
-</PolycodeProject>

+ 0 - 0
Examples/Lua/2D_Graphics/2DParticles/particle.png → Examples/Lua/2D_Graphics/2DParticles/Resources/particle.png


+ 6 - 3
Examples/Lua/2D_Graphics/2DParticles/2DParticles.lua → Examples/Lua/2D_Graphics/2DParticles/Scripts/2DParticles.lua

@@ -1,7 +1,10 @@
+-- 2D Particle emitter example
+
 screen = Screen()
 screen = Screen()
-emitter = ScreenParticleEmitter("particle.png", screen, BILLBOARD_PARTICLE,
-	CONTINUOUS_EMITTER, 4, 200, Vector3(0.0,-50.0,0.0), Vector3(0.0,0.0,0.0),
-	Vector3(20.5, 40.0, 0.0))
+
+emitter = ScreenParticleEmitter("Resources/particle.png", screen, Particle.BILLBOARD_PARTICLE,
+	ParticleEmitter.CONTINUOUS_EMITTER, 4, 200, Vector3(0.0,-50.0,0.0), Vector3(0.0,0.0,0.0),
+	Vector3(20.5, 40.0, 0.0), Vector3(0.0,0.0,0.0))
 
 
 emitter:getEmitter().useScaleCurves = true
 emitter:getEmitter().useScaleCurves = true
 emitter:getEmitter().scaleCurve:addControlPoint2d(0, 0.3)
 emitter:getEmitter().scaleCurve:addControlPoint2d(0, 0.3)

+ 0 - 9
Examples/Lua/2D_Graphics/2DTransforms/2DTransforms.lua

@@ -1,9 +0,0 @@
-screen = Screen()
-for i=0,9 do
-        image = ScreenImage("polycode_logo.png")
-        screen:addChild(image)
-        image:setPosition(160+(42*i), 230)
-        image:setPositionMode(POSITION_CENTER)
-        image:setRotation(45*i)
-        image:setScale(1.0-(0.1*i),1.0-(0.1*i))
-end

+ 8 - 0
Examples/Lua/2D_Graphics/2DTransforms/2DTransforms.polyproject

@@ -0,0 +1,8 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/2DTransforms.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <polyarray:packedItems>
+        <item type="folder" path="Resources" />
+        <item type="folder" path="Scripts" />
+    </polyarray:packedItems>
+</PolycodeProject>

+ 0 - 7
Examples/Lua/2D_Graphics/2DTransforms/2DTransforms.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>2DTransforms.lua</entryPoint>
-	<packedItems>
-		<item path="polycode_logo.png" type="file"/>
-        </packedItems>
-</PolycodeProject>

+ 0 - 0
Examples/Lua/2D_Graphics/2DTransforms/polycode_logo.png → Examples/Lua/2D_Graphics/2DTransforms/Resources/polycode_logo.png


+ 22 - 0
Examples/Lua/2D_Graphics/2DTransforms/Scripts/2DTransforms.lua

@@ -0,0 +1,22 @@
+
+-- Simple example showing how to move, scale and rotate 2d entities
+
+screen = Screen()
+for i=0,9 do
+        image = ScreenImage("Resources/polycode_logo.png")
+        screen:addChild(image)
+
+		-- Set position and position mode. Setting position mode to ScreenEntity.POSITION_CENTER, makes
+		-- the entity's anchor point its middle, rather than its top left.
+		-- Try commenting out that line and see how it affects the transfomrations
+        image.position.x = 160+(42*i)
+		image.position.y = 230
+        image:setPositionMode(ScreenEntity.POSITION_CENTER)
+
+		-- Rotate the image. You can alternatively call image:setPosition(45 * i)
+        image.rotation.roll = 45 * i
+
+		-- Set the image scale. You can alternatively call image:setScale(1.0-(0.1*i), 1.0-(0.1*i))
+        image.scale.x = 1.0-(0.1*i)
+		image.scale.y = 1.0-(0.1*i)
+end

+ 0 - 3
Examples/Lua/2D_Graphics/BasicImage/BasicImage.lua

@@ -1,3 +0,0 @@
-screen = Screen()
-image = ScreenImage("polycode_logo.png")
-screen:addChild(image)

+ 8 - 0
Examples/Lua/2D_Graphics/BasicImage/BasicImage.polyproject

@@ -0,0 +1,8 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/BasicImage.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <packedItems>
+        <item type="folder" path="Resources" />
+        <item type="folder" path="Scripts" />
+    </packedItems>
+</PolycodeProject>

+ 0 - 7
Examples/Lua/2D_Graphics/BasicImage/BasicImage.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>BasicImage.lua</entryPoint>
-	<packedItems>
-		<item path="polycode_logo.png" type="file"/>
-        </packedItems>
-</PolycodeProject>

+ 0 - 0
Examples/Lua/2D_Graphics/BasicImage/polycode_logo.png → Examples/Lua/2D_Graphics/BasicImage/Resources/polycode_logo.png


+ 5 - 0
Examples/Lua/2D_Graphics/BasicImage/Scripts/BasicImage.lua

@@ -0,0 +1,5 @@
+-- Simple example of displaying an image
+
+screen = Screen()
+image = ScreenImage("Resources/polycode_logo.png")
+screen:addChild(image)

+ 7 - 0
Examples/Lua/2D_Graphics/BasicText/BasicText.polyproject

@@ -0,0 +1,7 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/BasicText.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <packedItems>
+        <item type="folder" path="Scripts" />
+    </packedItems>
+</PolycodeProject>

+ 0 - 4
Examples/Lua/2D_Graphics/BasicText/BasicText.xml

@@ -1,4 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>BasicText.lua</entryPoint>
-</PolycodeProject>

+ 2 - 0
Examples/Lua/2D_Graphics/BasicText/BasicText.lua → Examples/Lua/2D_Graphics/BasicText/Scripts/BasicText.lua

@@ -1,3 +1,5 @@
+-- Simple text label example.
+
 screen = Screen()
 screen = Screen()
 label = ScreenLabel("Hello, Polycode!", 32)
 label = ScreenLabel("Hello, Polycode!", 32)
 screen:addChild(label)
 screen:addChild(label)

+ 7 - 0
Examples/Lua/2D_Graphics/ScreenEntities/ScreenEntities.polyproject

@@ -0,0 +1,7 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/ScreenEntities.lua" vSync="true" anisotropyLevel="0" frameRate="90">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <packedItems>
+        <item type="folder" path="Scripts" />
+    </packedItems>
+</PolycodeProject>

+ 0 - 4
Examples/Lua/2D_Graphics/ScreenEntities/ScreenEntities.xml

@@ -1,4 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>ScreenEntities.lua</entryPoint>
-</PolycodeProject>

+ 10 - 4
Examples/Lua/2D_Graphics/ScreenEntities/ScreenEntities.lua → Examples/Lua/2D_Graphics/ScreenEntities/Scripts/ScreenEntities.lua

@@ -1,18 +1,24 @@
+--
+--	This example demonstrates entity hierarchy by simulating a simple solar system.
+--	Since entity transformations are always relative to the entity's parent
+--	so the moon's rotation takes places around the planet, which is its parent.
+--
+
 screen = Screen()
 screen = Screen()
 
 
-sun = ScreenShape(SHAPE_CIRCLE, 100,100, 30)
+sun = ScreenShape(ScreenShape.SHAPE_CIRCLE, 100,100, 30)
 sun:setPosition(640/2, 480/2)
 sun:setPosition(640/2, 480/2)
-sun:setColor(1.0, 0.0, 0, 1)
+sun:setColor(0.7, 0.5, 0.3, 1)
 sun.colorAffectsChildren = false
 sun.colorAffectsChildren = false
 screen:addChild(sun)
 screen:addChild(sun)
 
 
-planet = ScreenShape(SHAPE_CIRCLE, 50,50, 30)
+planet = ScreenShape(ScreenShape.SHAPE_CIRCLE, 50,50, 30)
 planet:setPosition(150,0)
 planet:setPosition(150,0)
 planet:setColor(0.2, 0.8, 0, 1)
 planet:setColor(0.2, 0.8, 0, 1)
 planet.colorAffectsChildren = false
 planet.colorAffectsChildren = false
 sun:addChild(planet)
 sun:addChild(planet)
 
 
-moon = ScreenShape(SHAPE_CIRCLE, 20,20, 30)
+moon = ScreenShape(ScreenShape.SHAPE_CIRCLE, 20,20, 30)
 moon:setPosition(50,0)
 moon:setPosition(50,0)
 moon:setColor(1, 1, 0.6, 1)
 moon:setColor(1, 1, 0.6, 1)
 planet:addChild(moon)
 planet:addChild(moon)

+ 0 - 12
Examples/Lua/2D_Physics/2DPhysics_Basic/2DPhysics_Basic.lua

@@ -1,12 +0,0 @@
-screen = PhysicsScreen(10, 60)
-shape = ScreenShape(SHAPE_RECT, 600,30)
-shape:setColor(0.0,0.0,0.0,1.0)
-shape:setPosition(640/2, 400)
-screen:addPhysicsChild(shape, ENTITY_RECT, true)
-
-for i=0,200 do
-        shape = ScreenShape(SHAPE_RECT, 20,5)
-        shape:setRotation(random(360))
-        shape:setPosition(random(640), random(300))
-        screen:addPhysicsChild(shape, ENTITY_RECT, false);
-end

+ 10 - 0
Examples/Lua/2D_Physics/2DPhysics_Basic/2DPhysics_Basic.polyproject

@@ -0,0 +1,10 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/2DPhysics_Basic.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <polyarray:modules>
+        <module>Physics2D</module>
+    </polyarray:modules>
+    <packedItems>
+        <item type="folder" path="Scripts" />
+    </packedItems>
+</PolycodeProject>

+ 0 - 7
Examples/Lua/2D_Physics/2DPhysics_Basic/2DPhysics_Basic.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>2DPhysics_Basic.lua</entryPoint>
-	<modules>
-		<module>Physics2D</module>
-	</modules>
-</PolycodeProject>

+ 20 - 0
Examples/Lua/2D_Physics/2DPhysics_Basic/Scripts/2DPhysics_Basic.lua

@@ -0,0 +1,20 @@
+
+-- Simple 2D Physics example
+
+screen = PhysicsScreen(10, 60)
+
+-- add a static floor shape
+shape = ScreenShape(ScreenShape.SHAPE_RECT, 600,30)
+shape:setColor(0.0,0.0,0.0,1.0)
+shape.position.x = 640/2
+shape.position.y = 400
+screen:addPhysicsChild(shape, PhysicsScreenEntity.ENTITY_RECT, true)
+
+-- add 200 falling blocks
+for i=0,200 do
+        shape = ScreenShape(ScreenShape.SHAPE_RECT, 20,5)
+        shape:setRotation(random(360))
+        shape.position.x = random(640)
+		shape.position.y = random(300)
+        screen:addPhysicsChild(shape, PhysicsScreenEntity.ENTITY_RECT, false);
+end

+ 10 - 0
Examples/Lua/2D_Physics/2DPhysics_CollisionOnly/2DPhysics_CollisionOnly.polyproject

@@ -0,0 +1,10 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/2DPhysics_CollisionOnly.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <polyarray:modules>
+        <module>Physics2D</module>
+    </polyarray:modules>
+    <packedItems>
+        <item type="folder" path="Scripts" />
+    </packedItems>
+</PolycodeProject>

+ 0 - 7
Examples/Lua/2D_Physics/2DPhysics_CollisionOnly/2DPhysics_CollisionOnly.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>2DPhysics_CollisionOnly.lua</entryPoint>
-	<modules>
-		<module>Physics2D</module>
-	</modules>
-</PolycodeProject>

+ 14 - 13
Examples/Lua/2D_Physics/2DPhysics_CollisionOnly/2DPhysics_CollisionOnly.lua → Examples/Lua/2D_Physics/2DPhysics_CollisionOnly/Scripts/2DPhysics_CollisionOnly.lua

@@ -2,18 +2,18 @@ class "Detector" (EventHandler)
 
 
 function Detector:Detector(shape)
 function Detector:Detector(shape)
         self.shape = shape
         self.shape = shape
-        self:EventHandler()
+        EventHandler.EventHandler(self)
 end
 end
 
 
 function Detector:handleEvent(e)
 function Detector:handleEvent(e)
         if e:getDispatcher() == screen then
         if e:getDispatcher() == screen then
                 local pe = PhysicsScreenEvent(e)
                 local pe = PhysicsScreenEvent(e)
-                if e:getEventCode() == EVENT_NEW_SHAPE_COLLISION then
+                if e:getEventCode() == PhysicsScreenEvent.EVENT_NEW_SHAPE_COLLISION then
                         if pe:getFirstEntity() == self.shape or pe:getSecondEntity() == self.shape then
                         if pe:getFirstEntity() == self.shape or pe:getSecondEntity() == self.shape then
                                 pe:getFirstEntity():setColor(1.0, 0.0, 0.0, 1.0)
                                 pe:getFirstEntity():setColor(1.0, 0.0, 0.0, 1.0)
                                 pe:getSecondEntity():setColor(1.0, 0.0, 0.0, 1.0)
                                 pe:getSecondEntity():setColor(1.0, 0.0, 0.0, 1.0)
                         end
                         end
-                elseif e:getEventCode() == EVENT_END_SHAPE_COLLISION then
+                elseif e:getEventCode() == PhysicsScreenEvent.EVENT_END_SHAPE_COLLISION then
                         pe:getFirstEntity():setColor(1.0, 1.0, 1.0, 1.0)
                         pe:getFirstEntity():setColor(1.0, 1.0, 1.0, 1.0)
                         pe:getSecondEntity():setColor(1.0, 1.0, 1.0, 1.0)
                         pe:getSecondEntity():setColor(1.0, 1.0, 1.0, 1.0)
                 end
                 end
@@ -22,23 +22,24 @@ end
 
 
 screen = PhysicsScreen(10, 60)
 screen = PhysicsScreen(10, 60)
 
 
-checkShape = ScreenShape(SHAPE_RECT, 90,10)
-screen:addCollisionChild(checkShape, ENTITY_RECT)
+checkShape = ScreenShape(ScreenShape.SHAPE_RECT, 90,10)
+screen:addCollisionChild(checkShape, PhysicsScreenEntity.ENTITY_RECT)
 
 
 for i=0,50 do
 for i=0,50 do
-        shape = ScreenShape(SHAPE_RECT, 30,15)
+        shape = ScreenShape(ScreenShape.SHAPE_RECT, 30,15)
         shape:setRotation(random(360))
         shape:setRotation(random(360))
         shape:setPosition(random(640), random(480))
         shape:setPosition(random(640), random(480))
-        screen:addCollisionChild(shape, ENTITY_RECT)
+        screen:addCollisionChild(shape, PhysicsScreenEntity.ENTITY_RECT)
 end
 end
 
 
 detector = Detector(checkShape)
 detector = Detector(checkShape)
-screen:addEventListener(detector, EVENT_NEW_SHAPE_COLLISION)
-screen:addEventListener(detector, EVENT_END_SHAPE_COLLISION)
+screen:addEventListener(detector, PhysicsScreenEvent.EVENT_NEW_SHAPE_COLLISION)
+screen:addEventListener(detector, PhysicsScreenEvent.EVENT_END_SHAPE_COLLISION)
+
+function onMouseMove(x,y)
+	checkShape:setPosition(x,y)
+end
 
 
 function Update(e)
 function Update(e)
-        local mouse = Services.Core:getInput():getMousePosition()
-        checkShape:setPosition(mouse.x, mouse.y)
-        checkShape:setRotation(checkShape:getRotation() + (e*100))
-        delete(mouse)
+	checkShape:setRotation(checkShape:getRotation() + (e*100))
 end
 end

+ 11 - 0
Examples/Lua/2D_Physics/2DPhysics_Contacts/2DPhysics_Contacts.polyproject

@@ -0,0 +1,11 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/2DPhysics_Contacts.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <polyarray:modules>
+        <module>Physics2D</module>
+    </polyarray:modules>
+    <polyarray:packedItems>
+        <item type="folder" path="Resources" />
+        <item type="folder" path="Scripts" />
+    </polyarray:packedItems>
+</PolycodeProject>

+ 0 - 10
Examples/Lua/2D_Physics/2DPhysics_Contacts/2DPhysics_Contacts.xml

@@ -1,10 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>2DPhysics_Contacts.lua</entryPoint>
-	<modules>
-		<module>Physics2D</module>
-	</modules>
-	<packedItems>
-		<item path="collision.wav" type="file"/>
-        </packedItems>
-</PolycodeProject>

+ 0 - 0
Examples/Lua/2D_Physics/2DPhysics_Contacts/collision.wav → Examples/Lua/2D_Physics/2DPhysics_Contacts/Resources/collision.wav


+ 9 - 8
Examples/Lua/2D_Physics/2DPhysics_Contacts/2DPhysics_Contacts.lua → Examples/Lua/2D_Physics/2DPhysics_Contacts/Scripts/2DPhysics_Contacts.lua

@@ -1,14 +1,14 @@
 class "ImpactNoise" (EventHandler)
 class "ImpactNoise" (EventHandler)
 
 
 function ImpactNoise:ImpactNoise()
 function ImpactNoise:ImpactNoise()
-        self.collisionSound = Sound("collision.wav")
-        self:EventHandler()
+        self.collisionSound = Sound("Resources/collision.wav")
+        EventHandler.EventHandler(self)
 end
 end
 
 
 function ImpactNoise:handleEvent(e)
 function ImpactNoise:handleEvent(e)
         if e:getDispatcher() == screen then
         if e:getDispatcher() == screen then
                 local pe = PhysicsScreenEvent(e)
                 local pe = PhysicsScreenEvent(e)
-                if e:getEventCode() == EVENT_NEW_SHAPE_COLLISION then
+                if e:getEventCode() == PhysicsScreenEvent.EVENT_NEW_SHAPE_COLLISION then
                         if pe.impactStrength > 5 then
                         if pe.impactStrength > 5 then
                                 self.collisionSound:Play()
                                 self.collisionSound:Play()
                         end
                         end
@@ -17,18 +17,19 @@ function ImpactNoise:handleEvent(e)
 end
 end
 
 
 screen = PhysicsScreen(10, 60)
 screen = PhysicsScreen(10, 60)
-shape = ScreenShape(SHAPE_RECT, 600,30)
+shape = ScreenShape(ScreenShape.SHAPE_RECT, 600,30)
 shape:setColor(0.0,0.0,0.0,1.0)
 shape:setColor(0.0,0.0,0.0,1.0)
 shape:setPosition(640/2, 400)
 shape:setPosition(640/2, 400)
-screen:addPhysicsChild(shape, ENTITY_RECT, true)
+screen:addPhysicsChild(shape, PhysicsScreenEntity.ENTITY_RECT, true)
 
 
 for i=0,50 do
 for i=0,50 do
-        shape = ScreenShape(SHAPE_RECT, 20,5)
+        shape = ScreenShape(ScreenShape.SHAPE_RECT, 20,5)
         shape:setRotation(random(360))
         shape:setRotation(random(360))
         shape:setPosition(random(640), random(300))
         shape:setPosition(random(640), random(300))
-        screen:addPhysicsChild(shape, ENTITY_RECT, false)
+        screen:addPhysicsChild(shape, PhysicsScreenEntity.ENTITY_RECT, false)
 end
 end
 
 
+
 noiseMaker = ImpactNoise()
 noiseMaker = ImpactNoise()
 
 
-screen:addEventListener(noiseMaker, EVENT_NEW_SHAPE_COLLISION)
+screen:addEventListener(noiseMaker, PhysicsScreenEvent.EVENT_NEW_SHAPE_COLLISION)

+ 10 - 0
Examples/Lua/2D_Physics/2DPhysics_Joints/2DPhysics_Joints.polyproject

@@ -0,0 +1,10 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/2DPhysics_Joints.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <polyarray:modules>
+        <module>Physics2D</module>
+    </polyarray:modules>
+    <packedItems>
+        <item type="folder" path="Scripts" />
+    </packedItems>
+</PolycodeProject>

+ 0 - 7
Examples/Lua/2D_Physics/2DPhysics_Joints/2DPhysics_Joints.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>2DPhysics_Joints.lua</entryPoint>
-	<modules>
-		<module>Physics2D</module>
-	</modules>
-</PolycodeProject>

+ 10 - 10
Examples/Lua/2D_Physics/2DPhysics_Joints/2DPhysics_Joints.lua → Examples/Lua/2D_Physics/2DPhysics_Joints/Scripts/2DPhysics_Joints.lua

@@ -1,36 +1,36 @@
 screen = PhysicsScreen(10, 50)
 screen = PhysicsScreen(10, 50)
 
 
-ceiling = ScreenShape(SHAPE_RECT, 640, 20)
+ceiling = ScreenShape(ScreenShape.SHAPE_RECT, 640, 20)
 ceiling:setColor(0.0, 0.0, 0.0, 1.0)
 ceiling:setColor(0.0, 0.0, 0.0, 1.0)
 ceiling:setPosition(640/2, 10)
 ceiling:setPosition(640/2, 10)
-screen:addPhysicsChild(ceiling, ENTITY_RECT, true)
+screen:addPhysicsChild(ceiling, PhysicsScreenEntity.ENTITY_RECT, true)
 
 
 -- Revolute Joint
 -- Revolute Joint
-shape = ScreenShape(SHAPE_RECT, 10, 30)
+shape = ScreenShape(ScreenShape.SHAPE_RECT, 10, 30)
 shape:setPosition(150, 20+15)
 shape:setPosition(150, 20+15)
-screen:addPhysicsChild(shape, ENTITY_RECT, false)
+screen:addPhysicsChild(shape, PhysicsScreenEntity.ENTITY_RECT, false)
 screen:createRevoluteJoint(shape, ceiling, 0, -15)
 screen:createRevoluteJoint(shape, ceiling, 0, -15)
 screen:applyImpulse(shape, 10, 0)
 screen:applyImpulse(shape, 10, 0)
 
 
 -- Distance Joint
 -- Distance Joint
-shape = ScreenShape(SHAPE_RECT, 10, 30)
+shape = ScreenShape(ScreenShape.SHAPE_RECT, 10, 30)
 shape:setPosition(250, 20+25)
 shape:setPosition(250, 20+25)
-screen:addPhysicsChild(shape, ENTITY_RECT, false)
+screen:addPhysicsChild(shape, PhysicsScreenEntity.ENTITY_RECT, false)
 screen:createDistanceJoint(shape, ceiling, false)
 screen:createDistanceJoint(shape, ceiling, false)
 screen:applyImpulse(shape, 200, 0)
 screen:applyImpulse(shape, 200, 0)
 
 
-line = ScreenLine(shape, ceiling)
+line = ScreenLine.ScreenLineBetweenEntities(shape, ceiling)
 line:setColor(1.0, 0.0, 0.0, 1.0)
 line:setColor(1.0, 0.0, 0.0, 1.0)
 screen:addChild(line)
 screen:addChild(line)
 
 
 -- Prismatic Joint
 -- Prismatic Joint
-shape = ScreenShape(SHAPE_RECT, 10, 30)
+shape = ScreenShape(ScreenShape.SHAPE_RECT, 10, 30)
 shape:setPosition(450, 20+25)
 shape:setPosition(450, 20+25)
-screen:addPhysicsChild(shape, ENTITY_RECT, false)
+screen:addPhysicsChild(shape, PhysicsScreenEntity.ENTITY_RECT, false)
 screen:createPrismaticJoint(ceiling, shape, Vector2(0,1), 0,0, false, 100, 0, true)
 screen:createPrismaticJoint(ceiling, shape, Vector2(0,1), 0,0, false, 100, 0, true)
 
 
 lineAnchor = ScreenEntity()
 lineAnchor = ScreenEntity()
 lineAnchor:setPosition(450,10)
 lineAnchor:setPosition(450,10)
-line = ScreenLine(shape, lineAnchor)
+line = ScreenLine.ScreenLineBetweenEntities(shape, lineAnchor)
 line:setColor(0.0, 1.0, 0.0, 1.0)
 line:setColor(0.0, 1.0, 0.0, 1.0)
 screen:addChild(line)
 screen:addChild(line)

+ 0 - 20
Examples/Lua/2D_Physics/2DPhysics_PointCollision/2DPhysics_PointCollision.lua

@@ -1,20 +0,0 @@
-screen = PhysicsScreen(10, 60)
-lastEntity = nil
-
-for i=0,50 do
-        shape = ScreenShape(SHAPE_RECT, 30,15)
-        shape:setRotation(random(360))
-        shape:setPosition(random(640), random(480))
-        screen:addCollisionChild(shape, ENTITY_RECT)
-end
-
-function Update(e)
-        if lastEntity ~= nil then lastEntity:setColor(1.0,1.0,1.0,1.0) end
-        local mouse = Services.Core:getInput():getMousePosition()
-        local entity = screen:getEntityAtPosition(mouse.x, mouse.y)
-        if entity ~= nil then
-                entity:setColor(1.0, 0.0, 0.0, 1.0)
-                lastEntity = entity
-        end
-        delete(mouse)
-end

+ 10 - 0
Examples/Lua/2D_Physics/2DPhysics_PointCollision/2DPhysics_PointCollision.polyproject

@@ -0,0 +1,10 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/2DPhysics_PointCollision.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <polyarray:modules>
+        <module>Physics2D</module>
+    </polyarray:modules>
+    <packedItems>
+        <item type="folder" path="Scripts" />
+    </packedItems>
+</PolycodeProject>

+ 0 - 7
Examples/Lua/2D_Physics/2DPhysics_PointCollision/2DPhysics_PointCollision.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>2DPhysics_PointCollision.lua</entryPoint>
-	<modules>
-		<module>Physics2D</module>
-	</modules>
-</PolycodeProject>

+ 18 - 0
Examples/Lua/2D_Physics/2DPhysics_PointCollision/Scripts/2DPhysics_PointCollision.lua

@@ -0,0 +1,18 @@
+screen = PhysicsScreen(10, 60)
+lastEntity = nil
+
+for i=0,50 do
+	shape = ScreenShape(ScreenShape.SHAPE_RECT, 30,15)
+	shape:setRotation(random(360))
+	shape:setPosition(random(640), random(480))
+	screen:addCollisionChild(shape, PhysicsScreenEntity.ENTITY_RECT)
+end
+
+function onMouseMove(x,y)
+	if lastEntity ~= nil then lastEntity:setColor(1.0,1.0,1.0,1.0) end
+	local entity = screen:getEntityAtPosition(x,y)
+	if entity ~= nil then
+		entity:setColor(1.0, 0.0, 0.0, 1.0)
+		lastEntity = entity
+	end
+end

+ 0 - 13
Examples/Lua/3D_Graphics/3DBasics/3DBasics.lua

@@ -1,13 +0,0 @@
-scene = Scene()
-ground = ScenePrimitive(TYPE_PLANE, 5,5)
-ground:loadTexture("green_texture.png")
-scene:addEntity(ground)
-
-box =  ScenePrimitive(TYPE_BOX, 1,1,1)
-box:loadTexture("pink_texture.png")
-box:setPosition(0.0, 0.5, 0.0)
-scene:addEntity(box)
-
-scene:getDefaultCamera():setPosition(7,7,7)
-scene:getDefaultCamera():lookAt(Vector3(0,0,0), Vector3(0,1,0))
-

+ 8 - 0
Examples/Lua/3D_Graphics/3DBasics/3DBasics.polyproject

@@ -0,0 +1,8 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/3DBasics.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <polyarray:packedItems>
+        <item type="folder" path="Resources" />
+        <item type="folder" path="Scripts" />
+    </polyarray:packedItems>
+</PolycodeProject>

+ 0 - 8
Examples/Lua/3D_Graphics/3DBasics/3DBasics.xml

@@ -1,8 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>3DBasics.lua</entryPoint>
-	<packedItems>
-		<item path="pink_texture.png" type="file"/>
-		<item path="green_texture.png" type="file"/>
-        </packedItems>
-</PolycodeProject>

+ 0 - 0
Examples/Lua/3D_Graphics/3DBasics/green_texture.png → Examples/Lua/3D_Graphics/3DBasics/Resources/green_texture.png


+ 0 - 0
Examples/Lua/3D_Graphics/3DBasics/pink_texture.png → Examples/Lua/3D_Graphics/3DBasics/Resources/pink_texture.png


+ 15 - 0
Examples/Lua/3D_Graphics/3DBasics/Scripts/3DBasics.lua

@@ -0,0 +1,15 @@
+-- Simple 3D example. A box sitting on a plane
+
+scene = Scene()
+ground = ScenePrimitive(ScenePrimitive.TYPE_PLANE, 5,5)
+ground:loadTexture("Resources/green_texture.png")
+scene:addEntity(ground)
+
+box =  ScenePrimitive(ScenePrimitive.TYPE_BOX, 1,1,1)
+box:loadTexture("Resources/pink_texture.png")
+box:setPosition(0.0, 0.5, 0.0)
+scene:addEntity(box)
+
+scene:getDefaultCamera():setPosition(7,7,7)
+scene:getDefaultCamera():lookAt(Vector3(0,0,0), Vector3(0,1,0))
+

+ 8 - 0
Examples/Lua/3D_Graphics/AdvancedLighting/AdvancedLighting.polyproject

@@ -0,0 +1,8 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/AdvancedLighting.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <polyarray:packedItems>
+        <item type="folder" path="Resources" />
+        <item type="folder" path="Scripts" />
+    </polyarray:packedItems>
+</PolycodeProject>

+ 0 - 7
Examples/Lua/3D_Graphics/AdvancedLighting/AdvancedLighting.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>AdvancedLighting.lua</entryPoint>
-	<packedItems>
-		<item path="Resources" type="folder"/>
-        </packedItems>
-</PolycodeProject>

+ 38 - 25
Examples/Lua/3D_Graphics/AdvancedLighting/Resources/example.mat

@@ -1,26 +1,39 @@
 <?xml version="1.0" ?>
 <?xml version="1.0" ?>
-<polycode>	
-	<materials>
-		<material name="TestParticle">
-			<shader name="DefaultParticleShader">
-				<textures>
-					<texture name="diffuse">particle.png</texture>
-				</textures>
-			</shader>
-		</material>	
-		<material name="CubeMaterial">
-			<shader name="DefaultShaderShadows">
-				<textures>
-					<texture name="diffuse">pink_texture.png</texture>
-				</textures>
-			</shader>
-		</material>			
-		<material name="GroundMaterial">
-			<shader name="DefaultShaderShadows">
-				<textures>
-					<texture name="diffuse">green_texture.png</texture>
-				</textures>
-			</shader>
-		</material>					
-	</materials>
-</polycode>
+<polycode_material_library>
+    <materials>
+        <material name="TestParticle" blendingMode="0">
+            <shader name="DefaultParticleShader">
+                <textures>
+                    <texture name="diffuse">default/default.png</texture>
+                </textures>
+                <params>
+                    <param name="diffuse_color" type="Color" value="1.00 1.00 1.00 1.00" />
+                </params>
+            </shader>
+        </material>
+        <material name="CubeMaterial" blendingMode="0">
+            <shader name="DefaultShaderShadows">
+                <textures>
+                    <texture name="diffuse">Resources/pink_texture.png</texture>
+                </textures>
+                <params>
+                    <param name="shininess" type="Number" value="50.00" />
+                    <param name="diffuse_color" type="Color" value="1.00 1.00 1.00 1.00" />
+                    <param name="specular_color" type="Color" value="1.00 1.00 1.00 1.00" />
+                </params>
+            </shader>
+        </material>
+        <material name="GroundMaterial" blendingMode="0">
+            <shader name="DefaultShaderShadows">
+                <textures>
+                    <texture name="diffuse">Resources/green_texture.png</texture>
+                </textures>
+                <params>
+                    <param name="shininess" type="Number" value="50.00" />
+                    <param name="diffuse_color" type="Color" value="1.00 1.00 1.00 1.00" />
+                    <param name="specular_color" type="Color" value="0.00 0.00 0.00 1.00" />
+                </params>
+            </shader>
+        </material>
+    </materials>
+</polycode_material_library>

+ 23 - 9
Examples/Lua/3D_Graphics/AdvancedLighting/AdvancedLighting.lua → Examples/Lua/3D_Graphics/AdvancedLighting/Scripts/AdvancedLighting.lua

@@ -1,50 +1,64 @@
 Services.ResourceManager:addDirResource("Resources", false)
 Services.ResourceManager:addDirResource("Resources", false)
 
 
 scene = Scene()
 scene = Scene()
-ground = ScenePrimitive(TYPE_PLANE, 5,5)
+ground = ScenePrimitive(ScenePrimitive.TYPE_PLANE, 5,5)
 ground:setMaterialByName("GroundMaterial")
 ground:setMaterialByName("GroundMaterial")
 scene:addEntity(ground)
 scene:addEntity(ground)
 
 
-box =  ScenePrimitive(TYPE_TORUS, 0.8,0.3,30,20)
+box =  ScenePrimitive(ScenePrimitive.TYPE_TORUS, 0.8,0.3,30,20)
 box:setMaterialByName("CubeMaterial")
 box:setMaterialByName("CubeMaterial")
 box:setPosition(0.0, 0.5, 0.0)
 box:setPosition(0.0, 0.5, 0.0)
 scene:addEntity(box)
 scene:addEntity(box)
 
 
-light = SceneLight(AREA_LIGHT, scene, 20)
+lightBase = SceneEntity()
+
+light = SceneLight(SceneLight.AREA_LIGHT, scene, 20)
 light:setPosition(3,2,7)
 light:setPosition(3,2,7)
 light:setLightColor(1,0,0)
 light:setLightColor(1,0,0)
 scene:addLight(light)
 scene:addLight(light)
+lightBase:addChild(light)
 
 
-light = SceneLight(AREA_LIGHT, scene, 20)
+light = SceneLight(SceneLight.AREA_LIGHT, scene, 20)
 light:setPosition(-3,2,7)
 light:setPosition(-3,2,7)
 light:setLightColor(0,1,0)
 light:setLightColor(0,1,0)
 scene:addLight(light)
 scene:addLight(light)
+lightBase:addChild(light)
 
 
-light = SceneLight(AREA_LIGHT, scene, 20)
+light = SceneLight(SceneLight.AREA_LIGHT, scene, 20)
 light:setPosition(-3,2,-7)
 light:setPosition(-3,2,-7)
 light:setLightColor(0,0,1)
 light:setLightColor(0,0,1)
 scene:addLight(light)
 scene:addLight(light)
+lightBase:addChild(light)
 
 
-light = SceneLight(AREA_LIGHT, scene, 20)
+light = SceneLight(SceneLight.AREA_LIGHT, scene, 20)
 light:setPosition(3,2,-7)
 light:setPosition(3,2,-7)
 light:setLightColor(1,0,1)
 light:setLightColor(1,0,1)
 scene:addLight(light)
 scene:addLight(light)
+lightBase:addChild(light)
 
 
-light = SceneLight(SPOT_LIGHT, scene, 5)
+light = SceneLight(SceneLight.SPOT_LIGHT, scene, 5)
 light:setPosition(0,2,2)
 light:setPosition(0,2,2)
 light:setSpotlightProperties(30,6)
 light:setSpotlightProperties(30,6)
 light:setLightColor(1,1,0)
 light:setLightColor(1,1,0)
 scene:addLight(light)
 scene:addLight(light)
+lightBase:addChild(light)
+
 light:lookAt(Vector3(0,0,0), Vector3(0,1,0))
 light:lookAt(Vector3(0,0,0), Vector3(0,1,0))
 light:enableShadows(true)
 light:enableShadows(true)
 
 
-light = SceneLight(SPOT_LIGHT, scene, 5)
+light = SceneLight(SceneLight.SPOT_LIGHT, scene, 5)
 light:setPosition(0,2,-2)
 light:setPosition(0,2,-2)
 light:setSpotlightProperties(30,6)
 light:setSpotlightProperties(30,6)
 light:setLightColor(0,1,1)
 light:setLightColor(0,1,1)
 scene:addLight(light)
 scene:addLight(light)
+lightBase:addChild(light)
 light:lookAt(Vector3(0,0,0), Vector3(0,1,0))
 light:lookAt(Vector3(0,0,0), Vector3(0,1,0))
 light:enableShadows(true)
 light:enableShadows(true)
 
 
-scene:getDefaultCamera():setPosition(7,7,7)
+scene:getDefaultCamera():setPosition(5,5,5)
 scene:getDefaultCamera():lookAt(Vector3(0,0,0), Vector3(0,1,0))
 scene:getDefaultCamera():lookAt(Vector3(0,0,0), Vector3(0,1,0))
+
+function Update(elapsed)
+	lightBase.rotation.yaw = lightBase.rotation.yaw + (elapsed * 10.0)
+end
+

+ 0 - 18
Examples/Lua/3D_Graphics/BasicLighting/BasicLighting.lua

@@ -1,18 +0,0 @@
-Services.ResourceManager:addDirResource("Resources", false)
-
-scene = Scene()
-ground = ScenePrimitive(TYPE_PLANE, 5,5)
-ground:setMaterialByName("GroundMaterial")
-scene:addEntity(ground)
-
-box =  ScenePrimitive(TYPE_TORUS, 0.8,0.3,30,20)
-box:setMaterialByName("CubeMaterial")
-box:setPosition(0.0, 0.5, 0.0)
-scene:addEntity(box)
-
-light = SceneLight(AREA_LIGHT, scene, 6)
-light:setPosition(1,2,1)
-scene:addLight(light)
-
-scene:getDefaultCamera():setPosition(7,7,7)
-scene:getDefaultCamera():lookAt(Vector3(0,0,0), Vector3(0,1,0))

+ 8 - 0
Examples/Lua/3D_Graphics/BasicLighting/BasicLighting.polyproject

@@ -0,0 +1,8 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/BasicLighting.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <polyarray:packedItems>
+        <item type="folder" path="Resources" />
+        <item type="folder" path="Scripts" />
+    </polyarray:packedItems>
+</PolycodeProject>

+ 0 - 7
Examples/Lua/3D_Graphics/BasicLighting/BasicLighting.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>BasicLighting.lua</entryPoint>
-	<packedItems>
-		<item path="Resources" type="folder"/>
-        </packedItems>
-</PolycodeProject>

+ 38 - 25
Examples/Lua/3D_Graphics/BasicLighting/Resources/example.mat

@@ -1,26 +1,39 @@
 <?xml version="1.0" ?>
 <?xml version="1.0" ?>
-<polycode>	
-	<materials>
-		<material name="TestParticle">
-			<shader name="DefaultParticleShader">
-				<textures>
-					<texture name="diffuse">particle.png</texture>
-				</textures>
-			</shader>
-		</material>	
-		<material name="CubeMaterial">
-			<shader name="DefaultShaderShadows">
-				<textures>
-					<texture name="diffuse">pink_texture.png</texture>
-				</textures>
-			</shader>
-		</material>			
-		<material name="GroundMaterial">
-			<shader name="DefaultShaderShadows">
-				<textures>
-					<texture name="diffuse">green_texture.png</texture>
-				</textures>
-			</shader>
-		</material>					
-	</materials>
-</polycode>
+<polycode_material_library>
+    <materials>
+        <material name="TestParticle" blendingMode="0">
+            <shader name="DefaultParticleShader">
+                <textures>
+                    <texture name="diffuse">default/default.png</texture>
+                </textures>
+                <params>
+                    <param name="diffuse_color" type="Color" value="1.00 1.00 1.00 1.00" />
+                </params>
+            </shader>
+        </material>
+        <material name="CubeMaterial" blendingMode="0">
+            <shader name="DefaultShader">
+                <textures>
+                    <texture name="diffuse">Resources/pink_texture.png</texture>
+                </textures>
+                <params>
+                    <param name="shininess" type="Number" value="50.00" />
+                    <param name="diffuse_color" type="Color" value="1.00 1.00 1.00 1.00" />
+                    <param name="specular_color" type="Color" value="1.00 1.00 1.00 1.00" />
+                </params>
+            </shader>
+        </material>
+        <material name="GroundMaterial" blendingMode="0">
+            <shader name="DefaultShader">
+                <textures>
+                    <texture name="diffuse">Resources/green_texture.png</texture>
+                </textures>
+                <params>
+                    <param name="shininess" type="Number" value="4.72" />
+                    <param name="diffuse_color" type="Color" value="1.00 1.00 1.00 1.00" />
+                    <param name="specular_color" type="Color" value="0.00 0.00 0.00 1.00" />
+                </params>
+            </shader>
+        </material>
+    </materials>
+</polycode_material_library>

+ 27 - 0
Examples/Lua/3D_Graphics/BasicLighting/Scripts/BasicLighting.lua

@@ -0,0 +1,27 @@
+-- 3D lighting and materials example
+
+Services.ResourceManager:addDirResource("Resources", false)
+
+scene = Scene()
+ground = ScenePrimitive(ScenePrimitive.TYPE_PLANE, 5,5)
+ground:setMaterialByName("GroundMaterial")
+scene:addEntity(ground)
+scene.ambientColor:setColor(0.2, 0.2, 0.2, 1.0)
+
+box =  ScenePrimitive(ScenePrimitive.TYPE_TORUS, 0.8,0.3,30,20)
+box:setMaterialByName("CubeMaterial")
+box:setPosition(0.0, 0.5, 0.0)
+scene:addEntity(box)
+
+light = SceneLight(SceneLight.AREA_LIGHT, scene, 6)
+scene:addLight(light)
+
+scene:getDefaultCamera():setPosition(5,5,5)
+scene:getDefaultCamera():lookAt(Vector3(0,0,0), Vector3(0,1,0))
+
+lightPositionVal = 0
+
+function Update(elapsed)
+	lightPositionVal = lightPositionVal + elapsed
+	light:setPosition(sin(lightPositionVal), 2.0, sin(lightPositionVal))
+end

+ 8 - 0
Examples/Lua/Audio/2DAudio/2DAudio.polyproject

@@ -0,0 +1,8 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/2DAudio.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <polyarray:packedItems>
+        <item type="folder" path="Resources" />
+        <item type="folder" path="Scripts" />
+    </polyarray:packedItems>
+</PolycodeProject>

+ 0 - 7
Examples/Lua/Audio/2DAudio/2DAudio.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>2DAudio.lua</entryPoint>
-	<packedItems>
-		<item path="test.wav" type="file"/>
-        </packedItems>
-</PolycodeProject>

+ 0 - 0
Examples/Lua/Audio/2DAudio/test.wav → Examples/Lua/Audio/2DAudio/Resources/test.wav


+ 7 - 4
Examples/Lua/Audio/2DAudio/2DAudio.lua → Examples/Lua/Audio/2DAudio/Scripts/2DAudio.lua

@@ -1,17 +1,21 @@
+
+-- Basic 2D positional sound example
+
 screen = Screen()
 screen = Screen()
 
 
 sourceEntity = ScreenEntity()
 sourceEntity = ScreenEntity()
-testSound = ScreenSound("test.wav", 200, 600)
+testSound = ScreenSound("Resources/test.wav", 200, 600)
 testSound:getSound():Play(true)
 testSound:getSound():Play(true)
 sourceEntity:addChild(testSound)
 sourceEntity:addChild(testSound)
-soundShape = ScreenShape(SHAPE_CIRCLE, 20,20,10)
+soundShape = ScreenShape(ScreenShape.SHAPE_CIRCLE, 20,20,10)
 sourceEntity:addChild(soundShape)
 sourceEntity:addChild(soundShape)
 screen:addChild(sourceEntity)
 screen:addChild(sourceEntity)
 
 
 listenerEntity = ScreenEntity()
 listenerEntity = ScreenEntity()
 soundListener = ScreenSoundListener()
 soundListener = ScreenSoundListener()
 listenerEntity:addChild(soundListener)
 listenerEntity:addChild(soundListener)
-soundShape = ScreenShape(SHAPE_CIRCLE, 20,20,10)
+
+soundShape = ScreenShape(ScreenShape.SHAPE_CIRCLE, 20,20,10)
 soundShape:setColor(0.0, 1.0, 0.0, 1.0)
 soundShape:setColor(0.0, 1.0, 0.0, 1.0)
 listenerEntity:addChild(soundShape)
 listenerEntity:addChild(soundShape)
 screen:addChild(listenerEntity)
 screen:addChild(listenerEntity)
@@ -22,7 +26,6 @@ positionValue = 0
 function Update(elapsed)
 function Update(elapsed)
         positionValue = positionValue + elapsed
         positionValue = positionValue + elapsed
         listenerPositionValue = listenerPositionValue + elapsed * 0.3
         listenerPositionValue = listenerPositionValue + elapsed * 0.3
-
         sourceEntity:setPosition(300 + (sin(positionValue) * 300), 250 + cos(positionValue) * 100)
         sourceEntity:setPosition(300 + (sin(positionValue) * 300), 250 + cos(positionValue) * 100)
         listenerEntity:setPosition(300 + (sin(listenerPositionValue) * 300), 250)
         listenerEntity:setPosition(300 + (sin(listenerPositionValue) * 300), 250)
 end
 end

+ 8 - 0
Examples/Lua/Audio/3DAudio/3DAudio.polyproject

@@ -0,0 +1,8 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/3DAudio.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <packedItems>
+        <item type="folder" path="Resources" />
+        <item type="folder" path="Scripts" />
+    </packedItems>
+</PolycodeProject>

+ 0 - 7
Examples/Lua/Audio/3DAudio/3DAudio.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>3DAudio.lua</entryPoint>
-	<packedItems>
-		<item path="test.wav" type="file"/>
-        </packedItems>
-</PolycodeProject>

+ 0 - 0
Examples/Lua/Audio/3DAudio/test.wav → Examples/Lua/Audio/3DAudio/Resources/test.wav


+ 6 - 3
Examples/Lua/Audio/3DAudio/3DAudio.lua → Examples/Lua/Audio/3DAudio/Scripts/3DAudio.lua

@@ -1,15 +1,18 @@
+
+-- Simple positional 3D Audio example.
+
 scene = Scene()
 scene = Scene()
 
 
 sourceEntity = SceneEntity()
 sourceEntity = SceneEntity()
-testSound = SceneSound("test.wav", 20, 50)
+testSound = SceneSound("Resources/test.wav", 20, 50)
 testSound:getSound():Play(true)
 testSound:getSound():Play(true)
 sourceEntity:addChild(testSound)
 sourceEntity:addChild(testSound)
-soundShape = ScenePrimitive(TYPE_BOX, 1,1,1)
+soundShape = ScenePrimitive(ScenePrimitive.TYPE_BOX, 1,1,1)
 soundShape:setMaterialByName("Default")
 soundShape:setMaterialByName("Default")
 sourceEntity:addChild(soundShape)
 sourceEntity:addChild(soundShape)
 scene:addEntity(sourceEntity)
 scene:addEntity(sourceEntity)
 
 
-light = SceneLight(AREA_LIGHT, scene, 300, 0,0)
+light = SceneLight(SceneLight.AREA_LIGHT, scene, 300, 0,0)
 scene:addLight(light)
 scene:addLight(light)
 soundListener = SceneSoundListener()
 soundListener = SceneSoundListener()
 scene:addEntity(soundListener)
 scene:addEntity(soundListener)

+ 0 - 17
Examples/Lua/Audio/PlayingSounds/PlayingSounds.lua

@@ -1,17 +0,0 @@
-class "SoundApp" (EventHandler)
-
-function SoundApp:SoundApp(image)
-        self.sound = Sound("test.wav")
-        self:EventHandler()
-end
-
-function SoundApp:handleEvent(e)
-        if e:getDispatcher() == Services.Core:getInput() then
-               if e:getEventCode() == EVENT_MOUSEDOWN then
-                        self.sound:Play(false)
-                end
-        end
-end
-
-app = SoundApp()
-Services.Core:getInput():addEventListener(app, EVENT_MOUSEDOWN)

+ 8 - 0
Examples/Lua/Audio/PlayingSounds/PlayingSounds.polyproject

@@ -0,0 +1,8 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/PlayingSounds.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <polyarray:packedItems>
+        <item type="folder" path="Resources" />
+        <item type="folder" path="Scripts" />
+    </polyarray:packedItems>
+</PolycodeProject>

+ 0 - 7
Examples/Lua/Audio/PlayingSounds/PlayingSounds.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>PlayingSounds.lua</entryPoint>
-	<packedItems>
-		<item path="test.wav" type="file"/>
-        </packedItems>
-</PolycodeProject>

+ 0 - 0
Examples/Lua/Audio/PlayingSounds/test.wav → Examples/Lua/Audio/PlayingSounds/Resources/test.wav


+ 8 - 0
Examples/Lua/Audio/PlayingSounds/Scripts/PlayingSounds.lua

@@ -0,0 +1,8 @@
+
+-- Simple sound loading and playing example
+
+sound = Sound("Resources/test.wav")
+
+function onMouseDown(x,y)
+	sound:Play()
+end

+ 0 - 22
Examples/Lua/Events_And_Input/EventHandling/EventHandling.lua

@@ -1,22 +0,0 @@
-class "ImageRotator" (EventHandler)
-
-timer = Timer(true, 1000)
-
-function ImageRotator:ImageRotator(image)
-        self.image = image
-        self:EventHandler()
-end
-
-function ImageRotator:handleEvent(e)
-        if e:getDispatcher() == timer and e:getEventCode() == EVENT_TRIGGER then
-                self.image:setRotation(self.image:getRotation()+90)
-        end
-end
-
-screen = Screen()
-image = ScreenImage("polycode_logo.png")
-screen:addChild(image)
-
-rotator = ImageRotator(image)
-timer:addEventListener(rotator, EVENT_TRIGGER)
-

+ 0 - 7
Examples/Lua/Events_And_Input/EventHandling/EventHandling.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>EventHandling.lua</entryPoint>
-	<packedItems>
-		<item path="polycode_logo.png" type="file"/>
-        </packedItems>
-</PolycodeProject>

+ 0 - 46
Examples/Lua/Events_And_Input/KeyboardInput/KeyboardInput.lua

@@ -1,46 +0,0 @@
-
-class "ImageRotator" (EventHandler)
-
-function ImageRotator:ImageRotator(image)
-        self.image = image
-        self.rotationSpeed = 0
-        self:EventHandler()
-end
-
-function ImageRotator:rotate(e)
-        self.image:setRotation(self.image:getRotation() + e * self.rotationSpeed)
-end
-
-function ImageRotator:handleEvent(e)
-        if e:getDispatcher() == Services.Core:getInput() then
-                local inputEvent = InputEvent(e)
-                local key = inputEvent:keyCode()
-                if e:getEventCode() == EVENT_KEYDOWN then
-                        if key == KEY_LEFT then
-                                self.rotationSpeed = -200
-                        elseif key == KEY_RIGHT then
-                                self.rotationSpeed = 200
-                        end
-                elseif e:getEventCode() == EVENT_KEYUP then
-                        if key == KEY_LEFT or key == KEY_RIGHT then
-                                self.rotationSpeed = 0
-                        end
-                end
-        end
-end
-
-screen = Screen()
-image = ScreenImage("polycode_logo.png")
-image:setPositionMode(POSITION_CENTER)
-image:setPosition(640/2,480/2)
-screen:addChild(image)
-
-
-imageRotator = ImageRotator(image)
-
-Services.Core:getInput():addEventListener(imageRotator, EVENT_KEYDOWN)
-Services.Core:getInput():addEventListener(imageRotator, EVENT_KEYUP)
-
-function Update(elapsed)
-        imageRotator:rotate(elapsed)
-end

+ 0 - 7
Examples/Lua/Events_And_Input/KeyboardInput/KeyboardInput.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>KeyboardInput.lua</entryPoint>
-	<packedItems>
-		<item path="polycode_logo.png" type="file"/>
-        </packedItems>
-</PolycodeProject>

+ 0 - 33
Examples/Lua/Events_And_Input/MouseInput/MouseInput.lua

@@ -1,33 +0,0 @@
-class "MouseImage" (EventHandler)
-
-function MouseImage:MouseImage(image)
-        self.image = image
-        self:EventHandler()
-end
-
-function MouseImage:handleEvent(e)
-        if e:getDispatcher() == Services.Core:getInput() then
-                local inputEvent = InputEvent(e)
-                if e:getEventCode() == EVENT_MOUSEMOVE then
-                        local pos = inputEvent:getMousePosition()
-                        self.image:setPosition(pos.x, pos.y)
-                        delete(pos)
-                elseif e:getEventCode() == EVENT_MOUSEDOWN then
-                        self.image:setColor(1,0,0,1)
-                elseif e:getEventCode() == EVENT_MOUSEUP then
-                        self.image:setColor(1,1,1,1)
-                end
-        end
-end
-
-screen = Screen()
-image = ScreenImage("polycode_logo.png")
-image:setPositionMode(POSITION_CENTER)
-screen:addChild(image)
-
-mouseImage = MouseImage(image)
-
-
-Services.Core:getInput():addEventListener(mouseImage, EVENT_MOUSEMOVE)
-Services.Core:getInput():addEventListener(mouseImage, EVENT_MOUSEDOWN)
-Services.Core:getInput():addEventListener(mouseImage, EVENT_MOUSEUP)

+ 0 - 7
Examples/Lua/Events_And_Input/MouseInput/MouseInput.xml

@@ -1,7 +0,0 @@
-<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0">
-	<backgroundColor red="0.25" green="0.25" blue="0.25" />
-	<entryPoint>MouseInput.lua</entryPoint>
-	<packedItems>
-		<item path="polycode_logo.png" type="file"/>
-        </packedItems>
-</PolycodeProject>

BIN
Examples/Lua/Events_And_Input/MouseInput/polycode_logo.png


+ 8 - 0
Examples/Lua/Input/KeyboardInput/KeyboardInput.polyproject

@@ -0,0 +1,8 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/KeyboardInput.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <polyarray:packedItems>
+        <item type="folder" path="Resources" />
+        <item type="folder" path="Scripts" />
+    </polyarray:packedItems>
+</PolycodeProject>

+ 0 - 0
Examples/Lua/Events_And_Input/EventHandling/polycode_logo.png → Examples/Lua/Input/KeyboardInput/Resources/polycode_logo.png


+ 29 - 0
Examples/Lua/Input/KeyboardInput/Scripts/KeyboardInput.lua

@@ -0,0 +1,29 @@
+
+-- Keyboard input example.
+-- Rotate the Polycode logo with left and right keys
+
+screen = Screen()
+
+image = ScreenImage("Resources/polycode_logo.png")
+image:setPositionMode(ScreenEntity.POSITION_CENTER)
+image:setPosition(640/2,480/2)
+screen:addChild(image)
+rotationSpeed = 0
+
+function onKeyDown(key)
+	if key == KEY_LEFT then
+		rotationSpeed = -200
+	elseif key == KEY_RIGHT then
+		rotationSpeed = 200
+	end
+end
+
+function onKeyUp(key)
+	if key == KEY_LEFT or key == KEY_RIGHT then
+		rotationSpeed = 0
+	end
+end
+
+function Update(elapsed)
+        image.rotation.roll = image.rotation.roll + (elapsed * rotationSpeed)
+end

+ 8 - 0
Examples/Lua/Input/MouseInput/MouseInput.polyproject

@@ -0,0 +1,8 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="640" defaultHeight="480" antiAliasingLevel="0" entryPoint="Scripts/MouseInput.lua" vSync="false" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.25" green="0.25" blue="0.25" />
+    <polyarray:packedItems>
+        <item type="folder" path="Resources" />
+        <item type="folder" path="Scripts" />
+    </polyarray:packedItems>
+</PolycodeProject>

+ 0 - 0
Examples/Lua/Events_And_Input/KeyboardInput/polycode_logo.png → Examples/Lua/Input/MouseInput/Resources/polycode_logo.png


+ 27 - 0
Examples/Lua/Input/MouseInput/Scripts/MouseInput.lua

@@ -0,0 +1,27 @@
+
+-- Mouse input example
+-- Set the image position to mouse position when the mouse is moved
+-- and change the image color when mouse is left or right clicked
+
+screen = Screen()
+image = ScreenImage("Resources/polycode_logo.png")
+image:setPositionMode(ScreenEntity.POSITION_CENTER)
+screen:addChild(image)
+
+function onMouseMove(x,y)
+	image.position.x = x
+	image.position.y = y
+end
+
+function onMouseDown(button, x,y)
+	if button == 0 then
+		image:setColor(1.0, 0.0, 0.0, 1.0)
+	else
+		image:setColor(0.0, 1.0, 0.0, 1.0)
+	end
+end
+
+function onMouseUp(button, x,y)
+	image:setColor(1.0, 1.0, 1.0, 1.0)
+end
+

+ 2 - 0
IDE/Contents/Include/PolycodeRemoteDebugger.h

@@ -69,6 +69,8 @@ class PolycodeRemoteDebugger : EventHandler {
 					
 					
 	protected:
 	protected:
 		
 		
+		bool hasErred;
+		
 		PolycodeProjectManager *projectManager;
 		PolycodeProjectManager *projectManager;
 		
 		
 		Server *server;
 		Server *server;

+ 1 - 1
IDE/Contents/Source/ExampleBrowserWindow.cpp

@@ -79,7 +79,7 @@ ExampleBrowserWindow::ExampleBrowserWindow() : UIWindow(L"Example Browser", 320,
 String ExampleBrowserWindow::getExamplePath() {
 String ExampleBrowserWindow::getExamplePath() {
 	String suffix;
 	String suffix;
 	std::vector<String> parts = templateFolder.split("/");	
 	std::vector<String> parts = templateFolder.split("/");	
-	return templateFolder+"/"+parts[parts.size()-1]+".xml";
+	return templateFolder+"/"+parts[parts.size()-1]+".polyproject";
 }
 }
 
 
 
 

+ 3 - 1
IDE/Contents/Source/PolycodeProject.cpp

@@ -127,6 +127,7 @@ bool PolycodeProject::saveFile() {
 	configFile.root["defaultWidth"]->intVal = data.defaultWidth;
 	configFile.root["defaultWidth"]->intVal = data.defaultWidth;
 	configFile.root["defaultHeight"]->intVal = data.defaultHeight;
 	configFile.root["defaultHeight"]->intVal = data.defaultHeight;
 	configFile.root["entryPoint"]->stringVal = data.entryPoint;
 	configFile.root["entryPoint"]->stringVal = data.entryPoint;
+	configFile.root["entryPoint"]->type = ObjectEntry::STRING_ENTRY;
 	
 	
 	ObjectEntry *color = configFile.root["backgroundColor"];
 	ObjectEntry *color = configFile.root["backgroundColor"];
 	
 	
@@ -146,7 +147,8 @@ bool PolycodeProject::saveFile() {
 	for(int j=0; j < data.modules.size(); j++) {
 	for(int j=0; j < data.modules.size(); j++) {
 		if(!configFile.root["modules"]) {
 		if(!configFile.root["modules"]) {
 			configFile.root.addChild("modules");	
 			configFile.root.addChild("modules");	
-		}		
+		}	
+		configFile.root["modules"]->type = ObjectEntry::ARRAY_ENTRY;	
 		configFile.root["modules"]->addChild("module", data.modules[j]);
 		configFile.root["modules"]->addChild("module", data.modules[j]);
 	}
 	}
 	
 	

+ 15 - 6
IDE/Contents/Source/PolycodeRemoteDebugger.cpp

@@ -30,6 +30,8 @@ PolycodeRemoteDebugger::PolycodeRemoteDebugger(PolycodeProjectManager *projectMa
 
 
 	server->addEventListener(this, ServerEvent::EVENT_CLIENT_CONNECTED);
 	server->addEventListener(this, ServerEvent::EVENT_CLIENT_CONNECTED);
 	server->addEventListener(this, ServerEvent::EVENT_CLIENT_DISCONNECTED);		
 	server->addEventListener(this, ServerEvent::EVENT_CLIENT_DISCONNECTED);		
+	
+	hasErred = false;
 
 
 }
 }
 
 
@@ -69,22 +71,29 @@ void PolycodeRemoteDebugger::handleEvent(Event *event) {
 						}
 						}
 						break;	
 						break;	
 						case EVENT_DEBUG_ERROR:
 						case EVENT_DEBUG_ERROR:
-						{			
-							RemoteErrorData *data = (RemoteErrorData*)clientEvent->data;			
-							PolycodeConsole::print("Error in file "+String(data->fileName)+" on line "+String::IntToString(data->lineNumber)+"\n");
-							PolycodeConsole::print(String(data->errorMessage)+"\n");
-							PolycodeConsole::print("Backtrace:\n");
+						{		
+						
+							if(!hasErred) {
+								RemoteErrorData *data = (RemoteErrorData*)clientEvent->data;			
+								PolycodeConsole::print("Error in file "+String(data->fileName)+" on line "+String::IntToString(data->lineNumber)+"\n");
+								PolycodeConsole::print(String(data->errorMessage)+"\n");
+								PolycodeConsole::print("Backtrace:\n");
+							
+								CoreServices::getInstance()->getCore()->makeApplicationMain();
+							}
 							
 							
-							CoreServices::getInstance()->getCore()->makeApplicationMain();
+//							hasErred = true;
 							
 							
 						}
 						}
 						break;			
 						break;			
 						case EVENT_DEBUG_BACKTRACE_INFO:
 						case EVENT_DEBUG_BACKTRACE_INFO:
 						{			
 						{			
+
 							RemoteBacktraceData *data = (RemoteBacktraceData*)clientEvent->data;			
 							RemoteBacktraceData *data = (RemoteBacktraceData*)clientEvent->data;			
 							PolycodeConsole::print("In file "+String(data->fileName)+" on line "+String::IntToString(data->lineNumber)+"\n");
 							PolycodeConsole::print("In file "+String(data->fileName)+" on line "+String::IntToString(data->lineNumber)+"\n");
 							
 							
 							PolycodeConsole::addBacktrace(String(data->fileName), data->lineNumber, projectManager->getActiveProject());
 							PolycodeConsole::addBacktrace(String(data->fileName), data->lineNumber, projectManager->getActiveProject());
+							
 						}
 						}
 						break;							
 						break;							
 										
 										

+ 1 - 1
Modules/Contents/2DPhysics/Source/PolyPhysicsScreen.cpp

@@ -440,7 +440,7 @@ void PhysicsScreen::destroyMouseJoint(b2MouseJoint *mJoint) {
 
 
 PhysicsScreenEntity *PhysicsScreen::addPhysicsChild(ScreenEntity *newEntity, int entType, bool isStatic, Number friction, Number density, Number restitution, bool isSensor, bool fixedRotation) {
 PhysicsScreenEntity *PhysicsScreen::addPhysicsChild(ScreenEntity *newEntity, int entType, bool isStatic, Number friction, Number density, Number restitution, bool isSensor, bool fixedRotation) {
 	addChild(newEntity);
 	addChild(newEntity);
-	return trackPhysicsChild(newEntity, entType, isSensor, friction, density, restitution, isSensor, fixedRotation);
+	return trackPhysicsChild(newEntity, entType, isStatic, friction, density, restitution, isSensor, fixedRotation);
 }
 }
 
 
 PhysicsScreenEntity *PhysicsScreen::trackPhysicsChild(ScreenEntity *newEntity, int entType, bool isStatic, Number friction, Number density, Number restitution, bool isSensor, bool fixedRotation) {
 PhysicsScreenEntity *PhysicsScreen::trackPhysicsChild(ScreenEntity *newEntity, int entType, bool isStatic, Number friction, Number density, Number restitution, bool isSensor, bool fixedRotation) {