Преглед изворни кода

easier setColour() function (support for rgb and monochrome) + tweaks for builder

tags/v0.0.6_dev
Niro пре 4 година
родитељ
комит
1d9446df67
10 измењених фајлова са 66 додато и 37 уклоњено
  1. +0
    -2
      .build/builds/readme.txt
  2. +14
    -5
      .build/make-exe.sh
  3. +2
    -1
      .build/make-love.sh
  4. +14
    -1
      build.sh
  5. +1
    -1
      data/starshipTypes.lua
  6. +19
    -5
      src/calc.lua
  7. +4
    -4
      src/class/Button.lua
  8. +4
    -10
      src/class/Menubutton.lua
  9. +2
    -2
      src/class/Planet.lua
  10. +6
    -6
      src/class/Textbox.lua

+ 0
- 2
.build/builds/readme.txt Прегледај датотеку

@@ -1,2 +0,0 @@
your builds will be moved into this folder :)
dont delete me, im here so github doesn't delete this directory... i found out the hard way qwq

+ 14
- 5
.build/make-exe.sh Прегледај датотеку

@@ -1,13 +1,22 @@
#!/bin/bash #!/bin/bash
echo -e "\e[1;33m Building .exe! \e[0m"
doZip=true
path="./.build" path="./.build"


# Windows Folder # Windows Folder
winPATH=$path"/builds/"$1"-win"
mkdir $winPATH
winPATH=$path"/builds/$1-win"
mkdir "$winPATH"


# Creating .exe # Creating .exe
cat $path"/love/love.exe" $path"/builds/"$1.love > $1.exe
mv $1.exe $winPATH
cat $path"/love/love.exe" $path"/builds/$1.love" > "$1.exe"
mv "$1.exe" "$winPATH"


# Moving dll's # Moving dll's
cp $path"/win/"* $winPATH
cp $path"/win/"* "$winPATH"

# Zip it if $doZip == "true"
if [[ $doZip == "true" ]]; then
name=$1"-win.zip"
zip "$path/builds/$name" -r "$winPATH"
rm -rf "$winPATH"
fi

+ 2
- 1
.build/make-love.sh Прегледај датотеку

@@ -1,3 +1,4 @@
#!/bin/bash #!/bin/bash
echo -e "\e[1;33m Building .love \e[0m"
zip -9 -r $1.love . -x ./.build/**\* ./.git/**\* zip -9 -r $1.love . -x ./.build/**\* ./.git/**\*
mv $1.love ./.build/builds
mv $1.love ./.build/builds

+ 14
- 1
build.sh Прегледај датотеку

@@ -1,11 +1,24 @@
#!/bin/bash #!/bin/bash
project=$1 project=$1


# Give Permissions
# Check if main.lua exists:
if [[ ! -f "main.lua" ]]; then
echo -e "\e[31m !! Could not find main.lua file, terminating build process !! \e[0m"
exit 1
fi

# Give Permissions and check for build directory:
chmod +x -R ./.build chmod +x -R ./.build
if [[ ! -d ./.build/builds ]]; then
mkdir ./.build/builds
fi


# Build .love # Build .love
./.build/make-love.sh $project ./.build/make-love.sh $project


# Build .exe # Build .exe
./.build/make-exe.sh $project ./.build/make-exe.sh $project

# End
echo -e "\e[1;33m Finished Building Project! \e[0m"
exit 0

+ 1
- 1
data/starshipTypes.lua Прегледај датотеку

@@ -3,7 +3,7 @@ starshipTypes = {
orbiter = { orbiter = {
name = "Classic 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.", 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 = 3,
impacttolerance = 5,
mass = 1000000, -- idk, feels better but holy fuck thats a thicc ass boi xD mass = 1000000, -- idk, feels better but holy fuck thats a thicc ass boi xD
speed = 0.01, speed = 0.01,
specials = {"orbitSync"}, specials = {"orbitSync"},


+ 19
- 5
src/calc.lua Прегледај датотеку

@@ -15,14 +15,26 @@ function calc.debug(text)
end end
end end


function calc.colour(r, g, b)
return { r/255, g/255, b/255 }
end
-- Turn 0-1 colour to 0-range (default: 255):
function calc.setColour(r, g, b, a)
-- Supported Inputs:
-- RGB: (r, g, b, a)
-- Greyscale: (luminance, a)
local range = 255

-- Set g and b value to r if in greyscale and :
if b == nil and a == nil then
a = g
g, b = r, r
end
-- Colour Conversion (0-1 -> 0-range)
r, g, b = r/range, g/range, b/range

-- If alpha not provided, set to 1 by default:
if a == nil then a = 1 end


function calc.c(value)
return value/255
-- Change Draw Colour:
love.graphics.setColor(r, g, b, a)
end end


-- Distance Formula: -- Distance Formula:


+ 4
- 4
src/class/Button.lua Прегледај датотеку

@@ -13,8 +13,8 @@ function Button:init(tempX, tempY, tempW, tempH, tempText, tempTC, tempBC, tempA
-- Text and Colours: -- Text and Colours:
self.text = tempText self.text = tempText
self.colour = { self.colour = {
text = calc.colour(tempTC[1], tempTC[2], tempTC[3]),
background = calc.colour(tempBC[1], tempBC[2], tempBC[3])
text = tempTC,
background = tempBC
} }


-- Click Cooldown: -- Click Cooldown:
@@ -76,11 +76,11 @@ function Button:draw()
end end


-- Draw Background -- Draw Background
love.graphics.setColor(bg[1], bg[2], bg[3])
calc.setColour(bg[1], bg[2], bg[3], bg[4])
love.graphics.rectangle("fill", x, y, w, h) love.graphics.rectangle("fill", x, y, w, h)


-- Draw Text -- Draw Text
love.graphics.setFont(font.default) love.graphics.setFont(font.default)
love.graphics.setColor(tx[1], tx[2], tx[3])
calc.setColour(tx[1], tx[2], tx[3], tx[4])
love.graphics.printf(self.text, x, y+h/8, w, "center") love.graphics.printf(self.text, x, y+h/8, w, "center")
end end

+ 4
- 10
src/class/Menubutton.lua Прегледај датотеку

@@ -60,26 +60,20 @@ end
function Menubutton:draw() function Menubutton:draw()
local x, y, w, h = self.x, self.y, self.w, self.h local x, y, w, h = self.x, self.y, self.w, self.h
local bg, tx = self.colour.background, self.colour.text local bg, tx = self.colour.background, self.colour.text
bg, tx = calc.colour(bg[1], bg[2], bg[3]), calc.colour(tx[1], tx[2], tx[3])


-- Hover Effects
-- Hover Effects:
if self:hover() then if self:hover() then
-- Slight Colour Lightup
for i = 1, #bg do
bg[i] = bg[i]*1.1
end

-- Slight pop up effect (purly visual)
-- Slight pop up effect (purly visual):
local pop = 3 local pop = 3
x, y, w, h = x-pop, y-pop, w+pop*2, h+pop*2 x, y, w, h = x-pop, y-pop, w+pop*2, h+pop*2
end end


-- Draw Background -- Draw Background
love.graphics.setColor(bg[1], bg[2], bg[3])
calc.setColour(bg[1], bg[2], bg[3], bg[4])
love.graphics.rectangle("fill", x, y, w, h) love.graphics.rectangle("fill", x, y, w, h)


-- Draw Text -- Draw Text
love.graphics.setFont(font.default) love.graphics.setFont(font.default)
love.graphics.setColor(tx[1], tx[2], tx[3])
calc.setColour(tx[1], tx[2], tx[3], tx[4])
love.graphics.printf(self.text, x, y, w, "center") love.graphics.printf(self.text, x, y, w, "center")
end end

+ 2
- 2
src/class/Planet.lua Прегледај датотеку

@@ -93,8 +93,8 @@ end


function Planet:draw() function Planet:draw()
local col = self.colour local col = self.colour
love.graphics.setColor(calc.c(col[1]), calc.c(col[2]), calc.c(col[3]))
calc.setColour(col[1], col[2], col[3], col[4])
love.graphics.circle("fill", self.x, self.y, self.r) love.graphics.circle("fill", self.x, self.y, self.r)
love.graphics.setColor(0.1,0.1,0.1,0.2)
love.graphics.setColor(0.1, 0.1, 0.1, 0.2)
love.graphics.circle("fill", self.x, self.y, self.r*2) love.graphics.circle("fill", self.x, self.y, self.r*2)
end end

+ 6
- 6
src/class/Textbox.lua Прегледај датотеку

@@ -13,8 +13,8 @@ function Textbox:init(tempX, tempY, tempW, tempH, tempText, tempAlign, tempTC, t


-- Colours: -- Colours:
self.colour = { self.colour = {
text = calc.colour(tempTC[1], tempTC[2], tempTC[3]),
background = calc.colour(tempBC[1], tempBC[2], tempBC[3])
text = tempTC,
background = tempBC
} }
end end


@@ -22,16 +22,16 @@ end
-- FUNCTIONS -- FUNCTIONS


function Textbox:drawBox() function Textbox:drawBox()
local c = self.colour.background
love.graphics.setColor(c[1], c[2], c[3], 0.7)
local col = self.colour.background
calc.setColour(col[1], col[2], col[3], 0.7)
love.graphics.rectangle("fill", self.x, self.y, self.w, self.h) love.graphics.rectangle("fill", self.x, self.y, self.w, self.h)
end end


function Textbox:drawText() function Textbox:drawText()
local border = 3 local border = 3
local c = self.colour.text
local col = self.colour.text
love.graphics.setFont(font.default) love.graphics.setFont(font.default)
love.graphics.setColor(c[1], c[2], c[3])
calc.setColour(col[1], col[2], col[3])
love.graphics.printf(self.text, self.x + border, self.y + border, self.w + border*2, self.align) love.graphics.printf(self.text, self.x + border, self.y + border, self.w + border*2, self.align)
end end




Loading…
Откажи
Сачувај