Created
November 17, 2013 18:26
-
-
Save CodeaLuis/7516420 to your computer and use it in GitHub Desktop.
Codea Project Gist Created with AutoGist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AutoGist Tab Order Version: 2.2.8 | |
------------------------------ | |
This file should not be included in the Codea project. | |
#Main | |
#Balls | |
#Box | |
#Buttons | |
#Line | |
#Sound | |
#Stuff | |
#Tween |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------ | |
-- ENEMY | |
-- by luismi | |
------------------------------------------ | |
Enemy = class() | |
function Enemy:init(x,y) | |
self.posicion = vec2(x,y) | |
self.radio = math.random(60,120) | |
-- self.velocidad=5+math.random() | |
self.velocidad = vec2(-0.2,0.1) | |
self.distance = "" | |
-- self.c = color(265, 190, 0, 255) | |
--local box = physics.body(POLYGON, vec2(-w/2,h/2), vec2(-w/2,-h/2), vec2(w/2,-h/2), vec2(w/2,h/2)) | |
end | |
function Enemy:draw() | |
math.randomseed(self.radio) | |
-- fill(self.c) | |
fill(math.random(255),math.random(255),math.random(255),math.random(255)) | |
if score >= 30 and score <= 33 then | |
fill(50, 239, 69, 75) | |
end | |
if score >= 60 and score <= 65 then | |
fill(5, 26, 238, 75) | |
end | |
noStroke() | |
ellipseMode(CENTER) | |
if score > 40 then | |
end | |
--self.velocidad = vec2(Gravity.x,Gravity.y) | |
if score >= 10 then | |
self.posicion = self.posicion + self.velocidad *10 | |
end | |
if score >= 30 then | |
self.posicion = self.posicion + self.velocidad *12 | |
end | |
if score >= 50 then | |
self.posicion = self.posicion + self.velocidad *16 | |
end | |
self.posicion = self.posicion + self.velocidad * 15 | |
ellipse(self.posicion.x, self.posicion.y, self.radio) | |
-- createBox(self.posicion.x,self.posicion.y,20) | |
if (self.posicion.x + self.radio) >= WIDTH then | |
self.posicion.x = WIDTH - self.radio | |
self.velocidad.x = -self.velocidad.x | |
elseif (self.posicion.x - self.radio) <= 0 then | |
self.posicion.x = self.radio | |
self.velocidad.x = -self.velocidad.x | |
elseif (self.posicion.y + self.radio) >= HEIGHT then | |
self.posicion.y = HEIGHT - self.radio | |
self.velocidad.y = -self.velocidad.y | |
elseif (self.posicion.y - self.radio) <= 0 then | |
self.posicion.y = self.radio | |
self.velocidad.y = -self.velocidad.y | |
end | |
if lives < 0 then | |
self.radio = 0 | |
end | |
end | |
function Enemy:style(num) | |
-- restyle the enemy based on how we're colliding | |
if num == NOT_HIT then | |
fill(math.random(255),math.random(255),math.random(255),math.random(255)) | |
elseif num == HIT then | |
sound(DATA,"ZgNADQA9PUJCQAthAAAAALicKz7PfFA+fwBZRkA+QzM+PDtD") | |
self.distance = "" | |
self.c = color(20, 255, 162, 255) | |
fill(50, 239, 69, 75) | |
lives = lives -1 | |
end | |
if score >= 30 and score <= 33 and num == HIT then | |
sound(DATA, "ZgJAMgA8fQ5FSEVY5OdRPe3iwDxqs4s+CwAnbTpARD8uZVZ1") | |
lives = lives + 1 | |
-- hit = hit + 1 | |
self.radio = 0 | |
-- gamestate = WIN | |
elseif score >= 60 and score <= 65 and num == HIT then | |
sound(DATA, "ZgJAMgA8fQ5FSEVY5OdRPe3iwDxqs4s+CwAnbTpARD8uZVZ1") | |
lives = lives + 1 | |
-- hit = hit + 1 | |
self.radio = 0 | |
-- gamestate = WIN | |
end | |
-- setup() | |
end | |
-- register the current distance from the line to this enemy | |
function Enemy:skim(distance) | |
self.distance = distance | |
end | |
function Enemy:miss() | |
self.distance = 0 | |
end | |
function Enemy:halfWidth() | |
return self.radio * 0.5 | |
end | |
------------------------------ | |
------------------------------- | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------ | |
-- ENEMY | |
------------------------------------------ | |
Box = class() | |
function Box:init(x,y) | |
self.posicion = vec2(x,y) | |
self.radio = math.random(40,80) | |
-- self.velocidad=5+math.random() | |
self.velocidad = vec2(-0.2,0.1) | |
self.distance = "" | |
self.sonido = 0 | |
-- self.c = color(265, 190, 0, 255) | |
--local box = physics.body(POLYGON, vec2(-w/2,h/2), vec2(-w/2,-h/2), vec2(w/2,-h/2), vec2(w/2,h/2)) | |
end | |
function Box:draw() | |
math.randomseed(self.radio) | |
-- fill(self.c) | |
fill(math.random(755),math.random(2755),math.random(965),math.random(655)) | |
--noStroke() | |
rectMode(CENTER) | |
self.posicion = self.posicion + self.velocidad * 18 | |
--roundRect(self.posicion.x,self.posicion.y,self.radio) | |
--sprite("Cargo Bot:Crate Goal Red",self.posicion.x, self.posicion.y, self.radio) | |
sprite("Cargo Bot:Crate Goal Red",self.posicion.x,self.posicion.y,self.radio) | |
if (self.posicion.x + self.radio) >= WIDTH then | |
self.posicion.x = WIDTH - self.radio | |
self.velocidad.x = -self.velocidad.x | |
sprite("Cargo Bot:Smoke Particle",self.posicion.x+40,self.posicion.y,100) | |
if ElapsedTime > self.sonido then | |
self.sonido = ElapsedTime + 2 | |
sound(DATA, "ZgNAIgBBQEBAZ11AAAAAABei5D1NMsk9VgBAf0BAQEBAQHkS") | |
end | |
elseif (self.posicion.x - self.radio) <= 0 then | |
self.posicion.x = self.radio | |
self.velocidad.x = -self.velocidad.x | |
sprite("Cargo Bot:Smoke Particle",self.posicion.x-40,self.posicion.y,100) | |
if ElapsedTime > self.sonido then | |
self.sonido = ElapsedTime + 2 | |
sound(DATA, "ZgNAIgBBQEBAZ11AAAAAABei5D1NMsk9VgBAf0BAQEBAQHkS") | |
end | |
elseif (self.posicion.y + self.radio) >= HEIGHT then | |
self.posicion.y = HEIGHT - self.radio | |
self.velocidad.y = -self.velocidad.y | |
sprite("Cargo Bot:Smoke Particle",self.posicion.x,self.posicion.y+40,100) | |
if ElapsedTime > self.sonido then | |
self.sonido = ElapsedTime + 2 | |
sound(DATA, "ZgNAIgBBQEBAZ11AAAAAABei5D1NMsk9VgBAf0BAQEBAQHkS") | |
end | |
elseif (self.posicion.y - self.radio) <= 0 then | |
self.posicion.y = self.radio | |
self.velocidad.y = -self.velocidad.y | |
sprite("Cargo Bot:Smoke Particle",self.posicion.x,self.posicion.y-40,100) | |
if ElapsedTime > self.sonido then | |
self.sonido = ElapsedTime + 2 | |
sound(DATA, "ZgNAIgBBQEBAZ11AAAAAABei5D1NMsk9VgBAf0BAQEBAQHkS") | |
end | |
end | |
if lives < 0 then | |
self.radio = 0 | |
end | |
end | |
function Box:style(num) | |
-- restyle the enemy based on how we're colliding | |
if num == NOT_HIT then | |
fill(math.random(255),math.random(255),math.random(255),math.random(255)) | |
elseif num == HIT then | |
sound(DATA,"ZgNADQA9PUJCQAthAAAAALicKz7PfFA+fwBZRkA+QzM+PDtD") | |
self.distance = "" | |
fill(50, 239, 69, 75) | |
lives = lives -1 | |
end | |
end | |
-- register the current distance from the line to this enemy | |
function Box:skim(distance) | |
self.distance = distance | |
end | |
function Box:miss() | |
self.distance = 0 | |
end | |
function Box:halfWidth() | |
return self.radio * 0.5 | |
end | |
function roundRect(x, y) | |
w = WIDTH | |
h = HEIGHT | |
pushStyle() | |
Pos = vec2(x,y) | |
Size = vec2(60,60) | |
rectMode(CORNER) | |
rect(Pos.x,Pos.y,Size.x,Size.y) | |
--smooth() | |
-- lineCapMode(ROUND) | |
popStyle() | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------ | |
-- SHIP | |
------------------------------------------ | |
Ship = class() | |
function Ship:init(col) | |
self:reset(col) | |
end | |
function Ship:reset(col) | |
self.x = nil | |
self.y = nil | |
self.lineLength = 0.0 | |
self.lineWidth = 3 | |
self.currentWidth = 9 | |
self.lightColor = col or color(0, 255, 23, 255) | |
self.darkColor = col or color(157, 11, 216, 57) | |
end | |
function Ship:setPoints(startp, endp) | |
-- keep track of which point is leftmost | |
if startp.x < endp.x then | |
self.x = startp | |
self.y = endp | |
else | |
self.x = endp | |
self.y = startp | |
end | |
end | |
function Ship:draw() | |
self.lineLength = self.x:dist( self.y ) | |
pushStyle() | |
noSmooth() | |
lineCapMode(PROJECT) | |
strokeWidth(5.5) | |
line(self.x.x, self.x.y, self.y.x, self.y.y) | |
popStyle() | |
if math.abs( math.floor((self.y.x / self.y.y)/(self.x.x / self.x.y))) > 1 or | |
math.abs( math.floor((self.y.x / self.x.y)/(self.x.x / self.y.y))) > 1 | |
then | |
self.MaxAngle = true | |
else | |
self.MaxAngle = false | |
end | |
if math.abs( math.floor((self.y.x / self.y.y)/(self.x.x / self.x.y))) > 9 or | |
math.abs( math.floor((self.y.x / self.x.y)/(self.x.x / self.y.y))) > 9 then | |
self.MaxAngle1 = false | |
else self.MaxAngle1 = true | |
end | |
if self.MaxAngle then | |
stroke(112, 225, 93, 255) | |
else | |
stroke(255, 0, 0, 255) | |
if ElapsedTime > sounds then | |
sounds = ElapsedTime + 0.2 | |
sound(DATA, "ZgBAfwA8Pm0/DWNgmzY7PdCjMT+0smQ/ZAANUx9ZA3giGXBh") | |
end | |
strokeWidth(11) | |
line(self.x.x, self.x.y, self.y.x, self.y.y) | |
end | |
if self.MaxAngle1 then | |
stroke(81, 255, 0, 255) | |
else | |
stroke(0, 65, 255, 305) | |
if ElapsedTime > sounds then | |
sounds = ElapsedTime + 0.3 | |
sound(DATA, "ZgBAPwArYmpCPi8SAAAAADfimT7hc4q+SQBEfztACU0/QnJ9") | |
--sound(DATA, "ZgBAHABMQGVAQEBApDGqPPbdLz3gJOw+QABAf0BAQEBAXUBA") | |
end | |
strokeWidth(6) | |
line(self.x.x, self.x.y, self.y.x, self.y.y) | |
end | |
end | |
function Ship:collide(circle) | |
-- rebase to one end of line | |
local w = self.y - self.x | |
local u = circle.posicion - self.x | |
local r = circle:halfWidth() | |
-- projection of centre along line (not normalised) | |
local a = u:dot(w) | |
local d | |
if a <= 0 then | |
-- circle is closest to start of line | |
d = u:lenSqr() | |
else | |
local b = w:lenSqr() | |
if a >= b then | |
-- circle is closest to end of line | |
d = u:distSqr(w) | |
else | |
-- circle is closest to a point along the line | |
d = u:lenSqr() - a*a/b | |
end | |
end | |
if d > r*r then | |
-- no intersection | |
circle:style(NOT_HIT) | |
else | |
-- intersection | |
circle:style(HIT) | |
end | |
return d | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VERSION = "2.2.8" --Do not edit this | |
PROJECTNAME = "AutoGist" --Do not change this, your project should be named AutoGist | |
--The name of the project must match your Codea project name if dependencies are used. | |
--Project: Touchplay | |
--Version: Beta 2.1 | |
--Comments: Fixed problem with the images of the presentation, you can download now | |
--------------------------------- | |
--Main | |
--------------------------------- | |
displayMode(FULLSCREEN) | |
supportedOrientations(LANDSCAPE_RIGHT) | |
function setup() | |
exitButtoninit() | |
PhysicsBodies={} | |
music=Sound() | |
-- hs=highScore(1) | |
READY = 0 | |
PLAYING = 1 | |
DEAD = 2 | |
time = 10 | |
hola = false | |
WIN = 3 | |
HELP = 4 | |
touches = {} | |
tono = 0 | |
t1 = 0 | |
t2 = 5 | |
time1 = ElapsedTime | |
time2 = ElapsedTime | |
gamestate = READY | |
--gameOver=true | |
--gamestate = PLAYING | |
textura=color(math.random(555),math.random(555),math.random(555),math.random(555)) | |
texturas=color(math.random(155),math.random(155),math.random(155),math.random(155)) | |
bolass=color(math.random(7775),math.random(7775),math.random(7775),math.random(7775)) | |
enemies = {} | |
enemies2 = {} | |
balls = lineas() | |
q = 10 | |
combo = 3 | |
combo2 = 5 | |
p = 120 | |
hit = 0 | |
startTime = ElapsedTime | |
bolas =22 | |
c = color(255,0,0,255) | |
times = 1 | |
tamano = 90 | |
tiempo = -5 | |
a = 0 | |
sounds = 0 | |
sounds2 = 0 | |
sounds3 = 0 | |
sounds4 = 0 | |
l = 0 | |
t = ElapsedTime | |
FPS = 60 | |
r = readImage("Cargo Bot:Goal Area") | |
score = 0 --TIEMPO | |
score1 = 0 | |
lives = 0.5 | |
---------------- | |
imagen1 = nil | |
http.request("http://i780.photobucket.com/albums/yy81/luismigueldirauso/mialbum/lol_zps6d0b5d0b.png",loadImagen1) | |
imagen2 = nil | |
http.request("http://i780.photobucket.com/albums/yy81/luismigueldirauso/mialbum/letra_zpsbc512c99.png" ,loadImagen2) | |
imagen3 = nil | |
http.request("http://i780.photobucket.com/albums/yy81/luismigueldirauso/mialbum/touchplay2_zpsde7486bd.png",loadImagen3) | |
---------------- | |
---------- shaders -------------- | |
CIRCLE = readImage("Cargo Bot:Codea Icon") | |
m = mesh() | |
m.texture = CIRCLE | |
m.shader = shader("Effects:Ripple") | |
p = m:addRect(0,0,0,0) | |
--------- end shaders ---------- | |
tweens = Tween() | |
tweens:init() | |
for i=1 ,bolas do | |
local x = math.random( 5,WIDTH -60) | |
local y = math.random(4, HEIGHT/2+50) | |
table.insert(enemies, Enemy(x,y)) | |
end | |
for y=1 ,20 do | |
local x = math.random(5,WIDTH-60) | |
local y = math.random(0,HEIGHT/2-100) | |
table.insert(enemies2, Enemy(x,y)) | |
end | |
ship = Ship() | |
end | |
function draw() | |
background(textura) | |
highScore = readLocalData("highScore",0) | |
if score1 > highScore then | |
saveLocalData("highScore",score1) | |
highScore = score1 | |
end | |
if gamestate == READY then | |
GameState = "home" | |
---------------------------------- | |
touchcount = 0 | |
for u,touch in pairs(touches) do | |
touchcount = touchcount + 1 | |
end | |
noStroke() | |
-- music:draw()--traemos los tonos empleados en la clase Sound() | |
sprite("Cargo Bot:Goal Area",WIDTH/2,HEIGHT/2,WIDTH+200,HEIGHT+100) | |
FPS = .9*FPS + .1/DeltaTime | |
fontSize(50) | |
font("GillSans-Light") | |
fill(0,0,0,105) | |
text(FPS,WIDTH-140,HEIGHT-50) | |
------------------------------------------------------------------------------------------------------- | |
if CurrentTouch.x >= WIDTH/2+148 and CurrentTouch.x <= WIDTH/2+195 and | |
CurrentTouch.y <= HEIGHT/2+290 and CurrentTouch.y >= HEIGHT/2+220 and touchcount == 2 | |
then | |
gamestate = PLAYING | |
end | |
if CurrentTouch.x <= WIDTH/2-135 and CurrentTouch.x >= WIDTH/2-180 and | |
CurrentTouch.y <= HEIGHT/2+280 and CurrentTouch.y >= HEIGHT/2+200 and | |
touchcount == 2 then | |
gamestate=PLAYING | |
end | |
------------------------------------------------------------------- | |
pushStyle() | |
fill(0, 0, 0, 89) | |
font("CourierNewPS-ItalicMT") | |
fontSize(30) | |
text("Toca los dos circulos para poder empezar",WIDTH/2,HEIGHT/2+140) | |
popStyle() | |
sprite("Cargo Bot:Codea Logo",WIDTH/2+13,HEIGHT/2-250,240) | |
pushMatrix() | |
stroke(textura) | |
strokeWidth(12) | |
--sprite("Documents:ExampleCircle",WIDTH/2+167,HEIGHT/2+250,145) | |
fill(25,290,295,22) | |
line(402,630,638,630) | |
ellipse(WIDTH/2-155,HEIGHT/2+250,90) | |
ellipse(WIDTH/2+167,HEIGHT/2+250,90) | |
if imagen1 ~=nil then | |
sprite(imagen1,obj.x,obj.y,obj.size) | |
sprite(imagen1,obj_2.x,obj_2.y,obj_2.size) | |
end | |
popMatrix() | |
tweens:draw() | |
if CurrentTouch.x >= WIDTH/2+148 and CurrentTouch.x <= WIDTH/2+195 and | |
CurrentTouch.y <= HEIGHT/2+290 and CurrentTouch.y >= HEIGHT/2+220 then | |
m.shader.freq = 9.6 | |
t6 = tween(0.8, obj, {x = WIDTH/2+167, y = HEIGHT/2+250,z=360, size = 110}, | |
{easing = tween.easing.backOut, | |
loop = tween.loop.once}) | |
elseif CurrentTouch.x <= WIDTH/2-135 and CurrentTouch.x >= WIDTH/2-180 and | |
CurrentTouch.y <= HEIGHT/2+280 and CurrentTouch.y >= HEIGHT/2+200 then | |
t6 = tween(0.8, obj_2, {x = WIDTH/2-155, y = HEIGHT/2+250, size = 110}, | |
{easing = tween.easing.backOut, | |
loop = tween.loop.once}) | |
end | |
elseif gamestate == WIN then | |
sprite("Cargo Bot:Starry Background",WIDTH/2,HEIGHT/2,WIDTH+200,HEIGHT+200) | |
balls:cargar() | |
balls:dibujar() | |
fontSize(90) | |
font("Arial-BoldMT") | |
fill(247, 239, 22, 190) | |
text("GANASTE",WIDTH/2,HEIGHT/2) | |
fontSize(60) | |
font("GillSans-Light") | |
hs = "Tu puntaje fue: "..score1 | |
hswidth = textSize(hs) | |
text(hs, WIDTH - hswidth - 110, HEIGHT - 60) | |
if CurrentTouch.tapCount == 2 then | |
setup() | |
-- draw() | |
gamestate = READY | |
end | |
elseif gamestate == DEAD then | |
background(255,0,0,1) | |
-- GameState = "home" | |
fontSize(340) | |
fill(255) | |
font("Arial-BoldMT") | |
hs = ""..score1 | |
textAlign(CENTER) | |
text(hs,WIDTH/2,HEIGHT/2) | |
fontSize(20) | |
text("2 touches for play again",WIDTH/2-329,HEIGHT/2+360) | |
if CurrentTouch.tapCount == 2 then | |
setup() | |
-- draw() | |
gamestate = READY end | |
elseif gamestate == PLAYING then | |
GameState = nil | |
-- if CurrentTouch.state == ENDED then | |
-- touches[CurrentTouch.id]=nil | |
-- gamestate = DEAD | |
-- end | |
font("GillSans-Light") | |
fontSize(50) | |
fill(0,0,0,160) | |
hs = "High Score: "..highScore | |
-- hswidth = textSize(hs) | |
text(hs, WIDTH/2, HEIGHT/2-300) | |
fontSize(144) | |
font("GillSans-Light") | |
fill(0, 0, 0, 70) | |
text(" "..score1,WIDTH/2-380,HEIGHT/2+300) | |
if score >= 30 and score <= 33 then | |
fontSize(50) | |
font("GillSans-Light") | |
fill(0, 0, 0, 190) | |
text("DESTROZA LAS BOLAS!! AHORA ",WIDTH/2,HEIGHT/2) | |
fontSize(220) | |
fill(0,0,0,90) | |
text(""..combo,WIDTH/2,HEIGHT/2+240) | |
if ElapsedTime-t > 1 then | |
-- t=ElapsedTime | |
combo = combo - 1 | |
end | |
end | |
if score >= 60 and score <= 65 then | |
fontSize(50) | |
font("GillSans-Light") | |
fill(0, 0, 0, 190) | |
text("DESTROZA LAS BOLAS!! AHORA ",WIDTH/2,HEIGHT/2) | |
fontSize(220) | |
fill(0,0,0,90) | |
text(""..combo2,WIDTH/2,HEIGHT/2+240) | |
if ElapsedTime-t > 1 then | |
-- t=ElapsedTime | |
combo2 = combo2 - 1 | |
end | |
end | |
if score >= 66 then | |
gamestate = WIN | |
end | |
sprite("Cargo Bot:Goal Area",WIDTH/2,HEIGHT/2,WIDTH+200,HEIGHT+100) | |
fill(145, 92, 92, 255) | |
if ElapsedTime-t > 1 then | |
score = score + 1 | |
t=ElapsedTime | |
end | |
score1 = score1 + 1 | |
if lives < 0 then | |
gamestate = DEAD | |
end | |
local x = nil | |
local y= nil | |
for k,o in pairs(touches) do | |
y = x | |
x = o | |
end | |
if y then | |
-- if we have two touches, tell the ship about them | |
ship:setPoints(x, y) | |
ship:draw() | |
end | |
for i,v in ipairs(enemies) do | |
-- check for collisions and update enemies | |
if y then ship:collide(v) end | |
v:draw() | |
end | |
if score >= 35 then | |
for i,u in ipairs(enemies2) do | |
if y then ship:collide(u) end | |
u:draw() | |
end | |
end | |
end | |
if GameState == "home" then | |
exitButtondraw() | |
elseif GameState == "playNEXTPAGE" then | |
playNEXTPAGEdraw() | |
end | |
end --draw() | |
function touched(touch) | |
if CurrentTouch.state == BEGAN then | |
touches[touch.id] = vec2(touch.x, touch.y) | |
elseif CurrentTouch.state == MOVING then | |
touches[touch.id] = vec2(touch.x,touch.y) | |
elseif CurrentTouch.state == ENDED then | |
touches[touch.id]=nil | |
gamestate = DEAD | |
end | |
if GameState == "home" then | |
exitButtontouch(touch) | |
elseif GameState == "playNEXTPAGE" then | |
playNEXTPAGEtouch(touch) | |
end | |
if lives < 0 then | |
touches[touch.id]=nil | |
end | |
end | |
HIT = 6 | |
NOT_HIT = 1 | |
function exitButtoninit() | |
salir= Buttons(WIDTH/2-350,HEIGHT/2-300,"Salir",close,true) | |
reestart = Buttons(WIDTH/2-55,HEIGHT/2-360,"Reiniciar",restart,true) | |
nextPAGE = Buttons(WIDTH/2+330,HEIGHT/2-270,"Como Jugar",playNEXTPAGE) | |
end | |
function exitButtondraw() | |
salir:draw() | |
reestart:draw() | |
nextPAGE:draw() | |
end | |
function exitButtontouch(touch) | |
salir:touched(touch) | |
reestart:touched(touch) | |
nextPAGE:touched(touch) | |
end | |
function playNEXTPAGEinit() | |
BACK = Buttons(WIDTH/2-330,HEIGHT/2-260,"JUGAR YA",back) | |
end | |
function playNEXTPAGEdraw() | |
background(121, 129, 225, 255) | |
-- sprite("Planet Cute:Water Block",WIDTH/2,HEIGHT/2,WIDTH*2,HEIGHT*4) | |
pushStyle() | |
fill(0) | |
fontSize(40) | |
text("Como Jugar a TOUCHPLAY",WIDTH/2+10,HEIGHT/2+300) | |
popStyle() | |
pushStyle() | |
fontSize(30) | |
fill(0) | |
text("Toca dos veces para empezar a jugar",WIDTH/2+120,HEIGHT/2-250) | |
popStyle() | |
pushStyle() | |
font("GillSans-Light") | |
fontSize(30) | |
sprite("Platformer Art:Coin",WIDTH/2-430,HEIGHT/2+217,25) | |
text("Manten los dos dedos fijos en los dos ellipses para poder empezar",510,601) | |
sprite("Platformer Art:Coin",WIDTH/2-430,HEIGHT/2+147,25) | |
text("Mueve los dos dedos en conjunto con la recta para esquivar las",492,530) | |
text("bolas y no morir",215,490) | |
sprite("Platformer Art:Coin",WIDTH/2-430,HEIGHT/2+37,25) | |
text("Cada 30 seg se podran explotar bolas en un tiempo limitado",476,419) | |
sprite("Platformer Art:Coin",WIDTH/2-430,HEIGHT/2-39,25) | |
text("No se puede soltar un dedo mientras se este jugando, sino pierdes",512,343) | |
sprite("Platformer Art:Coin",WIDTH/2-430,HEIGHT/2-109,25) | |
text("La velocidad de las bolas aumentara en el transcurso de la partida",502,274) | |
popStyle() | |
BACK:draw() | |
end | |
function playNEXTPAGEtouch(touch) | |
BACK:touched(touch) | |
end | |
function playNEXTPAGE() | |
ChangeState("playNEXTPAGE",playNEXTPAGEinit) | |
end | |
function home() | |
ChangeState("home",exitButtoninit) | |
end | |
function back() | |
ChangeState("back",setup) | |
end | |
function ChangeState(State,funct) | |
for k,v in pairs(PhysicsBodies) do | |
v:destroy() | |
v=nil | |
end | |
PhysicsBodies={} | |
funct() | |
GameState=State | |
end | |
-------------------------- | |
function loadImagen1(IMG1) | |
imagen1 = IMG1 | |
end | |
function loadImagen2(IMG2) | |
imagen2 = IMG2 | |
end | |
function loadImagen3(IMG3) | |
imagen3 = IMG3 | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--------------------------------- | |
--Sound class | |
--clase importada | |
--------------------------------- | |
Sound = class() | |
function Sound:init() | |
-- you can accept and set parameters here | |
createPitchTable() | |
song = { | |
{x=100,n="e"}, | |
{x=200,n="g"}, | |
{x=300,n="c"}, | |
{x=500,n="E"}, | |
{x=600,n="G"}, | |
{x=700,n="C"}, | |
} | |
for i,v in ipairs(song) do | |
v.x = v.x * .8 | |
v.p = convertNoteToPitch(v.n) | |
v.data = sound(ENCODE, { Waveform = SOUND_SINEWAVE, StartFrequency = v.p | |
}) | |
end | |
end | |
function Sound:draw() | |
-- Codea does not automatically call this method | |
fill(bolass) | |
local x =math.floor((ElapsedTime*WIDTH*.15)%WIDTH) | |
local hh = HEIGHT/2 | |
for i,v in ipairs(song) do | |
local s = 0 | |
if x > v.x then | |
local d = math.abs(x-v.x) | |
if d <200 then | |
s = s + d | |
else | |
s = math.max(0, s+(400-d)) | |
end | |
end | |
--math.randomseed(s) | |
-- fill(255,255,255,80) | |
ellipse(v.x*1.7, v.p*940, s) | |
if math.abs(x-v.x) < 6 then | |
sound(DATA, v.data) | |
end | |
end | |
end | |
function createPitchTable() | |
multiplier = 1.0296 | |
pitchTable = {1} | |
pitch = pitchTable[1] | |
semitoneModifier = 0 | |
gsNoteOrder = "CDEFGABcdefgab" | |
gsTonalSystem = "22122212221221" | |
-- There are 88 keys on a piano, so we will start from our highest note and go down. | |
-- We calculate the notes ourselves and put them in a table. | |
for i = 88, 1, -1 do | |
pitch = pitch / multiplier | |
table.insert(pitchTable,1,pitch) | |
end | |
end | |
function convertNoteToPitch(n) | |
semitoneModifier = 0 | |
gsNoteBeingPlayed = n | |
for j = 1, #gsNoteBeingPlayed do | |
local currentChar = string.sub(gsNoteBeingPlayed,j,j) | |
if currentChar == "_" then | |
semitoneModifier = semitoneModifier - 1 | |
end | |
if currentChar == "\^" then | |
semitoneModifier = semitoneModifier + 1 | |
currentChar = "%^" | |
end | |
-- NB need to implement naturals = | |
-- if the current char is a note | |
if string.find("abcdefg",string.lower(currentChar)) ~= nil then | |
-- modify octave | |
-- search through the next characters for , and ' | |
local nextCharIndex = 1 | |
local nextChar = string.sub(gsNoteBeingPlayed,j+nextCharIndex,j+nextCharIndex) | |
if nextChar == "," then | |
semitoneModifier = semitoneModifier - 12 | |
end | |
if nextChar == "'" then | |
semitoneModifier = semitoneModifier + 12 | |
end | |
pos = string.find(gsNoteOrder,currentChar) | |
local tonalModifier = string.sub(gsTonalSystem, 1, pos - 1) | |
for i = 1, #tonalModifier do | |
semitoneModifier = semitoneModifier + tonumber(string.sub(tonalModifier,i,i)) | |
end | |
end | |
end | |
pos = semitoneModifier + 44 | |
pitch = pitchTable[pos] | |
return pitch | |
end | |
function play() | |
local note = string.sub(gsNoteOrder,X,X) | |
print(note) | |
sound({ | |
Waveform = SOUND_SINEWAVE, | |
StartFrequency = convertNoteToPitch(note) | |
}) | |
end | |
function Sound:touched(touch) | |
-- Codea does not automatically call this method | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
linea = class() | |
function linea:init(vel , pos) | |
-- you can accept and set parameters here | |
self.velocidad = vel | |
self.posicion = pos | |
tamano =80 | |
end | |
function linea:cargar() | |
self.posicion.y = self.posicion.y - self.velocidad | |
end | |
function linea:mostrar() | |
if (self.posicion.y + self.velocidad) < 0 then | |
return true | |
end | |
return false | |
end | |
function linea:dibujar() | |
p = self.posicion | |
fill(math.random(255),math.random(255),math.random(255),math.random(255)) | |
noStroke() | |
ellipse(p.x,p.y,tamano/9+self.velocidad) | |
end | |
------------------------------------------------------------------------- | |
lineas = class() | |
function lineas:init() | |
self.velocidad_0 = 10 | |
self.velocidad_1 = 10 | |
self.rango =1 | |
self.lines = {} | |
end | |
function lineas:mostrarTodo() | |
for i,v in ipairs(self.lines) do | |
if v:mostrar() then | |
table.remove(self.lines , i ) | |
else | |
v:cargar() | |
end | |
end | |
end | |
function lineas:cargar() | |
for i = 1 , self.rango do | |
Velocidad = math.random(self.velocidad_0 , self.velocidad_1) | |
dato_1 = vec2(math.random(WIDTH) , HEIGHT - Velocidad) | |
table.insert(self.lines , linea(Velocidad , dato_1)) | |
end | |
self:mostrarTodo() | |
end | |
function lineas:dibujar() | |
--sound(DATA,"ZgNAeABCQj4/Pj1DWQtwPxDT77u1THs/dQBHf0JFQD9AQj9A") | |
pushStyle() | |
noSmooth() | |
stroke(255,25,255,73.9) | |
strokeWidth(3) | |
for i,v in ipairs(self.lines) do | |
v:dibujar() | |
end | |
popStyle() | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tween = class() | |
function Tween:init(x) | |
-- you can accept and set parameters here | |
obj_2 = {x = WIDTH/2-155, y = HEIGHT/2+250, size =20} | |
obj = {x = WIDTH/2+167, y = HEIGHT/2+250, z= 0,size = 20} | |
move = vec3(WIDTH/2+167,HEIGHT/2+250,100) | |
tween(7,move,{x=WIDTH/2+167,y=HEIGHT/2+250,z=360}, | |
{easing=tween.easing.linear, | |
loop = tween.loop.pingpong}) | |
move2 = vec3(WIDTH/2-155,HEIGHT/2+250,0) | |
tween(7,move2,{x=WIDTH/2-155,y=HEIGHT/2+250,z=360}, | |
{easing=tween.easing.linear, | |
loop = tween.loop.pingpong}) | |
texto = vec3(WIDTH/2+167,HEIGHT/2+250,100) | |
tween(5,texto,{x=WIDTH/2+167,y=HEIGHT/2+250,z=360}, | |
{easing=tween.easing.linear, | |
loop = tween.loop.pingpong}) | |
texto2 = vec3(WIDTH/2-155,HEIGHT/2+250,100) | |
tween(5,texto2,{x=WIDTH/2-155,y=HEIGHT/2+250,z=360}, | |
{easing=tween.easing.linear, | |
loop = tween.loop.pingpong}) | |
presentacion = vec3(WIDTH/2+3455,HEIGHT/2+100) | |
tween(2.0,presentacion,{x=WIDTH/2+15,y=HEIGHT/2+100,z=0}, | |
{easing=tween.easing.cubicOut, | |
loop = tween.loop.once}) | |
presentacion2 = vec3(WIDTH/2-3455,HEIGHT/2+100) | |
tween(2.0,presentacion2,{x=WIDTH/2+15,y=HEIGHT/2+100,z=0}, | |
{easing=tween.easing.cubicOut, | |
loop = tween.loop.once}) | |
end | |
function Tween:draw() | |
-- Codea does not automatically call this method | |
pushMatrix() | |
translate(move.x,move.y) | |
rotate(move.z) | |
if imagen1 ~= nil then | |
sprite(imagen1,0,0,110) | |
end | |
popMatrix() | |
pushMatrix() | |
translate(move2.x,move2.y) | |
rotate(move2.z) | |
if imagen1 ~= nil then | |
sprite(imagen1,0,0,110) | |
end | |
popMatrix() | |
pushMatrix() | |
translate(texto.x,texto.y) | |
rotate(texto.z) | |
if imagen2 ~= nil then | |
sprite(imagen2,0,0,86) | |
end | |
popMatrix() | |
pushMatrix() | |
translate(texto2.x,texto2.y) | |
rotate(texto2.z) | |
if imagen2 ~= nil then | |
sprite(imagen2,0,0,86) | |
end | |
popMatrix() | |
pushMatrix() | |
translate(presentacion.x,presentacion.y) | |
rotate(presentacion.z) | |
if imagen3 ~= nil then | |
sprite(imagen3,0,0,940) | |
end | |
popMatrix() | |
pushMatrix() | |
translate(presentacion2.x,presentacion2.y) | |
rotate(presentacion2.z) | |
if imagen3 ~= nil then | |
sprite(imagen3,0,0,940) | |
end | |
popMatrix() | |
-- sprite() | |
end | |
function Tween:touched(touch) | |
-- Codea does not automatically call this method | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment