Skip to content

Commit

Permalink
Released v0.1
Browse files Browse the repository at this point in the history
Create arena.map if there's no map folder yet
Player has fire spread
Bullets travel slower
  • Loading branch information
darkwater committed Nov 15, 2013
1 parent 4664752 commit 0477ba0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Lazors in Space
It's a space shooter inspired by Pewpew and Geometry Wars. Requires [LÖVE](http://love2d.org/) [0.9.0](https://bitbucket.org/rude/love/) to play.

Have a progress vlog:
- [`current`](http://dev.novaember.com/s/13-11-15_23-56-54_446338902.webm)
- [`95b7b9a`](http://dev.novaember.com/s/13-10-23_22-01-27_140703724.webm)
- [`21d7a0c`](http://dev.novaember.com/s/13-10-10_15-51-48_834298746.webm)
- [`2a465d3`](http://dev.novaember.com/s/13-10-06_00-27-19_050951243.webm)
Expand Down
19 changes: 12 additions & 7 deletions bute.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ Bute = class("Bute", BaseAI)
--
function Bute:initialize(x, y)
BaseAI.initialize(self, x, y)
self.speed = math.random(2, 5)
self.speed = math.random(5, 10)
-- self.turnSspeed = 500
self.body:setLinearDamping(3)
self.body:setLinearDamping(0.1)
self.fixture:setRestitution(1)

self.nextFire = 0
self.fireInterval = 0.1
self.fireInterval = {100, 500}

self.nextMove = 0
self.moveInterval = {10, 200}

self.moveOffset = math.random(-20, 20) / 180 * math.pi

Expand All @@ -38,15 +41,17 @@ function Bute:update(dt)

self:aimInDirection(ang)

if math.random(1, 600) > 500 + dt * 100 then
if self.nextMove <= love.timer.getTime() then
self.nextMove = love.timer.getTime() + math.random(unpack(self.moveInterval)) / 100

self:pushInDirection(utils.randomAngle(), self.speed)
end


if self.nextFire <= love.timer.getTime() and math.random(1,200) == 1 then
self.nextFire = love.timer.getTime() + self.fireInterval
if self.nextFire <= love.timer.getTime() then
self.nextFire = love.timer.getTime() + math.random(unpack(self.fireInterval)) / 100

Bullet:new(self.body:getX(), self.body:getY(), self.body:getAngle(), 20, colgroup.ENEMY)
Bullet:new(self.body:getX(), self.body:getY(), self.body:getAngle(), 8, colgroup.ENEMY)
end


Expand Down
5 changes: 5 additions & 0 deletions main.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
function love.load()
love.physics.setMeter(64)

if not love.filesystem.isDirectory("maps") then
love.filesystem.createDirectory("maps")
love.filesystem.write("maps/arena.map", [=[{"author":"Darkwater","name":"Arena","mapdata":[["StaticDebris",{"points":[-600,0,0,-600,600,0,0,600]}],["StaticDebris",{"points":[-400,-200,-400,200,-600,0]}],["StaticDebris",{"points":[-200,-400,0,-600,200,-400]}],["StaticDebris",{"points":[400,-200,400,200,600,0]}],["StaticDebris",{"points":[-200,400,200,400,0,600]}],["EntitySpawner",{"y":0,"x":-350,"amount":[1,4],"interval":[1,12],"data":[],"type":"Bute"}],["EntitySpawner",{"y":-350,"x":0,"amount":[1,4],"interval":[1,12],"data":[],"type":"Bute"}],["EntitySpawner",{"y":0,"x":350,"amount":[1,4],"interval":[1,12],"data":[],"type":"Bute"}],["EntitySpawner",{"y":350,"x":0,"amount":[1,4],"interval":[1,12],"data":[],"type":"Bute"}],["StaticDebris",{"points":[-400,-200,-200,-200,-200,-400]}],["StaticDebris",{"points":[200,400,400,200,200,200]}],["StaticDebris",{"points":[-400,200,-200,200,-200,400]}],["StaticDebris",{"points":[200,-400,400,-200,200,-200]}]]}]=])
end

class = require("middleclass")
require("json")
require("constants")
Expand Down
29 changes: 23 additions & 6 deletions ship.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ function Ship:initialize(x, y)
self.fixture:setGroupIndex(colgroup.PLAYER)

self.nextFire = 0
self.fireInterval = 0.12
self.accuracy = 10 -- TODO: change accuracy according to distance of mouse?
self.fireInterval = 0.08
self.fireSpread = false -- to toggle between double/single shot
self.spread = 0.1 -- TODO: change spread according to distance of mouse?

self.damage = 5

Expand Down Expand Up @@ -55,10 +56,13 @@ function Ship:update(dt)
if love.mouse.isDown("l") and self.nextFire <= love.timer.getTime() then
self.nextFire = love.timer.getTime() + self.fireInterval

local ang = self.body:getAngle()-- + math.random(-self.accuracy, self.accuracy) / 100
local dx = math.cos(ang) * 15
local dy = math.sin(ang) * 15
Bullet:new(self.body:getX() + dx, self.body:getY() + dy, ang, 20, colgroup.PLAYER)
if self.fireSpread then
self:shoot(self.body:getAngle() + self.spread)
self:shoot(self.body:getAngle() - self.spread)
else
self:shoot(self.body:getAngle())
end
self.fireSpread = not self.fireSpread

sounds.play("player_shoot")
end
Expand Down Expand Up @@ -125,3 +129,16 @@ end
function Ship:aimInDirection(ang)
self.body:setAngle(ang)
end


---
-- Ship:shoot
-- Shoots a bullet
--
-- @param ang The direction of the bullet (radians)
--
function Ship:shoot(ang)
local dx = math.cos(ang) * 15
local dy = math.sin(ang) * 15
Bullet:new(self.body:getX() + dx, self.body:getY() + dy, ang, 12, colgroup.PLAYER)
end

0 comments on commit 0477ba0

Please sign in to comment.