Created
September 28, 2013 22:26
-
-
Save CodeaLuis/6747380 to your computer and use it in GitHub Desktop.
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
displayMode(FULLSCREEN) | |
function setup() | |
xc=WIDTH/2 | |
yc=HEIGHT/2 | |
tiempo = 0 | |
--sprite("Planet Cute:Gem Green") | |
caracteres = {""} | |
objetos = {} | |
contador=0 | |
pared_1 = physics.body(EDGE,vec2(0,0),vec2(WIDTH,0)) | |
pared_2 = physics.body(EDGE,vec2(0,0),vec2(0,HEIGHT)) --PARED IZQUIERDA | |
pared_4 = physics.body(EDGE,vec2(WIDTH,0),vec2(WIDTH,HEIGHT)) | |
-- physics.gravity(Gravity) | |
ball = physics.body(CIRCLE, 39) | |
ball.x = xc-340 | |
ball.y = yc+1220 | |
ball.restitution = 0.7 | |
pelota_2 = physics.body(CIRCLE , 50) | |
pelota_2.x = xc | |
pelota_2.y = yc+400 | |
pelota_2.restitution = 0.3 | |
rampa_esquina=physics.body(POLYGON,vec2(200-200,600),vec2(200-200,yc), | |
vec2(500-300,yc)) | |
rampa_esquina.type=STATIC | |
mesa_mitad1=physics.body(POLYGON,vec2(xc-100,yc+230),vec2(xc-100,yc+258), | |
vec2(xc-20,yc+234),vec2(xc-20,yc+230)) | |
mesa_mitad1.type=STATIC | |
mesa_mitad2=physics.body(POLYGON,vec2(xc+90,yc+230),vec2(xc+90,yc+234), | |
vec2(xc+130,yc+258),vec2(xc+130,yc+230)) | |
mesa_mitad2.type=STATIC | |
pared_derecha=physics.body(POLYGON,vec2(xc+130,1000),vec2(xc+130,784), | |
vec2(xc+120,784),vec2(xc+120,1000)) | |
pared_derecha.type=STATIC | |
pared_derecha_rampa=physics.body(POLYGON, | |
vec2(xc-180,yc+190), | |
vec2(xc-180,yc-1), | |
vec2(xc-170,yc-1), | |
vec2(xc-170,yc+190)) | |
pared_derecha_rampa.type=STATIC | |
pared_izquierda=physics.body(POLYGON,vec2(xc-100,1000),vec2(xc-100,784), | |
vec2(xc-90,784),vec2(xc-90,1000)) | |
pared_izquierda.type=STATIC | |
a = physics.body(POLYGON,vec2(xc-105,yc+270),vec2(xc-105,yc+280), | |
vec2(xc+140,yc+280),vec2(xc+140,yc+270)) | |
a.type=DYNAMIC | |
piso_soporte = physics.body(POLYGON,vec2(xc+135,yc+230),vec2(xc+135,yc+250), | |
vec2(xc+350,yc+250),vec2(xc+350,yc+230)) | |
piso_soporte.type=STATIC | |
piso_soporte2 = physics.body(POLYGON,vec2(xc+135,yc+50),vec2(xc+135,yc+29), | |
vec2(xc+350,yc+29),vec2(xc+350,yc+50)) | |
piso_soporte2.type=STATIC | |
piso_abajo = physics.body(POLYGON,vec2(xc+125,yc-390),vec2(xc+125,yc-400), | |
vec2(xc-250,yc-400),vec2(xc-250,yc-390)) | |
piso_abajo.type=DYNAMIC | |
piso_abajo.restitution=0.3 | |
soporte_piso_abajo = physics.body(POLYGON, vec2(xc-160,100),vec2(xc-160,50), | |
vec2(xc-55,50),vec2(xc-55,100)) | |
soporte_piso_abajo.type = STATIC | |
domino_piso_abajo = physics.body(POLYGON,vec2(xc-156,160),vec2(xc-156,120) | |
,vec2(xc-170,120),vec2(xc-170,160)) | |
domino_piso_abajo.type = DYNAMIC | |
domino_piso_abajo.restitution = 0.2 | |
end | |
function drawpoints(body) | |
pushMatrix() | |
translate(body.x, body.y) | |
rotate(body.angle) | |
local points = body.points | |
local a, b | |
for j = 1,#points do | |
a = points[j] | |
b = points[(j % #points)+1] | |
line(a.x, a.y, b.x, b.y) | |
end | |
popMatrix() | |
end | |
function draw() | |
background(97, 97, 14, 0) | |
fill(255,255) | |
mostrar_advertencia("TOUCH HERE",WIDTH/2+12,HEIGHT/2+470) | |
-- strokeWidth(2) | |
contador = contador + 1 | |
if contador >= 20 then | |
cambioLetra = true | |
contador = 0 | |
else | |
cambioLetra = false | |
end | |
fill(251, 251, 251, 255) | |
-- stroke(76, 75, 143, 255) | |
for i,v in ipairs(objetos) do | |
if cambioLetra == true then | |
v.obtener = caracteres[math.ceil(math.random(1,#caracteres))] | |
end | |
pushMatrix() | |
translate(v.x,v.y) | |
rotate(v.angle) | |
fill(255,2888,255) | |
fontSize(30) | |
text(v.obtener,0,0) | |
popMatrix() | |
end | |
fill(5, 5, 5, 255) | |
strokeWidth(3) | |
ellipse(ball.x,ball.y,ball.radius*2) | |
ellipse(pelota_2.x,pelota_2.y,pelota_2.radius*2) | |
-- ellipse(ball2.x,ball2.y,ball2.radius*2) | |
stroke(239, 237, 239, 255) | |
strokeWidth(3) | |
drawpoints(a) | |
drawpoints(piso_soporte) | |
drawpoints(piso_soporte2) | |
drawpoints(rampa_esquina) | |
drawpoints(mesa_mitad1) | |
drawpoints(mesa_mitad2) | |
drawpoints(pared_derecha) | |
drawpoints(pared_derecha_rampa) | |
drawpoints(pared_izquierda) | |
drawpoints(piso_abajo) | |
drawpoints(soporte_piso_abajo) | |
stroke(0,0,0) | |
strokeWidth(5) | |
drawpoints(domino_piso_abajo) | |
stroke(255,255,255) | |
strokeWidth(12) | |
drawpoints(pared_1) | |
drawpoints(pared_2) | |
drawpoints(pared_4) | |
setContext() | |
end | |
function touched (txy) | |
table.insert(objetos,physics.body(CIRCLE,fontSize()/3)) | |
objetos[#objetos].x = txy.x | |
objetos[#objetos].y = txy.y | |
objetos[#objetos].restitution = 0 | |
objetos[#objetos].obtener = caracteres[math.ceil(math.random(1,#caracteres))] | |
end | |
function mostrar_advertencia(acomodar,x,y) | |
pushMatrix() | |
fill(255,255,25,255)--rojo | |
font("Georgia") | |
fontSize(20) | |
textWrapWidth(300) | |
text(acomodar,x,y) | |
popMatrix() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment