Help with my program

Blitz3D Forums/Blitz3D Programming/Help with my program

CarlosEures(Posted 2005) [#1]
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)


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



jfk EO-11110(Posted 2005) [#2]
Maybe you should describe your problem closer. People usually don't like to read long listings to find a problem.

And use the forum bb-codes for sourcecode:
(code)
print "hello world"
(/code)
, only [] for ()
This makes reading the code easier too.

So where exactly is your problem? What do you mean by "extrange"? BTW you can edit your post.


WolRon(Posted 2005) [#3]
What are the forum codes?

Perhaps you'd like to take a look at my basic tetris clone code at my programming tutorial. I think it would be easier to convert it to a 3D game, then it would to try to get your code to work...


Rook Zimbabwe(Posted 2005) [#4]
aLL OF THE ABOVE...


CarlosEures(Posted 2005) [#5]
ok look that when i check the collision of the cubes it's when the program comes to do extrange things , i don't now what's up with the collisions but generate bugs, how i resolve that execute the code(i edited for best comprenssion of my code check the top of the post ), and remove the lines that indicate in the program and the program runs good but if you put the lines to validate the collisions(EntityType..) the program do the extrange things,please help because i need to finish that program.
the extrange things that the program do it's appear more cubes in the wrong possition and form check it.


CarlosEures(Posted 2005) [#6]
Please Help me



Ross C(Posted 2005) [#7]
The main problem here is no-one can really run your source code, because there is no media. Another problem is that the code is poorly structured, so checking through it looks like a nightmare. May i suggest a different approach to your tetris game?

Store all the block positions in an array. When a block is coming down and you want to check for collisions, check the array to see if it has a block flagged in that location.

Array layout

Dim Grid(6,11)

;array contents for an example

.......
.......
.......
.......
.......
..2....
..2....
.22....
.......
1..1..1
1111111
1111111


The 1's represent a block that has fallen and landed. a "." represents an empty space and a 2 represents the space occupied by a falling block. Simply check the array positions to see if they contain zero's before moving your block down.


WolRon(Posted 2005) [#8]
Like I said, I already have a (free) tetris game that you can use...

My code does what Ross is talking about.


jfk EO-11110(Posted 2005) [#9]
You should not use the QUOTE forum-code to format sourcecode. And yes, why don't you save yourself the time and use Wolrons working Tetris example, simply follow his signature link.