Răsfoiți Sursa

Added platformer game example to Lua examples

Ivan Safrin 12 ani în urmă
părinte
comite
438a160ccf
69 a modificat fișierele cu 320 adăugiri și 0 ștergeri
  1. 11 0
      Examples/Lua/Game_Demos/Platformer/Platformer.polyproject
  2. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/entities/button.entity2d
  3. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/entities/coin.entity2d
  4. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/entities/fly.entity2d
  5. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/entities/spaceman.entity2d
  6. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/fonts/LondrinaSolid-Regular.otf
  7. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/fonts/Sniglet Regular.otf
  8. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/alien_plant.png
  9. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/background.png
  10. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/block.png
  11. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/bonus.png
  12. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/bonus_used.png
  13. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/bridge.png
  14. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/bush.png
  15. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/cloud_1.png
  16. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/cloud_2.png
  17. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/cloud_3.png
  18. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/coin_bronze.png
  19. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/coin_gold.png
  20. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/coin_silver.png
  21. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/crate.png
  22. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/enemies/fly.png
  23. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/enemies/slime_normal.png
  24. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/enemies/slime_walk.png
  25. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/fence.png
  26. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/fence_broken.png
  27. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/grass.png
  28. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/ground.png
  29. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/ground_cave.png
  30. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/ground_dirt.png
  31. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/ground_rock.png
  32. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/ground_sand.png
  33. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/hill_long.png
  34. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/hill_short.png
  35. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/key_blue.png
  36. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/key_green.png
  37. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/key_red.png
  38. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/key_yellow.png
  39. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/lava.png
  40. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/lock_blue.png
  41. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/lock_green.png
  42. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/lock_red.png
  43. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/lock_yellow.png
  44. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/plank.png
  45. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/rock.png
  46. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/shroom.png
  47. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/spaceman.png
  48. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/spikes.png
  49. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/switch_blue_off.png
  50. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/switch_blue_on.png
  51. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/switch_green_off.png
  52. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/switch_green_on.png
  53. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/switch_red_off.png
  54. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/switch_red_on.png
  55. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/switch_yellow_off.png
  56. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/switch_yellow_on.png
  57. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/images/water.png
  58. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/levels/level1.entity2d
  59. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/sounds/button.wav
  60. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/sounds/coin.wav
  61. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/sounds/die.wav
  62. BIN
      Examples/Lua/Game_Demos/Platformer/Resources/sounds/jump.wav
  63. 7 0
      Examples/Lua/Game_Demos/Platformer/Resources/sprites/fly.sprite
  64. 9 0
      Examples/Lua/Game_Demos/Platformer/Resources/sprites/spaceman.sprite
  65. 22 0
      Examples/Lua/Game_Demos/Platformer/Scripts/Fly.lua
  66. 16 0
      Examples/Lua/Game_Demos/Platformer/Scripts/HUD.lua
  67. 163 0
      Examples/Lua/Game_Demos/Platformer/Scripts/Level.lua
  68. 14 0
      Examples/Lua/Game_Demos/Platformer/Scripts/Main.lua
  69. 78 0
      Examples/Lua/Game_Demos/Platformer/Scripts/Player.lua

+ 11 - 0
Examples/Lua/Game_Demos/Platformer/Platformer.polyproject

@@ -0,0 +1,11 @@
+<?xml version="1.0" ?>
+<PolycodeProject defaultWidth="1280" defaultHeight="720" antiAliasingLevel="0" entryPoint="Scripts/Main.lua" textureFiltering="linear" vSync="true" anisotropyLevel="0" frameRate="60">
+    <backgroundColor red="0.224599" green="0.224599" blue="0.224599" />
+    <polyarray:packedItems>
+        <item type="folder" path="Resources" />
+        <item type="folder" path="Scripts" />
+    </polyarray:packedItems>
+    <polyarray:fonts>
+        <font name="Sniglet" path="Resources/fonts/Sniglet Regular.otf" />
+    </polyarray:fonts>
+</PolycodeProject>

BIN
Examples/Lua/Game_Demos/Platformer/Resources/entities/button.entity2d


BIN
Examples/Lua/Game_Demos/Platformer/Resources/entities/coin.entity2d


BIN
Examples/Lua/Game_Demos/Platformer/Resources/entities/fly.entity2d


BIN
Examples/Lua/Game_Demos/Platformer/Resources/entities/spaceman.entity2d


BIN
Examples/Lua/Game_Demos/Platformer/Resources/fonts/LondrinaSolid-Regular.otf


BIN
Examples/Lua/Game_Demos/Platformer/Resources/fonts/Sniglet Regular.otf


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/alien_plant.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/background.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/block.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/bonus.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/bonus_used.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/bridge.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/bush.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/cloud_1.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/cloud_2.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/cloud_3.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/coin_bronze.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/coin_gold.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/coin_silver.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/crate.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/enemies/fly.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/enemies/slime_normal.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/enemies/slime_walk.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/fence.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/fence_broken.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/grass.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/ground.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/ground_cave.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/ground_dirt.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/ground_rock.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/ground_sand.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/hill_long.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/hill_short.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/key_blue.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/key_green.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/key_red.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/key_yellow.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/lava.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/lock_blue.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/lock_green.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/lock_red.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/lock_yellow.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/plank.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/rock.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/shroom.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/spaceman.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/spikes.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/switch_blue_off.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/switch_blue_on.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/switch_green_off.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/switch_green_on.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/switch_red_off.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/switch_red_on.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/switch_yellow_off.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/switch_yellow_on.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/images/water.png


BIN
Examples/Lua/Game_Demos/Platformer/Resources/levels/level1.entity2d


BIN
Examples/Lua/Game_Demos/Platformer/Resources/sounds/button.wav


BIN
Examples/Lua/Game_Demos/Platformer/Resources/sounds/coin.wav


BIN
Examples/Lua/Game_Demos/Platformer/Resources/sounds/die.wav


BIN
Examples/Lua/Game_Demos/Platformer/Resources/sounds/jump.wav


+ 7 - 0
Examples/Lua/Game_Demos/Platformer/Resources/sprites/fly.sprite

@@ -0,0 +1,7 @@
+<?xml version="1.0" ?>
+<sprite>
+    <image frameWidth="69" frameHeight="32" fileName="Resources/images/enemies/fly.png" />
+    <animations>
+        <animation name="fly" frames="0,1" speed="0.05" />
+    </animations>
+</sprite>

+ 9 - 0
Examples/Lua/Game_Demos/Platformer/Resources/sprites/spaceman.sprite

@@ -0,0 +1,9 @@
+<?xml version="1.0" ?>
+<sprite>
+    <image frameWidth="72" frameHeight="98" fileName="Resources/images/spaceman.png" />
+    <animations>
+        <animation name="walk" frames="0,1,2,3,4,5,6,7,8" speed="0.05" />
+        <animation name="idle" frames="10" speed="0.5" />
+        <animation name="jump" frames="11" speed="0.5" />
+    </animations>
+</sprite>

+ 22 - 0
Examples/Lua/Game_Demos/Platformer/Scripts/Fly.lua

@@ -0,0 +1,22 @@
+
+class "Fly"
+
+function Fly:Fly(flyBody)
+	self.startPosition = Vector3(flyBody.position.x, flyBody.position.y, flyBody.position.z)
+	self.body = flyBody
+	self.direction = -1.0
+end
+
+function Fly:Update(elapsed)
+	self.body:Translate(self.direction * elapsed * 150.0, 0.0, 0.0)
+	if self.startPosition:distance(self.body.position) > 100 then
+		if self.body.position.x < self.startPosition.x then
+			self.direction = 1.0
+		else
+			self.direction = -1.0
+		end
+	end
+
+	self.body.scale.x = self.direction * -1.0
+end
+

+ 16 - 0
Examples/Lua/Game_Demos/Platformer/Scripts/HUD.lua

@@ -0,0 +1,16 @@
+
+class "HUD"
+
+function HUD:HUD()
+	self.screen = Screen()
+	self.screen:setNormalizedCoordinates(true, 720)
+	self.coinsLabel = ScreenLabel("COINS: 0", 48, "Sniglet")
+	self.screen:addChild(self.coinsLabel)
+	self.coinsLabel.position.x = -400
+	self.coinsLabel.position.y = (-720/2)+10
+
+	self.winLabel = ScreenLabel("WOW, YOU WON THE GAME!", 72, "Sniglet")
+	self.screen:addChild(self.winLabel)
+	self.winLabel:setPositionMode(ScreenEntity.POSITION_CENTER)
+	self.winLabel.visible = false
+end

+ 163 - 0
Examples/Lua/Game_Demos/Platformer/Scripts/Level.lua

@@ -0,0 +1,163 @@
+
+require "Scripts/Player"
+require "Scripts/Fly"
+require "Scripts/HUD"
+
+class "Level"
+
+function Level:Level(levelFile)
+	self.loaded = false
+	self.levelFile = levelFile
+
+	self.coinSound = Sound("Resources/sounds/coin.wav")
+	self.buttonSound = Sound("Resources/sounds/button.wav")
+
+	self:initLevel()
+end
+
+function Level:initLevel()
+
+	self.backgroundScreen = Screen()
+	self.backgroundScreen:setNormalizedCoordinates(true, 720)
+	for i=0,4 do
+		self.background = ScreenImage("Resources/images/background.png")
+		self.backgroundScreen:addChild(self.background)
+		self.background.position.x =  -450 + (1280 * i)
+		self.background.position.y = -720/2
+	end
+
+	self.screen = PhysicsScreen(40, 60.0)
+
+	self.screen:setGravity(Vector2(0.0, 80))
+	self.screen:setNormalizedCoordinates(true, 720)
+	self.level = ScreenEntityInstance("Resources/levels/"..self.levelFile..".entity2d")
+	self.screen:addChild(self.level)
+	self.playerEntity = self.level:getScreenEntityById("player", true)
+	self.player = Player(self.screen, self.playerEntity)
+	self.screen:trackCollisionChild(self.player.groundSensor, PhysicsScreenEntity.ENTITY_RECT)
+
+	local ground_blocks = self.level:getScreenEntitiesByTag("ground", true)
+	for i=1,count(ground_blocks) do
+		self.screen:trackPhysicsChild(ground_blocks[i], PhysicsScreenEntity.ENTITY_RECT , true, 2.0, 1, 0, false, false)
+	end
+
+	self.coins = self.level:getScreenEntitiesByTag("coin", true)
+	for i=1,count(self.coins) do
+		self.coins[i].width = 20
+		self.coins[i].height = 20
+		self.screen:trackCollisionChild(self.coins[i], PhysicsScreenEntity.ENTITY_CIRCLE)
+	end
+
+	self.buttons = self.level:getScreenEntitiesByTag("button", true)
+	for i=1,count(self.buttons) do
+		self.buttons[i].width = 40
+		self.buttons[i].height = 95
+		self.screen:trackPhysicsChild(self.buttons[i], PhysicsScreenEntity.ENTITY_RECT , true, 2.0, 1, 0, false, false)
+	end
+
+
+	self.enemies = {}
+	local flies = self.level:getScreenEntitiesByTag("fly", true)
+	for i=1,count(flies) do
+		self.screen:trackCollisionChild(flies[i], PhysicsScreenEntity.ENTITY_CIRCLE)
+		self.enemies[count(self.enemies)+1] = Fly(flies[i])
+	end	
+	
+	self.screen:addEventListener(self, Level.onNewCollision, PhysicsScreenEvent.EVENT_NEW_SHAPE_COLLISION)
+	self.coinSinVal = 0
+
+	self.hud = HUD()
+
+	self.loaded = true
+end
+
+function Level:clearLevel()
+
+	self.screen.rootEntity:setOwnsChildrenRecursive(true)
+	self.backgroundScreen.rootEntity:setOwnsChildrenRecursive(true)
+	self.hud.screen.rootEntity:setOwnsChildrenRecursive(true)
+
+	safe_delete(self.player.jumpSound)
+	safe_delete(self.player.dieSound              )
+
+	safe_delete(self.screen)
+	safe_delete(self.backgroundScreen)
+	safe_delete(self.hud.screen)
+
+	self.loaded = false
+end
+
+function Level:reloadLevel()
+	self:clearLevel()
+	self:initLevel()
+end
+
+function Level:onNewCollision(event)
+	physicsEvent = safe_cast(event, PhysicsScreenEvent)
+	local collidedEntity =  physicsEvent:getSecondEntity()
+	local firstEntity = physicsEvent:getFirstEntity()
+
+	if same_c_class(firstEntity, self.player.groundSensor) then
+		if collidedEntity:hasTag("button") then
+			local buttonUp = collidedEntity:getEntityById("button_up", true)
+			local buttonDown = collidedEntity:getEntityById("button_down", true)
+			if buttonUp.visible == true then
+				buttonUp.visible = false
+				buttonDown.visible = true
+				self.screen:stopTrackingChild(collidedEntity)
+				collidedEntity.height = 55
+				self.screen:trackPhysicsChild(collidedEntity, PhysicsScreenEntity.ENTITY_RECT , true, 2.0, 1, 0, false, false)
+				self.buttonSound:Play()
+				self:levelButtonPushed(collidedEntity.id)
+			end	
+		end
+	end
+
+	if same_c_class(firstEntity, self.player.playerEntity) then
+		if collidedEntity:hasTag("coin") and collidedEntity.visible == true then
+			collidedEntity.visible = false
+			self.player.numCoins = self.player.numCoins + 1
+			self.coinSound:Play()
+		elseif collidedEntity:hasTag("enemy") and self.player.dead == false then
+			self.player:Die()
+		end
+	end
+end
+
+function Level:levelButtonPushed(buttonID)
+	if buttonID == "level_end_button" then
+		self.hud.winLabel.visible = true 
+	end
+end
+
+function Level:Update(elapsed)	
+
+	if self.player.deadCounter > 2.0 then
+		self:reloadLevel()
+	end
+
+	if self.loaded == false then return end
+
+	self.player:Update(elapsed)
+
+	for i=1,count(self.enemies) do
+		self.enemies[i]:Update(elapsed)
+	end
+
+	self.coinSinVal = self.coinSinVal + elapsed * 5.0
+	for i=1,count(self.coins) do
+		self.coins[i].scale.x = sin(self.coinSinVal)
+	end
+
+	local screenOffset = Vector2(-self.player.playerEntity.position.x, -self.player.playerEntity.position.y)
+	if screenOffset.y < 310 then
+		screenOffset.y = 310
+	end
+	if screenOffset.x > -650 then
+		screenOffset.x = -650
+	end
+	self.screen:setScreenOffset(screenOffset.x, 310)
+	self.backgroundScreen:setScreenOffset(screenOffset.x/3, 0.0)
+
+	self.hud.coinsLabel:setText("COINS: "..self.player.numCoins)
+end

+ 14 - 0
Examples/Lua/Game_Demos/Platformer/Scripts/Main.lua

@@ -0,0 +1,14 @@
+require "Scripts/Level"
+require "Scripts/HUD"
+
+level = Level("level1")
+
+function onKeyDown(key)
+	if key == KEY_z then 
+		level.player:Jump()
+	end
+end
+
+function Update(elapsed)
+	level:Update(elapsed)
+end

+ 78 - 0
Examples/Lua/Game_Demos/Platformer/Scripts/Player.lua

@@ -0,0 +1,78 @@
+
+class "Player"
+
+function Player:Player(screen, playerEntity)
+	self.screen = screen
+	self.playerEntity = playerEntity
+	playerEntity.width = 50
+	playerEntity.height = 90
+	self.playerPhysics = screen:trackPhysicsChild(playerEntity, PhysicsScreenEntity.ENTITY_TRIPLE_CIRCLE, false, 0.0, 1, 0, false, true, -1)
+	self.playerSprite = safe_cast(playerEntity:getEntityById("playerSprite", true), ScreenSprite)
+	self.groundSensor = safe_cast(playerEntity:getEntityById("groundSensor", true), ScreenShape)
+	self.playerVelocity = 0.0
+	self.jumping = true
+	self.numCoins = 0
+	self.dead = false
+	self.deadCounter = 0
+	self.jumpSound = Sound("Resources/sounds/jump.wav")
+	self.dieSound = Sound("Resources/sounds/die.wav")
+end
+
+function Player:Jump()
+	if self.jumping == false and self.dead == false then
+		self.playerPhysics:applyImpulse(0.0, -80.0)
+		self.jumpSound:Play()
+	end
+end
+ 
+function Player:Die()
+	if self.dead == true then return end
+	self.playerSprite.rotation.roll = -90
+	self.playerSprite.position.y = 10
+	self.playerPhysics:applyImpulse(0.0, -80.0)
+	self.dead = true
+	self.dieSound:Play()
+end
+
+function Player:Update(elapsed)
+
+	if self.playerEntity.position.y > 400 then 
+		self:Die()
+	end
+
+	if self.dead then
+		self.deadCounter = self.deadCounter + elapsed
+		self.playerSprite:playAnimation("idle", 0, false)
+		self.playerPhysics:setVelocityX(0)
+		return
+	end
+
+	if self.screen:isEntityColliding(self.groundSensor) then
+		self.jumping = false
+	else
+		self.jumping = true
+	end
+
+	if Services.Input:getKeyState(KEY_LEFT) then
+		self.playerVelocity = -7.2
+		self.playerSprite.scale.x = -1
+	elseif Services.Input:getKeyState(KEY_RIGHT) then
+		self.playerVelocity = 7.2
+		self.playerSprite.scale.x = 1
+	else
+		self.playerVelocity = 0.0
+	end
+
+	self.playerPhysics:setVelocityX(self.playerVelocity)
+
+	if self.jumping == true then
+		self.playerSprite:playAnimation("jump", 0, false)
+	else
+		if self.playerVelocity == 0.0 then
+			self.playerSprite:playAnimation("idle", 0, false)
+		else
+			self.playerSprite:playAnimation("walk", 0, false)
+		end
+	end
+
+end