GlovePIE:PING PONG 3D

From WiiLi

Jump to: navigation, search
//PING PONG 3D [by marsuten @gmail.com-any improvement is welcome]

//Variables
         var.ir = true    //True= IR ; False= wiimote Left-Right
 var.dificultad = 0       //Dificulty (0-30)
 var.progresivo = false   //Progresive difficulty
      var.bola2 = true    //True= 2 balls ; False= 1 ball

//!The script is a bit chaotic, it has some bug,
//and the explanations are in spanish, sorry for that.

//Debug de inicio
if var.ini=false then
   cursor8.Caption="press A to start"
   var.debug="Have fun!"
   var.ini=true
endif

if var.bola2=false then
   var.b2.start=true
   obj21.Visible=false
   obj22.Visible=false
   obj23.Visible=false
   obj24.Visible=false
endif

//Restart
if pressed(helddown(wiimote.A,0ms)) and var.by<4,5 and var.b2.by<4,5 then
cursor8.Caption="2"
wait 600 ms
cursor8.Caption="1"
wait 600 ms
cursor8.Caption="PLAY"
var.frame=var.dificultad

var.restart=false
wait 25 ms
var.c=var.pum
var.velo=((random(5)+15)/100)-abs(30-var.dificultad)/400
var.counter=0
  obj1.Visible=true
  obj2.Visible=true
  obj3.Visible=true
  obj4.Visible=true
wait 300 ms
var.start=true
cursor8.Caption=""
var.debug="PLAY!"
endif

var.launch=(0,99-(var.dificultad/320))
if var.cos>var.launch and var.b2.start=false then
var.b2.restart=false
wait 25 ms
var.b2.c=var.b2.pum
var.b2.velo=-(((random(5)+15)/100)-abs(30-var.dificultad)/400)
  obj21.Visible=true
  obj22.Visible=true
  obj23.Visible=true
  obj24.Visible=true
wait 300 ms
var.b2.start=true
endif

//Coincidencia en Y
if var.by>5,7 and var.by<6,25
var.ytrue=true
else
var.ytrue=false
endif

//Coincidencia en X
if var.bx<=(var.dotx+0,3) and var.bx>=(var.dotx-0,3)
var.xtrue=true
else
var.xtrue=false
endif

//Coincidencia en Y   bola 2
if var.b2.by>5,7 and var.b2.by<6,25
var.b2.ytrue=true
else
var.b2.ytrue=false
endif

//Coincidencia en X   bola 2
if var.b2.bx<=(var.dotx+0,3) and var.b2.bx>=(var.dotx-0,3)
var.b2.xtrue=true
else
var.b2.xtrue=false
endif

//Si coincide en XY entonces se reinicia el coseno
//se suma 1 al contador, cambia la la velocidad X de
//la bola segun el roll y vibra 40 ms
if var.xtrue and var.ytrue
var.c=var.pum
var.counter=var.counter+1
var.velo=(var.roll/var.desvio)+(var.velo/1,5)
wiimote.Rumble=true
wait 40ms
wiimote.Rumble=false
endif

//Bola 2

if var.b2.xtrue and var.b2.ytrue
var.b2.c=var.b2.pum
var.counter=var.counter+1
var.b2.velo=(var.roll/var.desvio)+(var.b2.velo/1,5)
wiimote.Rumble=true
wait 40ms
wiimote.Rumble=false
endif

//Cuando toca el cuadro en X se invierte la velocidad
if var.start=true and (var.bx>=4.4 or var.bx<=-4.4) then
var.velo=var.velo*-1
endif

//Bola 2

if var.b2.start=true and (var.b2.bx>=4.4 or var.b2.bx<=-4.4) then
var.b2.velo=var.b2.velo*-1
endif

//Dificultad (aumenta con tiempo)
var.velocidad=2+(var.frame/15)
var.desvio=350-(var.frame*10)
var.top=1100-(var.frame*6)

if var.velocidad>4 then var.velocidad=4
if var.desvio<100 then var.desvio=100

if var.start=true and var.progresivo=true then
   var.frame=var.frame+(1/removeunits(pie.realframerate))
   if var.frame>30 then var.frame=30
endif

//Si sale por debajo del cuadro en Y no se ve la bola
if var.bola2
if (var.by<4,5 or var.b2.by<4,5) and (var.start=true and var.b2.start=true) then
  obj1.Visible=false
  obj2.Visible=false
  obj3.Visible=false
  obj4.Visible=false
  obj21.Visible=false
  obj22.Visible=false
  obj23.Visible=false
  obj24.Visible=false
  var.dificultad=0
  var.start=false
  var.b2.start=false
  var.b2.velo=0
  var.velo=0
  var.on=true
endif
else
if var.by<4,5 and var.start=true then
  obj1.Visible=false
  obj2.Visible=false
  obj3.Visible=false
  obj4.Visible=false
  var.velo=0
  var.start=false
  var.on=true
endif
endif


//Cursor debug
if var.on=true then
cursor8.Caption="YOU LOST"
var.debug="press A to start"
var.on=false
endif

//>> Movimiento de Bola <<

*Restart
if var.restart=false then
var.c=65
var.bx=-5
var.restart=true
endif

*Tope de -Y y velocidad
if var.c>=65 then
var.c=65
else
var.c=var.c+var.velocidad
endif

*Rebote en el marco superior
if var.by m >= (var.top-23) cm  then
var.c=(var.c*-1)+2
wait 110 ms
endif

*Movimiento sinoidal de bola en Y
var.cos=cos(var.c)
var.by=(smooth(var.cos,1)*10,5)

*Golpe de bola (el +1 evita el smooth cuando golpea)
var.pum=-acos(var.cos)+1

*Eje X segun Roll
var.bx=var.bx+var.velo m


//>> Movimiento de Bola 2<<

*Restart
if var.b2.restart=false then
var.b2.c=65
var.b2.bx=5
var.b2.restart=true
endif

*Tope de -Y y velocidad
if var.b2.c>=65 then
var.b2.c=65
else
var.b2.c=var.b2.c+var.velocidad
endif

*Rebote en el marco superior
if var.b2.by m >= (var.top-23) cm  then
var.b2.c=(var.b2.c*-1)+2
wait 110 ms
endif

*Movimiento sinoidal de bola en Y
var.b2.cos=cos(var.b2.c)
var.b2.by=(smooth(var.b2.cos,1)*10,5)

*Golpe de bola (el +1 evita el smooth cuando golpea)
var.b2.pum=-acos(var.b2.cos)+1

*Eje X segun Roll
var.b2.bx=var.b2.bx+var.b2.velo m



//Movimiento de Pala
if !var.IR then
if wiimote.Right and not (wiimote.B) then var.dotx=var.dotx+0,1
if wiimote.Left and not (wiimote.B ) then var.dotx=var.dotx-0,1
if wiimote.Right and wiimote.B then var.dotx=var.dotx+0,22
if wiimote.Left and wiimote.B then var.dotx=var.dotx-0,22
if var.dotx>4,2 then var.dotx=4,2
if var.dotx<-4,2 then var.dotx=-4,2
else
var.dot1x=-smooth(maprange(wiimote.dot1x,1024,0, 4,2, -4,2),2)
var.dot2x=-smooth(maprange(wiimote.dot2x,1024,0, 4,2, -4,2),2)
var.dotx=(var.dot1x+var.dot2x)/2
endif


//Rescale de ventana y cursor informador
if window.BeforeDash="GlovePIE"
window.Width=587
window.Height=609
cursor2.Image="C:\GlovePIE\miscripts\no.ico"
cursor2.Caption=""+int(var.counter)+" strokes          Difficulty: "+int(var.frame)+""//+"  Velocidad: "+(var.velocidad-2)+"  Altura: "+var.altura+"  Desvio: "+int(var.desvio-350)*-1
cursor2.x=(1/(screen.Width/(window.left+180)))
cursor2.y=(1/(screen.Height/(window.top+530)))
cursor8.Image="C:\GlovePIE\miscripts\no.ico"
cursor8.x=(1/(screen.Width/(window.left+195)))
cursor8.y=(1/(screen.Height/(window.top+510)))
endif

debug=var.debug


//Pala
var.roll=smooth(wiimote.SmoothRoll,2)
if var.roll>45 then var.roll=45
if var.roll<-45 then var.roll=-45

obj5.x=var.dotx
obj5.y=6 m
obj5.colour = 0xdd3300
obj5.size = [50, 10, 50] cm
obj5.roll=smooth(var.roll,2)

obj6.x=var.dotx
obj6.y=6 m
obj6.colour = 0xcccccc
obj6.size = [10, 8, 50] cm
obj6.roll=smooth(var.roll,2)

//Cuadro
obj7.x=-450 cm
obj7.y=758 cm
obj7.colour = 0xcccccc
obj7.size = [0, 50, 685] cm
obj7.pitch=90

obj8.x=450 cm
obj8.y=758 cm
obj8.colour = 0xaaaaaa
obj8.size = [0, 50, 685] cm
obj8.pitch=90

obj9.x=0 m
obj9.y=smooth(var.top) cm
obj9.colour = 0xffffff
obj9.size = [0, 50, 900] cm
obj9.pitch=90
obj9.roll=90

obj10.x=0 m
obj10.y=415 cm
obj10.colour = 0xffffff
obj10.size = [0, 50, 900] cm
obj10.pitch=90
obj10.roll=90

//Sombra de bola
obj11.x=var.bx m
obj11.y=415 cm
obj11.colour = 0x000000
obj11.size = [0, 10, 10] cm
obj11.pitch=0
obj11.roll=90

//Sombra de bola 2
obj31.x=var.b2.bx m
obj31.y=415 cm
obj31.colour = 0x000000
obj31.size = [0, 10, 10] cm
obj31.pitch=0
obj31.roll=90

//Bola
var.ballr=var.ballr+10
var.ballp=var.ballp-10

obj1.x=var.bx
obj1.y=var.by
obj1.colour = 0xffffff
obj1.size = [10, 10, 10] cm
obj1.roll=var.ballr
obj1.pitch=var.ballp

obj2.x=var.bx
obj2.y=obj1.y
obj2.roll=45+var.ballr
obj2.pitch=var.pitch
obj2.colour = obj1.colour
obj2.size = obj1.size

obj3.x=var.bx
obj3.y=obj1.y
obj3.roll=var.ballr
obj3.pitch=45+var.ballp
obj3.colour = obj1.colour
obj3.size = obj1.size

obj4.x=var.bx
obj4.y=obj1.y
obj4.roll=45+var.ballr
obj4.pitch=45+var.ballp
obj4.colour = obj1.colour
obj4.size = obj1.size


//Bola 2

//Bola
var.b2.ballr=var.b2.ballr+10
var.b2.ballp=var.b2.ballp-10

obj21.x=var.b2.bx
obj21.y=var.b2.by
obj21.colour = 0xffffff
obj21.size = [10, 10, 10] cm
obj21.roll=var.b2.ballr
obj21.pitch=var.b2.ballp

obj22.x=var.b2.bx
obj22.y=obj21.y
obj22.roll=45+var.b2.ballr
obj22.pitch=var.pitch
obj22.colour = obj21.colour
obj22.size = obj21.size

obj23.x=var.b2.bx
obj23.y=obj21.y
obj23.roll=var.ballr
obj23.pitch=45+var.b2.ballp
obj23.colour = obj21.colour
obj23.size = obj21.size

obj24.x=var.b2.bx
obj24.y=obj21.y
obj24.roll=45+var.b2.ballr
obj24.pitch=45+var.b2.ballp
obj24.colour = obj21.colour
obj24.size = obj21.size

//Camara
cam.y=7m
cam.z = -10m
cam.BgColour=0x00adff

if not(window.beforeDash="GlovePIE") then
cursor1.x=mouse.x+0,01
cursor1.y=mouse.y+0,01
cursor1.Caption="Click inside the square"
cursor1.Image="C:\GlovePIE\miscripts\no.ico"
else
cursor1.Visible=false
endif
Personal tools
Online Casino - best online casino reviews.
Facebook Developers - facebook applications, facebook developers, facebook development, social network application development and viral widget social media strategy