diff --git a/data/controls.lua b/data/controls.lua index bec4621..a3eeb32 100755 --- a/data/controls.lua +++ b/data/controls.lua @@ -29,7 +29,10 @@ controls = { reset = "-", down = ",", up = "." - } + }, + + -- Special + special = "f" }, -- Player Camera Controls: diff --git a/data/planetdata.lua b/data/planetdata.lua index e55c493..60421da 100755 --- a/data/planetdata.lua +++ b/data/planetdata.lua @@ -1,7 +1,7 @@ planetdata = { { x = 0, y = 0, - r = 500000, m = 5e15, + r = 500000, m = 1e9, xSpeed = 0, ySpeed = 0, name = "Testos", colour = {42, 04, 20}, @@ -9,11 +9,19 @@ planetdata = { }, { x = 2000000, y = 0, - r = 40000, m = 4e7, - xSpeed = 0, ySpeed = 12000, + r = 100000, m = 4e10, + xSpeed = 0, ySpeed = 50, name = "Deez", colour = {50, 50, 50}, parent = 1 + }, + { + x = 2200000, y = 0, + r = 10000, m = 1e9, + xSpeed = 0, ySpeed = 100, + name = "Ligos", + colour = {10, 50, 20}, + parent = 2 } } diff --git a/data/starshipTypes.lua b/data/starshipTypes.lua new file mode 100755 index 0000000..e7ee308 --- /dev/null +++ b/data/starshipTypes.lua @@ -0,0 +1,19 @@ +-- This is completely temporary, THIS WILL CHANGE +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, + speed = 0.05, + specials = {"orbitSync"} + --TEXTURE HERE? + } +} + +return starshipTypes + + + + + diff --git a/import.lua b/import.lua index a8deaea..7606e86 100755 --- a/import.lua +++ b/import.lua @@ -8,6 +8,7 @@ info = require "data/info" controls = require "data/controls" settings = require "data/settings" texture = require "textures/textures" +starshipTypes = require "data/starshipTypes" -- Game Source: calc = require "src/calc" diff --git a/main.lua b/main.lua index a2754fd..1701854 100755 --- a/main.lua +++ b/main.lua @@ -23,7 +23,7 @@ function love.load() loadPlanets() local spawnPlanet = planet[1] - player = Player(spawnPlanet.x, spawnPlanet.y-spawnPlanet.r-1) + player = Player(spawnPlanet.x, spawnPlanet.y-spawnPlanet.r-1, "orbiter") gui = Gui(1) effects = {} end diff --git a/src/Abilities.lua b/src/Abilities.lua new file mode 100755 index 0000000..c09d436 --- /dev/null +++ b/src/Abilities.lua @@ -0,0 +1,20 @@ +-- THIS ENTIRE THING WILL NOT BE USED PROBABLY, JUST TESTING OUT POSSIBLE WAYS THIS COULD WORK + + +Abilities = {} + +function Abilities.orbitSync() --Synchronise speed with closest orbit + +end + + +function Abilities.update(dt) + for i, #player.abilities do + if player.abilities[i] == "orbitSync" then + Abilities.orbitSync() + end + end +end + + + diff --git a/src/class/Planet.lua b/src/class/Planet.lua index b0d6dac..6f92277 100755 --- a/src/class/Planet.lua +++ b/src/class/Planet.lua @@ -9,6 +9,10 @@ function Planet:init(tempX, tempY, tempR, tempM, tempXSpeed, tempYSpeed, tempNam self.xSpeed = 0 self.ySpeed = 0 + -- Orbital speed: + self.orbitalX = 0 + self.orbitalY = 0 + -- Speed Change: (throttle 0 - 1; variable) (speed; constant (max speed change)) self.throttle = 0.5 self.speed = 0.05 @@ -39,8 +43,8 @@ end -- FUNCTIONS function Planet: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 debug("Updating position of planet " .. self.name .. ": " .. self.x .. " " .. self.y) end @@ -49,10 +53,16 @@ function Planet:attract(dt) --Planet doing the attracting, divided in two parts for i, child in ipairs(self.children) do local grav = calc.gPull(self, child) local dist = calc.distance(self.x, self.y, child.x, child.y) - local pull = 20/dist * grav - - child.xSpeed = child.xSpeed - (child.x - self.x)*pull - child.ySpeed = child.ySpeed - (child.y - self.y)*pull + + -- Reworked planetary gravity, now works with multiple layers of parent-children. Also more realistc?? + local angle = math.atan((child.y-self.y)/(child.x-self.x)) + if self.x < child.x then + angle = angle - 3.14159 + end + child.orbitalX = self.xSpeed + self.orbitalX + child.orbitalY = self.ySpeed + self.orbitalY + child.xSpeed = child.xSpeed + grav/child.m*math.cos(angle)*1e9 + child.ySpeed = child.ySpeed + grav/child.m*math.sin(angle)*1e9 end --Attracting the player diff --git a/src/class/Player.lua b/src/class/Player.lua index 4bb2520..bdb764a 100755 --- a/src/class/Player.lua +++ b/src/class/Player.lua @@ -1,6 +1,6 @@ Player = Class {} -function Player:init(tempX, tempY) +function Player:init(tempX, tempY, tempT) -- Position: (variable) self.x = tempX self.y = tempY @@ -15,20 +15,22 @@ function Player:init(tempX, tempY) -- Speed Change: (throttle 0 - 1; variable) (speed; constant (max speed change)) self.throttle = 0.5 - self.speed = 0.05 + self.speed = starshipTypes[tempT].speed -- Landings: - self.impacttolerance = 0.5 + self.impacttolerance = starshipTypes[tempT].impacttolerance self.landingspeed = 0 -- Mass: - self.m = 10 + self.m = starshipTypes[tempT].mass -- Rotation: self.angle = calc.pi/2 -- Status: self.exploding = false + + --TEXTURE HERE? end