Laubsaugersimulation
Übersicht

![]() |
Horst der BiberBetreff: Laubsaugersimulation |
![]() Antworten mit Zitat ![]() |
---|---|---|
Code: [AUSKLAPPEN] Const cgb=640,cgh=480
Const cblobcount=100 Const cblobsize=16 Const cbodengrip:float=1.1 Const cstaerke:float=5 Type tspiel Field staubsauger:tstaubsauger Field blobliste:TList=new TList Method init() staubsauger=new tstaubsauger.create(cstaerke) For i=0 To cblobcount blobliste.addlast(tblob.create(Rnd(0,cgb),Rnd(0,cgh))) Next End Method Method update() staubsauger.update() For b:tblob=eachin blobliste b.update() Next End Method Method draw() For b:tblob=eachin blobliste b.draw() Next End Method End Type Type tblob Field x:float,y:float,richtung:float,speed:float Method update() speed:/cbodengrip speed:/cbodengrip x:+speed*Sin(richtung) y:-speed*Cos(richtung) End Method Method draw() SetColor 0,160,230 DrawOval x-cblobsize/2,y-cblobsize/2,cblobsize,cblobsize End Method Function create:tblob(x:float,y:float) created:tblob=new tblob created.x=x created.y=y Return created End Function End Type Type tstaubsauger Field staerke:float Method update() If MouseDown(MOUSE_LEFT) Then saugen(MouseX(),MouseY()) EndIf If MouseDown(MOUSE_RIGHT) Then pusten(MouseX(),MouseY()) EndIf End Method Function create:tstaubsauger(staerke:float) created:tstaubsauger=new tstaubsauger created.staerke=staerke Return created End Function Method saugen(x,y) For b:tblob=eachin spiel.blobliste b.richtung=getangle(x,y,b.x,b.y)+180 b.speed:+staerke Next End Method Method pusten(x,y) For b:tblob=eachin spiel.blobliste b.richtung=getangle(x,y,b.x,b.y) b.speed:+staerke Next End Method End Type Graphics cgb,cgh,0,60 SetClsColor 255,255,255 Global spiel:tspiel=new tspiel spiel.init() Repeat spiel.update() Cls spiel.draw() Flip Until KeyHit(KEY_ESCAPE) End Function GetAngle:float(x1:float,y1:float,x2:float,y2:float) Local ax:float=x2-x1 Local ay:float=y1-y2 'keine ahnung warum... Return ATan2(ax,ay) End Function |
||
![]() |
rema |
![]() Antworten mit Zitat ![]() |
---|---|---|
Wäre schön wenn du eine Einleitung zum Code geben könntest, auch wenn es nur eine Spielerrei ist... | ||
![]() |
Horst der Biber |
![]() Antworten mit Zitat ![]() |
---|---|---|
ja gut mach ich das ma
also es gibt halt 3 types: das spiel, das alles verwaltet, den staubsauger, der 2 funktionen hat: saugen und pusten, und dann noch die blobs, die vom staubsauger angesaugt oder weggepustet werden können. cbodengrip darf nich 0 sein sonst läuft das ding nich. am besten ist so 1-2 viel spaß |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group