At the request of Rigidity on Discord, I've made a tutorial showing a complete walk-through of making a simple game in Mini Micro.
Here's the final code from that. (But I recommend, if possible, you retype this as you follow the video, rather than just copying & pasting... you'll learn better that way.)
// Cell game!
clear
disp = display(4)
// draw our cell (128x128)
gfx.clear color.clear
gfx.fillEllipse 5,5,118,118, color.gray
gfx.drawEllipse 5,5,118,118, color.white, 10
Cell = new Sprite
Cell.image = gfx.getImage(0, 0, 128,128)
gfx.clear
Cell.vx = 0
Cell.vy = 0
Cell.update = function()
self.vx = (self.vx + rnd - 0.5) * 0.9
self.vy = (self.vy + rnd - 0.5) * 0.9
self.x = self.x + self.vx
self.y = self.y + self.vy
if self.touchingPlayer then
if self.scale > player.scale then
print "Game over!"
exit
else
player.scale = player.scale + self.scale * 0.1
disp.sprites.remove disp.sprites.indexOf(self)
globals.score = score + round(100*self.scale)
text.row = 25
print score
end if
end if
end function
Cell.touchingPlayer = function(margin=0)
d = sqrt((self.x - player.x)^2 + (self.y - player.y)^2)
return d < 64*self.scale + 64*player.scale + margin
end function
// create the player cell
player = new Cell
player.x = 480
player.y = 320
player.scale = 0.35
player.tint = "#8888FF"
disp.sprites.push player
player.update = function()
dx = mouse.x - self.x
dy = mouse.y - self.y
dist = sqrt(dx*dx + dy*dy)
self.vx = (self.vx + dx/dist) * 0.9
self.vy = (self.vy + dy/dist) * 0.9
self.x = self.x + self.vx
self.y = self.y + self.vy
end function
newCell = function()
noob = new Cell
noob.scale = player.scale + (rnd - 0.4) * 0.5
while true
noob.x = 960*rnd
noob.y = 640*rnd
if not noob.touchingPlayer(10) then break
end while
noob.tint = "#FF8888"
disp.sprites.push noob
end function
// create a bunch of other cells
for i in range(30)
newCell
end for
// Main loop
nextSpawnTime = 1
score = 0
while true
for s in disp.sprites
s.update
end for
if time > nextSpawnTime then
newCell
nextSpawnTime = time + rnd
end if
yield
end while