Skip to content

Commit

Permalink
Basic baddie is now rendered. Objects are now broken into classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Robinson committed Jan 14, 2012
1 parent 66ba830 commit c7455bf
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bad.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Bad = {}

function Bad:new()
return setmetatable({x = 50, y = 50, state = "enter"}, {__index = self})
end

function Bad:update(dt)
end

function Bad:draw()
local size = 20

love.graphics.triangle(
'line',
self.x, self.y + (size / 2),
self.x + (size / 2), self.y - (size / 2),
self.x - (size / 2), self.y - (size / 2)
)
end
24 changes: 24 additions & 0 deletions bullet.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Bullet = {}

function Bullet:new(x, y)
return setmetatable({
x = x,
y = y,
v = 1000,
r = 0}, {__index = self})
end

function Bullet:update(dt)
self.x = self.x + self.v * math.sin(self.r) * dt
self.y = self.y - self.v * math.cos(self.r) * dt
end

function Bullet:draw()
love.graphics.circle('fill', self.x, self.y, 10)
end

function Bullet:is_offscreen()
return self.x < 0 or self.y < 0
or self.y > love.graphics.getHeight()
or self.x > love.graphics.getWidth()
end

0 comments on commit c7455bf

Please sign in to comment.