Ich hab mal ne Funktion geschrieben, mit der man eine Variable mittels klick auf Pfeile erhöht oder verringert und auf True und False stellen kann.
Als Anwendungsbeispiel habe ich das ganze habe ich in ein Rechteck umgesetzt, bei dem man mit diesen Feldern die Farbe verändern kann.
Eine schöne Aufgabe wäre es z.B , das texturerstellungsprogramm von Holzchopf mit diesen Funktionen zu schreiben.
BlitzBasic: [AUSKLAPPEN] [EINKLAPPEN] Graphics 1024,768 Global yesbutton1 = CreateImage(25,20) Dim yes(24,19) Data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,1,1,0,1,1,0,1,1,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,1,1,0,0,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,1,1,0,0,1,1,0,1,1,0,1,1,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 Data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
For y= 0 To 19 For x = 0 To 24 Read yes(x,y) Next Next
SetBuffer ImageBuffer(yesbutton1) For y = 0 To 19 For x = 0 To 24 If yes(x,y) = 0 Then Color 255,255,255 If yes(x,y) = 1 Then Color 0,0,0 If yes(x,y) = 2 Then Color 255,0,0 Plot x,y Next Next
Global yesbutton2 = CreateImage(25,30) SetBuffer ImageBuffer(yesbutton2) For y = 0 To 19 For x = 0 To 24 If yes(x,y) = 0 Then Color 0,0,0 If yes(x,y) = 1 Then Color 255,255,255 If yes(x,y) = 2 Then Color 255,0,0 Plot x,y Next Next
Global nobutton1 = CreateImage(30,20) Dim no(29,19) Data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,1,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,1,0,0,1,1,0,1,0,0,1,1,1,0,0,1,1,1,0,1,1,1,0,1,1,0,0,2 Data 2,0,0,1,0,0,1,1,0,1,0,1,1,0,1,1,0,0,1,1,0,0,1,1,1,1,1,0,0,2 Data 2,0,0,1,0,0,0,1,1,1,0,1,1,1,1,1,0,0,1,1,0,0,1,1,0,1,1,0,0,2 Data 2,0,0,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,1,0,0,1,1,0,1,1,0,0,2 Data 2,0,0,1,0,0,0,0,1,1,0,1,1,0,0,1,0,0,1,1,0,0,1,1,0,1,1,0,0,2 Data 2,0,1,1,1,0,0,0,0,1,0,0,1,1,1,0,0,1,1,1,1,1,1,1,0,1,1,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 Data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 Data 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
For y = 0 To 19 For x = 0 To 29 Read no(x,y) Next Next
SetBuffer ImageBuffer(nobutton1) For y = 0 To 19 For x = 0 To 29 If no(x,y) = 0 Then Color 255,255,255 If no(x,y) = 1 Then Color 0,0,0 If no(x,y) = 2 Then Color 255,0,0 Plot x,y Next Next
Global nobutton2 = CreateImage(30,20) SetBuffer ImageBuffer(nobutton2) For y = 0 To 19 For x = 0 To 29 If no(x,y) = 0 Then Color 0,0,0 If no(x,y) = 1 Then Color 255,255,255 If no(x,y) = 2 Then Color 255,0,0 Plot x,y Next Next
Global scrolldown =CreateImage(20,20)
MaskImage scrolldown,255,255,255
Dim scrolldownbutton(19,19) Data 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1 Data 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1 Data 0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,0 Data 0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,0 Data 0,0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,0,0 Data 0,0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,0,0 Data 0,0,0,1,2,2,2,2,2,2,2,2,2,2,2,2,1,0,0,0 Data 0,0,0,1,2,2,2,2,2,2,2,2,2,2,2,2,1,0,0,0 Data 0,0,0,0,1,2,2,2,2,2,2,2,2,2,2,1,0,0,0,0 Data 0,0,0,0,1,2,2,2,2,2,2,2,2,2,2,1,0,0,0,0 Data 0,0,0,0,0,1,2,2,2,2,2,2,2,2,1,0,0,0,0,0 Data 0,0,0,0,0,1,2,2,2,2,2,2,2,2,1,0,0,0,0,0 Data 0,0,0,0,0,0,1,2,2,2,2,2,2,1,0,0,0,0,0,0 Data 0,0,0,0,0,0,1,2,2,2,2,2,2,1,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,1,2,2,2,2,1,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,1,2,2,2,2,1,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,1,2,2,1,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,1,2,2,1,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0
For y= 0 To 19 For x= 0 To 19 Read scrolldownbutton(x,y) Next Next
SetBuffer ImageBuffer(scrolldown) For y = 0 To 19 For x = 0 To 19 If scrolldownbutton(x,y) = 0 Then Color 255,255,255 If scrolldownbutton(x,y) = 1 Then Color 255,255,255 If scrolldownbutton(x,y) = 2 Then Color 255,255,0 Plot x,y Next Next
Global scrollup = CreateImage(20,20)
MaskImage scrollup,255,255,255
Dim scrollupbutton(19,19) Data 0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,1,2,2,1,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,0,1,2,2,1,0,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,1,2,2,2,2,1,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,0,1,2,2,2,2,1,0,0,0,0,0,0,0 Data 0,0,0,0,0,0,1,2,2,2,2,2,2,1,0,0,0,0,0,0 Data 0,0,0,0,0,0,1,2,2,2,2,2,2,1,0,0,0,0,0,0 Data 0,0,0,0,0,1,2,2,2,2,2,2,2,2,1,0,0,0,0,0 Data 0,0,0,0,0,1,2,2,2,2,2,2,2,2,1,0,0,0,0,0 Data 0,0,0,0,1,2,2,2,2,2,2,2,2,2,2,1,0,0,0,0 Data 0,0,0,0,1,2,2,2,2,2,2,2,2,2,2,1,0,0,0,0 Data 0,0,0,1,2,2,2,2,2,2,2,2,2,2,2,2,1,0,0,0 Data 0,0,0,1,2,2,2,2,2,2,2,2,2,2,2,2,1,0,0,0 Data 0,0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,0,0 Data 0,0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,0,0 Data 0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,0 Data 0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,0 Data 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1 Data 1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
For y = 0 To 19 For x = 0 To 19 Read scrollupbutton(x,y) Next Next
SetBuffer ImageBuffer(scrollup) For y = 0 To 19 For x = 0 To 19 If scrollupbutton(x,y) = 0 Then Color 255,255,255 If scrollupbutton(x,y) = 1 Then Color 255,255,255 If scrollupbutton(x,y) = 2 Then Color 255,255,0 Plot x,y Next Next
Global mausbutton = CreateImage(20,20) SetBuffer ImageBuffer (mausbutton) Line 10,0,10,20 Line 0,10,20,10
Global rot = 200 Global blau =200 Global gruen = 200
Global rahmen_rot = 255 Global rahmen_gruen Global rahmen_blau
Global rahmen = True
Global mausx Global mausy
x= 100:y= 100
SetBuffer BackBuffer()
Repeat Cls
mausx = MouseX() mausy = MouseY() DrawImage mausbutton,Mausx,Mausy rot = scrollfeld(800,20,rot,0,255,"Rot") gruen = scrollfeld(875,20,gruen,0,255,"Grün") blau = scrollfeld(950,20,blau,0,255,"Blau") rahmen_rot = scrollfeld(800,200,rahmen_rot,0,255,"Rot") rahmen_gruen = scrollfeld(875,200,rahmen_gruen,0,255,"Grün") rahmen_blau = scrollfeld(950,200,rahmen_blau,0,255,"Blau") rahmen = janeinfeld(800,150,rahmen,"Rahmen") texturmalen() Flip Until KeyHit(1)
Function scrollfeld(x,y,variable,min,max,ueberschrift$)
DrawImage scrollup,x+15,y DrawImage scrolldown,x+15,y+50 Color 255,255,255 Rect x,y+25,50,20
Color 155,155,155 If MouseDown(1) If ImagesCollide(mausbutton,mausx,mausy,0,scrollup,x+15,y,0) Then variable = variable +1 If ImagesCollide(mausbutton,mausx,mausy,0,scrolldown,x+15,y+50,0) Then variable = variable -1 EndIf
If variable > max Then variable = min If variable < min Then variable = max
Text x,y-15,ueberschrift Text x,y+25,variable Return variable End Function
Function janeinfeld(x,y,variable,ueberschrift$)
If variable = True DrawImage yesbutton2,x,y+15 DrawImage nobutton1,x+45,y+15 If ImagesCollide(mausbutton,mausx,mausy,0,nobutton1,x+45,y+15,0) And MouseHit(1) Then variable = False EndIf
If variable = False DrawImage yesbutton1,x,y+15 DrawImage nobutton2,x+45,y+15 If ImagesCollide(mausbutton,mausx,mausy,0,yesbutton1,x,y+15,0) And MouseHit(1) Then variable = True EndIf Text x,y,ueberschrift Return variable End Function
Function texturmalen() Color rot,gruen,blau Rect 448,320,128,128
If rahmen = True Color rahmen_rot,rahmen_gruen,rahmen_blau Rect 448,320,128,128,0 Rect 447,319,130,130,0 EndIf
End Function
|