Advertisement
Guest User

Untitled

a guest
Dec 16th, 2011
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.07 KB | None | 0 0
  1. x=WIDTH/2
  2. y=HEIGHT/2
  3. xx=10
  4. yy=10
  5. movfact=5
  6. mivfact = 1
  7. mov=20
  8. i=500
  9. -- Use this function to perform your initial setup
  10. function setup()
  11.     displayMode(FULLSCREEN_NO_BUTTONS)
  12.     print("Hello World!")
  13.     parameter("movfact", 1 , 100)
  14.     parameter("mivfact",0,100)
  15.     egg={}
  16.  --   table.insert(egg,vec2(300,200))
  17.     block = image(20,20)
  18.     for i=1,20 do for j=1,20 do block:set(i,j,255,0,0,255) end end
  19. end
  20.  
  21. -- This function gets called once every frame
  22. function draw()
  23.     -- This sets the background color to black
  24.     i = i + 1
  25.  --   mivfact = mivfact + 0.1
  26.     background(0, 0, 0)
  27.     sprite("Tyrian Remastered:Blimp Boss",x,y)
  28.    for z=1,i/500 do monmove() end
  29.     sprite("Tyrian Remastered:Chest Mecha",xx,yy)
  30.     x=x-(x%1)
  31.     y=y-(y%1)
  32.     xx=xx-(xx%1)
  33.     yy=yy-(yy%1)
  34.     if(i%10==0) then sprite(block,xx,yy)end
  35.     if(i%100==0)then 
  36.         table.insert(egg,vec2(xx,yy))
  37.         sound(SOUND_PICKUP)
  38.     end
  39.     for key,i in pairs(egg)do
  40.         mivfact=0.5
  41.      --   sprite(block,i.x,i.y)
  42.         ll=yy
  43.         ii=xx
  44.         yy=i.y
  45.         xx=i.x
  46.         monmove()
  47.         i.x=xx
  48.         i.y=yy
  49.         xx=ii
  50.         yy=ll
  51.         sprite(block,i.x,i.y)
  52.     end
  53.     mivfact=1
  54.     if x==xx and y==yy then closee() end
  55.     if i==2500 then woon() end
  56.     -- Do your drawing here
  57. end
  58.  
  59. function touched (touch)
  60.     if touch.x < x then zx = x - movfact end
  61.     if touch.x > x then zx = x + movfact end
  62.     if touch.y < y then zy = y - movfact end
  63.     if touch.y > y then zy = y + movfact end    
  64.     point =vec2(zx,zy)
  65.     if(ic(point))then
  66.         --crash with egg
  67.     else
  68.         x=zx
  69.         y=zy
  70.     end
  71.         
  72. end
  73.  
  74. function monmove()
  75.     if x < xx then xx = xx - mivfact end
  76.     if x > xx then xx = xx + mivfact end
  77.     if y < yy then yy = yy- mivfact end
  78.     if y> yy then yy = yy + mivfact end
  79. end
  80.  
  81. function closee()
  82.     background()
  83.     sprite("Tyrian Remastered:Blimp Boss Destroyed",x,y)
  84.     
  85.     for i = 0,10 do
  86.         sprite(block,200+i*mov , 600 -i*mov)
  87.         sprite(block,400-i*mov , 600-i*mov)
  88.     end
  89.     for i = 1,50 do
  90.     sound(SOUND_EXPLODE)
  91.     end
  92.     close()
  93. end
  94.  
  95. function woon()
  96.     background()
  97.     sprite("Tyrian Remastered:Blimp Boss",x,y)
  98.      for i = 0,10 do
  99.         if i>5 then      sprite(block,300-i*mov , 300 +i*mov) end
  100.         sprite(block,400-i*mov , 600-i*mov)
  101.     end
  102.     for i=1,50 do sound(SOUND_BLIT) end
  103.     close()
  104. end
  105.  
  106. function ic(point)
  107.     for i,v in pairs(egg) do
  108.         if icc(point,v) then
  109.             return true
  110.         end
  111.     end
  112.     
  113.     return false
  114. end
  115.  
  116.  
  117. function icc(point,v)
  118.     c=vec2(20,20)
  119.     ll = v - c * 0.5
  120.     ur = v + c * 0.5
  121.     
  122.     if point.x > ll.x and point.x < ur.x and
  123.        point.y > ll.y and point.y < ur.y then
  124.         return true
  125.     end
  126.     
  127.     return false
  128. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement