Browse Source

Added hints, level 5 and made some limited changes to code

tags/6
Madiwka 3 years ago
parent
commit
74f54faa3f
13 changed files with 205 additions and 21 deletions
  1. +7
    -2
      buttonClutter.lua
  2. +12
    -3
      entities/ship/ship.lua
  3. +11
    -1
      levels/level1.lua
  4. +10
    -0
      levels/level2.lua
  5. +10
    -1
      levels/level3.lua
  6. +12
    -2
      levels/level4.lua
  7. +74
    -0
      levels/level5.lua
  8. +4
    -4
      levels/levelgeneral.lua
  9. +11
    -2
      levels/menu.lua
  10. +8
    -0
      levels/practice.lua
  11. +18
    -3
      levels/selectlv.lua
  12. +1
    -0
      main.lua
  13. +27
    -3
      src/GUI.lua

+ 7
- 2
buttonClutter.lua View File

@@ -9,7 +9,7 @@ function buttonClutter()
function()
gameState = "selectlv"
end))
--[[table.insert(buttons, menu:addButton("Toggle Fullscreen",
table.insert(buttons, menu:addButton("Toggle Fullscreen",
function()
myscreen:toggle(WINDOW_HEIGHT, WINDOW_WIDTH)
DIFFERENCE_X = myscreen.c
@@ -17,7 +17,12 @@ function buttonClutter()
OFFSET_X = myscreen.e
OFFSET_Y = myscreen.f
end
))]]--
))
table.insert(buttons, menu:addButton("Quit",
function()
love.event.quit()
end
))
end
local t=0
function explode(x, y)


+ 12
- 3
entities/ship/ship.lua View File

@@ -19,17 +19,22 @@ self.path = {}
self.dottimer = 0.5
self.fuel = 0
end
function ship:newPathDot(dotx, doty)
function ship:newPathDot(dotx, doty, color)
return {
x = dotx,
y = doty
y = doty,
color = color
}
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))
if (love.keyboard.isDown('w') and self.fuel > 0) then
table.insert(self.path, self:newPathDot(self.x, self.y, 1))
else
table.insert(self.path, self:newPathDot(self.x, self.y, 2))
end
self.dottimer = 0.2
end
if love.timer.getFPS() < 20 then
@@ -94,7 +99,11 @@ 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.9,0.9,0.9,1)
if (self.path[i].color < 2) then
love.graphics.setColor(0.9,0.4,0.4,1)
end
--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


+ 11
- 1
levels/level1.lua View File

@@ -33,6 +33,16 @@ function level1.load()
end))
table.insert(planets, planet(700, 200, 50, 0.3, planetImage, "nodelete"))
end
function level1.hint()
GUIDraw("left")
love.graphics.setFont(tinyfont)
if (VCAM.x > WINDOW_WIDTH/2) then
love.graphics.print("←[A]",10,50)
end
if (VCAM.x < WINDOW_WIDTH*2) then
love.graphics.print("[D]→",100,50)
end
end
function level1.reset()
firstShip:reset()
for k in pairs(planets) do
@@ -49,7 +59,7 @@ function level1.GUIControl()
if (love.keyboard.isDown('a') and VCAM.x > WINDOW_WIDTH/2) then
VCAM.x = VCAM.x - 10
end
if (love.keyboard.isDown('d')) then
if (love.keyboard.isDown('d') and VCAM.x < WINDOW_WIDTH*2) then
VCAM.x = VCAM.x + 10
end
end


+ 10
- 0
levels/level2.lua View File

@@ -45,6 +45,16 @@ function level2.reset()
shipIsHit = false
planetsleft = 3
end
function level2.hint()
GUIDraw("left")
love.graphics.setFont(tinyfont)
if (VCAM.x > WINDOW_WIDTH/2) then
love.graphics.print("←[A]",10,50)
end
if (VCAM.x < WINDOW_WIDTH*2) then
love.graphics.print("[D]→",100,50)
end
end
function level2.GUIControl()
if (love.keyboard.isDown('a') and VCAM.x > WINDOW_WIDTH/2) then
VCAM.x = VCAM.x - 10


+ 10
- 1
levels/level3.lua View File

@@ -35,7 +35,16 @@ function level3.load()
table.insert(planets, planet(700, 300, 50, 0.3, planetImage, "nodelete"))
table.insert(planets, planet(900, 200, 50, 0.3, planetImage, "nodelete"))
end

function level3.hint()
GUIDraw("left")
love.graphics.setFont(tinyfont)
if (VCAM.x > WINDOW_WIDTH/2) then
love.graphics.print("←[A]",10,50)
end
if (VCAM.x < WINDOW_WIDTH*2) then
love.graphics.print("[D]→",100,50)
end
end
function level3.reset()
firstShip:reset()
for k in pairs(planets) do


+ 12
- 2
levels/level4.lua View File

@@ -49,13 +49,23 @@ function level4.reset()
planetsleft = 3
end
function level4.GUIControl()
if (love.keyboard.isDown('a') and VCAM.x > -WINDOW_WIDTH) then
if (love.keyboard.isDown('a') and VCAM.x > -WINDOW_WIDTH/2) then
VCAM.x = VCAM.x - 10
end
if (love.keyboard.isDown('d') and VCAM.x < WINDOW_WIDTH*2) then
if (love.keyboard.isDown('d') and VCAM.x < WINDOW_WIDTH) then
VCAM.x = VCAM.x + 10
end
end
function level4.hint()
GUIDraw("left")
love.graphics.setFont(tinyfont)
if (VCAM.x > -WINDOW_WIDTH/2) then
love.graphics.print("←[A]",10,50)
end
if (VCAM.x < WINDOW_WIDTH) then
love.graphics.print("[D]→",100,50)
end
end
function level4.goBack()
levelgeneral.goBack()
end


+ 74
- 0
levels/level5.lua View File

@@ -0,0 +1,74 @@
level5 = Class{}
local levelLoaded = false
local M = {}
function level5.load()
shipsleft = 1
local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
planetsleft = 5
gameStatus = "setup"
playbutts = {}
guibutts = {}
thrusterMax = 100
firstShip.fuel = 100
VCAM.x, VCAM.y = 0, WINDOW_HEIGHT/2
explosions = {}
shipIsHit = false
guimenu = mainMenu()
reachedGoal = false
lvlbase = base(50, 2000)
levelLoaded = true
table.insert(playbutts, menu:addButton("Return to setup", function()
gameStatus = "setup"
levelgeneral.reset()
end ))
table.insert(guibutts, menu:addButton("Release brake!", function ()
if shipsleft == 0 then
selectedItem = "none"
gameStatus = "play"
end
end
))
table.insert(guibutts, menu:addButton("To menu", function ()
levelgeneral.goBack()
end))
table.insert(planets, planet(0, 2000, 50, 0.3, planetImage, "nodelete"))
table.insert(planets, planet(100, 2000, 50, 0.3, planetImage, "nodelete"))
table.insert(planets, planet(50, 1700, 50, 0.3, planetImage, "nodelete"))
end

function level5.reset()
firstShip:reset()
for k in pairs(planets) do
if planets[k].deletable then
planets[k] = nil
end
end
local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
shipsleft = 1
firstShip.fuel = 100
shipIsHit = false
planetsleft = 5
end
function level5.GUIControl()
if (love.keyboard.isDown('w') and VCAM.y > -WINDOW_WIDTH) then
VCAM.y = VCAM.y - 10
end
if (love.keyboard.isDown('s') and VCAM.y < WINDOW_WIDTH*2) then
VCAM.y = VCAM.y + 10
end
end
function level5.hint()
GUIDraw("up")
love.graphics.setFont(tinyfont)
if (VCAM.y > -WINDOW_WIDTH) then
love.graphics.print("↑[W]",50,10)
end
if (VCAM.y < WINDOW_WIDTH*2) then
love.graphics.print("↓[D]",50,100)
end
end
function level5.goBack()
levelgeneral.goBack()
end
return level5


+ 4
- 4
levels/levelgeneral.lua View File

@@ -95,12 +95,12 @@ function levelgeneral.draw()
love.graphics.printf("Press Enter to continue",0, 600, WINDOW_WIDTH, "center")
end
if gameStatus == "setup" and not reachedGoal then
GUIDraw("left")
level.hint()
elseif gameStatus == "play" then
if not reachedGoal then
love.graphics.printf("Thrusters: ", 0, WINDOW_HEIGHT-100, 300, "center")
local m = smallfont:getWidth("Thrusters: ")
local n = smallfont:getHeight("Thrusters: ")
love.graphics.printf("[W] Thrusters: ", 0, WINDOW_HEIGHT-100, 300, "center")
local m = smallfont:getWidth("[W] Thrusters: ")
local n = smallfont:getHeight("[W] Thrusters: ")
love.graphics.setColor(1,0,0,1)
love.graphics.rectangle("fill",0, WINDOW_HEIGHT-50, thrusterMax/2, n)
love.graphics.setColor(0,1,0,1)


+ 11
- 2
levels/menu.lua View File

@@ -4,9 +4,14 @@ menuLoaded = false
function menu.update(dt)
if not menuLoaded then
firstShip.x = -100
firstShip.y = love.math.random(0, WINDOW_HEIGHT)
menuLoaded = true
planets = {}
table.insert(planets, planet(love.math.random(100, WINDOW_WIDTH-100), love.math.random(100, WINDOW_HEIGHT-100), 90000000, 0.3, love.graphics.newImage("entities/planet/planet.png")))
if (planets[1].y < WINDOW_HEIGHT/2) then
firstShip.y = love.math.random(WINDOW_HEIGHT/2, WINDOW_HEIGHT)
else
firstShip.y = love.math.random(0, WINDOW_HEIGHT/2)
end
end
for i in ipairs(planets) do
planets[i]:update(dt)
@@ -19,7 +24,11 @@ function menu.update(dt)
shipIsHit = false
firstShip:reset()
firstShip.x = -100
firstShip.y = love.math.random(0, WINDOW_HEIGHT)
if (planets[1].y < WINDOW_HEIGHT/2) then
firstShip.y = love.math.random(WINDOW_HEIGHT/2, WINDOW_HEIGHT)
else
firstShip.y = love.math.random(0, WINDOW_HEIGHT/2)
end
--print("ship is hit")
end
end


+ 8
- 0
levels/practice.lua View File

@@ -119,4 +119,12 @@ function practice.GUIControl()
VCAM.x = VCAM.x + 10
end
end
function practice.hint()
love.graphics.setFont(tinyfont)
love.graphics.print("↑[W]",50,10)
love.graphics.print("↓[S]",50,100)
love.graphics.print("←[A]",10,50)
love.graphics.print("→[D]",100,50)

end
return practice

+ 18
- 3
levels/selectlv.lua View File

@@ -30,7 +30,14 @@ table.insert(levels, menu:addButton("Level 2", function ()
currentLevel = 4
end
end ))

table.insert(levels, menu:addButton("Level 5", function ()
if saveData.levelsBeaten > 3 then
menuLoaded = false
objReset()
gameState = "levelgeneral"
currentLevel = 5
end
end ))


table.insert(levels, menu:addButton("Go Back", function ()
@@ -40,9 +47,13 @@ local M = {}
function selectlv.update(dt)
if not menuLoaded then
firstShip.x = -100
firstShip.y = love.math.random(0, WINDOW_HEIGHT)
menuLoaded = true
table.insert(planets, planet(love.math.random(100, WINDOW_WIDTH-100), love.math.random(100, WINDOW_HEIGHT-100), 90000000, 0.3, love.graphics.newImage("entities/planet/planet.png")))
if (planets[1].y < WINDOW_HEIGHT/2) then
firstShip.y = love.math.random(WINDOW_HEIGHT/2, WINDOW_HEIGHT)
else
firstShip.y = love.math.random(0, WINDOW_HEIGHT/2)
end
end
for i in ipairs(planets) do
planets[i]:update(dt)
@@ -52,7 +63,11 @@ function selectlv.update(dt)
shipIsHit = false
firstShip:reset()
firstShip.x = -100
firstShip.y = love.math.random(0, WINDOW_HEIGHT)
if (planets[1].y < WINDOW_HEIGHT/2) then
firstShip.y = love.math.random(WINDOW_HEIGHT/2, WINDOW_HEIGHT)
else
firstShip.y = love.math.random(0, WINDOW_HEIGHT/2)
end
--print("ship is hit")
end
end


+ 1
- 0
main.lua View File

@@ -37,6 +37,7 @@ function love.load()
simpleScale.setWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT)
firstShip = ship(-500, -500, "entities/ship/smol_white_01.png")
VCAM = VCAM(WINDOW_WIDTH/2, WINDOW_HEIGHT/2)
tinyfont = love.graphics.newFont("font.ttf", 15)
smallfont = love.graphics.newFont("font.ttf", 25)
titlefont = love.graphics.newFont("font.ttf", 50)
myscreen = fullScreener(RESOLUTION_SET, isFullscreen, DIFFERENCE_X, DIFFERENCE_Y, OFFSET_X, OFFSET_Y)


+ 27
- 3
src/GUI.lua View File

@@ -29,11 +29,12 @@ function GUIDraw(mode)

--PLACING
local mx, my = love.mouse.getPosition()
local vmx, vmy = camera:getMousePosition()
local vmx = vmx * DIFFERENCE_X
local vmy = vmy * DIFFERENCE_Y
-- local vmx = vmx * DIFFERENCE_X
-- local vmy = vmy * DIFFERENCE_Y
local mx = mx * DIFFERENCE_X
local my = my * DIFFERENCE_Y
local vmx, vmy = camera:toWorldCoords(mx, my)
if mode == "anywhere" then
love.graphics.setColor(1,1,1,0.5)
if selectedItem == "ship" and mx < menuX then
@@ -73,6 +74,29 @@ function GUIDraw(mode)
selectedItem = "none"
end
end
elseif mode == "up" then
love.graphics.setColor(1,1,1,0.5)
if selectedItem == "ship" and mx < menuX then
local shipW = shipImage:getWidth()
local shipH = shipImage:getHeight()
if VCAM.y > WINDOW_HEIGHT/2-1 then
love.graphics.draw(shipImage,mx,10, 1.5708, 1, 1, shipW/2, shipH/2)
elseif VCAM.y > -WINDOW_HEIGHT/2+(WINDOW_HEIGHT-(WINDOW_HEIGHT-firstShip.width/2)) then
local timex, timey = camera:toCameraCoords(0, 100)
love.graphics.draw(shipImage,mx,timey, 1.5708, 1, 1, shipW/2, shipH/2)
else
love.graphics.draw(shipImage,mx,WINDOW_HEIGHT-firstShip.height/2, 1.5708, 1, 1, shipW/2, shipH/2)
end
if love.keyboard.mouseisReleased then
love.keyboard.mouseisReleased = false
firstShip.x = vmx
firstShip.y = 100
shipsleft = shipsleft - 1
end
if shipsleft == 0 then
selectedItem = "none"
end
end
end
local dx, dy = camera:toCameraCoords(firstShip.x, firstShip.y)
if VCAM.x - WINDOW_WIDTH/2+250 > firstShip.x and shipsleft == 0 then


Loading…
Cancel
Save