Verfasst: 24.11.2004 12:40
naja, gesachmacksfrage 
Das deutsche PureBasic-Forum
https://www.purebasic.fr/german/
Code: Alles auswählen
InitSprite()
InitMouse()
InitKeyboard()
OpenScreen(800,600,32,"")
Tim1.l
Tim2.l
Structure shoot
x.f
y.f
rx.w
ry.w
richtungx.f
richtungy.f
multi.f
farbe.l
EndStructure
NewList shoots.shoot()
For n=0 To 19
AddElement(shoots())
shoots()\x = 400
shoots()\y = 300
shoots()\farbe=Random($FFFFFF)
shoots()\richtungx = (MX-400)
shoots()\richtungy = (MY-300)
shoots()\multi = Sqr(Pow(speed,2)/(Pow(shoots()\richtungx,2)+Pow(shoots()\richtungy,2)))
shoots()\richtungx = shoots()\richtungx * shoots()\multi
shoots()\richtungy = shoots()\richtungy * shoots()\multi
Next
Tim1 = ElapsedMilliseconds()
For n= 0 To 1000000
StartDrawing(ScreenOutput())
ForEach Shoots()
Plot(Shoots()\x,Shoots()\y,Shoots()\Farbe)
Next
StopDrawing()
Next
Tim1 = ElapsedMilliseconds()-Tim1
Debug Tim1
Tim2 = ElapsedMilliseconds()
For n= 0 To 1000000
StartDrawing(ScreenOutput())
ForEach Shoots()
FrontColor(Red(shoots()\farbe), Green(shoots()\farbe), Blue(shoots()\farbe))
Plot(shoots()\x,shoots()\y) ;Circle(shoots()\x,shoots()\y,1,shoots()\farbe)
Next
StopDrawing()
Next
Tim2 = ElapsedMilliseconds()-Tim2
Debug Tim2
EndCode: Alles auswählen
InitSprite()
InitMouse()
InitKeyboard()
OpenScreen(800,600,32,"")
Global speed.f
speed = 5
Structure shoot
x.f
y.f
rx.w
ry.w
richtungx.f
richtungy.f
multi.f
farbe.l
EndStructure
NewList shoots.shoot()
Repeat
ExamineKeyboard()
ExamineMouse()
If MouseButton(1)
AddElement(shoots())
shoots()\x = 400
shoots()\y = 300
shoots()\farbe=Random($FFFFFF)
shoots()\richtungx = (MouseX()-400)
shoots()\richtungy = (MouseY()-300)
shoots()\multi = Sqr(Pow(speed,2)/(Pow(shoots()\richtungx,2)+Pow(shoots()\richtungy,2)))
shoots()\richtungx = shoots()\richtungx * shoots()\multi
shoots()\richtungy = shoots()\richtungy * shoots()\multi
EndIf
ForEach Shoots()
Shoots()\x + Shoots()\richtungx
Shoots()\y + Shoots()\richtungy
Shoots()\rx = Shoots()\x
Shoots()\ry = Shoots()\y
If Shoots()\x < 0 Or Shoots()\x > 800 Or Shoots()\y < 0 Or Shoots()\y > 600
DeleteElement(Shoots())
NextElement(Shoots())
EndIf
Next
StartDrawing(ScreenOutput())
Plot(MouseX(),MouseY(),RGB(255,0,100))
ForEach Shoots()
Plot(Shoots()\x,Shoots()\y,Shoots()\Farbe) ;Circle(Shoots()\x,Shoots()\y,1,Shoots()\Farbe)
Next
Circle(400,300,10,$FF0010)
StopDrawing()
FlipBuffers()
Delay(10)
ClearScreen(0,0,0)
Until KeyboardPushed(#pb_key_escape)
End