1cheepcheep = class:new()
2
3function cheepcheep:init(x, y, color)
4	self.x = x
5	self.y = y
6	self.starty = y
7	self.width = 12/16
8	self.height = 12/16
9	self.rotation = 0 --for portals
10
11	if math.random(2) == 1 then
12		self.verticalmoving = true
13	else
14		self.verticalmoving = false
15	end
16
17	self.color = color
18
19	self.active = true
20	self.static = false
21	self.autodelete = true
22	self.gravity = 0
23	self.category = 24
24
25	--IMAGE STUFF
26	self.drawable = true
27	self.graphic = cheepcheepimg
28	self.quad = cheepcheepquad[self.color][1]
29	self.offsetX = 6
30	self.offsetY = 3
31	self.quadcenterX = 8
32	self.quadcenterY = 8
33	self.portalable = false
34
35	self.mask = {	true,
36					true, false, true, true, true,
37					true, true, true, true, true,
38					true, false, true, true, true,
39					true, true, true, true, true,
40					true, true, true, true, true,
41					true, true, true, true, true}
42
43	self.speedy = 0
44	if self.color == 1 then
45		self.speedx = -cheepredspeed
46	else
47		self.speedx = -cheepwhitespeed
48	end
49
50	self.direction = "up"
51	self.animationtimer = 0
52
53	self.shot = false
54end
55
56function cheepcheep:update(dt)
57	--rotate back to 0 (portals)
58	if self.rotation > 0 then
59		self.rotation = self.rotation - portalrotationalignmentspeed*dt
60		if self.rotation < 0 then
61			self.rotation = 0
62		end
63	elseif self.rotation < 0 then
64		self.rotation = self.rotation + portalrotationalignmentspeed*dt
65		if self.rotation > 0 then
66			self.rotation = 0
67		end
68	end
69
70	if self.shot then
71		self.speedy = self.speedy + shotgravity*dt
72
73		self.x = self.x+self.speedx*dt
74		self.y = self.y+self.speedy*dt
75
76		return false
77
78	else
79		self.animationtimer = self.animationtimer + dt
80		while self.animationtimer > cheepanimationspeed do
81			self.animationtimer = self.animationtimer - cheepanimationspeed
82			if self.frame == 1 then
83				self.frame = 2
84			else
85				self.frame = 1
86			end
87			self.quad = cheepcheepquad[self.color][self.frame]
88		end
89
90		--move up and down
91		if self.verticalmoving then
92			if self.direction == "up" then
93				self.speedy = -cheepyspeed
94				if self.y < self.starty - cheepheight then
95					self.direction = "down"
96				end
97			else
98				self.speedy = cheepyspeed
99				if self.y > self.starty + cheepheight then
100					self.direction = "up"
101				end
102			end
103		end
104
105		return false
106	end
107end
108
109function cheepcheep:shotted(dir) --fireball, star, turtle
110	playsound(shotsound)
111	self.shot = true
112	self.active = false
113	self.gravity = shotgravity
114	self.speedy = -shotjumpforce
115	self.direction = dir or "right"
116	if self.direction == "left" then
117		self.speedx = -shotspeedx
118	else
119		self.speedx = shotspeedx
120	end
121end
122
123function cheepcheep:rightcollide(a, b)
124	if self:globalcollide() then
125		return false
126	end
127
128end
129
130function cheepcheep:leftcollide(a, b)
131	if self:globalcollide() then
132		return false
133	end
134
135end
136
137function cheepcheep:ceilcollide(a, b)
138	if self:globalcollide() then
139		return false
140	end
141
142end
143
144function cheepcheep:floorcollide(a, b)
145	if self:globalcollide() then
146		return false
147	end
148
149end
150
151function cheepcheep:globalcollide(a, b)
152	return true
153end