Im starting a 3d tetris, i use the comand entitycollide but when mi program put five pieces in line do extrange things this my code
; CreateCube Example
; ------------------
Graphics3D 640, 480
CamPivot = CreatePivot()
camera = CreateCamera(CamPivot)
luz% = CreateLight(1) ;Luz especular y ambiental
LightColor(luz%, 128, 128, 128)
mio = CreateCone(12)
PositionEntity mio, 1, 1, 20
PositionEntity camera, 0, 0, -24
HideEntity mio
SetBuffer BackBuffer()
SeedRnd MilliSecs()
Type pieza2
Field cubo
Field cubo1
Field cubo2
Field cubo3
End Type
Global r, g, b
Global posicionx = 9
Global posiciony
Global tmpcolor
Global Dz
Const PESC = 2
Global COL_CUBE = 1
Global GHT = 2
Global posicionz
Global tipopieza
Global Colores
Global contax
Global rotado90
Global rotado180
Global rotado270
Global gameover
Global contaz
Global Tiempo
Global temp
Global KeyLeft
Global KeyRight
Global KeyDwn
Global banchoque
Global KeyUp
Global KeyRt
Global piezat1.pieza2
Global aux.pieza2
Global piezaactual
Global RepeatSpeed
Global RepeatSpeed2
Global VelCaida
Global Tiempo2
Global primera
Global incremento
Dim Tex(5)
Global piezasiguiente
Tex(1) = LoadTexture("tex1.bmp")
Tex(2) = LoadTexture("tex2.bmp")
Tex(3) = LoadTexture("tex3.bmp")
Tex(4) = LoadTexture("tex4.bmp")
Tex(5) = LoadTexture("tex5.bmp")
posicionx = 0
banchoque = 1
posiciony = 25
posicionz = 0
signo = 0
contax = 1
contaz = 1
primera = 1
Tiempo2 = 0
Tiempo = 0
rotado90 = 0
rotado180 = 0
rotado270 = 0
RepeatSpeed = 0
RepeatSpeed2 = 0
; Create cube
dibujarpieza()
Repeat
Entrada()
bajar()
Tiempo = MilliSecs()
Tiempo2 = MilliSecs()
If KeyDown(45) = True Then
Dz = Dz - (0.0001 * signo)
If Dz<-.03 signo=-1
If Dz>.03 signo=1
MoveEntity camera,0,0,Dz ; Desplazamos la cámara
TurnEntity(CamPivot, 0, 3, 0)
End If
If KeyDown(46) = True Then
Dz = Dz - (0.0001 * signo)
If Dz<-.03 signo=-1
If Dz>.03 signo=1
MoveEntity camera,0,0,Dz ; Desplazamos la cámara
TurnEntity(CamPivot, 0, -3, 0)
End If
If KeyDown(31) = True Then
destruye()
End If
UpdateWorld()
RenderWorld()
checacoli()
Flip()
Until KeyHit(1);Esc key
End
Function dibujarpieza()
piezaactual = 7
textemp = 0
Select True
Case piezaactual = 1
piezat1.pieza2 = New pieza2
piezat1\cubo= CreateCube()
piezat1\cubo1= 0
piezat1\cubo2= 0
piezat1\cubo3= 0
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo, Tex(textemp)
EntityType piezat1 \ cubo, GHT
PositionEntity piezat1 \ cubo, posicionx, posiciony, posicionz
Case piezaactual = 2
piezat1.pieza2 = New pieza2
piezat1\cubo= CreateCube()
piezat1\cubo1= CreateCube()
piezat1\cubo2= CreateCube()
piezat1\cubo3= 0
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo, Tex(textemp)
EntityType piezat1 \ cubo, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo1, Tex(textemp)
EntityType piezat1 \ cubo1, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo2, Tex(textemp)
EntityType piezat1 \ cubo2, GHT
PositionEntity piezat1 \ cubo, posicionx, posiciony, posicionz
PositionEntity piezat1 \ cubo1, posicionx + 2, posiciony, posicionz
PositionEntity piezat1 \ cubo2, posicionx + 4, posiciony, posicionz
Case piezaactual = 3
piezat1.pieza2 = New pieza2
piezat1\cubo= CreateCube()
piezat1\cubo1= CreateCube()
piezat1\cubo2= CreateCube()
piezat1\cubo3= 0
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo, Tex(textemp)
EntityType piezat1 \ cubo, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo1, Tex(textemp)
EntityType piezat1 \ cubo1, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo2, Tex(textemp)
EntityType piezat1 \ cubo2, GHT
PositionEntity piezat1 \ cubo, posicionx, posiciony, posicionz
PositionEntity piezat1 \ cubo1, posicionx, posiciony + 2, posicionz
PositionEntity piezat1 \ cubo2, posicionx + 2, posiciony, posicionz
Case piezaactual = 4
piezat1.pieza2 = New pieza2
piezat1\cubo= CreateCube()
piezat1\cubo1= CreateCube()
piezat1\cubo2= CreateCube()
piezat1\cubo3= CreateCube()
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo, Tex(textemp)
EntityType piezat1 \ cubo, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo1, Tex(textemp)
EntityType piezat1 \ cubo1, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo2, Tex(textemp)
EntityType piezat1 \ cubo2, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo3, Tex(textemp)
EntityType piezat1 \ cubo3, GHT
PositionEntity piezat1 \ cubo, posicionx, posiciony, posicionz
PositionEntity piezat1 \ cubo1, posicionx + 2, posiciony, posicionz
PositionEntity piezat1 \ cubo2, posicionx + 2, posiciony + 2, posicionz
PositionEntity piezat1 \ cubo3, posicionx, posiciony - 2, posicionz
Case piezaactual = 5
piezat1.pieza2 = New pieza2
piezat1\cubo= CreateCube()
piezat1\cubo1= CreateCube()
piezat1\cubo2= CreateCube()
piezat1\cubo3= CreateCube()
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo, Tex(textemp)
EntityType piezat1 \ cubo, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo1, Tex(textemp)
EntityType piezat1 \ cubo1, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo2, Tex(textemp)
EntityType piezat1 \ cubo2, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo3, Tex(textemp)
EntityType piezat1 \ cubo3, GHT
PositionEntity piezat1 \ cubo, posicionx, posiciony, posicionz
PositionEntity piezat1 \ cubo1, posicionx + 2, posiciony, posicionz
PositionEntity piezat1 \ cubo2, posicionx + 4, posiciony, posicionz
PositionEntity piezat1 \ cubo3, posicionx + 2, posiciony + 2, posicionz
Case piezaactual = 6
piezat1.pieza2 = New pieza2
piezat1\cubo= CreateCube()
piezat1\cubo1= CreateCube()
piezat1\cubo2= CreateCube()
piezat1\cubo3= CreateCube()
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo, Tex(textemp)
EntityType piezat1 \ cubo, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo1, Tex(textemp)
EntityType piezat1 \ cubo1, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo2, Tex(textemp)
EntityType piezat1 \ cubo2, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo3, Tex(textemp)
EntityType piezat1 \ cubo3, GHT
PositionEntity piezat1 \ cubo, posicionx, posiciony, posicionz
PositionEntity piezat1 \ cubo1, posicionx + 2, posiciony, posicionz
PositionEntity piezat1 \ cubo2, posicionx, posiciony + 2, posicionz
PositionEntity piezat1 \ cubo3, posicionx + 2, posiciony + 2, posicionz
Case piezaactual = 7
piezat1.pieza2 = New pieza2
piezat1\cubo= CreateCube()
piezat1\cubo1= CreateCube()
piezat1\cubo2= CreateCube()
piezat1\cubo3= CreateCube()
EntityColor piezat1\cubo,Rand(1,255),Rand(1,255),Rand(1,255)
EntityColor piezat1\cubo,Rand(1,255),Rand(1,255),Rand(1,255)
EntityColor piezat1\cubo,Rand(1,255),Rand(1,255),Rand(1,255)
PositionEntity piezat1 \ cubo, posicionx, posiciony, posicionz
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) + 4, EntityZ(piezat1 \ cubo)
Default
End Select
End Function
Function rotar()
Select True
Case piezaactual = 1
Case piezaactual = 2
If (rotado90 = 0) Then
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 4, EntityZ(piezat1 \ cubo)
rotado90 = 1
contax = 1
Else
PositionEntity piezat1 \ cubo, 0, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 4, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
rotado90 = 0
End If
Case piezaactual = 3
If (rotado90 = 0) Then
If (EntityX(piezat1 \ cubo) = 0) Then
PositionEntity piezat1 \ cubo, 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
rotado90 = 1
Else
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
rotado90 = 1
End If
Else
If (rotado180 = 0) Then
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
rotado180 = 1
Else
If (rotado270 = 0) Then
If (EntityX(piezat1 \ cubo) = 4) Then
PositionEntity piezat1 \ cubo, 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
rotado270 = 1
Else
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
rotado270 = 1
End If
Else
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
rotado90 = 0
rotado180 = 0
rotado270 = 0
End If
End If
End If
Case piezaactual = 4
If (rotado90 = 0) Then
PositionEntity piezat1 \ cubo, 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
rotado90 = 1
Else
PositionEntity piezat1 \ cubo, 0, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
rotado90 = 0
End If
Case piezaactual = 5
If (rotado90 = 0) Then
PositionEntity piezat1 \ cubo, 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 4, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
rotado90 = 1
contax = 1
Else
If (rotado180 = 0) Then
PositionEntity piezat1 \ cubo, 0, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 4, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
rotado180 = 1
Else
If (rotado270 = 0) Then
PositionEntity piezat1 \ cubo, 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 4, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
contax = 2
rotado270 = 1
Else
PositionEntity piezat1 \ cubo, 0, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 4, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
rotado90 = 0
rotado180 = 0
rotado270 = 0
End If
End If
End If
Case piezaactual = 6
Case piezaactual = 7
If (rotado90 = 0) Then
PositionEntity piezat1 \ cubo, 4, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) - 4, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
rotado90 = 1
Else
If (rotado180 = 0) Then
PositionEntity piezat1 \ cubo, 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo) - 4, EntityZ(piezat1 \ cubo)
rotado180 = 1
Else
If (rotado270 = 0) Then
PositionEntity piezat1 \ cubo, 0, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) + 4, EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
rotado270 = 1
Else
PositionEntity piezat1 \ cubo, 0, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) + 4, EntityZ(piezat1 \ cubo)
rotado90 = 0
rotado180 = 0
rotado270 = 0
End If
End If
End If
Default
End Select
End Function
Function moverup()
If (contaz >= 2) Then
contaz = contaz - 1
If (piezat1 \ cubo <> 0) Then PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo) + 2.01
If (piezat1 \ cubo1 <> 0) Then PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1), EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1) + 2.01
If (piezat1 \ cubo2 <> 0) Then PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2), EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2) + 2.01
If (piezat1 \ cubo3 <> 0) Then PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo3), EntityY(piezat1 \ cubo3), EntityZ(piezat1 \ cubo3) + 2.01
End If
End Function
Function moverdown()
If (contaz <= 2) Then
If (piezat1 \ cubo <> 0) Then PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo) - 2.01
If (piezat1 \ cubo1 <> 0) Then PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1), EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1) - 2.01
If (piezat1 \ cubo2 <> 0) Then PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2), EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2) - 2.01
If (piezat1 \ cubo3 <> 0) Then PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo3), EntityY(piezat1 \ cubo3), EntityZ(piezat1 \ cubo3) - 2.01
contaz = contaz + 1
End If
End Function
Function moverlt()
If (piezaactual = 1) Then
If (contax >= 2) Then
contax = contax - 1
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) - 2.05, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
End If
Else
If (piezaactual = 2 Or piezaactual = 3) Then
If (piezaactual = 2 And rotado90 = 1) Then
If (contax >= 2) Then
contax = contax - 1
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1) - 2, EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2) - 2, EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2)
End If
Else
If (piezaactual = 2 And rotado90 = 0) Then
Else
If (contax >= 2) Then
contax = contax - 1
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1) - 2, EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2) - 2, EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2)
End If
End If
End If
Else
If (contax >= 2) Then
contax = contax - 1
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1) - 2, EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2) - 2, EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo3) - 2, EntityY(piezat1 \ cubo3), EntityZ(piezat1 \ cubo3)
End If
End If
End If
End Function
Function moverrt()
If (piezaactual = 1) Then
If (contax <= 2) Then
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) + 2.05, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
contax = contax + 1
End If
Else
If (piezaactual = 2 Or piezaactual = 3) Then
If (piezaactual = 2 And rotado90 = 1) Then
If (contax <= 2) Then
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1) + 2, EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2) + 2, EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2)
contax = contax + 1
End If
Else
If (piezaactual = 2 And rotado90 = 0) Then
Else
If (contax < 2) Then
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1) + 2, EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2) + 2, EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2)
contax = contax + 1
End If
End If
End If
Else
If (contax < 2) Then
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1) + 2, EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2) + 2, EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo3) + 2, EntityY(piezat1 \ cubo3), EntityZ(piezat1 \ cubo3)
contax = contax + 1
End If
End If
End If
End Function
Function destruye()
FreeEntity(piezat1 \ cubo3)
FreeEntity(piezat1 \ cubo2)
piezat1\cubo3=0
piezat1\cubo2=0
End Function
Function Entrada()
KeyLeft = KeyDown(203) ;left key
KeyRight = KeyDown(205) ;right key
KeyDwn = KeyDown(208) ;down key
KeyUp = KeyDown(200)
KeyRt = KeyDown(30)
If RepeatSpeed < Tiempo Then
RepeatSpeed = Tiempo + 50
If keyLeft Then moverlt()
If keyRight Then moverrt()
If keyDwn Then moverdown()
If KeyUp Then moverup()
End If
If RepeatSpeed2 < Tiempo Then
RepeatSpeed2 = Tiempo + 100
If keyRt Then rotar()
End If
End Function
Function bajar()
If Velcaida < Tiempo2 Then
VelCaida = Tiempo2 + 600
If (piezaactual = 1) Then
If banchoque = 1 Then
If (EntityY(piezat1 \ cubo) > -5) Then
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 1, EntityZ(piezat1 \ cubo)
Else
contax = 1
contaz = 1
rotado90 = 0
rotado180 = 0
rotado270 = 0
banchoque = 1
primera = 0
dibujarpieza()
End If
Else
contax = 1
contaz = 1
rotado90 = 0
rotado180 = 0
rotado270 = 0
banchoque = 1
dibujarpieza()
End If
Else
If (piezaactual = 2 Or piezaactual = 3) Then
If ((piezaactual = 2 And EntityY(piezat1 \ cubo) > -5 And rotado90 = 0) Or (piezaactual = 2 And EntityY(piezat1 \ cubo) > -5 And rotado90 = 1 And rotado180 = 0 And rotado270 = 0) Or (piezaactual = 3 And EntityY(piezat1 \ cubo) > -5 And rotado90 = 0) Or (piezaactual = 3 And EntityY(piezat1 \ cubo) > -5 And rotado90 = 1 And rotado180 = 0 And rotado270 = 0) Or (piezaactual = 3 And EntityY(piezat1 \ cubo1) > -5 And rotado180 = 1 And rotado270 = 0) Or (piezaactual = 3 And EntityY(piezat1 \ cubo2) > -5 And rotado270 = 1) )Then
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 1, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1), EntityY(piezat1 \ cubo1) - 1, EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2), EntityY(piezat1 \ cubo2) - 1, EntityZ(piezat1 \ cubo2)
Else
contax = 1
contaz = 1
rotado90 = 0
rotado180 = 0
rotado270 = 0
dibujarpieza()
End If
Else
If (piezaactual >= 4 And pieazaactual <= 7) Then
If (EntityY(piezat1 \ cubo) > -5) Then
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 1, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1), EntityY(piezat1 \ cubo1) - 1, EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2), EntityY(piezat1 \ cubo2) - 1, EntityZ(piezat1 \ cubo2)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo3), EntityY(piezat1 \ cubo3) - 1, EntityZ(piezat1 \ cubo3)
Else
contax = 1
contaz = 1
rotado90 = 0
rotado180 = 0
rotado270 = 0
dibujarpieza()
End If
End If
End If
End If
End If
End Function
; CreateCube Example
; ------------------
Graphics3D 640, 480
CamPivot = CreatePivot()
camera = CreateCamera(CamPivot)
luz% = CreateLight(1) ;Luz especular y ambiental
LightColor(luz%, 128, 128, 128)
mio = CreateCone(12)
PositionEntity mio, 1, 1, 20
PositionEntity camera, 0, 0, -24
HideEntity mio
SetBuffer BackBuffer()
SeedRnd MilliSecs()
Type pieza2
Field cubo
Field cubo1
Field cubo2
Field cubo3
End Type
Global r, g, b
Global posicionx = 9
Global posiciony
Global tmpcolor
Global Dz
Const PESC = 2
Global COL_CUBE = 1
Global GHT = 2
Global posicionz
Global tipopieza
Global Colores
Global contax
Global rotado90
Global rotado180
Global rotado270
Global gameover
Global contaz
Global Tiempo
Global temp
Global KeyLeft
Global KeyRight
Global KeyDwn
Global banchoque
Global KeyUp
Global KeyRt
Global piezat1.pieza2
Global aux.pieza2
Global piezaactual
Global RepeatSpeed
Global RepeatSpeed2
Global VelCaida
Global Tiempo2
Global primera
Global incremento
Dim Tex(5)
Global piezasiguiente
Tex(1) = LoadTexture("tex1.bmp")
Tex(2) = LoadTexture("tex2.bmp")
Tex(3) = LoadTexture("tex3.bmp")
Tex(4) = LoadTexture("tex4.bmp")
Tex(5) = LoadTexture("tex5.bmp")
posicionx = 0
banchoque = 1
posiciony = 25
posicionz = 0
signo = 0
contax = 1
contaz = 1
primera = 1
Tiempo2 = 0
Tiempo = 0
rotado90 = 0
rotado180 = 0
rotado270 = 0
RepeatSpeed = 0
RepeatSpeed2 = 0
; Create cube
dibujarpieza()
Repeat
Entrada()
bajar()
Tiempo = MilliSecs()
Tiempo2 = MilliSecs()
If KeyDown(45) = True Then
Dz = Dz - (0.0001 * signo)
If Dz<-.03 signo=-1
If Dz>.03 signo=1
MoveEntity camera,0,0,Dz ; Desplazamos la cámara
TurnEntity(CamPivot, 0, 3, 0)
End If
If KeyDown(46) = True Then
Dz = Dz - (0.0001 * signo)
If Dz<-.03 signo=-1
If Dz>.03 signo=1
MoveEntity camera,0,0,Dz ; Desplazamos la cámara
TurnEntity(CamPivot, 0, -3, 0)
End If
If KeyDown(31) = True Then
destruye()
End If
UpdateWorld()
RenderWorld()
checacoli()
Flip()
Until KeyHit(1);Esc key
End
Function dibujarpieza()
piezaactual = 7
textemp = 0
Select True
Case piezaactual = 1
piezat1.pieza2 = New pieza2
piezat1\cubo= CreateCube()
piezat1\cubo1= 0
piezat1\cubo2= 0
piezat1\cubo3= 0
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo, Tex(textemp)
EntityType piezat1 \ cubo, GHT
PositionEntity piezat1 \ cubo, posicionx, posiciony, posicionz
Case piezaactual = 2
piezat1.pieza2 = New pieza2
piezat1\cubo= CreateCube()
piezat1\cubo1= CreateCube()
piezat1\cubo2= CreateCube()
piezat1\cubo3= 0
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo, Tex(textemp)
EntityType piezat1 \ cubo, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo1, Tex(textemp)
EntityType piezat1 \ cubo1, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo2, Tex(textemp)
EntityType piezat1 \ cubo2, GHT
PositionEntity piezat1 \ cubo, posicionx, posiciony, posicionz
PositionEntity piezat1 \ cubo1, posicionx + 2, posiciony, posicionz
PositionEntity piezat1 \ cubo2, posicionx + 4, posiciony, posicionz
Case piezaactual = 3
piezat1.pieza2 = New pieza2
piezat1\cubo= CreateCube()
piezat1\cubo1= CreateCube()
piezat1\cubo2= CreateCube()
piezat1\cubo3= 0
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo, Tex(textemp)
EntityType piezat1 \ cubo, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo1, Tex(textemp)
EntityType piezat1 \ cubo1, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo2, Tex(textemp)
EntityType piezat1 \ cubo2, GHT
PositionEntity piezat1 \ cubo, posicionx, posiciony, posicionz
PositionEntity piezat1 \ cubo1, posicionx, posiciony + 2, posicionz
PositionEntity piezat1 \ cubo2, posicionx + 2, posiciony, posicionz
Case piezaactual = 4
piezat1.pieza2 = New pieza2
piezat1\cubo= CreateCube()
piezat1\cubo1= CreateCube()
piezat1\cubo2= CreateCube()
piezat1\cubo3= CreateCube()
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo, Tex(textemp)
EntityType piezat1 \ cubo, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo1, Tex(textemp)
EntityType piezat1 \ cubo1, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo2, Tex(textemp)
EntityType piezat1 \ cubo2, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo3, Tex(textemp)
EntityType piezat1 \ cubo3, GHT
PositionEntity piezat1 \ cubo, posicionx, posiciony, posicionz
PositionEntity piezat1 \ cubo1, posicionx + 2, posiciony, posicionz
PositionEntity piezat1 \ cubo2, posicionx + 2, posiciony + 2, posicionz
PositionEntity piezat1 \ cubo3, posicionx, posiciony - 2, posicionz
Case piezaactual = 5
piezat1.pieza2 = New pieza2
piezat1\cubo= CreateCube()
piezat1\cubo1= CreateCube()
piezat1\cubo2= CreateCube()
piezat1\cubo3= CreateCube()
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo, Tex(textemp)
EntityType piezat1 \ cubo, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo1, Tex(textemp)
EntityType piezat1 \ cubo1, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo2, Tex(textemp)
EntityType piezat1 \ cubo2, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo3, Tex(textemp)
EntityType piezat1 \ cubo3, GHT
PositionEntity piezat1 \ cubo, posicionx, posiciony, posicionz
PositionEntity piezat1 \ cubo1, posicionx + 2, posiciony, posicionz
PositionEntity piezat1 \ cubo2, posicionx + 4, posiciony, posicionz
PositionEntity piezat1 \ cubo3, posicionx + 2, posiciony + 2, posicionz
Case piezaactual = 6
piezat1.pieza2 = New pieza2
piezat1\cubo= CreateCube()
piezat1\cubo1= CreateCube()
piezat1\cubo2= CreateCube()
piezat1\cubo3= CreateCube()
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo, Tex(textemp)
EntityType piezat1 \ cubo, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo1, Tex(textemp)
EntityType piezat1 \ cubo1, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo2, Tex(textemp)
EntityType piezat1 \ cubo2, GHT
textemp = Rand(1, 5)
EntityTexture piezat1 \ cubo3, Tex(textemp)
EntityType piezat1 \ cubo3, GHT
PositionEntity piezat1 \ cubo, posicionx, posiciony, posicionz
PositionEntity piezat1 \ cubo1, posicionx + 2, posiciony, posicionz
PositionEntity piezat1 \ cubo2, posicionx, posiciony + 2, posicionz
PositionEntity piezat1 \ cubo3, posicionx + 2, posiciony + 2, posicionz
Case piezaactual = 7
piezat1.pieza2 = New pieza2
piezat1\cubo= CreateCube()
piezat1\cubo1= CreateCube()
piezat1\cubo2= CreateCube()
piezat1\cubo3= CreateCube()
EntityColor piezat1\cubo,Rand(1,255),Rand(1,255),Rand(1,255)
EntityType piezat1 \ cubo, GHT ;remove this line after the firts execution and the program works fine but the collision it's not validate put the line back and the problem appears again
EntityColor piezat1\cubo,Rand(1,255),Rand(1,255),Rand(1,255)
EntityType piezat1 \ cubo1, GHT ;remove this line after the firts execution and the program works fine but the collision it's not validate put the line back and the problem appears again
EntityColor piezat1\cubo,Rand(1,255),Rand(1,255),Rand(1,255)
EntityType piezat1 \ cubo2, GHT ;remove this line after the firts execution and the program works fine but the collision it's not validate put the line back and the problem appears again
EntityColor piezat1\cubo,Rand(1,255),Rand(1,255),Rand(1,255)
EntityType piezat1 \ cubo3, GHT ;remove this line after the firts execution and the program works fine but the collision it's not validate put the line back and the problem appears again
PositionEntity piezat1 \ cubo, posicionx, posiciony, posicionz
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) + 4, EntityZ(piezat1 \ cubo)
Default
End Select
End Function
Function rotar()
Select True
Case piezaactual = 1
Case piezaactual = 2
If (rotado90 = 0) Then
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 4, EntityZ(piezat1 \ cubo)
rotado90 = 1
contax = 1
Else
PositionEntity piezat1 \ cubo, 0, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 4, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
rotado90 = 0
End If
Case piezaactual = 3
If (rotado90 = 0) Then
If (EntityX(piezat1 \ cubo) = 0) Then
PositionEntity piezat1 \ cubo, 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
rotado90 = 1
Else
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
rotado90 = 1
End If
Else
If (rotado180 = 0) Then
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
rotado180 = 1
Else
If (rotado270 = 0) Then
If (EntityX(piezat1 \ cubo) = 4) Then
PositionEntity piezat1 \ cubo, 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
rotado270 = 1
Else
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
rotado270 = 1
End If
Else
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
rotado90 = 0
rotado180 = 0
rotado270 = 0
End If
End If
End If
Case piezaactual = 4
If (rotado90 = 0) Then
PositionEntity piezat1 \ cubo, 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
rotado90 = 1
Else
PositionEntity piezat1 \ cubo, 0, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
rotado90 = 0
End If
Case piezaactual = 5
If (rotado90 = 0) Then
PositionEntity piezat1 \ cubo, 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 4, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
rotado90 = 1
contax = 1
Else
If (rotado180 = 0) Then
PositionEntity piezat1 \ cubo, 0, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 4, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
rotado180 = 1
Else
If (rotado270 = 0) Then
PositionEntity piezat1 \ cubo, 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 4, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
contax = 2
rotado270 = 1
Else
PositionEntity piezat1 \ cubo, 0, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 4, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
rotado90 = 0
rotado180 = 0
rotado270 = 0
End If
End If
End If
Case piezaactual = 6
Case piezaactual = 7
If (rotado90 = 0) Then
PositionEntity piezat1 \ cubo, 4, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) - 4, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
rotado90 = 1
Else
If (rotado180 = 0) Then
PositionEntity piezat1 \ cubo, 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo) - 4, EntityZ(piezat1 \ cubo)
rotado180 = 1
Else
If (rotado270 = 0) Then
PositionEntity piezat1 \ cubo, 0, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) + 4, EntityY(piezat1 \ cubo) - 2, EntityZ(piezat1 \ cubo)
rotado270 = 1
Else
PositionEntity piezat1 \ cubo, 0, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) + 2, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo) + 4, EntityZ(piezat1 \ cubo)
rotado90 = 0
rotado180 = 0
rotado270 = 0
End If
End If
End If
Default
End Select
End Function
Function moverup()
If (contaz >= 2) Then
contaz = contaz - 1
If (piezat1 \ cubo <> 0) Then PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo) + 2.01
If (piezat1 \ cubo1 <> 0) Then PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1), EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1) + 2.01
If (piezat1 \ cubo2 <> 0) Then PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2), EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2) + 2.01
If (piezat1 \ cubo3 <> 0) Then PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo3), EntityY(piezat1 \ cubo3), EntityZ(piezat1 \ cubo3) + 2.01
End If
End Function
Function moverdown()
If (contaz <= 2) Then
If (piezat1 \ cubo <> 0) Then PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo) - 2.01
If (piezat1 \ cubo1 <> 0) Then PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1), EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1) - 2.01
If (piezat1 \ cubo2 <> 0) Then PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2), EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2) - 2.01
If (piezat1 \ cubo3 <> 0) Then PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo3), EntityY(piezat1 \ cubo3), EntityZ(piezat1 \ cubo3) - 2.01
contaz = contaz + 1
End If
End Function
Function moverlt()
If (piezaactual = 1) Then
If (contax >= 2) Then
contax = contax - 1
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) - 2.05, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
End If
Else
If (piezaactual = 2 Or piezaactual = 3) Then
If (piezaactual = 2 And rotado90 = 1) Then
If (contax >= 2) Then
contax = contax - 1
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1) - 2, EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2) - 2, EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2)
End If
Else
If (piezaactual = 2 And rotado90 = 0) Then
Else
If (contax >= 2) Then
contax = contax - 1
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1) - 2, EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2) - 2, EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2)
End If
End If
End If
Else
If (contax >= 2) Then
contax = contax - 1
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) - 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1) - 2, EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2) - 2, EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo3) - 2, EntityY(piezat1 \ cubo3), EntityZ(piezat1 \ cubo3)
End If
End If
End If
End Function
Function moverrt()
If (piezaactual = 1) Then
If (contax <= 2) Then
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) + 2.05, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
contax = contax + 1
End If
Else
If (piezaactual = 2 Or piezaactual = 3) Then
If (piezaactual = 2 And rotado90 = 1) Then
If (contax <= 2) Then
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1) + 2, EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2) + 2, EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2)
contax = contax + 1
End If
Else
If (piezaactual = 2 And rotado90 = 0) Then
Else
If (contax < 2) Then
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1) + 2, EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2) + 2, EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2)
contax = contax + 1
End If
End If
End If
Else
If (contax < 2) Then
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo) + 2, EntityY(piezat1 \ cubo), EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1) + 2, EntityY(piezat1 \ cubo1), EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2) + 2, EntityY(piezat1 \ cubo2), EntityZ(piezat1 \ cubo2)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo3) + 2, EntityY(piezat1 \ cubo3), EntityZ(piezat1 \ cubo3)
contax = contax + 1
End If
End If
End If
End Function
Function destruye()
FreeEntity(piezat1 \ cubo3)
FreeEntity(piezat1 \ cubo2)
piezat1\cubo3=0
piezat1\cubo2=0
End Function
Function Entrada()
KeyLeft = KeyDown(203) ;left key
KeyRight = KeyDown(205) ;right key
KeyDwn = KeyDown(208) ;down key
KeyUp = KeyDown(200)
KeyRt = KeyDown(30)
If RepeatSpeed < Tiempo Then
RepeatSpeed = Tiempo + 50
If keyLeft Then moverlt()
If keyRight Then moverrt()
If keyDwn Then moverdown()
If KeyUp Then moverup()
End If
If RepeatSpeed2 < Tiempo Then
RepeatSpeed2 = Tiempo + 100
If keyRt Then rotar()
End If
End Function
Function bajar()
If Velcaida < Tiempo2 Then
VelCaida = Tiempo2 + 600
If (piezaactual = 1) Then
If banchoque = 1 Then
If (EntityY(piezat1 \ cubo) > -5) Then
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 1, EntityZ(piezat1 \ cubo)
Else
contax = 1
contaz = 1
rotado90 = 0
rotado180 = 0
rotado270 = 0
banchoque = 1
primera = 0
dibujarpieza()
End If
Else
contax = 1
contaz = 1
rotado90 = 0
rotado180 = 0
rotado270 = 0
banchoque = 1
dibujarpieza()
End If
Else
If (piezaactual = 2 Or piezaactual = 3) Then
If ((piezaactual = 2 And EntityY(piezat1 \ cubo) > -5 And rotado90 = 0) Or (piezaactual = 2 And EntityY(piezat1 \ cubo) > -5 And rotado90 = 1 And rotado180 = 0 And rotado270 = 0) Or (piezaactual = 3 And EntityY(piezat1 \ cubo) > -5 And rotado90 = 0) Or (piezaactual = 3 And EntityY(piezat1 \ cubo) > -5 And rotado90 = 1 And rotado180 = 0 And rotado270 = 0) Or (piezaactual = 3 And EntityY(piezat1 \ cubo1) > -5 And rotado180 = 1 And rotado270 = 0) Or (piezaactual = 3 And EntityY(piezat1 \ cubo2) > -5 And rotado270 = 1) )Then
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 1, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1), EntityY(piezat1 \ cubo1) - 1, EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2), EntityY(piezat1 \ cubo2) - 1, EntityZ(piezat1 \ cubo2)
Else
contax = 1
contaz = 1
rotado90 = 0
rotado180 = 0
rotado270 = 0
dibujarpieza()
End If
Else
If (piezaactual >= 4 And pieazaactual <= 7) Then
If (EntityY(piezat1 \ cubo) > -5) Then
PositionEntity piezat1 \ cubo, EntityX(piezat1 \ cubo), EntityY(piezat1 \ cubo) - 1, EntityZ(piezat1 \ cubo)
PositionEntity piezat1 \ cubo1, EntityX(piezat1 \ cubo1), EntityY(piezat1 \ cubo1) - 1, EntityZ(piezat1 \ cubo1)
PositionEntity piezat1 \ cubo2, EntityX(piezat1 \ cubo2), EntityY(piezat1 \ cubo2) - 1, EntityZ(piezat1 \ cubo2)
PositionEntity piezat1 \ cubo3, EntityX(piezat1 \ cubo3), EntityY(piezat1 \ cubo3) - 1, EntityZ(piezat1 \ cubo3)
Else
contax = 1
contaz = 1
rotado90 = 0
rotado180 = 0
rotado270 = 0
dibujarpieza()
End If
End If
End If
End If
End If
End Function
Function checacoli() Collisions(GHT, GHT, 3, 1) If EntityCollided(piezat1 \ cubo, GHT) Or EntityCollided(piezat1 \ cubo1, GHT) Or EntityCollided(piezat1 \ cubo2, GHT) Or EntityCollided(piezat1 \ cubo3, GHT )Then banchoque = 0 End If End Function