Source     Discussion     Modifier     Historique     Forums     Salon IRC

Source:TraceCourbe.pb

Un article de Games Creators Network.

Capture d'écran
Capture d'écran

J'ignore si cette courbe a un nom ? Peu importe ,c'est joli :)

;Auteur : Tonton 
;http://purebasic.hmt-forum.com/viewtopic.php?t=2777

InitSprite()
InitKeyboard()
InitMouse()
OpenScreen(1024, 768, 32, "")

Dim tableau(1500)
Dim tableau2(1500)

X1.f
Y1.f
posi.f
a.f

emp = -100 ; amplitude de depart
negampli = -140 ; amplitude inferieur
posampli = 140 ; amplitude superieur
decomp = 0 ; vitesse

z = 0
posi = 1
limite = posi * 80
zoom = 200

Repeat
  
  ClearScreen(0, 0, 0)
  
  ;Initialise les données
  prem = 0
  x = 150
  y = 500
  a = 0
  X1 = -150
  Y1 = -150
  
  emp + decomp
  If emp > posampli Or emp < negampli
    decomp = -decomp
  EndIf
  
  For i = 1 To 1000
    tableau(i) = 1000
    tableau2(i) = 0
  Next
  
  ;Tracé
  StartDrawing(ScreenOutput())
  While a < limite 
    
    ;Pour le Test des points à afficher ( gestion des points cachés ) ?
    If prem = 0 Or tableau2(x) < y + z
      tableau2(x) = y + z
    EndIf
    
    If tableau(x) >= y + z 
      tableau(x) = y + z
    EndIf 
    
    
    x + 1
    X1 + 0.5
    z1 = (Cos(Sqr(((X1 * X1) + (Y1 * Y1)) / zoom ))) * emp
    z = z1
    
    If x < 760 + a
      
      If y + z < tableau(x) Or y + z > tableau2(x) ; test les points à afficher
        Plot(x, y + z, RGB( 255 , 200 ,200))
      EndIf 
      
    Else
      
      prem = 1
      x = 150
      X1 = -150
      Y1 + 3.8
      a  + posi
      y - 2
      x + a
      
    EndIf
    
  Wend
  
  StopDrawing()
  
  ;Gestion du clavier  
  ExamineKeyboard()
  
  If KeyboardPushed(#PB_Key_Left)
    posampli + 1
    negampli - 1
    emp + 1
  ElseIf KeyboardPushed(#PB_Key_Right)
    posampli - 1
    negampli + 1
    emp - 1
  EndIf
  If KeyboardPushed(#PB_Key_Up)
    zoom + 3
  ElseIf KeyboardPushed(#PB_Key_Down)
    zoom - 3
  EndIf
  
  ;Affiche le résultat 
  FlipBuffers()
  
Until KeyboardPushed(#PB_Key_Escape)

 

Rechercher
Installer l'extension de recherche Plus d'informations

 

Comprendre
Tu me dis, j'oublie. Tu m'enseignes, je me souviens. Tu m'impliques, j'apprends. - Benjamin Franklin

 

Partager
La connaissance est la seule chose qui s'accroit lorsqu'on la partage. - Sacha Boudjema

 

Créer
L'imagination est plus importante que la connaissance. - Albert Einstein

 

 

Le wiki en images Le wiki en images Image du mois: «Snowball: un prototype de jeu développé avec NeL.