Advertisement
xerpi

Untitled

Apr 12th, 2011
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. -- Juego
  2. blanco = color.new(255,255,255)
  3. fondo = image.load("fondo.png")
  4. punt={img=image.load("menu/puntero.png"),x=30,y=26,w=20,h=20}
  5. select={
  6. {x=25,y=73,w=20,h=20},
  7. {x=25,y=107,w=20,h=20},
  8. {x=25,y=150,w=20,h=20},
  9. {x=25,y=148,w=20,h=20}
  10. }
  11. select.img=img=image.load("menu/logo.png")
  12.  
  13. brad={img=brad = image.load("actores/brad.png"),x=213,y=65,w=216,h=140}
  14. function colision(objeto1,objeto2)
  15. if objeto1.x+objeto1.w >= objeto2.x and
  16.     objeto1.x <= objeto2.x +objeto2.w and
  17.     objeto1.y + objeto1.h >= objeto1.y and
  18.     objeto1.y <= objeto2.y + objeto2.h then
  19.     return true
  20. else return false
  21. end
  22. end
  23.  
  24.  
  25. temporizador = timer.new()
  26. temporizador:start()
  27. while true do
  28. controls.read()
  29. fondo:blit(0,0)
  30.  
  31. for i=1,#select do
  32. select.img:blit(select[i].x,select[i].y)
  33. if controls.press("cross") and colision(punt,select[i]) then
  34.     if i==1 then
  35.         os.message("Incorrecto")
  36.         dofile("niveles/nivel2.lua")
  37.     else os.message("Correcto")
  38.         dofile("niveles/nivel2.lua")
  39.     end
  40. end
  41. end
  42.  
  43.  
  44.  
  45. punt.img:blit(punt.x,punt.y)
  46. brad.img:blit(brad.x,brad.y)
  47. screen.print(45,73,"Brad Pitt",1,blanco,0x0)
  48. screen.print(45,113,"Bruce Willis",1,blanco,0x0)
  49. screen.print(45,150,"Tom Cruise",1,blanco,0x0)
  50. screen.print(45,188,"Nicolas cage",1,blanco,0x0)
  51. screen.print(134,228,"Tiempo = " .. math.floor(temporizador:time() /1000),1,blanco,0x0)
  52.  
  53. if temporizador:time() >= 15000 then
  54.     temporizador:reset()
  55.     temporizador:stop()
  56.     os.message("Se te acabo el tiempo")
  57.     dofile("script.lua")
  58. end
  59.  
  60. if math.abs(controls.analogy())>20 then punt.y = punt.y + controls.analogy()/30 end
  61. if math.abs(controls.analogx())>20 then punt.x = punt.x + controls.analogx()/30 end
  62.  
  63. screen.flip()
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement