merge thingytags/6
@@ -9,7 +9,7 @@ function buttonClutter() | |||||
function() | function() | ||||
gameState = "selectlv" | gameState = "selectlv" | ||||
end)) | end)) | ||||
--[[table.insert(buttons, menu:addButton("Toggle Fullscreen", | |||||
table.insert(buttons, menu:addButton("Toggle Fullscreen", | |||||
function() | function() | ||||
myscreen:toggle(WINDOW_HEIGHT, WINDOW_WIDTH) | myscreen:toggle(WINDOW_HEIGHT, WINDOW_WIDTH) | ||||
DIFFERENCE_X = myscreen.c | DIFFERENCE_X = myscreen.c | ||||
@@ -17,7 +17,12 @@ function buttonClutter() | |||||
OFFSET_X = myscreen.e | OFFSET_X = myscreen.e | ||||
OFFSET_Y = myscreen.f | OFFSET_Y = myscreen.f | ||||
end | end | ||||
))]]-- | |||||
)) | |||||
table.insert(buttons, menu:addButton("Quit", | |||||
function() | |||||
love.event.quit() | |||||
end | |||||
)) | |||||
end | end | ||||
local t=0 | local t=0 | ||||
function explode(x, y) | function explode(x, y) | ||||
@@ -19,17 +19,22 @@ self.path = {} | |||||
self.dottimer = 0.5 | self.dottimer = 0.5 | ||||
self.fuel = 0 | self.fuel = 0 | ||||
end | end | ||||
function ship:newPathDot(dotx, doty) | |||||
function ship:newPathDot(dotx, doty, color) | |||||
return { | return { | ||||
x = dotx, | x = dotx, | ||||
y = doty | |||||
y = doty, | |||||
color = color | |||||
} | } | ||||
end | end | ||||
function ship:update(dt) | function ship:update(dt) | ||||
if not shipIsHit then | if not shipIsHit then | ||||
self.dottimer = self.dottimer - dt | self.dottimer = self.dottimer - dt | ||||
if self.dottimer < 0 then | 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 | self.dottimer = 0.2 | ||||
end | end | ||||
if love.timer.getFPS() < 20 then | 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) | 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 | for i in ipairs(self.path) do | ||||
if i > 1 then | if i > 1 then | ||||
love.graphics.setColor(0.9,0.9,0.9,1) | 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) | --print("DOING".. i) | ||||
love.graphics.line(self.path[i].x, self.path[i].y, self.path[i-1].x, self.path[i-1].y) | love.graphics.line(self.path[i].x, self.path[i].y, self.path[i-1].x, self.path[i-1].y) | ||||
end | end | ||||
@@ -33,6 +33,16 @@ function level1.load() | |||||
end)) | end)) | ||||
table.insert(planets, planet(700, 200, 50, 0.3, planetImage, "nodelete")) | table.insert(planets, planet(700, 200, 50, 0.3, planetImage, "nodelete")) | ||||
end | 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() | function level1.reset() | ||||
firstShip:reset() | firstShip:reset() | ||||
for k in pairs(planets) do | 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 | if (love.keyboard.isDown('a') and VCAM.x > WINDOW_WIDTH/2) then | ||||
VCAM.x = VCAM.x - 10 | VCAM.x = VCAM.x - 10 | ||||
end | end | ||||
if (love.keyboard.isDown('d')) then | |||||
if (love.keyboard.isDown('d') and VCAM.x < WINDOW_WIDTH*2) then | |||||
VCAM.x = VCAM.x + 10 | VCAM.x = VCAM.x + 10 | ||||
end | end | ||||
end | end | ||||
@@ -45,6 +45,16 @@ function level2.reset() | |||||
shipIsHit = false | shipIsHit = false | ||||
planetsleft = 3 | planetsleft = 3 | ||||
end | 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() | function level2.GUIControl() | ||||
if (love.keyboard.isDown('a') and VCAM.x > WINDOW_WIDTH/2) then | if (love.keyboard.isDown('a') and VCAM.x > WINDOW_WIDTH/2) then | ||||
VCAM.x = VCAM.x - 10 | VCAM.x = VCAM.x - 10 | ||||
@@ -35,7 +35,16 @@ function level3.load() | |||||
table.insert(planets, planet(700, 300, 50, 0.3, planetImage, "nodelete")) | table.insert(planets, planet(700, 300, 50, 0.3, planetImage, "nodelete")) | ||||
table.insert(planets, planet(900, 200, 50, 0.3, planetImage, "nodelete")) | table.insert(planets, planet(900, 200, 50, 0.3, planetImage, "nodelete")) | ||||
end | 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() | function level3.reset() | ||||
firstShip:reset() | firstShip:reset() | ||||
for k in pairs(planets) do | for k in pairs(planets) do | ||||
@@ -49,13 +49,23 @@ function level4.reset() | |||||
planetsleft = 3 | planetsleft = 3 | ||||
end | end | ||||
function level4.GUIControl() | 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 | VCAM.x = VCAM.x - 10 | ||||
end | 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 | VCAM.x = VCAM.x + 10 | ||||
end | end | ||||
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() | function level4.goBack() | ||||
levelgeneral.goBack() | levelgeneral.goBack() | ||||
end | end | ||||
@@ -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 | |||||
@@ -95,12 +95,12 @@ function levelgeneral.draw() | |||||
love.graphics.printf("Press Enter to continue",0, 600, WINDOW_WIDTH, "center") | love.graphics.printf("Press Enter to continue",0, 600, WINDOW_WIDTH, "center") | ||||
end | end | ||||
if gameStatus == "setup" and not reachedGoal then | if gameStatus == "setup" and not reachedGoal then | ||||
GUIDraw("left") | |||||
level.hint() | |||||
elseif gameStatus == "play" then | elseif gameStatus == "play" then | ||||
if not reachedGoal 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.setColor(1,0,0,1) | ||||
love.graphics.rectangle("fill",0, WINDOW_HEIGHT-50, thrusterMax/2, n) | love.graphics.rectangle("fill",0, WINDOW_HEIGHT-50, thrusterMax/2, n) | ||||
love.graphics.setColor(0,1,0,1) | love.graphics.setColor(0,1,0,1) | ||||
@@ -4,9 +4,14 @@ menuLoaded = false | |||||
function menu.update(dt) | function menu.update(dt) | ||||
if not menuLoaded then | if not menuLoaded then | ||||
firstShip.x = -100 | firstShip.x = -100 | ||||
firstShip.y = love.math.random(0, WINDOW_HEIGHT) | |||||
menuLoaded = true | 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"))) | 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 | end | ||||
for i in ipairs(planets) do | for i in ipairs(planets) do | ||||
planets[i]:update(dt) | planets[i]:update(dt) | ||||
@@ -19,7 +24,11 @@ function menu.update(dt) | |||||
shipIsHit = false | shipIsHit = false | ||||
firstShip:reset() | firstShip:reset() | ||||
firstShip.x = -100 | 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") | --print("ship is hit") | ||||
end | end | ||||
end | end | ||||
@@ -119,4 +119,12 @@ function practice.GUIControl() | |||||
VCAM.x = VCAM.x + 10 | VCAM.x = VCAM.x + 10 | ||||
end | end | ||||
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 | return practice |
@@ -30,7 +30,14 @@ table.insert(levels, menu:addButton("Level 2", function () | |||||
currentLevel = 4 | currentLevel = 4 | ||||
end | end | ||||
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 () | table.insert(levels, menu:addButton("Go Back", function () | ||||
@@ -40,9 +47,13 @@ local M = {} | |||||
function selectlv.update(dt) | function selectlv.update(dt) | ||||
if not menuLoaded then | if not menuLoaded then | ||||
firstShip.x = -100 | firstShip.x = -100 | ||||
firstShip.y = love.math.random(0, WINDOW_HEIGHT) | |||||
menuLoaded = true | 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"))) | 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 | end | ||||
for i in ipairs(planets) do | for i in ipairs(planets) do | ||||
planets[i]:update(dt) | planets[i]:update(dt) | ||||
@@ -52,7 +63,11 @@ function selectlv.update(dt) | |||||
shipIsHit = false | shipIsHit = false | ||||
firstShip:reset() | firstShip:reset() | ||||
firstShip.x = -100 | 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") | --print("ship is hit") | ||||
end | end | ||||
end | end | ||||
@@ -37,6 +37,7 @@ function love.load() | |||||
simpleScale.setWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT) | simpleScale.setWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT) | ||||
firstShip = ship(-500, -500, "entities/ship/smol_white_01.png") | firstShip = ship(-500, -500, "entities/ship/smol_white_01.png") | ||||
VCAM = VCAM(WINDOW_WIDTH/2, WINDOW_HEIGHT/2) | VCAM = VCAM(WINDOW_WIDTH/2, WINDOW_HEIGHT/2) | ||||
tinyfont = love.graphics.newFont("font.ttf", 15) | |||||
smallfont = love.graphics.newFont("font.ttf", 25) | smallfont = love.graphics.newFont("font.ttf", 25) | ||||
titlefont = love.graphics.newFont("font.ttf", 50) | titlefont = love.graphics.newFont("font.ttf", 50) | ||||
myscreen = fullScreener(RESOLUTION_SET, isFullscreen, DIFFERENCE_X, DIFFERENCE_Y, OFFSET_X, OFFSET_Y) | myscreen = fullScreener(RESOLUTION_SET, isFullscreen, DIFFERENCE_X, DIFFERENCE_Y, OFFSET_X, OFFSET_Y) | ||||
@@ -29,11 +29,12 @@ function GUIDraw(mode) | |||||
--PLACING | --PLACING | ||||
local mx, my = love.mouse.getPosition() | 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 mx = mx * DIFFERENCE_X | ||||
local my = my * DIFFERENCE_Y | local my = my * DIFFERENCE_Y | ||||
local vmx, vmy = camera:toWorldCoords(mx, my) | |||||
if mode == "anywhere" then | if mode == "anywhere" then | ||||
love.graphics.setColor(1,1,1,0.5) | love.graphics.setColor(1,1,1,0.5) | ||||
if selectedItem == "ship" and mx < menuX then | if selectedItem == "ship" and mx < menuX then | ||||
@@ -73,6 +74,29 @@ function GUIDraw(mode) | |||||
selectedItem = "none" | selectedItem = "none" | ||||
end | end | ||||
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 | end | ||||
local dx, dy = camera:toCameraCoords(firstShip.x, firstShip.y) | local dx, dy = camera:toCameraCoords(firstShip.x, firstShip.y) | ||||
if VCAM.x - WINDOW_WIDTH/2+250 > firstShip.x and shipsleft == 0 then | if VCAM.x - WINDOW_WIDTH/2+250 > firstShip.x and shipsleft == 0 then | ||||