Bal volgt cursor

Originele schrijvers mogen hier hun eigen code Public Domain maken.

Bal volgt cursor

Berichtdoor Gordon » zo aug 07, 2005 12:41 pm

Hallo Allemaal,

Misschien hoort dit stuk verder veralgemeend te worden.
(start en stoppunt opgeven enz?)
Maar hiermee heb ik voorlopig iets voor deze rubriek.


Code: Selecteer alles
'follow the cursor

    nomainwin
    WindowWidth = 550
    WindowHeight = 410
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    graphicbox #m.g,   0,   0, 550, 410

    open "untitled" for window as #m
    #m.g, "down; fill blue; flush"
    #m.g, "when leftButtonDown [findMouse]"
    #m, "trapclose [quit.main]"

    startX = 150
    startY = 100
    #m.g, "color blue"
    #m.g, "place ";startX;" ";startY
    #m.g, "down"
    #m.g, "backcolor red"
    #m.g, "circlefilled 10"
    newX = startX
    newY = startY
    wait

[findMouse]
    if doubleClicked = 1 then wait
    doubleClicked = 1
    mX = MouseX :dX = (MouseX-startX)/200
    mY = MouseY :dY = (MouseY-startY)/200
[pcirc]
    'scan
    #m.g, "down"
    #m.g, "backcolor blue"
    #m.g, "circlefilled 10"
    if abs(newX-mX)>1 or abs(newY-mY)>1 then
    newX = newX + dX
    newY = newY + dY

    #m.g, "place ";newX;" ";newY
    #m.g, "down"
    #m.g, "backcolor red"
    #m.g, "circlefilled 10"
    for ti = 1 to 600 :next ti
    #m.g, "backcolor blue"
    #m.g, "circlefilled 10"
    goto [pcirc]
    end if
    #m.g, "backcolor red"
    #m.g, "circlefilled 10"
    startX = newX
    startY = newY
    doubleClicked = 0
    wait

[quit.main]
    close #m
    END




Succes.

Gordon
Avatar gebruiker
Gordon
Site Admin
 
Berichten: 684
Geregistreerd: zo mei 22, 2005 12:50 am

Keer terug naar Public Domain stukjes

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers. en 1 gast

cron