MorphingStars - Le même pour ceux qui connaissent

Partagez votre expérience de PureBasic avec les autres utilisateurs.
comtois
Messages : 5186
Inscription : mer. 21/janv./2004 17:48
Contact :

MorphingStars - Le même pour ceux qui connaissent

Message par comtois »

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 ? :)

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 
Oliv
Messages : 2117
Inscription : mer. 21/janv./2004 18:39

Message par Oliv »

8O 8O 8O
Bravo :flasingsmile:
Patrick88
Messages : 1564
Inscription : mer. 21/janv./2004 18:24

Message par Patrick88 »

houlà, à première vue y'a moyen de réduire le code de moitié :

la partie de code suivante :

Code : Tout sélectionner

         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 
se retrouve "n" fois, elle aurait pus être placée dans une fonction/procedure pour économiser de la place ... et des bugs

P@trick
comtois
Messages : 5186
Inscription : mer. 21/janv./2004 17:48
Contact :

Message par comtois »

pas tout à fait ,sinon tu aurais toujours la même forme qui s'affiche à l'écran :)

Il y a toujours une petite nuance , soit un cos à la place d'un sin , ou le paramètre d'un cos qui change, parfois c'est cosd(xd) parfois cosd(t*360/#nb)

Ceci dit , je me suis contenté de recopier un code existant et de remplacer ce qui n'allait pas pour que ça fonctionne sous purebasic , et j'ai un peu changé la forme du sprite principal , rien de plus :)

Je ne connais pas l'auteur , je sais que le source original était écrit en blitzbasic.
Avatar de l’utilisateur
Crystal Noir
Messages : 892
Inscription : mar. 27/janv./2004 10:07

Message par Crystal Noir »

c super chouette et j'aimerais bien savoir faire un truc comme ca, le seul problème, je capte rien au code là lol
fweil
Messages : 505
Inscription : dim. 16/mai/2004 17:50
Localisation : Bayonne (64)
Contact :

Message par fweil »

tiptop joli !
Mon avatar reproduit l'image de 4x1.8m présentée au 'Salon international du meuble de Paris' en janvier 2004, dans l'exposition 'Shades' réunisant 22 créateurs autour de Matt Sindall. L'original est un stratifié en 150 dpi.
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

tiens le mem mais en extincteur d'ecran

tu compille tu sauve en comtois.scr dans c:\windows

(j'ai pas gere la boite de dialogue de parametre mais c'est present dedans !!)


Code : Tout sélectionner

; morph Cree Par Contois
; ici les initialisations des variables et tableaux 
;"/s" pour le lancer
;"/c:" + un nombre pour le faire Paramétrer
;"/p", espace, et un nombre qd son nom est simplement séletionné dans la boîte des propriétés du bureau

;Sinon, un truc tout con:
;Code:

;OpenConsole()
;p$=ProgramParameter()
;While p$
;    PrintN(p$)
;    p$=ProgramParameter()
;Wend
;Input()
 #nb = 3600
;
Enumeration
    #Window_0
EndEnumeration

;- Gadget Constants
;
Enumeration
    #code
    #Text_0
EndEnumeration
Procedure Open_Window_0()
    If OpenWindow(#Window_0, 293, 129, 249, 109,  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "config")
        If CreateGadgetList(WindowID())
            StringGadget(#code, 40, 50, 170, 30, "", #PB_String_Password)
            TextGadget(#Text_0, 10, 20, 90, 20, "ENTREZ le Code")
        EndIf
    EndIf
EndProcedure




#Police=1
;*********** pour le screensaver
Param.s = Left(ProgramParameter(), 2)
If Param = "/p"
    End
EndIf

If Param = "/c" :;l'utilisateur veut paramettrer le screensaver !
    Open_Window_0():; jouvre ma fenetre ( cree a partir de visual designer)
    Repeat
        Texte$ = GetGadgetText(#code):;je recupere le contenu de ma boite de config
        If Texte$="dobro":;si le gars tappe le code "dobro"
            dobro=1:; c'est bon on affiche pas la surimpression
            code$="ok":;on se prepare a ecrire le mot "ok" dans un fichier
            Resultat = OpenFile(1, "matrix.ini") :;on cree le fichier
            WriteStringN(code$) :; on ecrit dedans "ok"
            CloseFile(1)
        Else
            dobro=0:; la le mec a pas rentré le bon code
        EndIf
    Until WindowEvent() = #PB_Event_CloseWindow :; le gars a fermé la boite de config
EndIf

GetCursorPos_(SourisOrigine.POINT)
ShowCursor_(0)
; ***********************************
Resultat = InitSprite()
FontID = LoadFont(#Police, "arial", 18, #PB_Font_Bold )
EcranX = GetSystemMetrics_(#SM_CXSCREEN)
EcranY = GetSystemMetrics_(#SM_CYSCREEN)

If ReadFile(1, "contois.ini"):;en temps normal on commence par regarder si le screen saver est enregistré
    code$ = ReadString() :; on lit le contenu de "matrix.ini"
    CloseFile(1)
EndIf
 
If code$="ok":; bon le gars est enregistré
    dobro=1:; ce flag va retirer la surimpression
Else
    dobro=0:; il n'est pas enregistrer donc on affiche la surimpression
EndIf
;************ c'est tout pour le parametrage du screen saver



GetCursorPos_(SourisOrigine.POINT)
ShowCursor_(0)
; ***********************************
Resultat = InitSprite()
Resultat = InitSprite3D() 
FontID = LoadFont(#Police, "system", 18, #PB_Font_Bold )
EcranX = GetSystemMetrics_(#SM_CXSCREEN)
EcranY = GetSystemMetrics_(#SM_CYSCREEN)
;NbSprite = EcranX / 40 * 3
NbSprite =12
OpenWindow(1, 0, 0, EcranX, EcranY, #PB_Window_BorderLess | #PB_Window_Invisible, "Dos 3.10")
SetWindowPos_(WindowID(), -1, 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE) ; fenêtre toujours au premier plan
OpenWindowedScreen(WindowID(), 0, 0, EcranX, EcranY, 1, 0, 0)

; faire ici les initialisations du pre affichage
;-Initialisation
If InitSprite() = 0 Or InitKeyboard() = 0
    MessageRequester( "Erreur" , "Impossible d'initialiser DirectX 7 Ou plus" , 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 :;boucle principale
    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) + EcranX/2
        ny = EcranY/2 - (512 * ty) / (d - tz)
        
        DisplayTransparentSprite(No,Int(nx),Int(ny))
    Next t
    
    FlipBuffers()
    GetCursorPos_(Souris.POINT):; test le curseur de la souris
Until WindowEvent() = #PB_Event_CloseWindow Or Souris\x <> SourisOrigine\x Or Souris\y <> SourisOrigine\y
ShowCursor_(1)


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
:D
Dernière modification par Backup le sam. 05/juin/2004 15:04, modifié 1 fois.
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

j'ai juste changer les ligne nx et ny
pour faire un centrage en fonction de la rez

nx = (512*tx) / (d - tz) + EcranX/2
ny = EcranY/2 - (512 * ty) / (d - tz)

la variable Ecranx et y :)

et mis 3600 sprites c'est plus jolie je trouve
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

extra 8) , j'ai regardé le principe, c'est en fait relativement simple, comme tout d'ailleurs, il suffit d'y penser :D

en tous cas, je vais essayer d'en faire un pour voir, ça m'intéresse ;)
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Anonyme2
Messages : 3518
Inscription : jeu. 22/janv./2004 14:31
Localisation : Sourans

Message par Anonyme2 »

Superbe.

Je vais me faire un économiseur d'écran pas cher!
Avatar de l’utilisateur
Crystal Noir
Messages : 892
Inscription : mar. 27/janv./2004 10:07

Message par Crystal Noir »

si quelqu'un pouvait expliquer le principe de ce truc ?? car là le code j'y gobe que dalle, c frustrant :(
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

c pas compliqué, on choisi une équation de plan 3D
on place des points aléatoirements dessus et on dit au points de rendre à ces nouvelle cordonnées.
par dessus ça, tu rajoutes une rotaion de la vue et hop :D
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
comtois
Messages : 5186
Inscription : mer. 21/janv./2004 17:48
Contact :

Message par comtois »

pour les équations ,tu peux jeter un oeil ici
http://www.mathcurve.com/surfaces/surfaces.shtml


Extrait un peu commenté

Code : Tout sélectionner

Repeat :;boucle principale 
  ClearScreen(0,0,0) 
  ExamineKeyboard()
  ;d permet de réduire l'affichage au début de l'animation 
  If d<250 : d + 1 : EndIf 
  ;Ici c'est la gestion du morphing , on va progressivement vers la valeur attendue 
  If cnt>375 ; quand on estime que le morphing est terminé 
    ;on incrémente l'effet courant
    curobj + 1 
    If curobj > numobjs : curobj = 1 : EndIf 
    object(curobj) 
    cnt=0 
  EndIf 
  For t=1 To #nb 
    If points1(t) > tpoint1(t) : tpoint1(t) + 1 : EndIf 
    If points1(t) < tpoint1(t) : tpoint1(t) - 1 : EndIf 
    If points2(t) > tpoint2(t) : tpoint2(t) + 1 : EndIf 
    If points2(t) < tpoint2(t) : tpoint2(t) - 1 : EndIf 
    If points3(t) > tpoint3(t) : tpoint3(t) + 1 : EndIf 
    If points3(t) < tpoint3(t) : tpoint3(t) - 1 : EndIf 
  Next t 
  cnt + 1 
  ;Ici on fait tourner l'objet 
  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)) 
    ;Projection 3D>2D 
    nx = (512*tx) / (d - tz) + EcranX/2 
    ny = EcranY/2 - (512 * ty) / (d - tz) 
    ;et on affiche le tout
    DisplayTransparentSprite(0,Int(nx),Int(ny)) 
  Next t 
  FlipBuffers() 
Pour en savoir plus sur la projection
http://www.mandragor.org/tutoriels/tuto ... d=5&chap=5
Avatar de l’utilisateur
Crystal Noir
Messages : 892
Inscription : mar. 27/janv./2004 10:07

Message par Crystal Noir »

bon je vais étudier ca mais j'ai bien peur que ce soit perdu d'avance lol. Je vais regarder...Pfff avec ca lol j'ai l'air malin moi avec mes tutos à deux francs 8O

Dis moi comtois, tu pourrais faire un commentaire sur tout ton code :p je veux dire sur les déclarations, par ex je vois que tu a fait ca sur la boucle repeat, je dois dire que pour moi c comme si j'essayais de soulever une maison à bous de bras sans bras ni jambe :oops:
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Message par Le Soldat Inconnu »

je fais un poste avec un code du genre mais plus simple ;)
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Répondre