-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic baddie is now rendered. Objects are now broken into classes.
- Loading branch information
Scott Robinson
committed
Jan 14, 2012
1 parent
66ba830
commit c7455bf
Showing
2 changed files
with
43 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,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 |
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,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 |