-
Notifications
You must be signed in to change notification settings - Fork 843
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
260979e
commit a9dd711
Showing
26 changed files
with
1,004 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
## Controls | ||
|
||
* `up` `down` `left` `right` arrows move cursor | ||
* `spacebar` fires bomb | ||
|
||
## Build From Source | ||
|
||
1. Download and install LÖVE for OS X, Windows or Linux. http://love2d.org | ||
2. Clone this repo and [load the game](https://love2d.org/wiki/Getting_Started#Running_Games). | ||
|
||
## Video | ||
* https://www.youtube.com/watch?v=9OOp6z5Ykw8 | ||
|
||
|
||
|
||
# **Missile-command** | ||
|
||
<br> | ||
|
||
## **Description 📃** | ||
<!-- add your game description here --> | ||
- A 2d game of shooting | ||
|
||
|
||
<br> | ||
|
||
## **Screenshots 📸** | ||
|
||
<br> | ||
<!-- add your screenshots like this --> | ||
<img src="./missile.png" alt="Image Description"> | ||
<br> | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
audio = class('audio') | ||
|
||
function audio:initialize() | ||
|
||
self.boom = love.audio.newSource('audio/missile_explode.ogg','static') | ||
self.launch = love.audio.newSource('audio/launch_bomb.ogg','static') | ||
self.start = love.audio.newSource('audio/start_level.ogg','static') | ||
self.over = love.audio.newSource('audio/game_over.ogg','static') | ||
self.noammo = love.audio.newSource('audio/no_ammo.ogg','static') | ||
|
||
end | ||
|
||
function audio:play(sound) | ||
|
||
if sound == 'boom' then | ||
|
||
self.boom:stop() | ||
self.boom:play() | ||
|
||
elseif sound == 'launch' then | ||
|
||
if not self.boom:isPlaying() then | ||
|
||
self.launch:stop() | ||
self.launch:play() | ||
|
||
end | ||
|
||
elseif sound == 'start_level' then | ||
|
||
self.start:stop() | ||
self.start:play() | ||
|
||
elseif sound == 'game_over' then | ||
|
||
self.over:stop() | ||
self.over:play() | ||
|
||
elseif sound == 'no_ammo' then | ||
|
||
if not self.boom:isPlaying() then | ||
|
||
self.noammo:stop() | ||
self.noammo:play() | ||
|
||
end | ||
|
||
end | ||
|
||
end |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
bomb = class('bomb') | ||
|
||
function bomb:initialize(world,x,y) | ||
|
||
self.xtarget = x | ||
self.ytarget = y | ||
|
||
self.body = love.physics.newBody(world,400,500,"kinematic") | ||
local vx = x - game.bombtower.x | ||
local vy = y - game.bombtower.y | ||
self.body:setBullet(true) | ||
self.body:setLinearVelocity(vx,vy) | ||
|
||
self.shape = love.physics.newRectangleShape(x,y,8,4) | ||
local x1, y1, x2, y2 = self.shape:computeAABB(0,0,0) | ||
self.width = x2 - x1 | ||
self.height = y2 - y1 | ||
|
||
self.fixture = love.physics.newFixture(self.body, self.shape, 1.0) | ||
|
||
end | ||
|
||
function bomb:draw() | ||
|
||
love.graphics.setColor(math.random(0,255),math.random(0,255),math.random(0,255)) | ||
love.graphics.rectangle('fill',self.body:getX(),self.body:getY(),self.width,self.height) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
rm missile-command.love | ||
zip -r missile-command.love * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
city = class('city') | ||
|
||
function city:initialize(x,y) | ||
|
||
self.x = x | ||
self.y = y | ||
self.width = 35 | ||
self.height = 25 | ||
|
||
self.body = love.physics.newBody(world,x,y,'dynamic') | ||
self.shape = love.physics.newRectangleShape(x,y,self.width,self.height) | ||
self.fixture = love.physics.newFixture(self.body, self.shape, 0.1) | ||
|
||
end | ||
|
||
function city:draw(color) | ||
|
||
love.graphics.setColor(color) | ||
love.graphics.polygon('fill',self.shape:getPoints()) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function love.conf(t) | ||
t.title = 'Missile Command' | ||
t.author = 'Chad Paulson' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
----------------------------------------------------------------------------------------------------------------------- | ||
-- cron.lua - v1.0 (2011-04) | ||
-- Enrique García Cota - enrique.garcia.cota [AT] gmail [DOT] com | ||
-- time-related functions for Lua. | ||
-- inspired by Javascript's setTimeout and setInterval | ||
----------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
local function isCallable(callback) | ||
local tc = type(callback) | ||
if tc == 'function' then return true end | ||
if tc == 'table' then | ||
local mt = getmetatable(callback) | ||
return type(mt) == 'table' and type(mt.__call) == 'function' | ||
end | ||
return false | ||
end | ||
|
||
local function checkTimeAndCallback(time, callback) | ||
assert(type(time) == "number" and time > 0, "time must be a positive number") | ||
assert(isCallable(callback), "callback must be a function") | ||
end | ||
|
||
local entries = setmetatable({}, {__mode = "k"}) | ||
|
||
local function newEntry(time, callback, update, ...) | ||
local entry = { | ||
time = time, | ||
callback = callback, | ||
args = {...}, | ||
running = 0, | ||
update = update | ||
} | ||
entries[entry] = entry | ||
return entry | ||
end | ||
|
||
local function updateTimedEntry(self, dt) -- returns true if expired | ||
self.running = self.running + dt | ||
if self.running >= self.time then | ||
self.callback(unpack(self.args)) | ||
return true | ||
end | ||
end | ||
|
||
local function updatePeriodicEntry(self, dt) | ||
self.running = self.running + dt | ||
|
||
while self.running >= self.time do | ||
self.callback(unpack(self.args)) | ||
self.running = self.running - self.time | ||
end | ||
end | ||
|
||
local cron = {} | ||
|
||
function cron.reset() | ||
entries = {} | ||
end | ||
|
||
function cron.cancel(id) | ||
entries[id] = nil | ||
end | ||
|
||
function cron.after(time, callback, ...) | ||
checkTimeAndCallback(time, callback) | ||
return newEntry(time, callback, updateTimedEntry, ...) | ||
end | ||
|
||
function cron.every(time, callback, ...) | ||
checkTimeAndCallback(time, callback) | ||
return newEntry(time, callback, updatePeriodicEntry, ...) | ||
end | ||
|
||
function cron.update(dt) | ||
assert(type(dt) == "number" and dt > 0, "dt must be a positive number") | ||
|
||
local expired = {} | ||
|
||
for _, entry in pairs(entries) do | ||
if entry:update(dt, runningTime) then table.insert(expired,entry) end | ||
end | ||
|
||
for i=1, #expired do entries[expired[i]] = nil end | ||
end | ||
|
||
return cron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cursor = class('cursor') | ||
|
||
function cursor:initialize(x,y) | ||
|
||
self.x = x | ||
self.y = y | ||
self.width = 36 | ||
self.height = 8 | ||
|
||
end | ||
|
||
function cursor:draw() | ||
|
||
love.graphics.setColor(255,255,255) | ||
love.graphics.rectangle('fill',self.x - (self.width / 2),self.y,self.width,self.height) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
explosion = class('explosion') | ||
|
||
function explosion:initialize(world,x,y) | ||
|
||
self.stage = 1 | ||
self.x = x | ||
self.y = y | ||
|
||
self.body = love.physics.newBody(world,self.x,self.y,'dynamic') | ||
self.shape = love.physics.newPolygonShape(self:plotExplosion(self.stage)) | ||
|
||
self.fixture = love.physics.newFixture(self.body, self.shape, 1.0) | ||
|
||
end | ||
|
||
function explosion:update() | ||
|
||
if self.stage == 75 then | ||
self.body:destroy() | ||
return false | ||
elseif self.stage < 75 then | ||
self.stage = self.stage + 1 | ||
self.shape = love.physics.newPolygonShape(self:plotExplosion(self.stage)) | ||
return true | ||
end | ||
|
||
end | ||
|
||
function explosion:draw() | ||
|
||
love.graphics.setColor(math.random(0,255),math.random(0,255),math.random(0,255)) | ||
love.graphics.polygon('fill', self.shape:getPoints()) | ||
|
||
end | ||
|
||
function explosion:plotExplosion(stage) | ||
|
||
x = 0 | ||
y = 0 | ||
if stage < 15 then | ||
padding = stage * 2 | ||
elseif stage > 15 and stage < 50 then | ||
padding = 45 | ||
elseif stage >= 50 then | ||
padding = 80 - stage | ||
end | ||
|
||
return self.x,self.y - padding, self.x + padding, self.y, self.x, self.y + padding, self.x - padding, self.y | ||
|
||
end |
Oops, something went wrong.