question de geometrie !

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

question de geometrie !

Message par Backup »

je continue ici car c'est une question de debutant n'est-ce pas !

dans ce code je fait tourner un polygone !!

je voudrais que le chiffre indiqué en haut a gauche donne le nombre de degres !!

la procedure polygone permet de faire un polygone de n'importe quel type
a X cotés !!

Excusez moi par avance pour le double post !! :D

Code : Tout sélectionner

#dobro=1
#Police=1
#Sprite=1
#PI=3.1415926
Declare polygone(x.l,y.l,taille.l,angle.l,rotation.f,color.l,t)
; ***********************************
Resultat = InitSprite()
FontID = LoadFont(#Police, "arial", 18, #PB_Font_Bold )
EcranX = GetSystemMetrics_(#SM_CXSCREEN):;=largeur de l'ecran
EcranY = GetSystemMetrics_(#SM_CYSCREEN):;=hauteur de l'ecran
  WindowID = OpenWindow(1, 0, 0, EcranX, EcranY,  #PB_Window_SystemMenu|#PB_Window_BorderLess |#PB_Window_ScreenCentered , "hello")
  
  WindowID = WindowID(1)
  Result = OpenWindowedScreen(WindowID,0,0,800, 600, 1, 0,0)
  
  
  
  Resultat = InitMouse() 
  Repeat
    ExamineMouse()
    Event=WindowEvent() 
    If MouseButton(2)
      End
    EndIf
    
    
    
    ;Star(x.l,y.l,intrad.l,n.l,phase.f,color.l)
    
    x.l=400 ;location x
    y.l=300 ; location y
    taille.l=100
    angle.l=4 ; pour un triangle  4 pour un carre , 8 pour un octogone ect ...
    rotation.f=180
    
    color.l=RGB($FF,$FF,$80)
    For t=0 To 360
     Delay (500)
    rotation.f=t
     rotation.f= rotation.f/100
      polygone(x.l,y.l,taille.l,angle.l,rotation.f,color.l,t)
     FlipBuffers():; affiche l'ecran
      ClearScreen(0,0,0) 
      ExamineMouse()
      Event=WindowEvent() 
      If MouseButton(2)
        End
      EndIf
    Next t
    

    
    
  Until Event=#PB_Event_CloseWindow
  
  
  
  
  Procedure  polygone(x.l,y.l,taille.l,angle.l,rotation.f,color.l,t)
    If angle.l=4 
      rotation.f=rotation.f+0.77+0.9  ;(70.9/0.9/100)
    Else
      ; rotation.f=(rotation.f+0.9/100)
    EndIf
    
    StartDrawing(ScreenOutput() )
    DrawText(StrF( t))
    alpha.f=2*(#PI/angle)
    For t.l=1 To angle
      d1.f=(t-1)*alpha+rotation.f
      d3.f=t*alpha+rotation.f
      LineXY(x+taille*Sin(d1),y+taille*Cos(d1),x+taille*Sin(d3),y+taille*Cos(d3),color)
    Next
    StopDrawing()
  EndProcedure 
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

je crois que j'ai trouvé !! :D

le code ci_dessous fera tourner le polygone d'un tour complet
dans une boucle qui va de 0 a 360
donc j'en deduit que c'est bon t = les degres !!


Code : Tout sélectionner

#dobro=1
#Police=1
#Sprite=1
#PI=3.1415926
Declare polygone(x.l,y.l,taille.l,angle.l,rotation.f,color.l,t)
; ***********************************
Resultat = InitSprite()
FontID = LoadFont(#Police, "arial", 18, #PB_Font_Bold )
EcranX = GetSystemMetrics_(#SM_CXSCREEN):;=largeur de l'ecran
EcranY = GetSystemMetrics_(#SM_CYSCREEN):;=hauteur de l'ecran
  WindowID = OpenWindow(1, 0, 0, EcranX, EcranY,  #PB_Window_SystemMenu|#PB_Window_BorderLess |#PB_Window_ScreenCentered , "hello")
  
  WindowID = WindowID(1)
  Result = OpenWindowedScreen(WindowID,0,0,800, 600, 1, 0,0)
  
  
  
  Resultat = InitMouse() 
  Repeat
    ExamineMouse()
    Event=WindowEvent() 
    If MouseButton(2)
      End
    EndIf
    
    
    
    ;Star(x.l,y.l,intrad.l,n.l,phase.f,color.l)
    
    x.l=400 ;location x
    y.l=300 ; location y
    taille.l=100
    angle.l=3 ; pour un triangle  4 pour un carre , 8 pour un octogone ect ...
    rotation.f=180
    
    color.l=RGB($FF,$FF,$80)
    For t=0 To 360
    ; Delay (200)
    rotation.f=t
     rotation.f= rotation.f*0.01745329
      polygone(x.l,y.l,taille.l,angle.l,rotation.f,color.l,t)
     FlipBuffers():; affiche l'ecran
      ClearScreen(0,0,0) 
      ExamineMouse()
      Event=WindowEvent() 
      If MouseButton(2)
        End
      EndIf
    Next t
    

    
    
  Until Event=#PB_Event_CloseWindow
  
  
  
  
  Procedure  polygone(x.l,y.l,taille.l,angle.l,rotation.f,color.l,t)
    If angle.l=4 
      rotation.f=rotation.f
      ;57.295779513082
    Else
      ; rotation.f=(rotation.f+0.9/100)
    EndIf
    
    StartDrawing(ScreenOutput() )
    DrawText(StrF( t))
    alpha.f=2*(#PI/angle)
    For t.l=1 To angle
      d1.f=(t-1)*alpha+rotation.f
      d3.f=t*alpha+rotation.f
      LineXY(x+taille*Sin(d1),y+taille*Cos(d1),x+taille*Sin(d3),y+taille*Cos(d3),color)
    Next
    StopDrawing()
  EndProcedure 
Répondre