 |
Das deutsche QBasic- und FreeBASIC-Forum Für euch erreichbar unter qb-forum.de, fb-forum.de und freebasic-forum.de!
|
Vorheriges Thema anzeigen :: Nächstes Thema anzeigen |
Autor |
Nachricht |
Löwenherz

Anmeldungsdatum: 25.08.2008 Beiträge: 86 Wohnort: auf einer sonnigen Insel :)
|
Verfasst am: 23.07.2009, 22:15 Titel: farbe für partikel kreise |
|
|
Hi und schönen Abend miteinander !
habe eine kurze Frage zum Thema Farbe und Partikel, ich habe diese Partikel Übung nachgebaut und kompiliert mit den Kreisen und würde gerne die Kreise mit unterschiedlicher Farbe fallen lassen... Hat jemand eine Idee ?
Bin noch nicht so fit mit der ganzen Materie, das braucht wohl Wochen und Monate, bis ich die Feinheiten drauf habe, uff !
Code: |
Screen 18, 32
Cls
Type PType
x As Single
y As Single
vx As Single
vy As Single
col As Single
End Type
Const PMAX As Integer = 1500
Dim Particle(1 to PMAX) As PType
dim ang as integer
dim i as long
For i = 1 To PMAX
Particle(i).x = 320
Particle(i).y = 240
Ang = Int(Rnd * 360) + 1
Particle(i).vx = Cos(Ang * (3.14/180)) * Rnd * 16
Particle(i).vy = Sin(Ang * (3.14/180)) * Rnd * 16
Particle(i).col = rnd * 255
Next i
Do
Cls
For i = 1 To PMAX
Particle(i).x = Particle(i).x + Particle(i).vx
Particle(i).y = Particle(i).y + Particle(i).vy
Particle(i).vx = Particle(i).vx / 1.01
Particle(i).col = Particle(i).col - 1
If Particle(i).col < 0 Then Particle(i).col = 0
If Particle(i).vy < 15 Then Particle(i).vy = Particle(i).vy + .1
If Particle(i).x < 0 Then
Particle(i).x = 0
Particle(i).vx = (Particle(i).vx / (Rnd * 4 + 4)) * -1
Endif
If Particle(i).x > 639 Then
Particle(i).x = 639
Particle(i).vx = (Particle(i).vx / (Rnd * 4 + 4)) * -1
Endif
If Particle(i).y > 479 Then
Particle(i).y = 479
Particle(i).vy = (Particle(i).vy / (Rnd * 4 + 4)) * -1
Endif
If Particle(i).y >= 0 Then Pset(Particle(i).x, Particle(i).y), RGB(Particle(i).col, Particle(i).col, Particle(i).col)
If Particle(i).y >= 0 Then Circle(Particle(i).x, Particle(i).y), 2, RGB(Particle(i).col, Particle(i).col, Particle(i).col)
Next i
Sleep 10
Loop Until Inkey$ <> ""
Cls
End |
beste Grüße aus dem schönen Werraland, wünscht Löwenherz _________________ Das Leben ist wie eine Pralinenschachtel, man weiß nie, was dort drinnen für tolle wie böse Überraschungen stecken |
|
Nach oben |
|
 |
nemored

Anmeldungsdatum: 22.02.2007 Beiträge: 4704 Wohnort: ~/
|
Verfasst am: 23.07.2009, 22:46 Titel: |
|
|
Code: | Type PType
x As Single
y As Single
vx As Single
vy As Single
col(1 to 3) As Single
End Type
[...]
FOR i = 1 TO PMAX
Particle(i).x = 320
Particle(i).y = 240
Ang = INT(RND * 360) + 1
Particle(i).vx = COS(Ang * (3.14/180)) * RND * 16
Particle(i).vy = SIN(Ang * (3.14/180)) * RND * 16
FOR k AS INTEGER = 1 TO 3
Particle(i).col(k) = RND * 255
NEXT
NEXT
[...]
FOR k AS INTEGER = 1 TO 3
Particle(i).col(k) = Particle(i).col(k) - 1
IF Particle(i).col(k) < 0 THEN Particle(i).col(k) = 0
[...]
IF Particle(i).y >= 0 THEN PSET(Particle(i).x, Particle(i).y), RGB(Particle(i).col(1), Particle(i).col(2), Particle(i).col(3))
IF Particle(i).y >= 0 THEN CIRCLE(Particle(i).x, Particle(i).y), 2, RGB(Particle(i).col(1), Particle(i).col(2), Particle(i).col(3)) |
Warum ist col eigentlich SINGLE und nicht INTEGER? _________________ Deine Chance beträgt 1:1000. Also musst du folgendes tun: Vergiss die 1000 und konzentriere dich auf die 1. |
|
Nach oben |
|
 |
Löwenherz

Anmeldungsdatum: 25.08.2008 Beiträge: 86 Wohnort: auf einer sonnigen Insel :)
|
Verfasst am: 24.07.2009, 13:04 Titel: |
|
|
hi nemored, super! Hat geklappt, vielen Dank, wieder was gelernt Das partikel skript mit den Kreisen ist schön bunt geworden ! Also ich freue mich über solche Dinge, wenn's farbig und gut aussieht, so macht programmieren auch Spass!
Stimmt: habe 'col' außerdem in 'integer' umgesetzt.
beste Grüße, Löwenherz _________________ Das Leben ist wie eine Pralinenschachtel, man weiß nie, was dort drinnen für tolle wie böse Überraschungen stecken |
|
Nach oben |
|
 |
|
|
Du kannst keine Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum nicht antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen.
|
|