-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a555599
commit c3c534c
Showing
56 changed files
with
659 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
screen = Screen() | ||
|
||
sourceEntity = ScreenEntity() | ||
testSound = ScreenSound("test.wav", 200, 600) | ||
testSound:getSound():Play(true) | ||
sourceEntity:addChild(testSound) | ||
soundShape = ScreenShape(SHAPE_CIRCLE, 20,20,10) | ||
sourceEntity:addChild(soundShape) | ||
screen:addChild(sourceEntity) | ||
|
||
listenerEntity = ScreenEntity() | ||
soundListener = ScreenSoundListener() | ||
listenerEntity:addChild(soundListener) | ||
soundShape = ScreenShape(SHAPE_CIRCLE, 20,20,10) | ||
soundShape:setColor(0.0, 1.0, 0.0, 1.0) | ||
listenerEntity:addChild(soundShape) | ||
screen:addChild(listenerEntity) | ||
|
||
listenerPositionValue = 0 | ||
positionValue = 0 | ||
|
||
function Update(elapsed) | ||
positionValue = positionValue + elapsed | ||
listenerPositionValue = listenerPositionValue + elapsed * 0.3 | ||
|
||
sourceEntity:setPosition(300 + (sin(positionValue) * 300), 250 + cos(positionValue) * 100) | ||
listenerEntity:setPosition(300 + (sin(listenerPositionValue) * 300), 250) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<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> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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:getEmitter().useScaleCurves = true | ||
emitter:getEmitter().scaleCurve:addControlPoint2d(0, 0.3) | ||
emitter:getEmitter().scaleCurve:addControlPoint2d(0.5, 1) | ||
emitter:getEmitter().scaleCurve:addControlPoint2d(1, 0) | ||
|
||
emitter:getEmitter().useColorCurves = true | ||
emitter:getEmitter().colorCurveR:addControlPoint2d(0, 0.3) | ||
emitter:getEmitter().colorCurveR:addControlPoint2d(0.1, 1) | ||
emitter:getEmitter().colorCurveR:addControlPoint2d(0.4, 1) | ||
emitter:getEmitter().colorCurveR:addControlPoint2d(0.5, 0) | ||
emitter:getEmitter().colorCurveR:addControlPoint2d(1, 0) | ||
|
||
emitter:getEmitter().colorCurveG:addControlPoint2d(0, 0.3) | ||
emitter:getEmitter().colorCurveG:addControlPoint2d(0.1, 0.6) | ||
emitter:getEmitter().colorCurveG:addControlPoint2d(0.4, 0.6) | ||
emitter:getEmitter().colorCurveG:addControlPoint2d(0.5, 0) | ||
emitter:getEmitter().colorCurveG:addControlPoint2d(1, 0.0) | ||
|
||
emitter:getEmitter().colorCurveB:addControlPoint2d(0, 1) | ||
emitter:getEmitter().colorCurveB:addControlPoint2d(0.1, 0) | ||
emitter:getEmitter().colorCurveB:addControlPoint2d(1, 0) | ||
|
||
emitter:getEmitter().colorCurveA:addControlPoint2d(0, 0) | ||
emitter:getEmitter().colorCurveA:addControlPoint2d(0.05, 1) | ||
emitter:getEmitter().colorCurveA:addControlPoint2d(0.6, 1) | ||
emitter:getEmitter().colorCurveA:addControlPoint2d(1, 0) | ||
|
||
emitter:setPosition(640/2, 400) | ||
screen:addChild(emitter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<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> |
44 changes: 44 additions & 0 deletions
44
Examples/Lua/2DPhysics_CollisionOnly/2DPhysics_CollisionOnly.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class "Detector" (EventHandler) | ||
|
||
function Detector:Detector(shape) | ||
self.shape = shape | ||
self:EventHandler() | ||
end | ||
|
||
function Detector:handleEvent(e) | ||
if e:getDispatcher() == screen then | ||
local pe = PhysicsScreenEvent(e) | ||
if e:getEventCode() == EVENT_NEW_SHAPE_COLLISION then | ||
if pe:getFirstEntity() == self.shape or pe:getSecondEntity() == self.shape then | ||
pe:getFirstEntity():setColor(1.0, 0.0, 0.0, 1.0) | ||
pe:getSecondEntity():setColor(1.0, 0.0, 0.0, 1.0) | ||
end | ||
elseif e:getEventCode() == EVENT_END_SHAPE_COLLISION then | ||
pe:getFirstEntity():setColor(1.0, 1.0, 1.0, 1.0) | ||
pe:getSecondEntity():setColor(1.0, 1.0, 1.0, 1.0) | ||
end | ||
end | ||
end | ||
|
||
screen = PhysicsScreen(10, 60) | ||
|
||
checkShape = ScreenShape(SHAPE_RECT, 90,10) | ||
screen:addCollisionChild(checkShape, ENTITY_RECT) | ||
|
||
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 | ||
|
||
detector = Detector(checkShape) | ||
screen:addEventListener(detector, EVENT_NEW_SHAPE_COLLISION) | ||
screen:addEventListener(detector, EVENT_END_SHAPE_COLLISION) | ||
|
||
function Update(e) | ||
local mouse = Services.Core:getInput():getMousePosition() | ||
checkShape:setPosition(mouse.x, mouse.y) | ||
checkShape:setRotation(checkShape:getRotation() + (e*100)) | ||
delete(mouse) | ||
end |
7 changes: 7 additions & 0 deletions
7
Examples/Lua/2DPhysics_CollisionOnly/2DPhysics_CollisionOnly.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
class "ImpactNoise" (EventHandler) | ||
|
||
function ImpactNoise:ImpactNoise() | ||
self.collisionSound = Sound("collision.wav") | ||
self:EventHandler() | ||
end | ||
|
||
function ImpactNoise:handleEvent(e) | ||
if e:getDispatcher() == screen then | ||
local pe = PhysicsScreenEvent(e) | ||
if e:getEventCode() == EVENT_NEW_SHAPE_COLLISION then | ||
if pe.impactStrength > 5 then | ||
self.collisionSound:Play() | ||
end | ||
end | ||
end | ||
end | ||
|
||
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,50 do | ||
shape = ScreenShape(SHAPE_RECT, 20,5) | ||
shape:setRotation(random(360)) | ||
shape:setPosition(random(640), random(300)) | ||
screen:addPhysicsChild(shape, ENTITY_RECT, false) | ||
end | ||
|
||
noiseMaker = ImpactNoise() | ||
|
||
screen:addEventListener(noiseMaker, EVENT_NEW_SHAPE_COLLISION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<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> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
screen = PhysicsScreen(10, 50) | ||
|
||
ceiling = ScreenShape(SHAPE_RECT, 640, 20) | ||
ceiling:setColor(0.0, 0.0, 0.0, 1.0) | ||
ceiling:setPosition(640/2, 10) | ||
screen:addPhysicsChild(ceiling, ENTITY_RECT, true) | ||
|
||
-- Revolute Joint | ||
shape = ScreenShape(SHAPE_RECT, 10, 30) | ||
shape:setPosition(150, 20+15) | ||
screen:addPhysicsChild(shape, ENTITY_RECT, false) | ||
screen:createRevoluteJoint(shape, ceiling, 0, -15) | ||
screen:applyImpulse(shape, 10, 0) | ||
|
||
-- Distance Joint | ||
shape = ScreenShape(SHAPE_RECT, 10, 30) | ||
shape:setPosition(250, 20+25) | ||
screen:addPhysicsChild(shape, ENTITY_RECT, false) | ||
screen:createDistanceJoint(shape, ceiling, false) | ||
screen:applyImpulse(shape, 200, 0) | ||
|
||
line = ScreenLine(shape, ceiling) | ||
line:setColor(1.0, 0.0, 0.0, 1.0) | ||
screen:addChild(line) | ||
|
||
-- Prismatic Joint | ||
shape = ScreenShape(SHAPE_RECT, 10, 30) | ||
shape:setPosition(450, 20+25) | ||
screen:addPhysicsChild(shape, ENTITY_RECT, false) | ||
screen:createPrismaticJoint(ceiling, shape, Vector2(0,1), 0,0, false, 100, 0, true) | ||
|
||
lineAnchor = ScreenEntity() | ||
lineAnchor:setPosition(450,10) | ||
line = ScreenLine(shape, lineAnchor) | ||
line:setColor(0.0, 1.0, 0.0, 1.0) | ||
screen:addChild(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<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> |
20 changes: 20 additions & 0 deletions
20
Examples/Lua/2DPhysics_PointCollision/2DPhysics_PointCollision.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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 |
7 changes: 7 additions & 0 deletions
7
Examples/Lua/2DPhysics_PointCollision/2DPhysics_PointCollision.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
scene = Scene() | ||
|
||
sourceEntity = SceneEntity() | ||
testSound = SceneSound("test.wav", 20, 50) | ||
testSound:getSound():Play(true) | ||
sourceEntity:addChild(testSound) | ||
soundShape = ScenePrimitive(TYPE_BOX, 1,1,1) | ||
soundShape:setMaterialByName("Default") | ||
sourceEntity:addChild(soundShape) | ||
scene:addEntity(sourceEntity) | ||
|
||
light = SceneLight(AREA_LIGHT, scene, 300, 0,0) | ||
scene:addLight(light) | ||
soundListener = SceneSoundListener() | ||
scene:addEntity(soundListener) | ||
|
||
positionValue = 0 | ||
|
||
|
||
function Update(elapsed) | ||
positionValue = positionValue + elapsed | ||
|
||
sourceEntity:setPosition((sin(positionValue) * 20), 0, cos(positionValue) * 50) | ||
sourceEntity:Roll(elapsed * 120) | ||
sourceEntity:Pitch(elapsed * 120) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<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> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
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)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.