1plant = class:new()
2
3function plant:init(x, y)
4	self.cox = x
5	self.coy = y
6
7	self.timer = 0
8
9	self.x = x-8/16
10	self.y = y+9/16
11	self.starty = self.y
12	self.width = 16/16
13	self.height = 14/16
14
15	self.static = true
16	self.active = true
17
18	self.destroy = false
19
20	self.category = 29
21
22	self.mask = {true}
23
24	--IMAGE STUFF
25	self.drawable = true
26	self.graphic = plantimg
27	self.quad = plantquads[spriteset][1]
28	self.offsetX = 0
29	self.offsetY = 17
30	self.quadcenterX = 0
31	self.quadcenterY = 0
32
33	self.customscissor = {x-1, y-2, 2, 2}
34
35	self.quadnum = 1
36	self.timer1 = 0
37	self.timer2 = plantouttime+1.5
38end
39
40function plant:update(dt)
41	self.timer1 = self.timer1 + dt
42	while self.timer1 > plantanimationdelay do
43		self.timer1 = self.timer1 - plantanimationdelay
44		if self.quadnum == 1 then
45			self.quadnum = 2
46		else
47			self.quadnum = 1
48		end
49		self.quad = plantquads[spriteset][self.quadnum]
50	end
51
52	self.timer2 = self.timer2 + dt
53	if self.timer2 < plantouttime then
54		self.y = self.y - plantmovespeed*dt
55		if self.y < self.starty - plantmovedist then
56			self.y = self.starty - plantmovedist
57		end
58	elseif self.timer2 < plantouttime+plantintime then
59		self.y = self.y + plantmovespeed*dt
60		if self.y > self.starty then
61			self.y = self.starty
62		end
63	else
64		for i = 1, players do
65			local v = objects["player"][i]
66			if inrange(v.x+v.width/2, self.x+self.width/2-3, self.x+self.width/2+3) then --no player near
67				return
68			end
69		end
70		self.timer2 = 0
71	end
72
73	return self.destroy
74end
75
76function plant:shotted()
77	playsound(shotsound)
78	self.destroy = true
79	self.active = false
80end