diff options
| author | jussi | 2022-05-31 00:31:39 +0300 |
|---|---|---|
| committer | jussi | 2022-05-31 00:31:39 +0300 |
| commit | b1bb77e1398b2f73623ef8c1e9cb2d7adbdea139 (patch) | |
| tree | 4bdab9a8c45ac18bc95168e36252f2aa707fb782 /examples/platformer | |
| parent | 381adb3ba2e1c668bf29f95b8356ac8a859e0f3e (diff) | |
| download | reilua-enhanced-b1bb77e1398b2f73623ef8c1e9cb2d7adbdea139.tar.gz reilua-enhanced-b1bb77e1398b2f73623ef8c1e9cb2d7adbdea139.tar.bz2 reilua-enhanced-b1bb77e1398b2f73623ef8c1e9cb2d7adbdea139.zip | |
Windows Lua build instructions.
Diffstat (limited to 'examples/platformer')
| -rw-r--r-- | examples/platformer/main.lua | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/platformer/main.lua b/examples/platformer/main.lua index 41254b7..b92999d 100644 --- a/examples/platformer/main.lua +++ b/examples/platformer/main.lua @@ -103,7 +103,7 @@ end local function tileCollision( entity ) local vPos = entity.pos + entity.vel -- Future pos with current vel. local vRect = util.tableClone( entity.colRect ) - local tinySlit = 0.001 -- Tiny slit between collisionRect and tile to prevent getting stuck on all seams. + local tinyGap = 0.001 -- Tiny slit between collisionRect and tile to prevent getting stuck on all seams. -- Move test rect to predicted position. vRect[1] = vPos.x - vRect[3] / 2 @@ -121,14 +121,14 @@ local function tileCollision( entity ) if isTileWall( Vec2:new( tileRect[3], y ) ) then -- Use new_x to push out of tile. local new_x = tileRect[3] * TILE_SIZE - ( entity.colRect[1] + entity.colRect[3] ) - entity.vel.x = new_x - tinySlit + entity.vel.x = new_x - tinyGap break end elseif entity.vel.x < 0 then if isTileWall( Vec2:new( tileRect[1], y ) ) then local new_x = ( tileRect[1] * TILE_SIZE + TILE_SIZE ) - entity.colRect[1] - entity.vel.x = new_x + tinySlit, 0 + entity.vel.x = new_x + tinyGap, 0 break end @@ -151,7 +151,7 @@ local function tileCollision( entity ) if isTileWall( Vec2:new( x, tileRect[4] ) ) then local new_y = tileRect[4] * TILE_SIZE - ( entity.colRect[2] + entity.colRect[4] ) -- math.max prevents bounce when hitting right on the corner. - entity.vel.y = math.max( new_y - tinySlit, 0 ) + entity.vel.y = math.max( new_y - tinyGap, 0 ) player.onFloor = true break @@ -159,7 +159,7 @@ local function tileCollision( entity ) elseif entity.vel.y < 0 then if isTileWall( Vec2:new( x, tileRect[2] ) ) then local new_y = ( tileRect[2] * TILE_SIZE + TILE_SIZE ) - entity.colRect[2] - entity.vel.y = new_y + tinySlit + entity.vel.y = new_y + tinyGap break end |
