Hey, i have been digging through my old projects and I found this:
manpos = vec2
function setup() --function
--global varibal
music("Game Music One:Trancey")
music.volume = 0.5
supportedOrientations(LANDSCAPE_LEFT) --orientation
displayMode(FULLSCREEN) -- display
noSmooth()
noStroke()
noFill()
manpos = vec2(WIDTH/2,HEIGHT/2)
border = 35
heartBorder = 100
speed = 60
tiltCalib = 0.65
heartRadius = 100
score = 0
highScore = readLocalData("highscore")
clock = 30
speech.rate = 0.1
speech.pitch = 1.2
speech.say("Tilt your device ")
moveHeart()
end
function moveHeart()
heartpos = vec2(math.random(heartBorder, WIDTH-heartBorder),
math.random(heartBorder, HEIGHT-heartBorder))
end
function draw()
textAlign(LEFT)
textMode(CORNER)
font("Georgia")
fill(255)
fontSize(20)
textWrapWidth(0)
text("Hello World!", WIDTH/2, HEIGHT/2)
-- Adjust the speech settings
speech.volume = 0.6
-- Just speak some words immediately
-- will be spoken at 0.6 volume
speech.volume = 1.0
speech.pitch = 300
local speedRate = vec2(0,0)
speedRate.x = (Gravity.x * speed)
speedRate.y = - (Gravity.z * speed * tiltCalib) + speed * (1-tiltCalib) * Gravity.y
manpos = manpos + speedRate
manpos.x = math.min(math.max(manpos.x, border), WIDTH-border)
manpos.y = math.min(math.max(manpos.y, border), HEIGHT-border)
local heartDistance = manpos:dist(heartpos)
if heartDistance < heartRadius then
sound("Game Sounds One:Female Cheer 2")
score = score + 10
moveHeart()
if highScore == nil or score > highScore then
highScore = score
saveLocalData("highscore", highScore)
end
end
clock = clock - DeltaTime
background(0,0,255,255)
sprite("SpaceCute:Background",512,384,1024,768)
pushMatrix()
translate(manpos.x,manpos.y)
if speedRate.x < 0 then
scale(-1,1)
end
sprite("SpaceCute:Beetle Ship")
popMatrix()
fill(0, 0, 0, 255)
sprite("Platformer Art:Coin",heartpos.x, heartpos.y)
strokeWidth(400)
font("Arial-BoldItalicMT")
textAlign(RIGHT)
textMode(CORNER)
fontSize(50)
text("Score: "..score,WIDTH/1,HEIGHT/2 -50,50)
if highScore then
textAlign(RIGHT)
text("Top: "..highScore, WIDTH - 200, HEIGHT - 75)
end
if clock > 0 then
textMode(CORNER)
textAlign(CENTER)
text("Time: "..math.ceil(clock), WIDTH/2 - 75, HEIGHT - 75)
else
textAlign(CENTER)
textMode(CENTER)
fontSize(100)
text("Game Over", WIDTH/2, HEIGHT/2)
fontSize(75)
fill(89, 89, 89, 255)
text("Hope you had fun!", WIDTH/2, HEIGHT/2 - 100)
heartpos= vec2(100000,100000)
end
end
popStyle()