-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
113 lines (100 loc) · 4.19 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
world=nil
gui = require "external/Quickie"
require 'src/GameObject'
require('assets/camera/camera')
require 'src/Screen'
require 'src/TitleScreen'
require 'src/HelpScreen'
require 'src/FailScreen'
require 'src/GameScreen'
require 'src/Whale'
require 'src/Boss'
require 'src/Enemies'
require 'src/Pickups'
--Declare shooting sound
src_shoot = love.audio.newSource("assets/sounds/shoot.wav", "static")
paused = false
function love.load()
love.physics.setMeter( 64 )
love.window.setTitle("LavaWhales")
love.window.setMode(1000, 600, { vsync = true } )
love.graphics.setBackgroundColor( 0, 0, 255 )
--set up quickie
fonts = {
[12] = love.graphics.newFont(12),
[20] = love.graphics.newFont(20),
}
love.graphics.setFont(fonts[12])
gui.group.default.size[1] = 150
gui.group.default.size[2] = 25
gui.group.default.spacing = 5
ActiveScreen = TitleScreen()
end
local start_button = false
function love.update( dt )
if not paused then
ActiveScreen:update( dt )
end
end
function love.draw()
ActiveScreen:render()
gui.core.draw()
end
function love.keypressed( key, isrepeat )
if key == ' ' and ActiveScreen:is( GameScreen ) and ActiveScreen.whale.ammo > 0 and ActiveScreen.whale.health > 0 then
if (ActiveScreen.whale:getDirection() == "right") then
table.insert( ActiveScreen.objects, Shots( ActiveScreen.whale:getX() + ActiveScreen.whale:getWidth() / 2,
ActiveScreen.whale:getY(), 500000 * 64, 0, "fire" ) )
else
table.insert( ActiveScreen.objects, Shots( ActiveScreen.whale:getX() - ActiveScreen.whale:getWidth() / 2,
ActiveScreen.whale:getY(), -500000 * 64, 0, "fire" ) )
end
ActiveScreen.whale.ammo = ActiveScreen.whale.ammo - 1
ActiveScreen.whale.special_state = "shoot"
ActiveScreen.whale.state_time = 0
src_shoot:play()
end
if key == 'b' and ActiveScreen:is( GameScreen ) and ActiveScreen.whale.air > 10 and ActiveScreen.whale.health > 0 then
if(ActiveScreen.whale:getDirection() == "right") then
table.insert( ActiveScreen.objects, Shots( ActiveScreen.whale:getX() + ActiveScreen.whale:getWidth() / 2,
ActiveScreen.whale:getY(), 0, -50000 * 64, "air" ) )
else
table.insert( ActiveScreen.objects, Shots( ActiveScreen.whale:getX() - ActiveScreen.whale:getWidth() / 2,
ActiveScreen.whale:getY(), 0, -50000 * 64, "air" ) )
end
ActiveScreen.whale.air = ActiveScreen.whale.air - 10
ActiveScreen.whale.special_state = "shoot"
ActiveScreen.whale.state_time = 0
src_shoot:play()
end
--Returns you to menu
if key == "escape" and ActiveScreen:is( GameScreen ) then
ActiveScreen = TitleScreen()
end
--Mute Button
if key == "m" and love.audio.getVolume( ) == 1.0 then
love.audio.setVolume( 0.0 )
elseif key == "m" and love.audio.getVolume( ) == 0.0 then
love.audio.setVolume( 1.0 )
end
if key == 'p' then
paused = not paused
elseif key == 's' and ActiveScreen:is( GameScreen ) and ActiveScreen.whale.health > 0 then
-- Spread Shot
if ActiveScreen.whale.ammo >= 3 then
if(ActiveScreen.whale:getDirection() == "right") then
table.insert( ActiveScreen.objects, Shots( ActiveScreen.whale:getX() + ActiveScreen.whale:getWidth() / 2, ActiveScreen.whale:getY(), 500000 * 64, -15000 * 64, "fire" ) )
table.insert( ActiveScreen.objects, Shots( ActiveScreen.whale:getX() + ActiveScreen.whale:getWidth() / 2,ActiveScreen.whale:getY(), 500000 * 64, 0, "fire" ) )
table.insert( ActiveScreen.objects, Shots( ActiveScreen.whale:getX() + ActiveScreen.whale:getWidth() / 2, ActiveScreen.whale:getY(), 500000 * 64, 15000 * 64, "fire" ) )
else
table.insert( ActiveScreen.objects, Shots( ActiveScreen.whale:getX() - ActiveScreen.whale:getWidth() / 2, ActiveScreen.whale:getY(), -500000 * 64, -15000 * 64, "fire" ) )
table.insert( ActiveScreen.objects, Shots( ActiveScreen.whale:getX() - ActiveScreen.whale:getWidth() / 2,ActiveScreen.whale:getY(), -500000 * 64, 0, "fire" ) )
table.insert( ActiveScreen.objects, Shots( ActiveScreen.whale:getX() - ActiveScreen.whale:getWidth() / 2, ActiveScreen.whale:getY(), -500000 * 64, 15000 * 64, "fire" ) )
end
ActiveScreen.whale.ammo = ActiveScreen.whale.ammo - 3
ActiveScreen.whale.special_state = "shoot"
ActiveScreen.whale.state_time = 0
src_shoot:play()
end
end
end