Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Medieval RPG #5169

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Games/Medieval RPG/missile-command-master/README.md
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>




50 changes: 50 additions & 0 deletions Games/Medieval RPG/missile-command-master/audio.lua
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.
28 changes: 28 additions & 0 deletions Games/Medieval RPG/missile-command-master/bomb.lua
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
3 changes: 3 additions & 0 deletions Games/Medieval RPG/missile-command-master/build.sh
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 *
21 changes: 21 additions & 0 deletions Games/Medieval RPG/missile-command-master/city.lua
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
4 changes: 4 additions & 0 deletions Games/Medieval RPG/missile-command-master/conf.lua
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
87 changes: 87 additions & 0 deletions Games/Medieval RPG/missile-command-master/cron.lua
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
17 changes: 17 additions & 0 deletions Games/Medieval RPG/missile-command-master/cursor.lua
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
50 changes: 50 additions & 0 deletions Games/Medieval RPG/missile-command-master/explosion.lua
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
Loading