Skip to content

Instantly share code, notes, and snippets.

View nadar71's full-sized avatar
🏠
Working from home

Simone Mapelli nadar71

🏠
Working from home
View GitHub Profile
@nadar71
nadar71 / main.lua
Last active August 29, 2015 14:16 — forked from wiiiim/main.lua
local springboard = require("springboard")
local group = display.newGroup() -- root display group
local pageTotal = 3
local board -- springboard instance
local pageDots = {} -- dots at the top
local function animatePageDot() -- called each time the springboard changes page
local currentPage = board.page
-- reset all pagedots
@nadar71
nadar71 / main.lua
Last active August 29, 2015 14:16 — forked from tariqkhatib/main.lua
Simulate Space In Less Than 30 Lines Of Code
starCtr = 0
stars = {}
currTransSpeed = 500
displayHeight = display.contentHeight
math.randomseed( os.time() )
local function removeMe() --remove stars after reaching end of screen
for i=1,1100 do
if stars[i] ~= nil then
if stars[i].y >= displayHeight then
currColor = "white"
local function save( )
display.save( allGroup, "group.jpg" )
end
local function loadVars(theSize)
math.randomseed( os.time( ) )
allGroup = display.newGroup()
rectangles = {}
currW = theSize
--
-- a simple Lua/Corona joystick module based on Rob Miracle's code:
-- http://forums.coronalabs.com/topic/32941-virtual-joystick-module-for-games/
-- simplified some of the code, removing some nice-ities, but it still works
local Joystick = {}
function Joystick.new( innerRadius, outerRadius )
local stage = display.getCurrentStage()
-- swipe library
--[[ Libraries ]]--
local composer = require("composer")
--[[ Fields ]]--
local mainstage = display.getCurrentStage()
local stage = composer.stage
{
"sheet_bat": {
"class": ",imagesheet,",
"path": "images/bat.png",
"options": {
"width": 32, "height": 48, "numFrames": 12,
"sheetContentWidth": 192, "sheetContentHeight": 96
}
},
"background_mountain": {
local bg = display.newImage("images/bg.png")
bg.x = _W/2; bg.y = _H/2;
local car = display.newImage("images/car.png")
car.x = _W/2
car.y = _H - 250
car.name = "car"
-- understood proprierties of bezier curve
--local curve = bezier:curve({xInitial, xControlPoint1, xControlPoint2, xControlPoint3}, {yInitial, yControlPoint1, yControlPoint2, yControlPoint3})
Ellipse = {
--declare constants
format='%d %d %d %d ',
class=',Ellipse,class,'
}
function Ellipse:tostring()
return string.format(self.format,self.x,self.y,self.width,self.height)
end --tostring
function Ellipse:new(centerX, centerY, wide, tall)
assert(wide>=0 and tall>=0)
--[[
statemachine.lua
Copyright (c) 2013 Erin Lin
erinylin.blogspot.com
Licensed under the MIT license.
Usage:
local sm = require("statemachine")
local process = sm.new(function(self, time)
--[[
Perspective v2.0.2
A library for easily and smoothly integrating a virtual camera into your game.
Based on modified version of the Dusk camera system.
v2.0.2 adds a more stable tracking system and re-implements scrollX and scrollY
--]]