Advertisement
Sajjad

Monster v2,0

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