Browse Source

changed the look and fixed bugs

tags/earlywindows
Madiwka3 3 years ago
parent
commit
1103891a74
11 changed files with 46 additions and 20 deletions
  1. +1
    -1
      entities/planet/planet.lua
  2. +11
    -2
      entities/ship/ship.lua
  3. BIN
      entities/ship/smol_white_01.png
  4. +4
    -4
      levels/level1.lua
  5. +4
    -4
      levels/level2.lua
  6. +10
    -1
      levels/menu.lua
  7. +1
    -1
      levels/selectlv.lua
  8. BIN
      logo.png
  9. +10
    -4
      main.lua
  10. +4
    -2
      src/GUI.lua
  11. +1
    -1
      src/mainMenu.lua

+ 1
- 1
entities/planet/planet.lua View File

@@ -1,6 +1,6 @@
planet = Class{}

G = 6.67e-5
G = 6.67e-1

function planet:init(x, y, mass, radius, img)
self.x = x


+ 11
- 2
entities/ship/ship.lua View File

@@ -15,6 +15,7 @@ self.rotation = 1.5708
self.vector = 1.5708
self.color = {1,1,1,1}
self.path = {}
self.dottimer = 0.5
end
function ship:newPathDot(dotx, doty)
return {
@@ -24,7 +25,14 @@ function ship:newPathDot(dotx, doty)
end
function ship:update(dt)
if not shipIsHit then
self.dottimer = self.dottimer - dt
if self.dottimer < 0 then
table.insert(self.path, self:newPathDot(self.x, self.y))
self.dottimer = 0.5
end
if love.timer.getFPS() < 20 then
self.path = {}
end
self.x = self.x + self.dx/2
self.y = self.y + self.dy/2
if self.dx ~= 0 then
@@ -81,7 +89,7 @@ function ship:draw()
love.graphics.draw(self.image, self.x, self.y, self.vector, 1, 1, self.width/2, self.height/2)
for i in ipairs(self.path) do
if i > 1 then
love.graphics.setColor(0,1,0,1)
love.graphics.setColor(0.9,0.9,0.9,1)
print("DOING".. i)
love.graphics.line(self.path[i].x, self.path[i].y, self.path[i-1].x, self.path[i-1].y)
end
@@ -94,10 +102,11 @@ function ship:reset()
self.x = self.ox
self.y = self.oy
self.dy = 0
self.dx = 20
self.dx = 5
self.rotation = 1.57
self.canvas = love.graphics.newCanvas(WINDOW_WIDTH, WINDOW_HEIGHT)
self.vector = 1.56
self.speed = 0
self.path = {}
self.dottimer = 0.5
end

BIN
entities/ship/smol_white_01.png View File

Before After
Width: 64  |  Height: 64  |  Size: 4.6 KiB

+ 4
- 4
levels/level1.lua View File

@@ -32,11 +32,11 @@ function level1.update(dt)
end
if reachedGoal then
if levelsBeaten < 1 then
levelsBeaten = 1
if saveData.levelsBeaten < 1 then
saveData.levelsBeaten = 1
end
print("levelsBeaten is " .. levelsBeaten)
love.filesystem.write("save", levelsBeaten)
print("saveData.levelsBeaten is " .. saveData.levelsBeaten)
love.filesystem.write("save", serialize(saveData))
level1.goBack()
end
camera:update(dt)


+ 4
- 4
levels/level2.lua View File

@@ -32,11 +32,11 @@ function level2.update(dt)
end
if reachedGoal then
if levelsBeaten < 2 then
levelsBeaten = 2
if saveData.levelsBeaten < 2 then
saveData.levelsBeaten = 2
end
print("levelsBeaten is " .. levelsBeaten)
love.filesystem.write("save", levelsBeaten)
print("saveData.levelsBeaten is " .. saveData.levelsBeaten)
love.filesystem.write("save", serialize(saveData))
level2.goBack()
end
camera:update(dt)


+ 10
- 1
levels/menu.lua View File

@@ -1,11 +1,20 @@
menu = Class{}
local M = {}
function menu.update(dt)

if animationSecsLeft > 0 then
animationSecsLeft = animationSecsLeft - dt
end
end

function menu.draw(dt)
if animationSecsLeft > 0 then
love.graphics.setColor(1,1,1,1-1/(animationSecsLeft+0.000001))
love.graphics.draw(logo, 0,0)
else
love.graphics.setFont(titlefont)
love.graphics.printf("NuclearGravity", 0, 20, WINDOW_WIDTH, "center")
menu:butt(buttons, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, 40, WINDOW_WIDTH/3)
end
end

return menu

+ 1
- 1
levels/selectlv.lua View File

@@ -4,7 +4,7 @@ table.insert(levels, menu:addButton("Level 1", function ()
gameState = "level1"
end ))
table.insert(levels, menu:addButton("Level 2", function ()
if levelsBeaten > 0 then
if saveData.levelsBeaten > 0 then
gameState = "level2"
end
end ))


BIN
logo.png View File

Before After
Width: 1280  |  Height: 720  |  Size: 22 KiB

+ 10
- 4
main.lua View File

@@ -1,4 +1,5 @@
gameState = "menu"
animationSecsLeft = 3
require 'src/dependencies'
math.randomseed(os.time())
--VARIABLES
@@ -11,7 +12,10 @@ WINDOW_HEIGHT = 720
OFFSET_X = 0
OFFSET_Y = 0

levelsBeaten = 0
saveData = {
levelsBeaten = 0
}

planets = {}
buttons = {}
menu = mainMenu()
@@ -19,7 +23,7 @@ menu = mainMenu()
function love.load()
testwalls = love.filesystem.load("save")
if testwalls ~= nil then
levelsBeaten = love.filesystem.load("save")
saveData = love.filesystem.load("save")()
print("Save file found")
else
print("No save file found!")
@@ -27,10 +31,12 @@ function love.load()
tick.framerate = 60
camera = Camera()
BG = love.graphics.newImage("entities/background.jpg")
logo = love.graphics.newImage("logo.png")
simpleScale.setWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT)
firstShip = ship(-500, -500, "entities/ship/smol_red_01.png")
firstShip = ship(-500, -500, "entities/ship/smol_white_01.png")
VCAM = VCAM(WINDOW_WIDTH/2, WINDOW_HEIGHT/2)
smallfont = love.graphics.newFont("font.ttf", 25)
titlefont = love.graphics.newFont("font.ttf", 50)
--table.insert(planets, planet(100, WINDOW_HEIGHT/2-100, 1010000000, 1))
buttonClutter()
--planet2 = planet(1000, 300, 1000000000, 20)
@@ -43,7 +49,7 @@ end

function love.draw()
simpleScale.set()
--love.graphics.draw(BG, 0, 0)
love.graphics.clear(30 / 255,30 / 255,30 / 255,1)
stateDraw()
simpleScale.unSet()
end


+ 4
- 2
src/GUI.lua View File

@@ -18,11 +18,12 @@ function GUIDraw(mode)
--MAIN

--SHIP
local shipImage = love.graphics.newImage("entities/ship/smol_red_01.png")
local shipImage = love.graphics.newImage("entities/ship/smol_white_01.png")
GUIButton(shipsleft, shipImage, menuX + 60, menuY+WINDOW_HEIGHT*0.2, function() selectedItem = "ship" end, 1, 1, {1,1,1,1}, 1.57)
--SHIP
--PLANET
GUIButton(planetsleft, planetImage, menuX + 60, menuY+WINDOW_HEIGHT*0.4, function() selectedItem = "planet" end, 0.5, 0.5, {1,1,1,1}, 1.57)
--PLANET


@@ -121,13 +122,14 @@ function GUIDraw(mode)
love.graphics.rectangle("fill", menuX-10, dy-lvlbase.w/2, 10, lvlbase.w)
end
end
love.graphics.setColor(1,1,1,1)
if selectedItem == "planet" and mx < menuX then
local shipW = planetImage:getWidth()
local shipH = planetImage:getHeight()
love.graphics.draw(planetImage,mx,my,0, 0.3, 0.3, shipW/2, shipH/2)
if love.keyboard.mouseisReleased then
love.keyboard.mouseisReleased = false
table.insert(planets, planet(vmx, vmy, 1000000000, 0.3, planetImage))
table.insert(planets, planet(vmx, vmy, 100000000, 0.3, planetImage))
planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
planetsleft = planetsleft-1
end


+ 1
- 1
src/mainMenu.lua View File

@@ -27,7 +27,7 @@ function mainMenu:butt(buttons, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, locationx, locati
break
end
if arg == "beatenGreen" then
if i <= levelsBeaten then
if i <= saveData.levelsBeaten then
color = {0,1,0,1}
end
end


Loading…
Cancel
Save