Browse Source

texture changes, minor tweaks

tags/v0.0.6_dev
Niro 2 years ago
parent
commit
00b96ce5f6
13 changed files with 127 additions and 51 deletions
  1. +1
    -1
      data/info.lua
  2. +3
    -2
      data/settings.lua
  3. +4
    -4
      data/starshipTypes.lua
  4. +1
    -1
      import.lua
  5. +42
    -16
      main.lua
  6. +58
    -23
      src/class/Player.lua
  7. BIN
      textures/player/orbiter.png
  8. BIN
      textures/player/orbiter/fullThrust.png
  9. BIN
      textures/player/orbiter/lowThrust.png
  10. BIN
      textures/player/orbiter/orbiter.png
  11. +18
    -4
      textures/textures.lua
  12. BIN
      textures/ui/arrow_grey.png
  13. BIN
      textures/ui/arrow_red.png

+ 1
- 1
data/info.lua View File

@@ -2,7 +2,7 @@ info = {}

info.name = "Questionable Örbital Mechanics"
info.title = info.name
info.version = "0.0.2_dev"
info.version = "0.0.6_dev"
info.authors = {
"NiroUwU",
"Madiwka4"


+ 3
- 2
data/settings.lua View File

@@ -3,11 +3,12 @@ settings = {
min = 0.0001,
max = 4,
step = 0.05,
reset = 0.0001
reset = 0.2,
arrowAppear = 0.03
},
warp = {
min = 1,
max = 10,
max = 25,
step = 1,

cooldown = 10


+ 4
- 4
data/starshipTypes.lua View File

@@ -3,11 +3,11 @@ 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.75,
mass = 100000, -- idk, feels better but holy fuck thats a thicc ass boi xD
speed = 0.05,
impacttolerance = 3,
mass = 1000000, -- idk, feels better but holy fuck thats a thicc ass boi xD
speed = 0.01,
specials = {"orbitSync"},
texture = texture.player.orbiter
textures = texture.player.orbiter
}
}



+ 1
- 1
import.lua View File

@@ -4,8 +4,8 @@
require "libraries"

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


+ 42
- 16
main.lua View File

@@ -19,8 +19,8 @@ function love.load()
-- Menubuttons:
menubutton = {
menu = {
startGame = Menubutton(20, 100, 200, 50, gamestate.game, nil, "Start Game", {255, 255, 255}, {57, 45, 66}),
quitGame = Menubutton(30, 170, 180, 40, gamestate.quit, nil, "Quit Game", {255, 255, 255}, {57, 45, 66})
Menubutton(20, 100, 200, 50, gamestate.game, nil, "Start Game", {255, 255, 255}, {57, 45, 66}),
Menubutton(30, 170, 180, 40, gamestate.quit, nil, "Quit Game", {255, 255, 255}, {57, 45, 66})
},
game = {
-- Pause button or something here in future?
@@ -83,6 +83,9 @@ function drawPlanets()
end
end


-- Effects

function drawEffects()
for i=1, #effects do
effects[i]:draw()
@@ -97,8 +100,6 @@ end

-- Camera



function cameraControls()
local step = settings.zoom.step

@@ -130,6 +131,9 @@ function cameraControls()
cam:zoomTo(zoomlevel)
end


-- Time Warp

function timewarpControls()
-- Time Warp Toggle Cooldowns:
local maxCooldown = settings.warp.cooldown
@@ -167,6 +171,35 @@ function timewarpControls()
end


-- Menubuttons

function menubuttonUpdate()
if GAMESTATE == gamestate.menu then
for i, button in ipairs(menubutton.menu) do
button:update()
end

elseif GAMESTATE == gamestate.game then
for i, button in ipairs(menubutton.game) do
button:update()
end

end
end

function menubuttonDraw()
if GAMESTATE == gamestate.menu then
for i, button in ipairs(menubutton.menu) do
button:draw()
end

elseif GAMESTATE == gamestate.game then
for i, button in ipairs(menubutton.game) do
button:draw()
end
end
end


-- MAIN

@@ -176,8 +209,6 @@ function love.update(dt)
love.event.quit(0)

elseif GAMESTATE == gamestate.menu then
menubutton.menu.startGame:update(dt)
menubutton.menu.quitGame:update(dt)

elseif GAMESTATE == gamestate.game then
-- Game Objects:
@@ -195,7 +226,10 @@ function love.update(dt)
cam:lookAt(player.x, player.y)
cameraControls()
--debug(player.x .. " " .. player.y)

end
menubuttonUpdate()
end

function love.draw()
@@ -205,25 +239,17 @@ function love.draw()
love.graphics.setFont(font.gametitle)
love.graphics.printf(info.title, 20, 20, width, "left")

-- Buttons:
menubutton.menu.startGame:draw()
menubutton.menu.quitGame:draw()

elseif GAMESTATE == gamestate.game then
cam:attach()
-- Game Objects:
drawPlanets()
drawEffects()
player:draw()

-- Camera Zoom Player Location Indicator: OVERWORK SOON PLS KAY; IT UGLY
if zoomlevel < 0.3 then
love.graphics.setColor(1, 1, 1, 0.2)
love.graphics.circle("fill", player.x, player.y, (1/zoomlevel)*10)
end
cam:detach()

-- Gui:
player:drawPositionIndicator()
gui:draw()
end
menubuttonDraw()
end

+ 58
- 23
src/class/Player.lua View File

@@ -9,6 +9,7 @@ function Player:init(tempX, tempY, tempT)
self.xStart = tempX
self.yStart = tempY

-- Speed of Parent:
self.orbitalX = 0
self.orbitalY = 0

@@ -32,19 +33,26 @@ function Player:init(tempX, tempY, tempT)
self.angle = calc.pi/2

-- Status:
self.isAccelerating = false
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()
-- Spacecraft Textures:
self.texture = {
ship = starshipTypes[tempT].textures.ship,
fullThrust = starshipTypes[tempT].textures.fullThrust,
lowThrust = starshipTypes[tempT].textures.lowThrust
}
self.width = self.texture.ship:getWidth()
self.height = self.texture.ship:getHeight()
end



-- FUNCTIONS

-- Player Controls:

function Player:throttleControls()
local change = 0.01
local max, min = 1, 0
@@ -129,9 +137,11 @@ function Player:flightControls()
if (calc.distance(closestPla.x, closestPla.y, self.x, self.y) > calc.distance(closestPla.x, closestPla.y, self.x+self.xSpeed + math.cos(self.angle) * speedChange*2, self.y+self.ySpeed - math.sin(self.angle) * speedChange*2) and self:isLanded()) then --Holy moly this is long
debug("Flying into a planet!")
else
self.xSpeed = self.xSpeed + math.cos(self.angle) * speedChange*2
self.xSpeed = self.xSpeed + math.cos(self.angle) * speedChange*10
--debug("Ship thrusters X: " .. math.cos(self.angle) .. " " .. math.sin(self.angle) .. " " .. self.angle)
self.ySpeed = self.ySpeed - math.sin(self.angle) * speedChange*2
self.ySpeed = self.ySpeed - math.sin(self.angle) * speedChange*10

self.isAccelerating = true
end
end
if love.keyboard.isDown(controls.flight.thrust.rotleft) then
@@ -148,6 +158,9 @@ function Player:flightControls()
end
end


-- Get Player Data:

function Player:getSpeed() -- absolute speed
return math.abs(self.xSpeed) + math.abs(self.ySpeed) + math.abs(self.orbitalY) + math.abs(self.orbitalX)
end
@@ -191,6 +204,9 @@ function Player:isLanded()
return landed
end


-- Player Calculations:

function Player:gravity()
if self:isLanded() then
-- Player is landed:
@@ -220,21 +236,33 @@ function Player:updatePosition()
self.y = self.y + self.ySpeed + self.orbitalY
end

function Player:drawTexture(x, y, r)

-- Graphics / Drawing:

function Player:drawTexture(x, y, r, s, texture)
-- Texture offset and size
local t = {s = 50}
local w, h = texture:getWidth(), texture:getHeight()

-- 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)
love.graphics.draw(texture, x, y, -(self.angle-calc.pi/2), s, s, w/2, h/2)
--debug("Angle: "..self.angle)
end

function Player:drawPositionIndicator(x, y)
-- Directional Arrow (when zoomed out)
if zoomlevel < settings.zoom.arrowAppear then
local s = 0.03
self:drawTexture(width/2, height/2, calc.pi/2 - self.angle, s, texture.ui.arrow.red)
end
end



-- MAIN

function Player:update(dt)
self.isAccelerating = false
if self.angle > calc.pi*2 then
self.angle = 0
elseif self.angle < 0 then
@@ -248,22 +276,29 @@ function Player:update(dt)
end

function Player:draw()
local x, y = self.x, self.y
local x, y, scale = self.x, self.y, 1
local dist = 10

if not self.exploding then
self:drawTexture(x, y, calc.pi/2 - self.angle)
end


local shake = 0
-- Shake (to textures):
if self.isAccelerating then
shake = math.random(0, 1) * self.throttle
x, y = x + shake, y + shake
end
-- Draw Spacecraft:
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)
-- Draw Thrust Exhaust:
if self.isAccelerating and self.throttle ~= 0 then
local limit = 0.5
if self.throttle < limit then
self:drawTexture(x, y, calc.pi/2 - self.angle, scale, self.texture.lowThrust)
else
self:drawTexture(x, y, calc.pi/2 - self.angle, scale, self.texture.fullThrust)
end
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)
end
-- Ship Texture Drawing:
self:drawTexture(x, y, calc.pi/2 - self.angle, scale, self.texture.ship)
end
end

BIN
textures/player/orbiter.png View File

Before After
Width: 326  |  Height: 381  |  Size: 52 KiB

BIN
textures/player/orbiter/fullThrust.png View File

Before After
Width: 324  |  Height: 379  |  Size: 8.0 KiB

BIN
textures/player/orbiter/lowThrust.png View File

Before After
Width: 324  |  Height: 379  |  Size: 4.7 KiB

BIN
textures/player/orbiter/orbiter.png View File

Before After
Width: 324  |  Height: 379  |  Size: 39 KiB

+ 18
- 4
textures/textures.lua View File

@@ -1,10 +1,24 @@
texture = {
-- (G)UI Textures:
ui = {
arrow = {
grey = love.graphics.newImage("textures/ui/arrow_grey.png"),
red = love.graphics.newImage("textures/ui/arrow_red.png")
}
},

-- Player/Spacecraft Textures:
player = {
orbiter = "textures/player/orbiter.png"
-- Orbiter Spacecraft:
orbiter = {
ship = love.graphics.newImage("textures/player/orbiter/orbiter.png"),
lowThrust = love.graphics.newImage("textures/player/orbiter/lowThrust.png"),
fullThrust = love.graphics.newImage("textures/player/orbiter/fullThrust.png")
}
},
planet = {
-- here will go planet textures in future
}
-- Planet Textures:
planet = {}
}

return texture

BIN
textures/ui/arrow_grey.png View File

Before After
Width: 1000  |  Height: 1000  |  Size: 56 KiB

BIN
textures/ui/arrow_red.png View File

Before After
Width: 1000  |  Height: 1000  |  Size: 57 KiB

Loading…
Cancel
Save