MorphingStars - Le même pour ceux qui connaissent
Publié : sam. 24/janv./2004 15:46
Désolé pour ceux qui connaissaient déjà , mais je cherchais un bout de code pour commencer à remplir cette section , et je n'ai rien trouvé , ma production en code source est faible 
Je précise que ce code est une légère adaptation d'un code en Blitzbasic.
J'ai bien un puissance4 en préparation , il reste quelques bugs à supprimer avant de le poster ,ou alors je le mets tel quel et le but du jeu c'est de le débugguer ?

Je précise que ce code est une légère adaptation d'un code en Blitzbasic.
J'ai bien un puissance4 en préparation , il reste quelques bugs à supprimer avant de le poster ,ou alors je le mets tel quel et le but du jeu c'est de le débugguer ?

Code : Tout sélectionner
#ScreenWidth = 640
#ScreenHeight = 480
#ScreenDepth = 16
#nb = 360
;-Initialisation
If InitSprite() = 0 Or InitKeyboard() = 0
MessageRequester( "Erreur" , "Impossible d'initialiser DirectX 7 Ou plus" , 0 )
End
ElseIf OpenScreen( #ScreenWidth , #ScreenHeight , #ScreenDepth , "PureSokoban3D" ) = 0
MessageRequester( "Erreur" , "Impossible d'ouvrir l'écran " , 0 )
End
EndIf
SetFrameRate(60)
Declare object(object)
Declare.f Cosd( Angle.f )
Declare.f Sind( Angle.f )
Global numobjs,d,curobj,cnt
numobjs=18
d=1
curobj=2
cnt=0
CreateSprite(0,7,7)
StartDrawing(SpriteOutput(0))
Circle(3,3,1,RGB(255,255,0))
Circle(3,1,1,RGB(255,100,100))
Circle(1,3,1,RGB(255,100,100))
Circle(5,3,1,RGB(255,100,100))
Circle(3,5,1,RGB(255,100,100))
StopDrawing()
Dim points1(#nb)
Dim points2(#nb)
Dim points3(#nb)
Dim tpoint1(#nb)
Dim tpoint2(#nb)
Dim tpoint3(#nb)
object(2)
For t=1 To #nb
tpoint1(t) = points1(t)
tpoint2(t) = points2(t)
tpoint3(t) = points3(t)
Next t
Repeat
ClearScreen(0,0,0)
ExamineKeyboard()
If d<250 : d + 1 : EndIf
If cnt>375
curobj + 1
If curobj > numobjs : curobj = 1 : EndIf
No =0
object(curobj)
cnt=0
EndIf
For t=1 To #nb
If points1(t) > tpoint1(t) : tpoint1(t) = tpoint1(t) + 1 : EndIf
If points1(t) < tpoint1(t) : tpoint1(t) = tpoint1(t) - 1 : EndIf
If points2(t) > tpoint2(t) : tpoint2(t) = tpoint2(t) + 1 : EndIf
If points2(t) < tpoint2(t) : tpoint2(t) = tpoint2(t) - 1 : EndIf
If points3(t) > tpoint3(t) : tpoint3(t) = tpoint3(t) + 1 : EndIf
If points3(t) < tpoint3(t) : tpoint3(t) = tpoint3(t) - 1 : EndIf
Next t
cnt + 1
vx.f + 0.75
vy.f + 0.75
vz.f + 0.75
For t=1 To #nb
x3d.f = tpoint1(t)
y3d.f = tpoint2(t)
z3d.f = tpoint3(t)
ty.f = (y3d * Cosd(vx)) - (z3d * Sind(vx))
tz.f = (y3d * Sind(vx)) + (z3d * Cosd(vx))
tx.f = (x3d * Cosd(vy)) - (tz * Sind(vy))
tz.f = (x3d * Sind(vy)) + (tz * Cosd(vy))
ox.f = tx
tx = (tx * Cosd(vz)) - (ty * Sind(vz))
ty = (ox * Sind(vz)) + (ty * Cosd(vz))
nx = (512*tx) / (d - tz) + 320
ny = 240 - (512 * ty) / (d - tz)
DisplayTransparentSprite(No,Int(nx),Int(ny))
Next t
FlipBuffers()
Until KeyboardPushed(#PB_Key_All)
End
Procedure.f Cosd( Angle.f )
;calcule le cos d'un angle en degré
a.f = Angle * 0.0174533
ProcedureReturn Cos( a )
EndProcedure
Procedure.f Sind( Angle.f )
;calcule le sin d'un angle en degré
a.f = Angle * 0.0174533
ProcedureReturn Sin( a )
EndProcedure
Procedure object(object)
xd.f = 0
x0.f = 0
y0.f = 0
z0.f = 0
If object=1
For t=1 To #nb
xd = -50
xd = xd + Random(100)
points1(t) = xd
points2(t) = 0
points3(t) = 0
Next t
EndIf
If object=2
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(xd) * 10) * (Cosd(t*360/#nb) * 10)
y0 = (Cosd(xd) * 10) * (Sind(t*360/#nb) * 10)
z0 = Sind(xd) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=3
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(xd)* 10) * (Cosd(t*360/#nb) * 10)
y0 = (Cosd(xd) * 10) * (Sind(t*360/#nb) * 10)
z0 = Sind(t*360/#nb) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=4
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(xd)* 10) * (Cosd(xd) * 10)
y0 = (Cosd(xd) * 10) * (Sind(xd) * 10)
z0 = Sind(xd) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=5
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(xd)* 10) * (Cosd(xd) * 10)
y0 = (Cosd(xd) * 10) * (Sind(xd) * 10)
z0 = Sind(t*360/#nb) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=6
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(xd)* 10) * (Cosd(xd) * 10)
y0 = (Cosd(t*360/#nb) * 10) * (Sind(xd) * 10)
z0 = Sind(t*360/#nb) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=7
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(t*360/#nb)* 10) * (Cosd(t*360/#nb) * 10)
y0 = (Cosd(t*360/#nb) * 10) * (Sind(xd) * 10)
z0 = Sind(t*360/#nb) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=8
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(t*360/#nb)* 10) * (Cosd(t*360/#nb) * 10)
y0 = (Cosd(t*360/#nb) * 10) * (Sind(t*360/#nb) * 10)
z0 = Sind(t*360/#nb) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=9
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(xd)* 10) * (Cosd(t*360/#nb) * 10)
y0 = (Cosd(t*360/#nb) * 10) * (Sind(t*360/#nb) * 10)
z0 = Sind(xd) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=10
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(xd)* 10) * (Cosd(t*360/#nb) * 10)
y0 = (Cosd(t*360/#nb) * 10) * (Sind(xd) * 10)
z0 = Sind(xd) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=11
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(t*360/#nb)* 10) * (Cosd(t*360/#nb) * 10)
y0 = (Cosd(xd) * 10) * (Sind(xd) * 10)
z0 = Sind(t*360/#nb) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=12
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(xd)* 10) * (Cosd(t*360/#nb) * 10)
y0 = (Sind(xd) * 10) * (Sind(t*360/#nb) * 10)
z0 = Sind(xd) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=13
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(xd)* 10) * (Cosd(xd) * 10)
y0 = (Sind(xd) * 10) * (Sind(xd) * 10)
z0 = Sind(t*360/#nb) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=14
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(xd)* 10) * (Cosd(xd) * 10)
y0 = (Sind(t*360/#nb) * 10) * (Sind(xd) * 10)
z0 = Sind(t*360/#nb) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=15
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Sind(xd)* 10) * (Cosd(xd) * 10)
y0 = (Sind(xd) * 10) * (Sind(t*360/#nb) * 10)
z0 = Sind(t*360/#nb) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=16
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(t*360/#nb)* 10) * (Cosd(t*360/#nb) * 10)
y0 = (Sind(t*360/#nb) * 10) * (Sind(xd) * 10)
z0 = Sind(t*360/#nb) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=17
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(xd)* 10) * (Cosd(t*360/#nb) * 10)
y0 = (Sind(t*360/#nb) * 10) * (Sind(xd) * 10)
z0 = Cosd(xd) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
If object=18
For t=1 To #nb
xd = -90 + Random(180)
x0 = (Cosd(xd)* 10) * (Cosd(xd) * 10)
y0 = (Cosd(t*360/#nb) * 10) * (Sind(t*360/#nb) * 10)
z0 = Sind(t*360/#nb) * 100
points1(t) = x0
points2(t) = y0
points3(t) = z0
Next t
EndIf
EndProcedure