6 Commitit

Tekijä SHA1 Viesti Päivämäärä
  Madiwka 3e41bd9e52 I swear i'm going to end the lives of those who inventer game developing if this keeps up 2 vuotta sitten
  Madiwka 9fcad0dde2 Fixed ship texture rotation 2 vuotta sitten
  Niro fd64b84fcd please work 2 vuotta sitten
  Niro 030e216bd6 added broken textures, broken relative landing speed and something else i probably forgot 2 vuotta sitten
  Madiwka b19d074d1f
Merge pull request #4 from NiroUwU/testing 2 vuotta sitten
  Madiwka 60522207d7
Merge pull request #3 from NiroUwU/testing 2 vuotta sitten
10 muutettua tiedostoa jossa 102 lisäystä ja 69 poistoa
  1. +6
    -6
      data/planetdata.lua
  2. +4
    -9
      data/starshipTypes.lua
  3. +1
    -1
      import.lua
  4. +3
    -2
      main.lua
  5. +0
    -1
      src/calc.lua
  6. +1
    -1
      src/class/FX.lua
  7. +7
    -4
      src/class/Planet.lua
  8. +72
    -44
      src/class/Player.lua
  9. BIN
      textures/player/orbiter.png
  10. +8
    -1
      textures/textures.lua

+ 6
- 6
data/planetdata.lua Näytä tiedosto

@@ -1,24 +1,24 @@
planetdata = {
{
x = 0, y = 0,
r = 500000, m = 1e9,
xSpeed = 0, ySpeed = 0,
r = 500000, m = 1e12,
xSpeed = 0, ySpeed = 100,
name = "Testos",
colour = {42, 04, 20},
parent = "star"
},
{
x = 2000000, y = 0,
r = 100000, m = 4e10,
xSpeed = 0, ySpeed = 50,
r = 100000, m = 4e9,
xSpeed = 0, ySpeed = 175,
name = "Deez",
colour = {50, 50, 50},
parent = 1
},
{
x = 2200000, y = 0,
r = 10000, m = 1e9,
xSpeed = 0, ySpeed = 100,
r = 10000, m = 1e4,
xSpeed = 0, ySpeed = 35,
name = "Ligos",
colour = {10, 50, 20},
parent = 2


+ 4
- 9
data/starshipTypes.lua Näytä tiedosto

@@ -3,17 +3,12 @@ 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,
mass = 10,
impacttolerance = 9999,
mass = 100000, -- idk, feels better but holy fuck thats a thicc ass boi xD
speed = 0.05,
specials = {"orbitSync"}
--TEXTURE HERE?
specials = {"orbitSync"},
texture = texture.player.orbiter
}
}

return starshipTypes






+ 1
- 1
import.lua Näytä tiedosto

@@ -5,9 +5,9 @@ require "libraries"

-- General Data:
info = require "data/info"
texture = require "textures/textures"
controls = require "data/controls"
settings = require "data/settings"
texture = require "textures/textures"
starshipTypes = require "data/starshipTypes"

-- Game Source:


+ 3
- 2
main.lua Näytä tiedosto

@@ -6,6 +6,7 @@ calc.isDebug = true
function love.load()
-- Declaration:
love.window.setTitle(info.name.." - v"..info.version)
--love.graphics.setDefaultFilter("nearest", "nearest")
width, height = love.graphics.getDimensions()

-- Camera:
@@ -24,6 +25,7 @@ function love.load()

local spawnPlanet = planet[1]
player = Player(spawnPlanet.x, spawnPlanet.y-spawnPlanet.r-1, "orbiter")
player.xSpeed, player.ySpeed = spawnPlanet.xSpeed, spawnPlanet.ySpeed
gui = Gui(1)
effects = {}
end
@@ -33,8 +35,7 @@ end

function loadPlanets()
debug("Planets in planet table: "..#planetdata)
for i=1, #planetdata do
local p = planetdata[i]
for i, p in ipairs(planetdata) do
debug(p.name.." is loading")
table.insert(planet, i,
Planet(


+ 0
- 1
src/calc.lua Näytä tiedosto

@@ -48,7 +48,6 @@ function calc.closestObj(target)
end

return minPlanet

end



+ 1
- 1
src/class/FX.lua Näytä tiedosto

@@ -29,7 +29,7 @@ end


function FX:draw()
debug("drawing flash")
--debug("drawing flash")
if self.type == "flash" then
self:flash()
end

+ 7
- 4
src/class/Planet.lua Näytä tiedosto

@@ -33,8 +33,6 @@ function Planet:init(tempX, tempY, tempR, tempM, tempXSpeed, tempYSpeed, tempNam
self.parent = planet[tempP]
table.insert(planet[tempP].children, self)
end


end


@@ -42,10 +40,14 @@ end

-- FUNCTIONS

function Planet:getSpeed()
return math.abs(self.xSpeed) + math.abs(self.ySpeed) + math.abs(self.orbitalY) + math.abs(self.orbitalX)
end

function Planet:updatePosition()
self.x = self.x + self.xSpeed + self.orbitalX
self.y = self.y + self.ySpeed + self.orbitalY
debug("Updating position of planet " .. self.name .. ": " .. self.x .. " " .. self.y)
--debug("Updating position of planet " .. self.name .. ": " .. self.x .. " " .. self.y)
end

function Planet:attract(dt) --Planet doing the attracting, divided in two parts:
@@ -93,5 +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

+ 72
- 44
src/class/Player.lua Näytä tiedosto

@@ -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
@@ -20,6 +23,7 @@ function Player:init(tempX, tempY, tempT)
-- Landings:
self.impacttolerance = starshipTypes[tempT].impacttolerance
self.landingspeed = 0
self.landedOn = nil

-- Mass:
self.m = starshipTypes[tempT].mass
@@ -29,8 +33,12 @@ function Player:init(tempX, tempY, tempT)

-- Status:
self.exploding = false
self.inRange = nil

--TEXTURE HERE?
self.texture = love.graphics.newImage(starshipTypes[tempT].texture)
self.width = self.texture:getWidth()
self.height = self.texture:getHeight()
end


@@ -69,7 +77,8 @@ 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
end
@@ -78,44 +87,39 @@ function Player:flightControls()
-- Anti-clipping feature
local closestPla = calc.closestObj(player)


-- Movement:
local speedChange = self.speed * self.throttle
-- Directional Thrust:
if love.keyboard.isDown(controls.flight.thrust.up)then
if (calc.distance(closestPla.x, closestPla.y, self.x, self.y) > calc.distance(closestPla.x, closestPla.y, self.x, self.y-10) and self:isLanded()) then
debug("Flying into a planet!")
--debug("Flying into a planet!")
else
self.ySpeed = self.ySpeed - speedChange
debug("Player control: up")
end
end

if love.keyboard.isDown(controls.flight.thrust.down) then
if (calc.distance(closestPla.x, closestPla.y, self.x, self.y) > calc.distance(closestPla.x, closestPla.y, self.x, self.y+10) and self:isLanded()) then
debug("Flying into a planet!")
--debug("Flying into a planet!")
else
self.ySpeed = self.ySpeed + speedChange
debug("Player control: down")
end
end

if love.keyboard.isDown(controls.flight.thrust.left) then
if (calc.distance(closestPla.x, closestPla.y, self.x, self.y) > calc.distance(closestPla.x, closestPla.y, self.x-10, self.y) and self:isLanded()) then
debug("Flying into a planet!")
--debug("Flying into a planet!")
else
self.xSpeed = self.xSpeed - speedChange
debug("Player control: left")
end
end

if love.keyboard.isDown(controls.flight.thrust.right) then
if (calc.distance(closestPla.x, closestPla.y, self.x, self.y) > calc.distance(closestPla.x, closestPla.y, self.x+10, self.y) and self:isLanded()) then
debug("Flying into a planet!")
--debug("Flying into a planet!")
else
self.xSpeed = self.xSpeed + speedChange
debug("Player control: right")
end
end

@@ -126,7 +130,7 @@ function Player:flightControls()
debug("Flying into a planet!")
else
self.xSpeed = self.xSpeed + math.cos(self.angle) * speedChange*2
debug("Ship thrusters X: " .. math.cos(self.angle) .. " " .. math.sin(self.angle) .. " " .. self.angle)
--debug("Ship thrusters X: " .. math.cos(self.angle) .. " " .. math.sin(self.angle) .. " " .. self.angle)
self.ySpeed = self.ySpeed - math.sin(self.angle) * speedChange*2
end
end
@@ -141,19 +145,19 @@ function Player:flightControls()
-- Reset:
if love.keyboard.isDown(controls.flight.reset) then
self:reset()
debug("Player control: reset")
end
end

function Player:getSpeed()
local x, y = self.xSpeed, self.ySpeed
if x < 0 then
x = -x
end
if y < 0 then
y = -y
end
return x+y
function Player:getSpeed() -- absolute speed
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
return math.abs(self:getSpeed() - obj:getSpeed())
end

function Player:getOrbitHeight(obj) -- gets the height of the orbit (above surface)
return calc.distance(self.x, self.y, obj.x, obj.y)-obj.r
end

function Player:hasCrashed() --Testing function, see if a player is inside a planet
@@ -168,15 +172,19 @@ end

function Player:isLanded()
local landed = false
for i=1, #planet do
local pla = planet[i]
if calc.distance(self.x, self.y, pla.x, pla.y) <= pla.r then
for i, p in ipairs(planet) do
if self:getOrbitHeight(p) <= 1 then
landed = true
self.landedOn = p
debug("Player touched down on: "..p.name)
end
end
-- Save Landing Speed:
if landed then
self.landingspeed = self:getSpeed()
local player = math.abs(self:getSpeed())
local planet = math.abs(self.landedOn:getSpeed())

self.landingspeed = math.abs(player-planet)
debug("Landing speed: "..self.landingspeed)
end
self:hasCrashed()
@@ -186,13 +194,40 @@ end
function Player:gravity()
if self:isLanded() then
-- Player is landed:
local p = self.landedOn
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)
-- Texture offset and size
local t = {s = 50}

-- 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)
end


@@ -200,8 +235,6 @@ end
-- MAIN

function Player:update(dt)
--debug(self.warpspeed)
if self.angle > calc.pi*2 then
self.angle = 0
elseif self.angle < 0 then
@@ -217,23 +250,18 @@ end
function Player:draw()
local x, y = self.x, self.y
local dist = 10
-- Funky arrow type form
local vertices = {
-- Top
x, y-dist,
-- Left Bottom
x-dist, y+dist,
-- Middle Down
x, y+dist/2,
-- Right Bottom
x+dist, y+dist
}

if not self.exploding then
love.graphics.setColor(0.5, 0.5, 0.7)
love.graphics.polygon("fill", vertices)
self:drawTexture(x, y, calc.pi/2 - self.angle)
end

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

if not self.exploding then
if calc.isDebug then
-- Debugging Draw of actual Player Position
love.graphics.setColor(1, 0, 0)
love.graphics.circle("fill", x, y, 5, 20)
end

-- 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)


BIN
textures/player/orbiter.png Näytä tiedosto

Before After
Leveys: 326  |  Korkeus: 381  |  Koko: 52 KiB

+ 8
- 1
textures/textures.lua Näytä tiedosto

@@ -1,3 +1,10 @@
texture = {}
texture = {
player = {
orbiter = "textures/player/orbiter.png"
},
planet = {
-- here will go planet textures in future
}
}

return texture

Ladataan…
Peruuta
Tallenna