Compare commits

...

10 Commits

Author SHA1 Message Date
Simon Kellet f689632a92 better wall init and clearing 4 months ago
Simon Kellet da8bb7d083 removed unused music stops 4 months ago
Simon Kellet 0a25d11ac5 hitbox now circle and slower going backwards 4 months ago
Simon Kellet 71d1f6e929 changed 4 months ago
Simon Kellet a392755844 global tracker of current level 4 months ago
Simon Kellet f4d3969a1f new map for testing 4 months ago
Simon Kellet 2cd9f263e6 walls now properly get destoryed 4 months ago
Simon Kellet ff40a5507b draws score 4 months ago
Simon Kellet 26398f52b5 fixed wins 4 months ago
Simon Kellet 38826d0cd8 debug keys 4 months ago
  1. 12
      Game/GameKeyPressed.lua
  2. 10
      Game/UpdateGame.lua
  3. 1
      Menu/MenuKeyPressed.lua
  4. 11
      Win/DrawWin.lua
  5. 3
      constants.lua
  6. 10
      libs/restart.lua
  7. 24
      main.lua
  8. 290
      maps/map2.lua
  9. 61
      maps/map2.tmx
  10. 4
      mapsloader.lua
  11. 11
      player.lua

@ -18,4 +18,16 @@ function GameKeyPressed(key)
_G.GAMESTATE = "GAME" _G.GAMESTATE = "GAME"
love.load() love.load()
end end
-- debug map changes!
if DebugFlag and key == "1" then
_G.CUR_LEVEL = 1
RestartGame()
love.load()
end
if DebugFlag and key == "2" then
_G.CUR_LEVEL = 2
RestartGame()
love.load()
end
end end

@ -1,12 +1,14 @@
local function checkWinState() local function checkLossState()
-- Check P1's health -- Check P1's health
if UserPlayer1.health <= 0 then --P1 win if UserPlayer1.health <= 0 then --P1 Lost, P2 Win
_G.P2_COUNT = _G.P2_COUNT + 1
_G.P1_WIN = false _G.P1_WIN = false
_G.P2_WIN = true _G.P2_WIN = true
return true return true
end end
if UserPlayer2.health <= 0 then --P2 win if UserPlayer2.health <= 0 then --P2 Lost, P1 Win
_G.P1_COUNT = _G.P1_COUNT + 1
_G.P1_WIN = true _G.P1_WIN = true
_G.P2_WIN = false _G.P2_WIN = false
return true return true
@ -18,7 +20,7 @@ local max = math.max -- optimisations
function UpdateGame(dt) function UpdateGame(dt)
--Check if anyone has won --Check if anyone has won
if checkWinState() == true then if checkLossState() == true then
print("STATE CHNAGED: WIN!") print("STATE CHNAGED: WIN!")
_G.GAMESTATE = "WIN" _G.GAMESTATE = "WIN"
end end

@ -38,7 +38,6 @@ function MenuKeyPressed(key)
musicBattle:stop() musicBattle:stop()
musicMenu:stop() musicMenu:stop()
musicPause:stop() musicPause:stop()
musicStory:stop()
_G.GAMESTATE = "MENU" _G.GAMESTATE = "MENU"
love.load() love.load()
end end

@ -4,9 +4,9 @@ local function winner()
local opacity = 0.3 local opacity = 0.3
local s = "" local s = ""
if _G.P1_WIN then if not _G.P1_WIN then
s = "P1 Win! R - Restart" s = "P1 Win! R - Restart"
elseif _G.P2_WIN then elseif not _G.P2_WIN then
s = "P2 Win! R - Restart" s = "P2 Win! R - Restart"
end end
@ -23,7 +23,12 @@ local function winner()
love.graphics.setFont(MenuFont) love.graphics.setFont(MenuFont)
love.graphics.setColor(1, 1, 1) -- white love.graphics.setColor(1, 1, 1) -- white
love.graphics.print(s, centreX - sw / 2, centreY - sh / 2) love.graphics.print(s, centreX - sw / 2, centreY - sh / 2) -- who won
love.graphics.print(
"" .. _G.P1_COUNT .. ":" .. "" .. _G.P2_COUNT,
(centreX - sw / 2),
(centreY - sh / 2) - sh / 1.5
) -- score
end end
end end

@ -26,3 +26,6 @@ P2_WIN = false
-- WIN counts! -- WIN counts!
P1_COUNT = 0 P1_COUNT = 0
P2_COUNT = 0 P2_COUNT = 0
-- Current Level
CUR_LEVEL = 1

@ -2,12 +2,10 @@
-- all objects -- all objects
-- Used in map switching and restarting! -- Used in map switching and restarting!
function ClearWalls() function ClearWalls(walls)
for w in pairs(Walls) do for i = #walls, 1, -1 do
Walls[w] = nil walls[i]:destroy()
end end
Walls = {}
end end
function StopAllMusic() function StopAllMusic()
@ -43,7 +41,7 @@ function RestartGame()
ClearBullets(Bullets2) ClearBullets(Bullets2)
--Clear Walls --Clear Walls
--ClearWalls() ClearWalls(Walls)
-- Done! -- Done!
end end

@ -10,6 +10,12 @@ World:addCollisionClass("Player2")
World:addCollisionClass("Bullet2") World:addCollisionClass("Bullet2")
World:addCollisionClass("Wall") World:addCollisionClass("Wall")
--Fonts used in the game
GameFont = love.graphics.newFont("assets/Daydream.ttf", 60)
DebugFont = love.graphics.newFont("assets/Daydream.ttf", 12)
MenuFont = love.graphics.newFont("assets/Daydream.ttf", 45)
Walls = {}
function love.run() function love.run()
if love.load then if love.load then
love.load(love.arg.parseGameArguments(arg), arg) love.load(love.arg.parseGameArguments(arg), arg)
@ -86,10 +92,8 @@ function love.load()
require("Pause/PauseKeyPressed") require("Pause/PauseKeyPressed")
require("Win/WinKeyPressed") require("Win/WinKeyPressed")
--Fonts used in the game -- Set a random seed
GameFont = love.graphics.newFont("assets/Daydream.ttf", 60) love.math.setRandomSeed(love.timer.getTime())
DebugFont = love.graphics.newFont("assets/Daydream.ttf", 12)
MenuFont = love.graphics.newFont("assets/Daydream.ttf", 45)
--Game consts --Game consts
HEALTH = 3 HEALTH = 3
@ -99,8 +103,6 @@ function love.load()
Bullets1 = {} Bullets1 = {}
Bullets2 = {} Bullets2 = {}
Walls = {}
DebugFlag = false DebugFlag = false
EnableKeyPress1 = true EnableKeyPress1 = true
KeyPressTime1 = 0 KeyPressTime1 = 0
@ -127,7 +129,7 @@ function love.load()
}) })
--STI Map loading --STI Map loading
LoadMap(1) LoadMap(_G.CUR_LEVEL)
end end
function love.keypressed(key) function love.keypressed(key)
@ -158,8 +160,8 @@ function love.update(dt)
UpdatePause(dt) UpdatePause(dt)
-- Handle music -- Handle music
if not musicPause:isPlaying() then if not musicPause:isPlaying() then
--musicBattle:setVolume(0) musicBattle:setVolume(0)
--musicPause:setVolume(0.5) musicPause:setVolume(0.5)
love.audio.play(musicBattle) love.audio.play(musicBattle)
love.audio.play(musicPause) love.audio.play(musicPause)
end end
@ -168,8 +170,8 @@ function love.update(dt)
UpdateGame(dt) UpdateGame(dt)
-- Handle music -- Handle music
if not musicBattle:isPlaying() then if not musicBattle:isPlaying() then
--musicBattle:setVolume(0.5) musicBattle:setVolume(0.5)
--musicPause:setVolume(0) musicPause:setVolume(0)
love.audio.play(musicBattle) love.audio.play(musicBattle)
love.audio.play(musicPause) love.audio.play(musicPause)
end end

@ -0,0 +1,290 @@
return {
version = "1.10",
luaversion = "5.1",
tiledversion = "1.11.0",
class = "",
orientation = "orthogonal",
renderorder = "right-down",
width = 25,
height = 15,
tilewidth = 64,
tileheight = 64,
nextlayerid = 4,
nextobjectid = 16,
properties = {},
tilesets = {
{
name = "floor",
firstgid = 1,
class = "",
tilewidth = 64,
tileheight = 64,
spacing = 0,
margin = 0,
columns = 9,
image = "../assets/tileset.png",
imagewidth = 576,
imageheight = 384,
objectalignment = "unspecified",
tilerendersize = "tile",
fillmode = "stretch",
tileoffset = {
x = 0,
y = 0
},
grid = {
orientation = "orthogonal",
width = 64,
height = 64
},
properties = {},
wangsets = {},
tilecount = 54,
tiles = {}
}
},
layers = {
{
type = "tilelayer",
x = 0,
y = 0,
width = 25,
height = 15,
id = 1,
name = "floor",
class = "",
visible = true,
opacity = 1,
offsetx = 0,
offsety = 0,
parallaxx = 1,
parallaxy = 1,
properties = {},
encoding = "lua",
data = {
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3,
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21
}
},
{
type = "tilelayer",
x = 0,
y = 0,
width = 25,
height = 15,
id = 2,
name = "inner walls",
class = "",
visible = true,
opacity = 1,
offsetx = 0,
offsety = 0,
parallaxx = 1,
parallaxy = 1,
properties = {},
encoding = "lua",
data = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 29, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 28, 29, 29, 29, 29, 29, 30, 0, 0, 37, 38, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 37, 38, 38, 38, 38, 38, 39, 0, 0, 46, 47, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 46, 47, 38, 38, 38, 47, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0, 28, 29, 30, 0, 0, 0, 0, 28, 29, 30, 0, 0, 0, 0,
0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0,
0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0,
0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0,
0, 0, 0, 0, 46, 47, 48, 0, 0, 0, 0, 46, 47, 48, 0, 0, 0, 0, 37, 38, 39, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 29, 38, 38, 38, 29, 30, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 29, 30, 0, 0, 37, 38, 38, 38, 38, 38, 39, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 38, 39, 0, 0, 46, 47, 47, 47, 47, 47, 48, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, 47, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}
},
{
type = "objectgroup",
draworder = "topdown",
id = 3,
name = "Walls",
class = "",
visible = false,
opacity = 1,
offsetx = 0,
offsety = 0,
parallaxx = 1,
parallaxy = 1,
properties = {},
objects = {
{
id = 1,
name = "",
type = "",
shape = "rectangle",
x = 128,
y = 128,
width = 448,
height = 192,
rotation = 0,
visible = true,
properties = {}
},
{
id = 2,
name = "",
type = "",
shape = "rectangle",
x = 256,
y = 320,
width = 192,
height = 320,
rotation = 0,
visible = true,
properties = {}
},
{
id = 3,
name = "",
type = "",
shape = "rectangle",
x = 704,
y = 80,
width = 192,
height = 176,
rotation = 0,
visible = true,
properties = {}
},
{
id = 4,
name = "",
type = "",
shape = "rectangle",
x = 704,
y = 320,
width = 192,
height = 320,
rotation = 0,
visible = true,
properties = {}
},
{
id = 5,
name = "",
type = "",
shape = "rectangle",
x = 704,
y = 704,
width = 192,
height = 192,
rotation = 0,
visible = true,
properties = {}
},
{
id = 6,
name = "",
type = "",
shape = "rectangle",
x = 1024,
y = 640,
width = 448,
height = 192,
rotation = 0,
visible = true,
properties = {}
},
{
id = 7,
name = "",
type = "",
shape = "rectangle",
x = 1152,
y = 320,
width = 192,
height = 320,
rotation = 0,
visible = true,
properties = {}
},
{
id = 9,
name = "",
type = "",
shape = "rectangle",
x = 0,
y = 0,
width = 1184,
height = 16,
rotation = 0,
visible = true,
properties = {}
},
{
id = 10,
name = "",
type = "",
shape = "rectangle",
x = 1184,
y = 0,
width = 416,
height = 16,
rotation = 0,
visible = true,
properties = {}
},
{
id = 11,
name = "",
type = "",
shape = "rectangle",
x = 1584,
y = 0,
width = 16,
height = 960,
rotation = 0,
visible = true,
properties = {}
},
{
id = 12,
name = "",
type = "",
shape = "rectangle",
x = 0,
y = 944,
width = 1600,
height = 16,
rotation = 0,
visible = true,
properties = {}
},
{
id = 13,
name = "",
type = "",
shape = "rectangle",
x = 0,
y = 0,
width = 16,
height = 960,
rotation = 0,
visible = true,
properties = {}
}
}
}
}
}

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="25" height="15" tilewidth="64" tileheight="64" infinite="0" nextlayerid="4" nextobjectid="16">
<editorsettings>
<export target="map2.lua" format="lua"/>
</editorsettings>
<tileset firstgid="1" name="floor" tilewidth="64" tileheight="64" tilecount="54" columns="9">
<image source="../assets/tileset.png" width="576" height="384"/>
</tileset>
<layer id="1" name="floor" width="25" height="15">
<data encoding="csv">
1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,
19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21
</data>
</layer>
<layer id="2" name="inner walls" width="25" height="15">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,28,29,30,0,0,0,0,0,0,0,0,0,0,0,
0,0,28,29,29,29,29,29,30,0,0,37,38,39,0,0,0,0,0,0,0,0,0,0,0,
0,0,37,38,38,38,38,38,39,0,0,46,47,48,0,0,0,0,0,0,0,0,0,0,0,
0,0,46,47,38,38,38,47,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,37,38,39,0,0,0,0,28,29,30,0,0,0,0,28,29,30,0,0,0,0,
0,0,0,0,37,38,39,0,0,0,0,37,38,39,0,0,0,0,37,38,39,0,0,0,0,
0,0,0,0,37,38,39,0,0,0,0,37,38,39,0,0,0,0,37,38,39,0,0,0,0,
0,0,0,0,37,38,39,0,0,0,0,37,38,39,0,0,0,0,37,38,39,0,0,0,0,
0,0,0,0,46,47,48,0,0,0,0,46,47,48,0,0,0,0,37,38,39,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,29,38,38,38,29,30,0,0,
0,0,0,0,0,0,0,0,0,0,0,28,29,30,0,0,37,38,38,38,38,38,39,0,0,
0,0,0,0,0,0,0,0,0,0,0,37,38,39,0,0,46,47,47,47,47,47,48,0,0,
0,0,0,0,0,0,0,0,0,0,0,46,47,48,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
</layer>
<objectgroup id="3" name="Walls" visible="0">
<object id="1" x="128" y="128" width="448" height="192"/>
<object id="2" x="256" y="320" width="192" height="320"/>
<object id="3" x="704" y="80" width="192" height="176"/>
<object id="4" x="704" y="320" width="192" height="320"/>
<object id="5" x="704" y="704" width="192" height="192"/>
<object id="6" x="1024" y="640" width="448" height="192"/>
<object id="7" x="1152" y="320" width="192" height="320"/>
<object id="9" x="0" y="0" width="1184" height="16"/>
<object id="10" x="1184" y="0" width="416" height="16"/>
<object id="11" x="1584" y="0" width="16" height="960"/>
<object id="12" x="0" y="944" width="1600" height="16"/>
<object id="13" x="0" y="0" width="16" height="960"/>
</objectgroup>
</map>

@ -1,12 +1,10 @@
function LoadMap(lvl) function LoadMap(lvl)
ClearWalls()
local mapfilelocation = "maps/" local mapfilelocation = "maps/"
local extention = ".lua" local extention = ".lua"
local mapname = mapfilelocation .. "map" .. lvl .. extention local mapname = mapfilelocation .. "map" .. lvl .. extention
GameMap = STI(mapname) GameMap = STI(mapname)
--Walls = {} Walls = {}
if GameMap.layers["Walls"] then if GameMap.layers["Walls"] then
for _, obj in ipairs(GameMap.layers["Walls"].objects) do for _, obj in ipairs(GameMap.layers["Walls"].objects) do
local wall = World:newRectangleCollider(obj.x, obj.y, obj.width, obj.height) local wall = World:newRectangleCollider(obj.x, obj.y, obj.width, obj.height)

@ -3,19 +3,19 @@ cos = math.cos
sin = math.sin --optimisation sin = math.sin --optimisation
-- Constructor for the Player class -- Constructor for the Player class
function Player:new(p, x, y, health, image, speed, max) function Player:new(p, x, y, health, image, speed)
self.p = p self.p = p
self.image = love.graphics.newImage(image) self.image = love.graphics.newImage(image)
self.x = x self.x = x
self.y = y self.y = y
self.health = health self.health = health
self.speed = speed self.speed = speed
self.max = max
self.width = self.image:getWidth() self.width = self.image:getWidth()
self.height = self.image:getHeight() self.height = self.image:getHeight()
-- Collision Stuff -- Collision Stuff
self.collider = World:newRectangleCollider(x, y, 64, 64) --self.collider = World:newRectangleCollider(x, y, 50, 62)
self.collider = World:newCircleCollider(x, y, 24)
self.collider:setFixedRotation(true) self.collider:setFixedRotation(true)
if self.p == 1 then if self.p == 1 then
@ -61,14 +61,13 @@ function Player:handleKeys(up, down, left, right, dt)
self.vx = cos(self.rotation) * (self.speed * dt) self.vx = cos(self.rotation) * (self.speed * dt)
self.vy = sin(self.rotation) * (self.speed * dt) self.vy = sin(self.rotation) * (self.speed * dt)
elseif love.keyboard.isDown(down) then elseif love.keyboard.isDown(down) then
self.vx = cos(self.rotation) * (self.speed * dt) * -1 self.vx = cos(self.rotation) * (self.speed / 2 * dt) * -1
self.vy = sin(self.rotation) * (self.speed * dt) * -1 self.vy = sin(self.rotation) * (self.speed / 2 * dt) * -1
elseif love.keyboard.isDown(left) then elseif love.keyboard.isDown(left) then
self.rotation = self.rotation - (self.rotSpeed * dt) self.rotation = self.rotation - (self.rotSpeed * dt)
elseif love.keyboard.isDown(right) then elseif love.keyboard.isDown(right) then
self.rotation = self.rotation + (self.rotSpeed * dt) self.rotation = self.rotation + (self.rotSpeed * dt)
end end
self.collider:setLinearVelocity(self.vx, self.vy) self.collider:setLinearVelocity(self.vx, self.vy)
end end

Loading…
Cancel
Save