Zecihen mit Maus!

Übersicht BlitzBasic Allgemein

Neue Antwort erstellen

Ironstorm

Erstklassiger Contest-Veranstalter

Betreff: Zecihen mit Maus!

BeitragMo, Nov 21, 2005 15:30
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi @ all!

Weiß jemand ob es geht das man mit der Maus einen Kreis z.b. macht und das es dann vonn BB erkannt wird.

Also wie in Black and White 1/2.

Gibts da irgendwie was?

THX im vorraus.

Blitzmaker
..:: blackbird design : blackbird photography : Futuro Verde : X-Commander ::..
MacBook | Intel Core 2 Duo 2,1 GHz | 2048 MB RAM | 80 GB HDD | Mac OS X 10.6.2 (Snow Leopard) | Adobe CS4 Design Premium

skey-z

BeitragMo, Nov 21, 2005 20:20
Antworten mit Zitat
Benutzer-Profile anzeigen
Hab dir mal ein kleines Beispiel geschrieben, was dir als Grundlage dienen kann, funktioniert noch nihct perfekt, aber das Prinzip sollte es dir erlauben daraus etwas zu machen

BlitzBasic: [AUSKLAPPEN]

Graphics 800, 600
SetBuffer BackBuffer()

Type kreis
Field x%, y%
Field radius#
End Type

Repeat

Cls

mx=MouseX()
my=MouseY()

mh1=MouseHit(1)
md1=MouseDown(1)

If md1 Then
k.kreis = New kreis
k\x=mx
k\y=my

k.kreis = Last kreis

wegx=Abs(k\x-x)
wegy=Abs(k\y-y)

weg=Sqr(wegx^2+wegy^2)

k\radius=weg
EndIf

For k.kreis=Each kreis

For winkel=0 To 359
Rect k\x+Sin(winkel)*k\radius, k\y+Cos(winkel)*k\radius, 1,1
Next

Next

Rect mx-1,my-1,3,3

Flip

Until KeyHit(1)

For k.kreis = Each kreis
Delete k.kreis
Next

End


für Verbesserungen habe ich auch ein offenes ohr, möchte auch wissen, was da noch nicht richtig läuft.
Awards:
Coffee's Monatswettbewerb Feb. 08: 1. Platz
BAC#57: 2. Platz
Twitter

SoNenTyp

BeitragMo, Nov 21, 2005 20:24
Antworten mit Zitat
Benutzer-Profile anzeigen
Glaube er meint das anders.
Du zeichnest einen Kreis und das Programm soll erkennen das es einer ist. Das ganze später natürlich noch mit anderen Figuren.
Gruss Der Typ.

User posted image

skey-z

BeitragMo, Nov 21, 2005 22:42
Antworten mit Zitat
Benutzer-Profile anzeigen
jo jetzt wo du es sagst, ist mir beim 2. durchlesen jetzt auch aufgefallen.

vlt sollte er sich dann noch etwas geauer ausdrücken, wie er es meint
Awards:
Coffee's Monatswettbewerb Feb. 08: 1. Platz
BAC#57: 2. Platz
Twitter

SpionAtom

BeitragDi, Nov 22, 2005 2:13
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich hab auch mal was probiert.
Zunächst berechne ich den Mittelpunkt (zumindest den geahnten Mittelpunkt).
Und dann den Radius. Schon habe ich einen geahnten Kreis
Den muss ich lediglich mit letzten Mauskoordinaten abgleichen. Ein wenig Toleranz und - tadaa - fertig ist die Kreisabfrage. Sicher auch noch verbesserungswürdig, aber ist schon spät, also müsst ihr das selber machen.
Wink

Code: [AUSKLAPPEN]

;Mausgesten
;heute: Kreis
;von SpionAtom
Const xr = 800, yr = 600
Graphics xr, yr, 16, 2
SetBuffer BackBuffer()

;Hier werden die Mauskoordinaten gespeichert
Type MP
   Field x
   Field y
End Type
Local MP.MP
   

   toleranz = 20
   doGeste = 0

   Repeat
   
      If doGeste = 0 And MouseDown(1) Then doGeste = 1: Delete Each MP
      If Not MouseDown(1) Then doGeste = 0
      If doGeste = 1 Then
         MP = New MP
         MP\x = MouseX()
         MP\y = MouseY()
      End If
      toleranz = toleranz + MouseZSpeed(): If toleranz < 1 Then toleranz = 1

      ;Kreis erahnen
      minx = xr:   miny = yr:   maxx = 0:maxy = 0
      For MP = Each MP
         If MP\x < minx Then minx = MP\x
         If MP\y < miny Then miny = MP\y
         If MP\x > maxx Then maxx = MP\x
         If MP\y > maxy Then maxy = MP\y
      Next
      radius = ((maxx-minx) + (maxy-miny)) / 4
      mittex = (minx+maxx)/2: mittey = (miny+maxy)/2

      ;Geste prüfen auf Kreis
      gefunden = True
      For MP = Each MP
         If quad(MP\x-mittex) + quad(MP\y-mittey) > quad(radius + toleranz) Or quad(MP\x-mittex) + quad(MP\y-mittey) < quad(radius - toleranz) Then
               gefunden = False
         End If
      Next

            
      ;völlig überladene Ausgabe
      Cls   
      Color 25, 25, 0
      Oval 300, 200, 200, 200, 1
      Color 255, 255,255
      Oval mittex - (radius+toleranz), mittey - (radius+toleranz), 2 * (radius+toleranz), 2 * (radius+toleranz), 0
      Oval mittex - (radius-toleranz), mittey - (radius-toleranz), 2 * (radius-toleranz), 2 * (radius-toleranz), 0
      Line minx, 0, minx, yr: Line maxx, 0, maxx, yr: Line 0, miny, xr, miny: Line 0, maxy, xr, maxy
      Text 0, 0, "Links klicken, um Geste zu vollführen"
      Text 0, 20, "Toleranz " + toleranz +  " (Mausrad zum ändern)"
      Text 0, 40, "Gefunden " + gefunden + " (1 = ja, 0 = nein)"
      Color 0, 255, 0
      Oval mittex - 5, mittey - 5, 10, 10
      Color 0, 0, 255
      Line mittex, mittey, mittex-radius, mittey
      
      
      Color 255, 0, 0
      For MP = Each MP
         Oval MP\x - 2, MP\y - 2, 4, 4
      Next
      
      
      Flip()
   Until KeyDown(1)
   End
   

Function quad(n)
   Return n * n
End Function

Neue Antwort erstellen


Übersicht BlitzBasic Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group