1miniblock = class:new()
2
3function miniblock:init(x, y, i)
4	self.x = x+math.random()*0.8-0.4
5	self.y = y
6	self.i = i
7	self.speedy = -10
8
9	self.timer = math.pi*1.5
10end
11
12function miniblock:update(dt)
13	self.speedy = self.speedy + yacceleration*dt
14	--check for collision
15	local x = math.floor(self.x)+1
16	local y = math.floor(self.y+self.speedy*dt)+1
17
18	if inmap(x, y) and self.speedy > 0 and tilequads[map[x][y][1]].collision then
19		self.y = math.ceil(self.y)
20		self.speedy = 0
21		self.timer = self.timer + dt*3
22	end
23
24	if self.timer > 5 then
25		--check for player pickup
26		for i = 1, players do
27			local x = objects["player"][i].x+objects["player"][i].width
28			local y = objects["player"][i].y+objects["player"][i].height
29
30			if math.abs(self.x-x) + math.abs(self.y-y) < 1 then
31				if collectblock(self.i) then
32					return true
33				end
34			end
35		end
36	end
37
38	self.y = self.y + self.speedy*dt
39
40	if self.y > 16 then
41		return true
42	end
43
44	return false
45end
46
47function miniblock:draw()
48	local img = customtilesimg
49	if self.i <= smbtilecount then
50		img = smbtilesimg
51	elseif self.i <= smbtilecount+portaltilecount then
52		img = portaltilesimg
53	end
54
55	local yadd = math.sin(self.timer)*0.1+0.15
56	love.graphics.drawq(img, tilequads[self.i].quad, math.floor((self.x-xscroll)*16*scale), math.floor((self.y-.5-yadd)*16*scale), 0, scale/2, scale/2, 8, 16)
57end