From 9fcad0dde2b472811bd700f4df78c716d1311ebc Mon Sep 17 00:00:00 2001 From: Madiwka Date: Sat, 22 Jan 2022 21:01:50 +0600 Subject: [PATCH 1/2] Fixed ship texture rotation --- src/class/Player.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/class/Player.lua b/src/class/Player.lua index 917b60e..7a8e0d2 100755 --- a/src/class/Player.lua +++ b/src/class/Player.lua @@ -33,6 +33,8 @@ function Player:init(tempX, tempY, tempT) --TEXTURE HERE? self.texture = love.graphics.newImage(starshipTypes[tempT].texture) + self.width = self.texture:getWidth() + self.height = self.texture:getHeight() end @@ -72,6 +74,7 @@ function Player:reset() self.x = self.xStart self.y = self.yStart + self.angle = calc.pi/2 self.xSpeed = 0 self.ySpeed = 0 end @@ -200,12 +203,10 @@ end function Player:drawTexture(x, y, r) -- Texture offset and size local t = {s = 50} - t.x = x - love.graphics.getPixelWidth(self.texture)/2 -- ????????????????????????????????? - t.y = y - love.graphics.getPixelHeight(self.texture)/2 -- Draw Texture love.graphics.setColor(1, 1, 1) - love.graphics.draw(self.texture, t.x, t.y, r) + love.graphics.draw(self.texture, self.x, self.y, -(self.angle-calc.pi/2), 1, 1, self.width/2, self.height/2) debug("Angle: "..self.angle) end @@ -230,7 +231,10 @@ function Player:draw() local x, y = self.x, self.y local dist = 10 + if not self.exploding then self:drawTexture(x, y, calc.pi/2 - self.angle) + end + if not self.exploding then if calc.isDebug then From 3e41bd9e52e71b9996a16768524b6770e71b7678 Mon Sep 17 00:00:00 2001 From: Madiwka Date: Sat, 22 Jan 2022 22:06:51 +0600 Subject: [PATCH 2/2] I swear i'm going to end the lives of those who inventer game developing if this keeps up --- data/starshipTypes.lua | 2 +- src/class/Planet.lua | 4 +++- src/class/Player.lua | 34 +++++++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/data/starshipTypes.lua b/data/starshipTypes.lua index 2fc2b3e..d89100e 100755 --- a/data/starshipTypes.lua +++ b/data/starshipTypes.lua @@ -3,7 +3,7 @@ starshipTypes = { orbiter = { name = "Classic Orbiter", description = "Dolor fugiat irure sit aliqua labore. Culpa voluptate occaecat anim exercitation proident sint ex dolor. Officia in labore sint Lorem ea. Ad minim aliqua aliqua non commodo qui in ea sit excepteur excepteur qui.", - impacttolerance = 0.5, + impacttolerance = 9999, mass = 100000, -- idk, feels better but holy fuck thats a thicc ass boi xD speed = 0.05, specials = {"orbitSync"}, diff --git a/src/class/Planet.lua b/src/class/Planet.lua index 347f3c2..5a6036f 100755 --- a/src/class/Planet.lua +++ b/src/class/Planet.lua @@ -41,7 +41,7 @@ end -- FUNCTIONS function Planet:getSpeed() - return math.abs(self.xSpeed) + math.abs(self.ySpeed) + return math.abs(self.xSpeed) + math.abs(self.ySpeed) + math.abs(self.orbitalY) + math.abs(self.orbitalX) end function Planet:updatePosition() @@ -95,4 +95,6 @@ function Planet:draw() local col = self.colour love.graphics.setColor(calc.c(col[1]), calc.c(col[2]), calc.c(col[3])) love.graphics.circle("fill", self.x, self.y, self.r) + love.graphics.setColor(0.1,0.1,0.1,0.2) + love.graphics.circle("fill", self.x, self.y, self.r*2) end \ No newline at end of file diff --git a/src/class/Player.lua b/src/class/Player.lua index 7a8e0d2..8ee883e 100755 --- a/src/class/Player.lua +++ b/src/class/Player.lua @@ -9,6 +9,9 @@ function Player:init(tempX, tempY, tempT) self.xStart = tempX self.yStart = tempY + self.orbitalX = 0 + self.orbitalY = 0 + -- Speed: self.xSpeed = 0 self.ySpeed = 0 @@ -30,6 +33,7 @@ function Player:init(tempX, tempY, tempT) -- Status: self.exploding = false + self.inRange = nil --TEXTURE HERE? self.texture = love.graphics.newImage(starshipTypes[tempT].texture) @@ -73,7 +77,7 @@ end function Player:reset() self.x = self.xStart self.y = self.yStart - + self.landingspeed = 0 self.angle = calc.pi/2 self.xSpeed = 0 self.ySpeed = 0 @@ -145,7 +149,7 @@ function Player:flightControls() end function Player:getSpeed() -- absolute speed - return math.abs(self.xSpeed) + math.abs(self.ySpeed) + return math.abs(self.xSpeed) + math.abs(self.ySpeed) + math.abs(self.orbitalY) + math.abs(self.orbitalX) end function Player:getSpeedTo(obj) -- relative speed to an object @@ -169,7 +173,7 @@ end function Player:isLanded() local landed = false for i, p in ipairs(planet) do - if self:getOrbitHeight(p) <= 0 then + if self:getOrbitHeight(p) <= 1 then landed = true self.landedOn = p debug("Player touched down on: "..p.name) @@ -191,13 +195,29 @@ function Player:gravity() if self:isLanded() then -- Player is landed: local p = self.landedOn - self.xSpeed, self.ySpeed = math.abs(p.xSpeed), math.abs(p.ySpeed) + self.xSpeed, self.ySpeed = 0, 0 + + end + local p = calc.closestObj(player) + if self:getOrbitHeight(p) < p.r and p.parent then + if self.inRange ~= p then + self.xSpeed = 0 + self.ySpeed = 0 + self.inRange = p + end + self.orbitalX = p.xSpeed + p.orbitalX + self.orbitalY = p.ySpeed + p.orbitalY + debug("Synced speed" .. self.orbitalX .. " " .. self.orbitalY .. " with " .. p.name) + else + self.inRange = nil + self.orbitalX = 0 + self.orbitalY = 0 end end function Player:updatePosition() - self.x = self.x + self.xSpeed - self.y = self.y + self.ySpeed + self.x = self.x + self.xSpeed + self.orbitalX + self.y = self.y + self.ySpeed + self.orbitalY end function Player:drawTexture(x, y, r) @@ -207,7 +227,7 @@ function Player:drawTexture(x, y, r) -- Draw Texture love.graphics.setColor(1, 1, 1) love.graphics.draw(self.texture, self.x, self.y, -(self.angle-calc.pi/2), 1, 1, self.width/2, self.height/2) - debug("Angle: "..self.angle) + --debug("Angle: "..self.angle) end