Permalink
Browse files

Rename ground to platform, to prepare for hackery.

  • Loading branch information...
matasar committed May 27, 2012
1 parent 7f8ac82 commit 7945c428dbec63065fc151ec1aa2b494c999d14c
Showing with 16 additions and 16 deletions.
  1. +2 −2 main.lua
  2. +9 −9 src/ground.lua
  3. +5 −5 src/player.lua
View
@@ -25,8 +25,8 @@ function love.load()
local skyBlue = {153, 204, 255}
player = Player.create(300, 485)
- ground = Ground.create()
- ground:isOnGround(player)
+ ground = Platform.create()
+ ground:isOnPlatform(player)
love.graphics.setBackgroundColor(skyBlue)
end
View
@@ -1,17 +1,17 @@
-Ground = {}
-Ground.__index = Ground
+Platform = {}
+Platform.__index = Platform
-function Ground.create()
+function Platform.create()
local instance = {
image = love.graphics.newImage("planetcute/Grass Block.png"),
imageHeight = 171,
imageWidth = 101
}
- setmetatable(instance, Ground)
+ setmetatable(instance, Platform)
return instance
end
-function Ground:draw()
+function Platform:draw()
for i = 1,12 do
local xPos = ((i - 1) * 100) + worldOffset
love.graphics.draw(self.image, xPos, self:getHeight() - 100)
@@ -20,14 +20,14 @@ function Ground:draw()
love.graphics.rectangle("line", x,y,width,height)
end
-function Ground:getHeight()
+function Platform:getHeight()
return love.graphics.getHeight() - self.imageHeight + 100
end
-function Ground:getBox()
+function Platform:getBox()
return 0, self:getHeight(), 1200 + worldOffset, love.graphics.getHeight()
end
-function Ground:isOnGround(player)
- return player.x - worldOffset < 1200
+function Platform:isOnPlatform(player)
+ return (player.x - worldOffset < 1200)
end
View
@@ -55,8 +55,8 @@ function Player:isMovingRight()
return not keyDownForAction("left") and keyDownForAction("right")
end
-function Player:isOnGround()
- return ground:isOnGround(self)
+function Player:isOnPlatform()
+ return ground:isOnPlatform(self)
end
function Player:moveX(direction, dt) -- -1 is left, 1 is right
@@ -91,22 +91,22 @@ end
function Player:updateJump(dt)
self.y = self.y - self.upVelocity * dt
self.upVelocity = self.upVelocity - (self.gravity * dt)
- if self.y > 485 and self:isOnGround() then
+ if self.y > 485 and self:isOnPlatform() then
self.upVelocity = 0
self.upAcceleration = 0
self.y = 485
end
end
function Player:update(dt)
- if self.upAcceleration > 0 and keyDownForAction("up") and self:isOnGround() then
+ if self.upAcceleration > 0 and keyDownForAction("up") and self:isOnPlatform() then
self.upAcceleration = self.upAcceleration - dt
self.upVelocity = self.upVelocity + self.jumpHeight * (dt / self.maxUpAcceleration)
end
if self:isJumping() then
self:updateJump(dt)
- elseif not self:isOnGround() then
+ elseif not self:isOnPlatform() then
self.upVelocity = self.upVelocity - (self.gravity * dt)
end

0 comments on commit 7945c42

Please sign in to comment.