Skip to content

Commit

Permalink
Fixed anti-aliasing error, made player blue.
Browse files Browse the repository at this point in the history
  • Loading branch information
zenzoa committed Feb 1, 2015
1 parent 275a2c1 commit adb4118
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 20 deletions.
Binary file modified assets/tutorial-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/tutorial-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/tutorial-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/tutorial-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/tutorial-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/tutorial-7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion flyers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function newFlyer (location, fixedDestination, origin, destination, color)
else
love.graphics.setColor(self.color.r, self.color.g, self.color.b)
end
love.graphics.circle('fill', self.location.x*ZOOM, self.location.y*ZOOM, UNIT_RADIUS*0.8*ZOOM, SEGMENTS)
drawFilledCircle(self.location.x, self.location.y, UNIT_RADIUS*0.8)
end

function f:setVelocityTo (location)
Expand Down
15 changes: 12 additions & 3 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ FPS = 60
TURN_TIME = 30.0
ZOOM = 0.5
UNIT_RADIUS = 5
SEGMENTS = 30
SEGMENTS = 60

UNIVERSE_SIZE = 10
WORLD_SIZE = {width = 0, height = 0}
Expand All @@ -40,9 +40,10 @@ function love.load()

-- Setup window
love.window.setTitle("Prospora")
love.window.setMode(600, 600, {fsaa=16})
love.window.setMode(600, 600)
love.graphics.setBackgroundColor(51, 51, 51)
love.graphics.setLineStyle('smooth')
love.graphics.setPointStyle('rough')

-- setup fonts
font = love.graphics.newFont('assets/furore.otf', 20)
Expand Down Expand Up @@ -139,4 +140,12 @@ end
function adjustOffset ()
OFFSET.x = math.min(0, math.max(-WORLD_SIZE.width * ZOOM + love.graphics.getWidth(), OFFSET.x))
OFFSET.y = math.min(0, math.max(-WORLD_SIZE.height * ZOOM + love.graphics.getHeight(), OFFSET.y))
end
end

--

function drawFilledCircle(x, y, r)
love.graphics.circle('fill', x*ZOOM, y*ZOOM, r*ZOOM-.5, SEGMENTS)
love.graphics.setLineWidth(1)
love.graphics.circle('line', x*ZOOM, y*ZOOM, r*ZOOM-.5, SEGMENTS)
end
18 changes: 18 additions & 0 deletions maths.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,22 @@ function tableSize(t)
count = count + 1
end
return count
end

--

function HSL(h, s, l, a)
if s<=0 then return l,l,l,a end
h, s, l = h/256*6, s/255, l/255
local c = (1-math.abs(2*l-1))*s
local x = (1-math.abs(h%2-1))*c
local m,r,g,b = (l-.5*c), 0,0,0
if h < 1 then r,g,b = c,x,0
elseif h < 2 then r,g,b = x,c,0
elseif h < 3 then r,g,b = 0,c,x
elseif h < 4 then r,g,b = 0,x,c
elseif h < 5 then r,g,b = x,0,c
else r,g,b = c,0,x
end
return (r+m)*255, (g+m)*255, (b+m)*255, a
end
26 changes: 17 additions & 9 deletions memes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ function newMeme ()
m.con = randomRealBetween(0, 1)
m.fec = randomRealBetween(0, 1)

m.color = {r = randomIntegerBetween(55, 255),
local hue = randomRealBetween(0,240)
if hue>180 then hue=hue+120 end
hue = hue*255/360
local sat = randomRealBetween(100,255)
local lit = randomRealBetween(100,200)

m.color = {}
m.color.r, m.color.g, m.color.b = HSL(hue, sat, lit)

--[[m.color = {
r = randomIntegerBetween(55, 255),
g = randomIntegerBetween(55, 255),
b = randomIntegerBetween(55, 255)
}
}]]--

function m:adjustGenes ()
local t = m.agg + m.con + m.fec
Expand Down Expand Up @@ -124,16 +134,14 @@ function newUnit (planet, meme)
end

function u:draw ()
local l = vMul(self.location, ZOOM)
self.meme:setToMyColor()
local r = UNIT_RADIUS * ZOOM
if self.growing then
love.graphics.circle('fill', l.x, l.y, r * self.animationCounter, SEGMENTS)
drawFilledCircle(self.location.x, self.location.y, UNIT_RADIUS * self.animationCounter)
elseif self.dying then
love.graphics.setColor(255, 255, 255, 255 * (1 - self.animationCounter))
love.graphics.circle('fill', l.x, l.y, r * self.animationCounter * 4, SEGMENTS)
drawFilledCircle(self.location.x, self.location.y, UNIT_RADIUS * self.animationCounter * 4)
self.meme:setToMyColor()
love.graphics.circle('fill', l.x, l.y, r * (1 - self.animationCounter), SEGMENTS)
drawFilledCircle(self.location.x, self.location.y, UNIT_RADIUS * (1 - self.animationCounter))

-- alert player to attacks on their home planet
if self.planet == human.homeWorld and self.meme == human.meme then
Expand All @@ -146,11 +154,11 @@ function newUnit (planet, meme)

elseif self.flying and self.flyer ~= nil then
if self.flyer.attackDrone then
love.graphics.circle('fill', l.x, l.y, r, SEGMENTS)
drawFilledCircle(self.location.x, self.location.y, UNIT_RADIUS)
end
self.flyer:draw()
elseif not self.waiting then
love.graphics.circle('fill', l.x, l.y, r, SEGMENTS)
drawFilledCircle(self.location.x, self.location.y, UNIT_RADIUS)
end
end

Expand Down
2 changes: 1 addition & 1 deletion planets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function newPlanet (id, sun, unitSpaces, isHomeWorld, meme)
else
love.graphics.setColor(100, 100, 100)
end
love.graphics.circle('fill', self.location.x*ZOOM, self.location.y*ZOOM, self.radius*ZOOM, SEGMENTS)
drawFilledCircle(self.location.x, self.location.y, self.radius)

-- draw memes
drawUnits(self)
Expand Down
4 changes: 2 additions & 2 deletions players.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function newPlayer ()
local p = {}

p.meme = newMeme()
p.meme.color = {r=255, g=255, b=255}
p.meme.color = { r=50, g=186, b=250 }
p.selectedPlanet = nil
p.homeWorld = nil
p.homeUnderAttack = false
Expand Down Expand Up @@ -34,7 +34,7 @@ function drawHalo ()
d = vNormalize(d)
d = vMul(d, haloRadius)
d = vAdd(d, p.location)
love.graphics.circle('fill', d.x * ZOOM, d.y * ZOOM, UNIT_RADIUS, SEGMENTS)
drawFilledCircle(d.x, d.y, UNIT_RADIUS/ZOOM)
end

else
Expand Down
2 changes: 1 addition & 1 deletion screenMode-game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function gameMode:draw ()
else
love.graphics.setColor(0, 170, 250, 150)
end
love.graphics.circle('fill', self.handlePause.x, self.handlePause.y, 20, SEGMENTS)
drawFilledCircle(self.handlePause.x/ZOOM, self.handlePause.y/ZOOM, 20/ZOOM)
love.graphics.setColor(255, 255, 255)
love.graphics.setLineWidth(5)
love.graphics.line(self.handlePause.x-6, self.handlePause.y-9, self.handlePause.x-6, self.handlePause.y+9)
Expand Down
3 changes: 2 additions & 1 deletion stars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ function newStar ()

function s:draw ()
love.graphics.setColor(self.glitter, self.glitter, self.glitter)
love.graphics.circle('fill', self.location.x*ZOOM, self.location.y*ZOOM, 0.5)
--love.graphics.circle('fill', self.location.x*ZOOM, self.location.y*ZOOM, 1)
love.graphics.point(self.location.x*ZOOM, self.location.y*ZOOM)
end

return s
Expand Down
4 changes: 2 additions & 2 deletions suns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ function newSun (location, radius)

function s:draw ()
love.graphics.setColor(255, 255, 255, 177)
love.graphics.circle('fill', self.location.x*ZOOM, self.location.y*ZOOM, (self.radius+self.corona)*ZOOM, SEGMENTS*2)
drawFilledCircle(self.location.x, self.location.y, self.radius+self.corona)
love.graphics.setColor(255, 255, 255, 255)
love.graphics.circle('fill', self.location.x*ZOOM, self.location.y*ZOOM, self.radius*ZOOM, SEGMENTS*2)
drawFilledCircle(self.location.x, self.location.y, self.radius)
end

s.newOrbit = function (self)
Expand Down

0 comments on commit adb4118

Please sign in to comment.