'create sprite
_PUTIMAGE , img
, Frame
(s
), (32 * (s
- 1), 0)-(32 * (s
- 1) + 31, 31)
'software animation to hardware animation
Frame(t) = sw
'create 3D cube and place animation as texture
DIM V
(1 TO 8) AS vertex3d
'8 3D vertexes
V(1).x = -2: V(1).y = 1: V(1).z = -3: V(2).x = 2: V(2).y = 1: V(2).z = -3: V(3).x = -2: V(3).y = -1: V(3).z = -3: V(4).x = 2: V(4).y = -1: V(4).z = -3 'openGL coordinate system
V(5).x = -2: V(5).y = 1: V(5).z = -5: V(6).x = 2: V(6).y = 1: V(6).z = -5: V(7).x = -2: V(7).y = -1: V(7).z = -5: V(8).x = 2: V(8).y = -1: V(8).z = -5
camX = -4
camZ = -10
camX2 = 4
camZ2 = -10
'calculate points angles (.a) and line lenght from middle (.l) - middle of the cube is in 0, 0, 0, rotation center is on 0, 0, camZ
V
(a
).a
= _ATAN2(V
(a
).z
+ 4, V
(a
).x
) ' 4 in Z axis is middle between coordinate 5 and 3 V
(a
).l
= _HYPOT(V
(a
).z
+ 4, V
(a
).x
)
DIM NP
(1 TO 8) AS vertex3d
'NP = new points DIM NP2
(1 TO 8) AS vertex3d
'NP2 = new points - rotated 90 degrees from the NP
i = 1: Himg = Frame(i)
roto = roto + .001
'calculate new points position: - rotation X/Z
NP
(c
).x
= camX
+ COS(roto
+ V
(c
).a
) * V
(c
).l
NP
(c
).z
= camZ
+ SIN(roto
+ V
(c
).a
) * V
(c
).l
NP(c).y = V(c).y
NP2
(c
).x
= camX2
+ COS(roto
- _PI / 2 + V
(c
).a
) * V
(c
).l
NP2
(c
).z
= camZ2
+ SIN(roto
- _PI / 2 + V
(c
).a
) * V
(c
).l
NP2(c).y = V(c).y
'map cube SEE ATTACHED PICTURE!
index:
DATA 7,8,3,4:
'dno bottom DATA 1,2,3,4:
'celo front DATA 5,6,7,8:
'zadek back DATA 1,5,3,7:
'levy bok left side DATA 2,6,4,8:
'pravy bok right side
_MAPTRIANGLE (0, 0)-(32, 0)-(0, 32), Himg
TO(NP
(i1
).x
, NP
(i1
).y
, NP
(i1
).z
)-(NP
(i2
).x
, NP
(i2
).y
, NP
(i2
).z
)-(NP
(i3
).x
, NP
(i3
).y
, NP
(i3
).z
), 0 _MAPTRIANGLE (32, 0)-(0, 32)-(32, 32), Himg
TO(NP
(i2
).x
, NP
(i2
).y
, NP
(i2
).z
)-(NP
(i3
).x
, NP
(i3
).y
, NP
(i3
).z
)-(NP
(i4
).x
, NP
(i4
).y
, NP
(i4
).z
), 0
_MAPTRIANGLE (0, 0)-(32, 0)-(0, 32), Himg
TO(NP2
(i1
).x
, NP2
(i1
).y
, NP2
(i1
).z
)-(NP2
(i2
).x
, NP2
(i2
).y
, NP2
(i2
).z
)-(NP2
(i3
).x
, NP2
(i3
).y
, NP2
(i3
).z
), 0 _MAPTRIANGLE (32, 0)-(0, 32)-(32, 32), Himg
TO(NP2
(i2
).x
, NP2
(i2
).y
, NP2
(i2
).z
)-(NP2
(i3
).x
, NP2
(i3
).y
, NP2
(i3
).z
)-(NP2
(i4
).x
, NP2
(i4
).y
, NP2
(i4
).z
), 0
ChangeFrame:
i
= i
+ 1:
IF i
> 15 THEN i
= 1Himg = Frame(i)