4 次程式碼提交

作者 SHA1 備註 提交日期
  Madi de02ee57bf Added directional indicator on zoom-out 2 年之前
  Madiwka 14e7941920
Merge pull request #2 from NiroUwU/master 2 年之前
  Madiwka da00dd181d
Merge branch 'main' into master 2 年之前
  Madi 9918992fbd Added rotatable engine controls 2 年之前
共有 3 個文件被更改,包括 32 次插入3 次删除
分割檢視
  1. +4
    -1
      data/controls.lua
  2. +1
    -1
      src/calc.lua
  3. +27
    -1
      src/class/Player.lua

+ 4
- 1
data/controls.lua 查看文件

@@ -18,7 +18,10 @@ controls = {
up = "w",
down = "s",
left = "a",
right = "d"
right = "d",
engine = "space",
rotleft = "q",
rotright = "e"
},

-- Time Warp Controls:


+ 1
- 1
src/calc.lua 查看文件

@@ -3,7 +3,7 @@ calc = {}

-- G-Constant
calc.G = 6.67e-11 -- TWEAKABLE FOR LATER DEPENDING ON SCALE!!!!!!!!!!!
calc.pi = 3.14
-- Development debugging/logging thing
function calc.debug(text)
if calc.isDebug then


+ 27
- 1
src/class/Player.lua 查看文件

@@ -23,6 +23,9 @@ function Player:init(tempX, tempY)

-- Mass:
self.m = 10

-- Rotation:
self.angle = calc.pi/2
end


@@ -91,6 +94,21 @@ function Player:flightControls()
debug("Player control: right")
end


-- Main Engine controls:
if love.keyboard.isDown(controls.flight.thrust.engine) then
self.xSpeed = self.xSpeed + math.cos(self.angle) * speedChange
debug("Ship thrusters X: " .. math.cos(self.angle) .. " " .. math.sin(self.angle) .. " " .. self.angle)
self.ySpeed = self.ySpeed - math.sin(self.angle) * speedChange
end
if love.keyboard.isDown(controls.flight.thrust.rotleft) then
self.angle = self.angle + 1/love.timer.getFPS()
end
if love.keyboard.isDown(controls.flight.thrust.rotright) then
self.angle = self.angle - 1/love.timer.getFPS()
end


-- Reset:
if love.keyboard.isDown(controls.flight.reset) then
self:reset()
@@ -144,6 +162,12 @@ end

function Player:update(dt)
--debug(self.warpspeed)
if self.angle > calc.pi*2 then
self.angle = 0
elseif self.angle < 0 then
self.angle = calc.pi*2
end
self:gravity()
self:flightControls()
self:updatePosition()
@@ -163,10 +187,12 @@ function Player:draw()
-- Right Bottom
x+dist, y+dist
}

love.graphics.setColor(0.5, 0.5, 0.7)
love.graphics.polygon("fill", vertices)

love.graphics.setColor(1, 0, 0)
love.graphics.circle("fill", x, y, 5, 20)

-- Directional Circle (temporary until actual rotatable ship texture is made)
love.graphics.circle("fill", x+dist*(1/zoomlevel*2)*math.cos(self.angle), y-dist*(1/zoomlevel*2)*math.sin(self.angle), 1/zoomlevel*2)
end

Loading…
取消
儲存