Skip to content

Instantly share code, notes, and snippets.

@ruilov
ruilov / CodeaSandbox.lua
Created June 3, 2012 21:40
Codea Sandbox
-- This file is loaded before any user scripts, removing unsafe environment functions
------------------------------------------------
-- Block out any dangerous or insecure functions
------------------------------------------------
arg=nil
__loadedProjects = {}
import = function(projectName)
@ruilov
ruilov / cargobot1
Created May 27, 2012 17:55
CargoBot1
-- Levels.lua
-- Level are organized in packs, each pack consists of 6 levels.
-- - Level definitions include;
-- - name: shows in the level chooser screen as well at at the top of the level. Also used to
-- save solutions and score
-- - claw: the starting position of the claw (the pile number where it starts)
-- - stars: an array of two elems. The first is the max number of instructions allowed for 2
-- starts and the second, the max number of instructions allowed for 3 stars
-- - funcs: specifies the number of progs and the lenght of progs allowed in that level
@ruilov
ruilov / pacman
Created May 27, 2012 17:11
Pacman
Actor = class()
function Actor:init(pos,side,color,backgroundC,lev)
self.pos = pos*side*8+vec2(side*4,0) -- actors start in between squares
self.targetPos = pos -- the square where we're going
self.side = side -- misnamed. this is the num of ipad pixels per pacman pixel
self.dir = vec2(0,0) -- once we get to targetPos, which direction to go
self.color = color
self.backgroundC = backgroundC
self.level = lev -- point back to the parent level
@ruilov
ruilov / Pentango.lua
Created February 22, 2012 03:55
Pentago
function draw()
    background()
    if not currentScreen then currentScreen = StartScreen() end
    currentScreen:draw()
end
function touched(t)
    if currentScreen and currentScreen.touched then currentScreen:touched(t) end
end
@ruilov
ruilov / Atlas.lua
Created January 27, 2012 01:36
Mesh atlas
function setup()
    noSmooth()
    atlas = Atlas()
    
    -- map a few test functions
    atlas:map("test1",draw1,200,100)
    atlas:map("test2",draw2,200,100)
    atlas:map("test3",draw3,101,171)
    atlas:map("test4",draw4,WIDTH-10,100)
    
tileSize = 40
wallThickness = 15
gridW = 15
gridH = 11
dims = vec2(tileSize*gridW,tileSize*gridH)
bottom = vec2(60,60)
top = bottom+dims
ballRadius = tileSize/4
speedY = 4.2
@ruilov
ruilov / Enduro
Created November 5, 2011 02:03
Atari Enduro port to Codify
--[[ ------------------------------------------------------------
Main.lua
--]] ------------------------------------------------------------
-- global screen size constants
bottomY = HEIGHT *.21
trackWidth = WIDTH * .9 -- width of the track at the bottom
horizonY = trackWidth * .55 + bottomY
trackHeight = horizonY - bottomY
trackLength = 100 -- in meters
@ruilov
ruilov / Pigs In Clover 3
Created November 1, 2011 12:32
source code
backgroundC = color(0, 0, 0, 255)
time = 0
won = false
-- open is the angle of the openning. top is where the hole is (top or bottom)
circles = {
{ radius = 75, top = true },
{ radius = 150, top = false },
{ radius = 225, top = true },
@ruilov
ruilov / Pigs In Clover 2
Created November 1, 2011 00:19
source code
backgroundC = color(0, 0, 0, 255)
time = 0
won = false
-- open is the angle of the openning. top is where the hole is (top or bottom)
circles = {
{ radius = 75, top = true },
{ radius = 150, top = false },
{ radius = 225, top = true },
--{ radius = 300, top = false },
@ruilov
ruilov / pigs_in_clover
Created October 29, 2011 22:14
Source code for Codify game Pigs in Clover
backgroundC = color(0, 0, 0, 255)
-- top is where the hole is (top or bottom) circles = { { radius = 75, top = true }, { radius = 150, top = false }, { radius = 225, top = true }, { radius = 300, top = false }, }
balls = { { x = 300, y = 300, speedX = 0, speedY = 0, radius = 10 }, { x = -300, y = -300, speedX = 0, speedY = 0, radius = 10 }, { x = -300, y = 300, speedX = 0, speedY = 0, radius = 10 }, { x = 300, y = -300, speedX = 0, speedY = 0, radius = 10 } }
-- This function gets called once every frame function draw() ellipseMode(RADIUS) pushMatrix() translate(WIDTH/2, HEIGHT/2) background(backgroundC)
drawWalls()