Advertisement
xerpi

dtmb engine v3

Aug 23rd, 2011
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.08 KB | None | 0 0
  1. --[[links
  2.  
  3. http://desmond.imageshack.us/Himg560/scaled.php?server=560&filename=20110822225402.png&res=medium
  4. http://desmond.imageshack.us/Himg51/scaled.php?server=51&filename=20110822225401.png&res=medium
  5. engine v3: http://www.mediafire.com/?jz5vdek99rc5kyz
  6.  
  7.  
  8. ]]
  9.  
  10. adhoc = adhoc or {send =  function() end, recv = function() end}
  11.  
  12. os.cpu(333)
  13. obj = {}
  14.     obj.pitch = {current = 1}
  15.     obj.pitch[1] = model.load("gfx/models/pitch1.obj",0.3,color.new(0,0,0))
  16.     obj.red = model.load("gfx/models/red.obj",0.3,color.new(0,0,0))
  17.     obj.blue = model.load("gfx/models/blue.obj",0.3,color.new(0,0,0))
  18.     obj.ball = model.load("gfx/models/ball.obj",0.3,color.new(0,0,0))
  19.     --obj.base = model.load("gfx/models/pitch.obj")
  20.     --obj.goal = model.load("gfx/models/goal.obj")
  21. ball = {inc=0.0002,side=1,velocity=1.5,obj = obj.ball, vel={x=nil,y=nil},pos={x=0,y=0,z=5},rot={x=0,y=0,z=0,vel = 0.2},old={},w=4,h=4,movebool = true, ang = nil}
  22. img = {}
  23. mode = {current = "normal",timer = timer.new()} mode.timer:reset() mode.timer:stop()
  24. snd = {}
  25.     mode.free = {horizontal = true, limit ={w=100,h=50},maxscore=10}
  26.     mode.normal = {horizontal = false, limit ={w=100,h=50},maxscore=10}
  27. player = {w=5,h=6,adhoc={},socket={}}
  28.     player[1] = {ballang=nil,vel=0, vacc=0, hacc=0, obj = obj.red, pos={x=-mode[mode.current].limit.w/2+player.w/2,y=0,z=5}, rot={x=0,y=0,z=0,vel = 0.1}, score=0, w=player.w, h=player.h, who = "human", move = true,difficulty=100}
  29.     player[2] = {ballang=nil,vel=0, vacc=0, hacc=0, obj = obj.blue, pos={x=mode[mode.current].limit.w/2-player.w/2,y=0,z=5}, rot={x=0,y=0,z=0,vel = 0.1}, score=0, w=player.w, h=player.h, who = "cpu", move = true,difficulty=100}
  30. goal = {w=5,h=16}
  31.     goal[1] = {pos={x = mode[mode.current].limit.w/2+goal.w/2, y = 0}}
  32.     goal[2] = {pos={x = -mode[mode.current].limit.w/2-goal.w/2, y = 0}}
  33.    
  34. os.cpu(222)
  35.  
  36.  
  37. adhoc.recv = function()
  38.     return player[1].pos.x.."|"..player[1].pos.y
  39. end
  40.  
  41. function mode.set(str)
  42.     mode.current = str
  43. end
  44.  
  45. function player.adhoc.recv()
  46.     local recvstr = adhoc.recv()
  47.     if recvstr then
  48.         local xyarray = string.explode(recvstr,"|")
  49.         player[2].pos.x = tonumber(-xyarray[1])
  50.         player[2].pos.y = tonumber(xyarray[2]) 
  51.     end
  52. end
  53.  
  54. function player.adhoc.send()
  55.     adhoc.send(player[1].pos.x.."|"..player[1].pos.y)
  56. end
  57.  
  58. function player.socket.send()
  59. end
  60. function player.socket.recv()
  61. end
  62.  
  63.  
  64. function mode.get()
  65.     return mode.current
  66. end
  67.  
  68. function mode.countdown()
  69.      mode.timer:reset(); mode.timer:start()
  70.      local size = 1.6
  71.     while mode.timer:time() < 3000 do
  72.         local txt = 3-math.floor(mode.timer:time()/1000)
  73.         controls.read()
  74.         size = 1.6+(mode.timer:time()/1000-math.floor(mode.timer:time()/1000))
  75.         blit_base()
  76.         player.blit()  
  77.         ball.blit()
  78.         mode.blitinfo()
  79.        
  80.         screen.print(240-screen.textwidth(txt,size)/2,130,txt,size,color.new(255,0,0),color.new(0,0,0))
  81.        
  82.         screen.flip()
  83.     end
  84.      mode.timer:reset(); mode.timer:stop()
  85. end
  86.  
  87. function mode.wait(mili)
  88.      mode.timer:reset(); mode.timer:start()
  89.     while mode.timer:time() < mili do
  90.         blit_base()
  91.         player.blit()  
  92.         ball.blit()
  93.         mode.blitinfo()
  94.         screen.flip()
  95.     end
  96.      mode.timer:reset(); mode.timer:stop()
  97. end
  98.  
  99. function mode.resetall()
  100.     ball.inc=0.0005
  101.     ball.velocity=1.5
  102.     ball.pos={x=0,y=0,z=0}
  103.     ball.rot={x=0,y=0,z=0,vel = 0.01}
  104.     ball.movebool = true
  105.     mode.free.maxscore=30
  106.     mode.normal.maxscore=2
  107.     player[1].pos={x=-mode[mode.current].limit.w/2+player.w/2,y=0,z=0}
  108.     player[2].pos={x=mode[mode.current].limit.w/2-player.w/2,y=0,z=0}
  109.     for i = 1, #player do
  110.         player[i].rot={x=0,y=0,z=0,vel = 0.1}
  111.         player[i].score=0
  112.         player[i].who = "human"
  113.         player[i].move = true
  114.         player[i].difficulty=50
  115.     end
  116. end
  117.  
  118. function mode.blitinfo()
  119.     screen.print(240-screen.textwidth(player[1].score.."   -   "..player[2].score,0.77)/2,6,player[1].score.."   -   "..player[2].score)   
  120.     screen.print(2,2,"Mode: "..mode.get(),0.58,color.new(255,255,255),0x0)
  121.     screen.print(475-screen.textwidth("@"..os.cpu().."mHz    @"..screen.fps(),0.58),2,"@"..os.cpu().."mHz    @"..screen.fps(),0.58,color.new(255,255,255),0x0) 
  122. end
  123.  
  124. function model.changecolor(material,clor)
  125.     local mat = io.open(material, "r"); mat:seek("set");
  126.     local mtl = mat:read("*a"); mat:flush(); mat:close();
  127.     r = color.R(clor); g = color.G(clor); b = color.B(clor);
  128.     r = r/255; g = g/255; b = b/255;
  129.     if r == 0 then r = "0.000000" end if r == 1 then r = "1.000000" end
  130.     if g == 0 then g = "0.000000" end if g == 1 then g = "1.000000" end
  131.     if b == 0 then b = "0.000000" end if b == 1 then b = "1.000000" end
  132.     mtl=mtl:gsub("Kd %d* %d* %d*","Kd "..r.." "..g.." "..b)
  133.     --os.message(mtl)
  134.     local mat = io.open(material, "w*"); mat:seek("set");
  135.     mat:write(mtl); mat:flush(); mat:close();  
  136. end
  137.  
  138.  
  139. function math.ang(x,y,x2,y2)
  140.     return math.atan2(x-x2,y-y2)+1.57
  141. end
  142.  
  143. function math.coli(tab,tab2)
  144.     if tab.x + tab.w >= tab2.x and tab.x <= tab2.x+tab2.w and
  145.     tab.y + tab.h >= tab2.y and tab.y <= tab2.y+tab2.h then  
  146.         return true
  147.     end
  148.     return false
  149. end
  150.  
  151.  
  152. function player.blit()
  153.     for i = 1, #player do
  154.         if player[i].move then player[i].rot.x = player[i].rot.x + player[i].rot.vel end
  155.         player[i].obj:position(player[i].pos.x, player[i].pos.y, player[i].pos.z)
  156.         player[i].obj:rotation(player[i].rot.x, player[i].rot.y, player[i].rot.z)
  157.         player[i].obj:blit()
  158.         --Calculate angles
  159.             player[i].ballang = math.ang(player[i].pos.x,player[i].pos.y,ball.pos.x,ball.pos.y)
  160.     end
  161. end
  162.  
  163. function player.win()
  164. local winah = "Ha ganado el jugador %i."
  165.     for i = 1, #player do
  166.         if player[i].score >= mode[mode.current].maxscore then
  167.             os.message(string.format(winah,i))
  168.             dofile("script.lua")
  169.         end
  170.     end
  171. end
  172.  
  173. function ball.blit()
  174.         if ball.move then
  175.             ball.rot.x = ball.rot.x + ball.rot.vel
  176.             --ball.rot.y = ball.rot.y - ball.rot.vel
  177.             --ball.rot.z = ball.rot.z + ball.rot.vel
  178.         end
  179.         ball.obj:position(ball.pos.x, ball.pos.y, ball.pos.z)
  180.         ball.obj:rotation(ball.rot.x, ball.rot.y, ball.rot.z)
  181.         ball.obj:blit()
  182. end
  183.  
  184. function ball.inverty()
  185.     ball.vel.y = -ball.vel.y
  186. end
  187.  
  188. function ball.invertx()
  189.     ball.vel.x = -ball.vel.x
  190. end
  191.  
  192. function ball.colision()
  193.     --Player collision
  194.         for i = 1, #player do
  195.             if math.coli({x=ball.pos.x-ball.w/2,y=ball.pos.y-ball.h/2,w=ball.w,h=ball.h},{x=player[i].pos.x-player[i].w/2,y=player[i].pos.y-player[i].h/2,w=player[i].w,h=player[i].h}) then
  196.                 ball.pos.x = ball.old.x
  197.                 ball.pos.y = ball.old.y
  198.                 if player[i].ballang >= -0.79 and player[i].ballang < 0.79 then
  199.                     --ball.inverty()
  200.                     ball.invertx()
  201.                 elseif player[i].ballang >= 0.79 and player[i].ballang < 2.36 then
  202.                     ball.inverty()
  203.                     --ball.invertx()
  204.                 elseif player[i].ballang >= 2.36 and player[i].ballang < 3.93 then
  205.                     --ball.inverty()
  206.                     ball.invertx()
  207.                 elseif player[i].ballang >= 3.93 and player[i].ballang <= 4.71 or player[i].ballang >= -1.57 and player[i].ballang < -0.79 then
  208.                     ball.inverty()
  209.                     --ball.invertx()
  210.                 end
  211.                 ball.pos.x = ball.pos.x + ball.vel.x*ball.velocity
  212.                 ball.pos.y = ball.pos.y + ball.vel.y*ball.velocity             
  213.             end
  214.         end
  215.     --Goal collision
  216.         for i = 1, #goal do
  217.             if math.coli({x=ball.pos.x-ball.w/2,y=ball.pos.y-ball.h/2,w=ball.w,h=ball.h},{x=goal[i].pos.x-goal.w/2,y=goal[i].pos.y-goal.h/2,w=goal.w,h=goal.h}) then
  218.                 if i == 1 then
  219.                     player[1].score = player[1].score + 1
  220.                     ball.serve()
  221.                     mode.wait(500)
  222.                 elseif i == 2 then
  223.                     player[2].score = player[2].score + 1
  224.                     ball.serve()
  225.                     mode.wait(500)
  226.                 end
  227.             end
  228.         end
  229. end
  230.  
  231. function ball.calcxy()
  232.     ball.vel.x = math.cos(ball.ang)
  233.     ball.vel.y = math.sin(ball.ang)
  234. end
  235.  
  236. function ball.serve()
  237.     ball.pos.x = 0
  238.     ball.pos.y = 0
  239.     ball.velocity = 1.5
  240.     ball.ang = ({ math.rad(math.random(30,60))  ,  math.rad(math.random(120,150))   ,  math.rad(math.random(210,240))   ,  math.rad(math.random(300,330))  })[math.random(1,4)]
  241.     ball.calcxy()
  242. end
  243.  
  244. function ball.move()
  245.     ball.velocity = ball.velocity + ball.inc
  246.     ball.old.x = ball.pos.x
  247.     ball.old.y = ball.pos.y
  248.  
  249.     ball.pos.x = ball.pos.x + ball.vel.x*ball.velocity
  250.     ball.pos.y = ball.pos.y + ball.vel.y*ball.velocity
  251.    
  252.     ball.colision()
  253.    
  254.     if ball.pos.y +  ball.h/2 >= mode[mode.current].limit.h/2 then
  255.         ball.inverty()
  256.         ball.pos.y = mode[mode.current].limit.h/2-ball.h/2
  257.     end
  258.     if ball.pos.y  - ball.h/2 <= -mode[mode.current].limit.h/2 then
  259.         ball.inverty()
  260.         ball.pos.y = -mode[mode.current].limit.h/2+ball.h/2
  261.     end
  262.     if ball.pos.x +  ball.w/2 >= mode[mode.current].limit.w/2 then
  263.         ball.invertx()
  264.         ball.pos.x = mode[mode.current].limit.w/2 - ball.w/2
  265.     end
  266.     if ball.pos.x  - ball.w/2 <= -mode[mode.current].limit.w/2 then
  267.         ball.invertx()
  268.         ball.pos.x = -mode[mode.current].limit.w/2 + ball.w/2
  269.     end
  270.     --Check ball side ( 1 is left side, 2 is right side, 0 is just the middle)
  271.         if ball.pos.x +  ball.w/2 > 0 then
  272.             ball.side = 2
  273.         elseif ball.pos.x  - ball.w/2 < 0 then
  274.             ball.side = 1
  275.         else
  276.             ball.side = 0
  277.         end
  278.         ball.ang = math.atan2(ball.vel.x,ball.vel.y)-1.57
  279. end
  280.  
  281.  
  282. function player.move()
  283.     --Move red player
  284.         if not math.coli({x=ball.pos.x-ball.w/2,y=ball.pos.y-ball.h/2,w=ball.w,h=ball.h},{x=player[1].pos.x-player[1].w/2,y=player[1].pos.y-player[1].h/2,w=player[1].w,h=player[1].h}) then
  285.             if player[1].who == "human" then
  286.                     if controls.down() then
  287.                         player[1].pos.y = player[1].pos.y - 1
  288.                         player[1].vacc = player[1].vacc + 0.06
  289.                     elseif controls.up() then
  290.                         player[1].pos.y = player[1].pos.y + 1
  291.                         player[1].vacc = player[1].vacc - 0.06
  292.                     end
  293.                     if player[1].vacc > 0 and not controls.down() then
  294.                         player[1].pos.y = player[1].pos.y - 0.6
  295.                         player[1].vacc = player[1].vacc-0.1
  296.                         if controls.press("up") then player[1].vacc = 0 end
  297.                     end
  298.                     if player[1].vacc < 0 and not controls.up() then
  299.                         player[1].pos.y = player[1].pos.y + 0.6
  300.                         player[1].vacc = player[1].vacc+0.1
  301.                         if controls.press("down") then player[1].vacc = 0 end
  302.                     end
  303.             elseif player[1].who == "cpu" then
  304.                     if ball.side == 1 and (ball.ang <- 1.57 or ball.ang > 1.57) then
  305.                         if player[1].pos.y < ball.pos.y then
  306.                             player[1].pos.y = player[1].pos.y + math.min(ball.pos.y-player[1].pos.y,(player[1].difficulty/100)*ball.velocity)
  307.                         elseif player[1].pos.y > ball.pos.y then
  308.                             player[1].pos.y = player[1].pos.y - math.min(player[1].pos.y-ball.pos.y,(player[1].difficulty/100)*ball.velocity)          
  309.                         end
  310.                     end
  311.             end
  312.         end
  313.                
  314.     --Move blue player
  315.         if not math.coli({x=ball.pos.x-ball.w/2,y=ball.pos.y-ball.h/2,w=ball.w,h=ball.h},{x=player[2].pos.x-player[2].w/2,y=player[2].pos.y-player[2].h/2,w=player[2].w,h=player[2].h}) then
  316.             if player[2].who == "human" then
  317.                     if controls.cross() then
  318.                         player[2].pos.y = player[2].pos.y - 1
  319.                         player[2].vacc = player[2].vacc + 0.06
  320.                     elseif controls.triangle() then
  321.                         player[2].pos.y = player[2].pos.y + 1
  322.                         player[2].vacc = player[2].vacc - 0.06
  323.                     end
  324.                     if player[2].vacc > 0 and not controls.cross() then
  325.                         player[2].pos.y = player[2].pos.y - 0.6
  326.                         player[2].vacc = player[2].vacc-0.1
  327.                         if controls.press("triangle") then player[2].vacc = 0 end
  328.                     end
  329.                     if player[2].vacc < 0 and not controls.triangle() then
  330.                         player[2].pos.y = player[2].pos.y + 0.6
  331.                         player[2].vacc = player[2].vacc+0.1
  332.                         if controls.press("cross") then player[2].vacc = 0 end
  333.                     end
  334.             elseif player[2].who == "cpu" then
  335.                     if ball.side == 2 and ball.ang > -1.57 and ball.ang < 1.57 then
  336.                         if player[2].pos.y < ball.pos.y then
  337.                             player[2].pos.y = player[2].pos.y + math.min(ball.pos.y-player[2].pos.y,(player[2].difficulty/100)*ball.velocity)
  338.                         elseif player[2].pos.y > ball.pos.y then
  339.                             player[2].pos.y = player[2].pos.y - math.min(player[2].pos.y-ball.pos.y,(player[2].difficulty/100)*ball.velocity)      
  340.                         end
  341.                     end
  342.             elseif player[2].who == "adhoc" then
  343.                     player.adhoc.send()
  344.                     player.adhoc.recv()
  345.             end
  346.         end
  347.     --Check vertical limits
  348.         for i = 1, #player do
  349.             if player[i].pos.y +  player[i].h/2 > mode[mode.current].limit.h/2 then
  350.                 player[i].pos.y = mode[mode.current].limit.h/2 - player[i].h/2
  351.             end
  352.             if player[i].pos.y  - player[i].h/2 < -mode[mode.current].limit.h/2 then
  353.                 player[i].pos.y = -mode[mode.current].limit.h/2 + player[i].h/2
  354.             end    
  355.         end
  356.        
  357.    
  358.     if mode[mode.current].horizontal then
  359.         --Move red player
  360.             if controls.left() then
  361.                 player[1].pos.x = player[1].pos.x - 1
  362.                 player[1].hacc = player[1].hacc + 0.06
  363.             elseif controls.right() then
  364.                 player[1].pos.x = player[1].pos.x + 1
  365.                 player[1].hacc = player[1].hacc - 0.06
  366.             end
  367.             if player[1].hacc > 0 and not controls.left() then
  368.                 player[1].pos.x = player[1].pos.x - 0.6
  369.                 player[1].hacc = player[1].hacc-0.1
  370.                 if controls.press("right") then player[1].hacc = 0 end
  371.             end
  372.             if player[1].hacc < 0 and not controls.right() then
  373.                 player[1].pos.x = player[1].pos.x + 0.6
  374.                 player[1].hacc = player[1].hacc+0.1
  375.                 if controls.press("left") then player[1].hacc = 0 end
  376.             end
  377.         --Move blue player
  378.             if controls.square() then
  379.                 player[2].pos.x = player[2].pos.x - 1
  380.                 player[2].hacc = player[2].hacc + 0.06
  381.             elseif controls.circle() then
  382.                 player[2].pos.x = player[2].pos.x + 1
  383.                 player[2].hacc = player[2].hacc - 0.06
  384.             end
  385.             if player[2].hacc > 0 and not controls.square() then
  386.                 player[2].pos.x = player[2].pos.x - 0.6
  387.                 player[2].hacc = player[2].hacc-0.1
  388.                 if controls.press("circle") then player[2].hacc = 0 end
  389.             end
  390.             if player[2].hacc < 0 and not controls.circle() then
  391.                 player[2].pos.x = player[2].pos.x + 0.6
  392.                 player[2].hacc = player[2].hacc+0.1
  393.                 if controls.press("square") then player[2].hacc = 0 end
  394.             end
  395.         --Check horizontal limits
  396.             --Player 1
  397.                     if player[1].pos.x +  player[1].w/2 > 0 then
  398.                         player[1].pos.x = -player[1].w/2
  399.                     end
  400.                     if player[1].pos.x  - player[1].w/2 < -mode[mode.current].limit.w/2 then
  401.                         player[1].pos.x = -mode[mode.current].limit.w/2 + player[1].w/2
  402.                     end
  403.             --Player 2                 
  404.                     if player[2].pos.x +  player[2].w/2 > mode[mode.current].limit.w/2 then
  405.                         player[2].pos.x = mode[mode.current].limit.w/2 - player[2].w/2
  406.                     end
  407.                     if player[2].pos.x  - player[2].w/2 < 0 then
  408.                         player[2].pos.x = player[2].w/2
  409.                     end
  410.     end
  411. end
  412.  
  413. function blit_base()
  414.     obj.pitch[obj.pitch.current]:position(0,0,0)
  415.     obj.pitch[obj.pitch.current]:rotation(0,0,0)
  416.     obj.pitch[obj.pitch.current]:blit()
  417. end
  418.  
  419. ball.serve()
  420.  
  421. --os.runeboot("LuaHM.PBP")
  422. --mode.countdown()
  423.  
  424. --TAB1 = { x, y, z } (posicion de la camara)
  425. --TAB2 = { x, y, z } (punto al que miramos)
  426. --TAB3 = { x, y, z } (donde está el techo, (rotacion de la camara)). ( Normalmente { 0, 1, 0 } )
  427.  
  428. lk={pos={x=0,y=0,z=45},roof={0,1,0}}
  429. lk.move = false
  430.  
  431. function mode.test()
  432.     screen.print(230,250,tostring(lk.move))
  433.     if lk.move then
  434.         if math.abs(controls.analogy()) > 70 then lk.pos.y = lk.pos.y -controls.analogy()/500 end
  435.         if math.abs(controls.analogx()) > 70 then lk.pos.x = lk.pos.x +controls.analogx()/500 end
  436.         if controls.r() then lk.pos.z = lk.pos.z-0.5 end
  437.         if controls.l() then lk.pos.z = lk.pos.z+0.5 end
  438.         world.lookat({player[1].pos.x+1,player[1].pos.y,player[1].pos.z},{0,0,0},{0,0,1})
  439.         screen.print(5,25,"x: "..lk.pos.x.."\ny: "..lk.pos.y.."\nz: "..lk.pos.z)   
  440.         if controls.press("square") then
  441.             arx = io.open("pos.txt","r+");
  442.             arx:seek("end");
  443.             arx:write("pos={"..lk.pos.x..","..lk.pos.y..","..lk.pos.z.."},roof={"..lk.roof[1]..","..lk.roof[2]..","..lk.roof[3].."}\n")
  444.             arx:flush(); arx:close()
  445.             end
  446.     else
  447.         if controls.press("r") then position.current = position.current +1 if position.current > #position then position.current = 1 end end
  448.         if controls.press("l") then position.current = position.current -1 if position.current < 1 then position.current = #position end end
  449.         world.lookat(position[position.current].pos,{0,0,0},{0,1,0})
  450.         screen.print(5,25,"x: "..position[position.current].pos[1].."\ny: "..position[position.current].pos[2].."\nz: "..position[position.current].pos[3])
  451.     end
  452.     if controls.press("triangle") then lk.pos.x = position[position.current].pos[1]; lk.pos.y=position[position.current].pos[2]; lk.pos.z=position[position.current].pos[3]; lk.move = not lk.move end
  453.     world.update() 
  454. end
  455.  
  456. position = {current=1}
  457.     position[1] ={pos={0,0,45},roof={0,1,0}}--Normal
  458.     position[2] ={pos={0,-52.8,34.5},roof={0,1,0}}
  459.     position[3] ={pos={0,-56,29.5},roof={0,1,0}}
  460.     position[4] ={pos={0,-53.3,20.5},roof={0,0,1}}
  461.    
  462. function mode.setcamera()
  463.  
  464.  
  465. end
  466.  
  467.  
  468. while true do
  469.     --change camera position
  470.         mode.test()
  471.        
  472. ---------DTMB GAME---------------------------------
  473.     controls.read()
  474.     blit_base()
  475.     player.move()
  476.     player.blit()  
  477.     ball.blit()
  478.     --Comprobar si ha ganado algun jugador
  479.         player.win()
  480.  
  481.     --     
  482.     screen.flip()
  483.     ball.move()
  484.     --Score
  485.         mode.blitinfo()
  486.         if controls.select() then os.cpu(333) a() end
  487. ---------------------------------------------------    
  488.        
  489.        
  490.     --[[screen.print(2,25,player[1].pos.x.."/"..player[1].pos.y,0.77,color.new(255,0,0),0x0)
  491.     screen.print(472-screen.textwidth(player[2].pos.x.."/"..player[2].pos.y),25,player[2].pos.x.."/"..player[2].pos.y,0.77,color.new(0,0,255),0x0)
  492.     screen.print(2,230,ball.velocity)
  493. -------------------------- 
  494.     screen.print(2,260,controls.analogy().."/"..controls.analogx())
  495.     screen.print(2,45,math.floor(ball.pos.x-ball.old.x).."\n"..math.floor(ball.pos.y-ball.old.y).."\n")
  496.     screen.print(130,2,math.deg(ball.ang)) 
  497.     screen.print(230,230,ball.side)
  498.     screen.print(2,90,player[1].ballang,0.58,color.new(255,255,255),0x0)
  499.     screen.print(440,90,player[2].ballang,0.58,color.new(255,255,255),0x0) 
  500.    
  501.     draw.pbar(140,258,200,10, color.new(255,255,255), color.new(255,0,0),player[2].difficulty-1,99)
  502.     if controls.r() then player[2].difficulty = player[2].difficulty + 0.5 end
  503.     if controls.l() then player[2].difficulty = player[2].difficulty - 0.5 end
  504.     player[2].difficulty = math.max(0,math.min(player[2].difficulty,100))
  505.     player[1].difficulty = math.max(0,math.min(player[2].difficulty,100))
  506.     screen.print(87,260,player[2].difficulty)
  507.    
  508.     if controls.start() then
  509.         if (math.abs(controls.analogx())>100 or math.abs(controls.analogy()) >100)  then
  510.             ball.ang = math.atan2(-controls.analogy(),controls.analogx())
  511.             ball.calcxy()
  512.         end
  513.         if controls.press("r") then ball.ang = math.rad(math.random(0,360)) ball.calcxy() end
  514.     end
  515.     --]]
  516. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement