Advertisement
Sajjad

Monster v1.2

Dec 17th, 2011
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.96 KB | None | 0 0
  1. x=WIDTH/2
  2. game=1
  3. y=HEIGHT/2
  4. xx=10
  5. yy=10
  6. movfact=10
  7. mivfact = 1
  8. mov=20
  9. i=500
  10. -- Use this function to perform your initial setup
  11. function setup()
  12.     displayMode(FULLSCREEN_NO_BUTTONS)
  13. --    print("Hello World!")
  14.     parameter("movfact", 1 , 100)
  15.     parameter("mivfact",0,100)
  16.     egg={}
  17.  --   table.insert(egg,vec2(300,200))
  18.     block = image(20,20)
  19.     for i=1,20 do for j=1,20 do block:set(i,j,255,0,0,255) end end
  20.     one= readLocalData("one",0)
  21.     two = readLocalData("two",0)
  22.      three=   readLocalData("three",0)
  23.       four=  readLocalData("four",0)
  24.      five =  readLocalData("five",0)
  25.     six   = readLocalData("six",0)
  26.      seven=   readLocalData("seven",0)
  27.     eight =   readLocalData("eight",0)
  28.     nine = readLocalData("nine",0)
  29.     ten   = readLocalData("ten",0)
  30. end
  31.  
  32. -- This function gets called once every frame
  33. function draw()
  34.     if game==1 then
  35.     -- This sets the background color to black
  36.     i = i + 1
  37.  --   mivfact = mivfact + 0.1
  38.     background(0, 0, 0)
  39.     sprite("Tyrian Remastered:Blimp Boss",x,y)
  40.    for z=1,i/500 do monmove() end
  41.     sprite("Tyrian Remastered:Chest Mecha",xx,yy)
  42.     x=x-(x%1)
  43.     y=y-(y%1)
  44.     xx=xx-(xx%1)
  45.     yy=yy-(yy%1)
  46.     if(i%10==0) then sprite(block,xx,yy)end
  47.     if(i%100==0)then 
  48.         table.insert(egg,vec2(xx,yy))
  49.         sound(SOUND_PICKUP)
  50.     end
  51.     for key,i in pairs(egg)do
  52.         mivfact=0.5
  53.      --   sprite(block,i.x,i.y)
  54.         ll=yy
  55.         ii=xx
  56.         yy=i.y
  57.         xx=i.x
  58.         monmove()
  59.         i.x=xx
  60.         i.y=yy
  61.         xx=ii
  62.         yy=ll
  63.         sprite(block,i.x,i.y)
  64.     end
  65.     mivfact=1
  66.     if x==xx and y==yy then closee() end
  67. --    if i==2500 then woon() end
  68.     -- Do your drawing here
  69.     end
  70. end
  71.  
  72. function touched (touch)
  73.     if touch.x < x then zx = x - movfact end
  74.     if touch.x > x then zx = x + movfact end
  75.     if touch.y < y then zy = y - movfact end
  76.     if touch.y > y then zy = y + movfact end    
  77.     point =vec2(zx,zy)
  78.     if(ic(point))then
  79.         --crash with egg
  80.     else
  81.         x=zx
  82.         y=zy
  83.     end
  84.         
  85. end
  86.  
  87. function monmove()
  88.     if x < xx then xx = xx - mivfact end
  89.     if x > xx then xx = xx + mivfact end
  90.     if y < yy then yy = yy- mivfact end
  91.     if y> yy then yy = yy + mivfact end
  92. end
  93.  
  94. function closee()
  95.     background()
  96.     sprite("Tyrian Remastered:Blimp Boss Destroyed",x,y)
  97.     
  98.     for i = 0,10 do
  99.         sprite(block,200+i*mov , 600 -i*mov)
  100.         sprite(block,400-i*mov , 600-i*mov)
  101.     end
  102.     for i = 1,50 do
  103.     sound(SOUND_EXPLODE,1)
  104.     end
  105.     highscore()
  106.     game=0
  107.  --   close()
  108. end
  109.  
  110. function woon()
  111.     background()
  112.     sprite("Tyrian Remastered:Blimp Boss",x,y)
  113.      for i = 0,10 do
  114.         if i>5 then      sprite(block,300-i*mov , 300 +i*mov) end
  115.         sprite(block,400-i*mov , 600-i*mov)
  116.     end
  117.     for i=1,50 do sound(SOUND_BLIT) end
  118. --    close()
  119. end
  120.  
  121. function ic(point)
  122.     for i,v in pairs(egg) do
  123.         if icc(point,v) then
  124.             return true
  125.         end
  126.     end
  127.     
  128.     return false
  129. end
  130.  
  131.  
  132. function icc(point,v)
  133.     c=vec2(20,20)
  134.     ll = v - c * 0.5
  135.     ur = v + c * 0.5
  136.     
  137.     if point.x > ll.x and point.x < ur.x and
  138.        point.y > ll.y and point.y < ur.y then
  139.         return true
  140.     end
  141.     
  142.     return false
  143. end
  144.  
  145. function highscore()
  146.     displayMode(STANDARD)
  147. --    background()
  148.     i=i-500
  149.     if i > one then
  150.         if i> two then
  151.             if i> three then
  152.                 if i > four then
  153.                     if i > five then
  154.                         if i> six then
  155.                             if i> seven then
  156.                                 if i>eight then
  157.                                     if i>nine then
  158.                                         if i> ten then
  159.                                             one=two
  160.                                             two=three
  161.                                             three=four
  162.                                             four=five
  163.                                             five=six
  164.                                             six=seven
  165.                                             seven=eight
  166.                                             eight=nine
  167.                                             nine=ten
  168.                                             ten=i
  169.                                             print("new recorde!")
  170.                                         else
  171.                                             one=two
  172.                                             two=three
  173.                                             three=four
  174.                                             four=five
  175.                                             five=six
  176.                                             six=seven
  177.                                             seven=eight
  178.                                             eight=nine
  179.                                             nine=i
  180.                                         end
  181.                                     else
  182.                                         one=two
  183.                                         two=three
  184.                                         three=four
  185.                                         four=five
  186.                                         five=six
  187.                                         six=seven
  188.                                         seven=eight
  189.                                         eight =i
  190.                                     end
  191.                                 else
  192.                                     one=two
  193.                                     two=three
  194.                                     three=four
  195.                                     four=five
  196.                                     five=six
  197.                                     six=seven
  198.                                     seven=i
  199.                                 end
  200.                             else
  201.                                 one=two
  202.                                 two=three
  203.                                 three=four
  204.                                 four=five
  205.                                 five=six
  206.                                 six=i
  207.                             end
  208.                         else
  209.                             one=two
  210.                             two=three
  211.                             three=four
  212.                             four=five
  213.                             five=i
  214.                         end
  215.                     else
  216.                         one=two
  217.                         two=three
  218.                         three=four
  219.                         four=i
  220.                     end
  221.                 else
  222.                     one=two
  223.                     two=three
  224.                     three=i
  225.                 end
  226.             else
  227.                 one=two
  228.                 two=i
  229.             end
  230.         else
  231.             one=i
  232.         end
  233.     else
  234.         print("sry , you didnt got a new high score")
  235.     end
  236.     print("your record is",i)
  237.     print(one)
  238.     print(two)
  239.     print(three)
  240.     print(four)
  241.     print(five)
  242.     print(six)
  243.     print(seven)
  244.     print(eight)
  245.     print(nine)
  246.     print(ten)
  247.     saveLocalData("one",one)
  248.     saveLocalData("two",two)
  249.     saveLocalData("three",three)
  250.     saveLocalData("four",four)
  251.     saveLocalData("five",five)
  252.     saveLocalData("six",six)
  253.     saveLocalData("seven",seven)
  254.     saveLocalData("eight",eight)
  255.     saveLocalData("nine",nine)
  256.     saveLocalData("ten",ten)
  257. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement