Graphics 1280,1024,32,1 SetBuffer BackBuffer() SeedRnd MilliSecs() AppTitle "Schöööne Farben" HidePointer() Global s = 50 ; size der 1. Kugel Global a = 40 ; anzahl der Kugeln Dim px(1000) Dim py(1000) Dim dx(1000) Dim dy(1000) Global rdir, avx#, avy# Global r = 255,g = 0,b = 0, empty = 1 Global mode = 1, helptimer = 0, helptimermax = 1000, errortimer, errormsg$ = "", mz Global dir = 225, x1 = GraphicsWidth()/3, y1 = 100, sp = 5, random = 2 ;Für Modus 2 Global rndsize = 100 ;Für Modus 4 Global abst = 240, graddir, abstmax = abst, abstsp = 1, modus5 = 0, md5grad While Not KeyHit(1) If KeyHit(28) Then empty = empty Xor 1 Rect 20,10,10,10 EndIf If Not MouseDown(1) Then For i = 1 To a-1 px(a-i) = px(a-1-i) ;Listenverschiebung um 1 nach hinten py(a-i) = py(a-1-i) Next EndIf For i = a-1 To 1 Step -1 ; Malen der Kugeln Color r-i*(r/a),g-i*(g/a),b-i*(b/a) size = size(i) Oval px(i)-size/2,py(i)-size/2,size,size,empty Next Select mode Case 1 px(0) = MouseX() py(0) = MouseY() Case 2 px(0) = x1 py(0) = y1 If Not MouseDown(1) Then Select dir Case 45 x1 = x1 + sp + Rnd(random) y1 = y1 - sp - Rnd(random) If (x1+size(0)/2) >= GraphicsWidth() dir = 315 If (y1-size(0)/2) <= 0 dir = 135 Case 135 x1 = x1 + sp + Rnd(random) y1 = y1 + sp + Rnd(random) If (x1+size(0)/2) >= GraphicsWidth() dir = 225 If (y1+size(0)/2) >= GraphicsHeight() dir = 45 Case 225 x1 = x1 - sp - Rnd(random) y1 = y1 + sp + Rnd(random) If (x1-size(0)/2) <= 0 dir = 135 If (y1+size(0)/2) >= GraphicsHeight() dir = 315 Case 315 x1 = x1 - sp - Rnd(random) y1 = y1 - sp - Rnd(random) If (x1-size(0)/2) <= 0 dir = 45 If (y1-size(0)/2) <= 0 dir = 225 End Select EndIf random = Sqr(s)/2 Case 3 px(0) = Rnd(GraphicsWidth()) py(0) = Rnd(GraphicsHeight()) Case 4 grad = Rnd(360) entf = Rnd(rndsize) px(0) = MouseX()+Cos(grad)*entf py(0) = MouseY()+Sin(grad)*entf If KeyDown(57) Then Color 255,255,255 Text 40,230,"Während Shift gehalten wird, kann die Größe des" Text 40,250," Farbklecksbereichs mit den Pfeiltasten geändert werden." EndIf If KeyDown(42) Then If KeyHit(200) rndsize = rndsize + sp If KeyHit(203) rndsize = rndsize - Ceil(sp/2) If KeyHit(205) rndsize = rndsize + Ceil(sp/2) If KeyHit(208) rndsize = rndsize - sp EndIf If rndsize < 2 Then errormsg = "Farbklecksbereich geht nicht kleiner!" rndsize = 2 EndIf If Rndsize > GraphicsWidth()/2 Then rndsize=GraphicsWidth()/2 errormsg = "Farbklecksbereich geht nicht größer!" EndIf Case 5 If modus5 Then middlex = MouseX() middley = MouseY() Else md5grad = md5grad - 20 If md5grad > 360 md5grad = md5grad Mod 360 middlex = MouseX()+Cos(md5grad)*abst middley = MouseY()+Sin(md5grad)*abst EndIf graddir = graddir + s/3 If graddir > 360 graddir = graddir Mod 360 px(0) = middlex+Cos(graddir)*abst py(0) = middley+Sin(graddir)*abst abst = abst + abstsp If abst > abstmax abstsp = -1 If abst < 10 abstsp = 1 If KeyDown(42) Then If KeyHit(200) abstmax = abstmax + sp If KeyHit(203) abstmax = abstmax - Ceil(sp/2) If KeyHit(205) abstmax = abstmax + Ceil(sp/2) If KeyHit(208) abstmax = abstmax - sp EndIf If abstmax < 20 Then abstmax = 20 errormsg = "Der gesamte Kreis kann nicht kleiner werden!" EndIf If abstmax > GraphicsWidth()/2 Then abstmax = GraphicsWidth()/2 errormsg = "Der gesamte Kreis kann nicht größer werden!" EndIf If KeyDown(57) Then Color 255,255,255 Text 40,230,"Die Größe des entstehenden Kreises wird mit den Pfeiltasten geändert." Text 40,250,"Hier gibt es noch einen weiteren Modus! (Tabulator)" EndIf If KeyHit(15) modus5 = modus5 Xor 1 End Select helptimer = helptimer + 1 If KeyDown(57) Then Color 255,255,255 Text 40,60,"Linke Maustaste hält das Bild an." Text 40,80,"Rechte Maustaste erzeugt eine zufällige Farbe." Text 40,100,"Das Mausrad verstellt die Größe der Kugel(n)." Text 40,120," (alternativ: Pfeiltasten: Rechts/Links)" Text 40,140,"Mit den Pfeiltasten Oben/Unten wird die Kugelanzahl verstellt." Text 40,160,"Während r,g oder b gedrückt gehalten wird, können mit den" Text 40,180," Pfeiltasten die einzelnen Farbwerte verändert werden." Text 40,200,"Mit Enter verändert sich die Kreisstruktur." helptimer = 0 Else If helptimer Mod helptimermax >= helptimermax/2 Then Color 255,255,255 Text 20,20,"Drücke die Leertaste für Weitere Spielereien!" EndIf EndIf If KeyHit(2) And mode <> 1 Then If mode = 2 MoveMouse(x1,y1) mode = 1 EndIf If KeyHit(3) And mode <> 2 Then mode = 2 x1 = MouseX() y1 = MouseY() dir = Ceil(rdir/90)*90 + 45 If dir = 405 dir = 45 EndIf Text 10,10,rdir + " " + dir If KeyHit(4) And mode <> 3 Then mode = 3 EndIf If KeyHit(5) And mode <> 4 Then If mode = 2 MoveMouse(x1,y1) mode = 4 EndIf If KeyHit(6) And mode <> 5 Then If mode = 2 MoveMouse(x1,y1) mode = 5 EndIf mz = MouseZSpeed() If (mz-MouseZSpeed()) <> 0 Then s = s + (mz-MouseZSpeed())*sp/2 EndIf If MouseHit(2) Then r = Rnd(0,255) g = Rnd(0,255) b = Rnd(0,255) EndIf If KeyDown(19) Or KeyDown(34) Or KeyDown(48) Then Color r,g,b Text 40,40,"Farben: Rot: " + r + " ; Grün: " + g + " ; Blau: " + b If KeyDown(19) Then If KeyHit(200) r = r + sp If KeyHit(203) r = r - Ceil(sp/2) If KeyHit(205) r = r + Ceil(sp/2) If KeyHit(208) r = r - sp EndIf If KeyDown(34) Then If KeyHit(200) g = g + sp If KeyHit(203) g = g - Ceil(sp/2) If KeyHit(205) g = g + Ceil(sp/2) If KeyHit(208) g = g - sp EndIf If KeyDown(48) Then If KeyHit(200) b = b + sp If KeyHit(203) b = b - Ceil(sp/2) If KeyHit(205) b = b + Ceil(sp/2) If KeyHit(208) b = b - sp EndIf Else If KeyHit(200) Then a = a + sp For i = 1 To a px(i) = -100 py(i) = -100 Next EndIf If KeyHit(208) a = a - sp If KeyHit(203) s = s - sp If KeyHit(205) s = s + sp EndIf If a < 10 a = 10 errormsg = "Anzahl kann nicht geringer sein!" If a > 300 a = 300 errormsg = "Anzahl kann nicht größer sein!" If s < 10 s = 10 errormsg = "Kugeln können nicht größer werden!" If s > 250 s = 250 errormsg = "Kugeln können nicht kleiner werden!" If r < 0 r = 0 errormsg = "Minimaler Rotanteil!" If g < 0 g = 0 errormsg = "Minimaler Grünanteil!" If b < 0 b = 0 errormsg = "Minimaler Blauanteil!" If r > 255 r = 255 errormsg = "Maximaler Rotanteil!" If g > 255 g = 255 errormsg = "Maximaler Grünanteil!" If b > 255 b = 255 errormsg = "Maximaler Blauanteil!" If Not errormsg = "" Then Color 255-errortimer*(254/(helptimer/3)),255-errortimer*(254/(helptimer/3)),254-errortimer*(254/(helptimer/3)) errortimer = errortimer + 1 If errortimer >= helptimer/3 Then errormsg = "" errortimer = 0 EndIf Text 200,GraphicsHeight()-60,errormsg EndIf calc_direction() Flip Cls Wend End Function size (i) Return s-Floor(i*(s*1.0/a*1.0)) End Function Function calc_direction () For i = 0 To a-2 dx(i) = px(i)-px(i+1) dy(i) = py(i)-py(i+1) avx = dx(i) + avx avy = dy(i) + avy Next avx = Floor(avx/a) avy = Floor(avy/a) If avx <> 0 Then rdir = Abs(ATan(avy/avx)) If avx > 0 And avy > 0 Then rdir = 90 + rdir EndIf If avx < 0 And avy > 0 Then rdir = 270 - rdir EndIf If avx < 0 And avy < 0 Then rdir = 270 + rdir EndIf If avx > 0 And avy < 0 Then rdir = 90 - rdir EndIf If avx = 0 Then If avy < 0 rdir = 360 If avy > 0 rdir = 180 EndIf If 1 > 2 Then Line GraphicsWidth()/2,GraphicsHeight()/2,GraphicsWidth()/2+Cos(rdir-90)*300,GraphicsHeight()/2+Sin(rdir-90)*300 EndIf If KeyDown(57) Text GraphicsWidth()-30,GraphicsHeight()-20,rdir End Function