Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 35 lines (26 sloc) 0.715 kB
3be4c95 @wilkie Adding Book and Brain objects.
wilkie authored
1 -- Brain
2
3 -- Represents a Brain object
4
5 Brain = {visible = true}
6
b664bf4 @wilkie Adding pictures.
wilkie authored
7 brain_img = love.graphics.newImage("img/brain.png")
8
3be4c95 @wilkie Adding Book and Brain objects.
wilkie authored
9 function Brain:new(o)
10 o = o or {}
11 setmetatable(o, self)
12 self.__index = self
13 return o
14 end
15
16 function Brain:with(position, world)
17 self.body = love.physics.newBody(world.physics, position.x*32, position.y*32, 0, 0)
b664bf4 @wilkie Adding pictures.
wilkie authored
18 self.shape = love.physics.newRectangleShape(self.body, -16, -16, 32, 32, 0)
3be4c95 @wilkie Adding Book and Brain objects.
wilkie authored
19 self.shape:setFriction(1.0)
20 self.shape:setSensor(true)
21 self.type = "brain"
22 self.shape:setData(self)
23
24 return self
25 end
26
27 function Brain:draw(x, y)
28 if self.visible == false then
29 return
30 end
31
32 local x1,y1,x2,y2 = self.shape:getPoints()
33
b664bf4 @wilkie Adding pictures.
wilkie authored
34 love.graphics.draw(brain_img, x1-x, y1-y)
3be4c95 @wilkie Adding Book and Brain objects.
wilkie authored
35 end
Something went wrong with that request. Please try again.