소스 검색

Merge pull request #4 from NiroUwU/testing

Reworked gravity. added moons and stuff
tags/v0.0.6_dev
Madiwka 2 년 전
committed by GitHub
부모
커밋
b19d074d1f
No known key found for this signature in database GPG 키 ID: 4AEE18F83AFDEB23
8개의 변경된 파일78개의 추가작업 그리고 15개의 파일을 삭제
  1. +4
    -1
      data/controls.lua
  2. +11
    -3
      data/planetdata.lua
  3. +19
    -0
      data/starshipTypes.lua
  4. +1
    -0
      import.lua
  5. +1
    -1
      main.lua
  6. +20
    -0
      src/Abilities.lua
  7. +16
    -6
      src/class/Planet.lua
  8. +6
    -4
      src/class/Player.lua

+ 4
- 1
data/controls.lua 파일 보기

@@ -29,7 +29,10 @@ controls = {
reset = "-",
down = ",",
up = "."
}
},

-- Special
special = "f"
},
-- Player Camera Controls:


+ 11
- 3
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
}
}


+ 19
- 0
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






+ 1
- 0
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"


+ 1
- 1
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


+ 20
- 0
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




+ 16
- 6
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


+ 6
- 4
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




불러오는 중...
취소
저장