Verfasst: 14.11.2008 08:02
Oder: "Schatz, hol mir mal bitte die Heliumflasche"...hardfalcon hat geschrieben:"Schatz, hol mir mal bitte die Fahradpumpe"...
SCNR

Hat einen weiteren Vorteil.

Das deutsche PureBasic-Forum
https://www.purebasic.fr/german/
Oder: "Schatz, hol mir mal bitte die Heliumflasche"...hardfalcon hat geschrieben:"Schatz, hol mir mal bitte die Fahradpumpe"...
SCNR
Code: Alles auswählen
;
;
Enumeration
#Window_0
EndEnumeration
Enumeration
#Image_0
#Image_1
#Button_Bounce
#Button_1
EndEnumeration
Image0=CreateImage(#PB_Any,130,260)
Image1=CreateImage(#PB_Any,130,260)
Macro ball(cx,cy)
Circle(cx,cy,50,RGB(255,222,192))
EndMacro
Macro courtyard(cx,cy)
Circle(cx,cy,20,RGB(255,192,192))
EndMacro
Macro proboscis(cx,cy)
Circle(cx,cy,10,RGB(255,125,125))
EndMacro
Macro bball(bbx,bby,Im)
StartDrawing(ImageOutput(Im))
BackColor(#Magenta)
Box(0,0,260,260,#Magenta)
DrawingMode(#PB_2DDrawing_Transparent)
by=bby
ball(bbx,by)
by+10
courtyard(bbx,by)
proboscis(bbx,by)
StopDrawing()
EndMacro
bball(65,130,Image0)
bball(65,130,Image1)
If OpenWindow(#Window_0, 237, 45, 600, 300, "Bouncing Balls", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
ImageGadget(#Image_0, 0, 0, 130, 260, ImageID(Image0))
ImageGadget(#Image_1, 130, 0, 130, 260, ImageID(Image1))
ButtonGadget(#Button_Bounce, 310, 50, 200, 20, "let's bounce",#PB_Button_Toggle)
ButtonGadget(#Button_1, 310, 80, 200, 20, "got enough")
EndIf
EndIf
x1=Random(360)
x2=Random(360)
Repeat
Event = WaitWindowEvent(50)
WindowID = EventWindow()
GadgetID = EventGadget()
EventType = EventType()
If Event = #PB_Event_Gadget
If GadgetID = #Image_0
ElseIf GadgetID = #Button_Bounce
Debug "p"
Select GetGadgetState(#Button_bounce)
Case 1:SetGadgetText(#Button_bounce,"bouncing")
Case 0:SetGadgetText(#Button_bounce,"let's bounce")
EndSelect
ElseIf GadgetID = #Button_1
End
EndIf
EndIf
If GetGadgetState(#Button_Bounce)
x1+1
x2+1
bball(65,Sin(x1)*15+130,Image0)
bball(65,Sin(x2)*15+130,Image1)
SetGadgetState(#image_0,ImageID(Image0))
SetGadgetState(#image_1,ImageID(Image1))
If x2>360
x2=0
EndIf
If x1>360
x1=0
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
End
Code: Alles auswählen
;
;
Enumeration
#Window_0
EndEnumeration
Enumeration
#Image_0
#Image_1
#Button_Bounce
#Button_1
EndEnumeration
Image0=CreateImage(#PB_Any,130,260)
Image1=CreateImage(#PB_Any,130,260)
Macro ball(cx,cy)
Circle(cx,cy,50,RGB(255,222,192))
EndMacro
Macro courtyard(cx,cy)
Circle(cx,cy,20,RGB(255,192,192))
EndMacro
Macro proboscis(cx,cy)
Circle(cx,cy,10,RGB(255,125,125))
EndMacro
Macro bball(bbx,bby,Im)
StartDrawing(ImageOutput(Im))
;BackColor(#Magenta)
Box(0,0,260,260,#Magenta)
DrawingMode(#PB_2DDrawing_Transparent)
by=bby
ball(bbx,by)
by+10
courtyard(bbx,by)
proboscis(bbx,by)
StopDrawing()
EndMacro
bball(65,130,Image0)
bball(65,130,Image1)
If OpenWindow(#Window_0, 237, 45, 600, 300, "Bouncing Balls", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
ImageGadget(#Image_0, 0, 0, 130, 260, ImageID(Image0))
ImageGadget(#Image_1, 130, 0, 130, 260, ImageID(Image1))
ButtonGadget(#Button_Bounce, 310, 50, 200, 20, "let's bounce",#PB_Button_Toggle)
ButtonGadget(#Button_1, 310, 80, 200, 20, "got enough")
EndIf
EndIf
x1=Random(360)
x2=Random(360)
Repeat
Event = WaitWindowEvent(50)
WindowID = EventWindow()
GadgetID = EventGadget()
EventType = EventType()
Debug event
If Event = #PB_Event_Gadget
If GadgetID = #Image_0
ElseIf GadgetID = #Button_Bounce
Debug "p"
Select GetGadgetState(#Button_bounce)
Case 1:SetGadgetText(#Button_bounce,"bouncing")
Case 0:SetGadgetText(#Button_bounce,"let's bounce")
EndSelect
ElseIf GadgetID = #Button_1
End
EndIf
EndIf
If GetGadgetState(#Button_Bounce)
If event<>512
x1+1
x2+1
x1p=Sin(x1)*2+130
x2p=Sin(x2)*2+130
bball(65,x1p,Image0)
bball(65,x2p,Image1)
SetGadgetState(#image_0,ImageID(Image0))
SetGadgetState(#image_1,ImageID(Image1))
If x2>360
x2=0
EndIf
If x1>360
x1=0
EndIf
EndIf
If event=512
x1+1
x2+1
bball(Sin(x1)*2+65,x1p,Image0)
bball(Sin(x2)*2+65,x2p,Image1)
SetGadgetState(#image_0,ImageID(Image0))
SetGadgetState(#image_1,ImageID(Image1))
If x2>360
x2=0
EndIf
If x1>360
x1=0
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
End
Code: Alles auswählen
;
;
Enumeration
#Window_0
EndEnumeration
Enumeration
#Image_0
#Image_1
#Button_Bounce
#Button_1
EndEnumeration
Image0=CreateImage(#PB_Any,130,260)
Image1=CreateImage(#PB_Any,130,260)
Macro ball(cx,cy)
Circle(cx,cy,50,RGB(255,222,192))
EndMacro
Macro courtyard(cx,cy)
Circle(cx,cy,20,RGB(255,192,192))
EndMacro
Macro proboscis(cx,cy)
Circle(cx,cy,10,RGB(255,125,125))
EndMacro
Macro bball(bbx,bby,Im,v)
StartDrawing(ImageOutput(Im))
;BackColor(#Magenta)
Box(0,0,260,260,#Magenta)
DrawingMode(#PB_2DDrawing_Transparent)
by=bby
ball(bbx,by)
by+10
courtyard(bbx+v*8,by)
proboscis(bbx+v*9,by)
StopDrawing()
EndMacro
bball(65,130,Image0,-1)
bball(65,130,Image1,1)
If OpenWindow(#Window_0, 237, 45, 600, 300, "Bouncing Balls", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
ImageGadget(#Image_0, 0, 0, 130, 260, ImageID(Image0))
ImageGadget(#Image_1, 130, 0, 130, 260, ImageID(Image1))
ButtonGadget(#Button_Bounce, 310, 50, 200, 20, "let's bounce",#PB_Button_Toggle)
ButtonGadget(#Button_1, 310, 80, 200, 20, "got enough")
EndIf
EndIf
x1=Random(360)
x2=Random(360)
Repeat
Event = WaitWindowEvent(50)
WindowID = EventWindow()
GadgetID = EventGadget()
EventType = EventType()
Debug event
If Event = #PB_Event_Gadget
If GadgetID = #Image_0
ElseIf GadgetID = #Button_Bounce
Debug "p"
Select GetGadgetState(#Button_bounce)
Case 1:SetGadgetText(#Button_bounce,"bouncing")
Case 0:SetGadgetText(#Button_bounce,"let's bounce")
EndSelect
ElseIf GadgetID = #Button_1
End
EndIf
EndIf
If GetGadgetState(#Button_Bounce)
If event<>512
x1+1
x2+1
x1p=Sin(x1)*5+130
x2p=Sin(x2)*5+130
bball(65,x1p,Image0,-1)
bball(65,x2p,Image1,1)
SetGadgetState(#image_0,ImageID(Image0))
SetGadgetState(#image_1,ImageID(Image1))
If x2>360
x2=0
EndIf
If x1>360
x1=0
EndIf
EndIf
If event=512
x1+1
x2+1
bball(Sin(x1)*5+65,x1p,Image0,-1)
bball(Sin(x2)*5+65,x2p,Image1,1)
SetGadgetState(#image_0,ImageID(Image0))
SetGadgetState(#image_1,ImageID(Image1))
If x2>360
x2=0
EndIf
If x1>360
x1=0
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
End