Windwomover V1.0

  • Hi mir ist eingefallen , dass ich noch ein kleines Spiel hatte
    ich poste mal den source vor den 2 wichtigsten teilen, denn es besteht 4skripten, da ich früher ja noch ein anfänger war aber egal hier der code

    Spoiler anzeigen

    Blaue Version

    [autoit]

    #include <GUIConstants.au3>
    #include <WindowsConstants.au3>
    #include <StaticConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Hotkeyset ("{UP}", "_WinMovehoch")
    Hotkeyset ("{DOWN}", "_WinMoverunter")
    Hotkeyset ("{LEFT}", "_WinMovelinks")
    Hotkeyset ("{RIGHT}", "_WinMoverechts")
    Hotkeyset ("{m}", "_WinMovemitte")
    Hotkeyset ("{ESC}", "_ende")

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $xpos = Random(5, 500, 1)
    Until Not Mod($xpos, 30)

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $ypos = Random(5, 500, 1)
    Until Not Mod($ypos, 30)

    [/autoit] [autoit][/autoit] [autoit]

    $gui = GUICreate("Windowmover V 1.0", 230, 210, $xpos, $ypos, -1, 0x8)
    GUISetBkColor(0x0)
    $mitteblau = GuiCtrlCreatePic("Bilddatein\mitteblau.gif",93,90,45,30)
    $bhoch1 = GuiCtrlCreatePic("Bilddatein\bhoch1.gif",100,10,30,50)
    $brunter1 = GuiCtrlCreatePic("Bilddatein\brunter1.gif",100,150,30,50)
    $blinks1 = GuiCtrlCreatePic("Bilddatein\blinks1.gif",15,86,50,33)
    $brechts1 = GuiCtrlCreatePic("Bilddatein\brechts1.gif",160,86,50,33)
    $exit = GUICtrlCreateLabel("Exit",10,180,80,20)
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetFont(-1, 12, 400, 1, "Arial")
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $xpos = Random(5, 500, 1)
    Until Not Mod($xpos, 30)

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $ypos = Random(5, 500, 1)
    Until Not Mod($ypos, 30)
    $gui2 = GUICreate("Krieg mich!", 230, 210, $xpos, $ypos)
    GUISetBkColor(0x0)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    $gui3 = GUICreate("Punktzahl", 130, 70, 50, 50)
    GUISetBkColor(0x0)
    $punktzahl = 0
    $punktelabel = GUICtrlCreateLabel("Deine Punktzahl" & @CRLF & "ist:" & $punktzahl,10,10,150,30)
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetFont(-1, 11, 400, 1, "Arial")
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(10)
    $msg = GUIGetMsg()

    [/autoit] [autoit][/autoit] [autoit]

    Select
    Case $msg = $bhoch1
    _WinMovehoch()
    Case $msg = $brunter1
    _WinMoverunter()
    Case $msg = $blinks1
    _WinMovelinks()
    Case $msg = $brechts1
    _WinMoverechts()
    Case $msg = $mitteblau
    _WinMovemitte()
    Case $msg = $exit
    Exit
    EndSelect
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _Ende()
    Exit
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _WinMovehoch()
    _DeSelectAll()
    GUICtrlSetImage($bhoch1, "Bilddatein\bhoch2.gif")
    $pos = WinGetPos("Windowmover V 1.0")
    WinMove("Windowmover V 1.0", "", $pos[0], $pos[1] -30)
    _Check()
    EndFunc

    Func _WinMoverunter()
    _DeSelectAll()
    GUICtrlSetImage($brunter1, "Bilddatein\brunter2.gif")
    $pos = WinGetPos("Windowmover V 1.0")
    WinMove("Windowmover V 1.0", "", $pos[0], $pos[1] + 30)
    _Check()
    EndFunc

    Func _WinMovelinks()
    _DeSelectAll()
    GUICtrlSetImage($blinks1, "Bilddatein\blinks2.gif")
    $pos = WinGetPos("Windowmover V 1.0")
    WinMove("Windowmover V 1.0", "", $pos[0] -30 , $pos[1])
    _Check()
    EndFunc

    Func _WinMoverechts()
    _DeSelectAll()
    GUICtrlSetImage($brechts1, "Bilddatein\brechts2.gif")
    $pos = WinGetPos("Windowmover V 1.0")
    WinMove("Windowmover V 1.0", "", $pos[0] +30 , $pos[1])
    _Check()
    EndFunc

    Func _WinMovemitte()
    _DeSelectAll()
    $pos = WinGetPos("Windowmover V 1.0")
    WinMove("Windowmover V 1.0", "", 370, 220)
    _Check()
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _DeSelectAll()
    GUICtrlSetImage($bhoch1, "Bilddatein\bhoch1.gif")
    GUICtrlSetImage($brunter1, "Bilddatein\brunter1.gif")
    GUICtrlSetImage($blinks1, "Bilddatein\blinks1.gif")
    GUICtrlSetImage($brechts1, "Bilddatein\brechts1.gif")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _Check()
    $Pos1 = WinGetPos("Windowmover V 1.0")
    $Pos2 = WinGetPos("Krieg mich!")
    If $Pos1[0] = $Pos2[0] And $Pos1[1] = $Pos2[1] Then
    $punktzahl += 1
    GUISwitch($gui3)
    GUICtrlSetData($punktelabel,"Deine Punktzahl" & @CRLF & "ist:" & $punktzahl)
    GUISetState(@SW_HIDE, $gui2)

    Do
    $xpos = Random(5, 500, 1)
    Until Not Mod($xpos, 30)

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $ypos = Random(5, 500, 1)
    Until Not Mod($ypos, 30)

    $gui2 = GUICreate("Krieg mich!", 230, 210, $xpos, $ypos)
    GUISetBkColor(0x0)
    GUISetState(@SW_SHOW)
    EndIf
    EndFunc

    [/autoit]
    Spoiler anzeigen

    Rote Version

    [autoit]

    #include <GUIConstants.au3>
    #include <WindowsConstants.au3>
    #include <StaticConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Hotkeyset ("{UP}", "_WinMovehoch")
    Hotkeyset ("{DOWN}", "_WinMoverunter")
    Hotkeyset ("{LEFT}", "_WinMovelinks")
    Hotkeyset ("{RIGHT}", "_WinMoverechts")
    Hotkeyset ("{m}", "_WinMovemitte")
    Hotkeyset ("{ESC}", "_ende")

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $xpos = Random(5, 500, 1)
    Until Not Mod($xpos, 30)

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $ypos = Random(5, 500, 1)
    Until Not Mod($ypos, 30)

    [/autoit] [autoit][/autoit] [autoit]

    $gui = GUICreate("Windowmover V 1.0", 230, 210, $xpos, $ypos, -1, 0x8)
    GUISetBkColor(0x0)
    $mitterot = GuiCtrlCreatePic("Bilddatein\mitterot.gif",93,90,45,30)
    $rhoch1 = GuiCtrlCreatePic("Bilddatein\rhoch1.gif",100,10,30,50)
    $rrunter1 = GuiCtrlCreatePic("Bilddatein\rrunter1.gif",100,150,30,50)
    $rlinks1 = GuiCtrlCreatePic("Bilddatein\rlinks1.gif",15,86,50,33)
    $rrechts1 = GuiCtrlCreatePic("Bilddatein\rrechts1.gif",160,86,50,33)
    $exit = GUICtrlCreateLabel("Exit",10,180,80,20)
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetFont(-1, 12, 400, 1, "Arial")
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $xpos = Random(5, 500, 1)
    Until Not Mod($xpos, 30)

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $ypos = Random(5, 500, 1)
    Until Not Mod($ypos, 30)
    $gui2 = GUICreate("Krieg mich!", 230, 210, $xpos, $ypos)
    GUISetBkColor(0x0)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    $gui3 = GUICreate("Punktzahl", 130, 70, 50, 50)
    GUISetBkColor(0x0)
    $punktzahl = 0
    $punktelabel = GUICtrlCreateLabel("Deine Punktzahl" & @CRLF & "ist:" & $punktzahl,10,10,150,30)
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetFont(-1, 11, 400, 1, "Arial")
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(10)
    $msg = GUIGetMsg()

    [/autoit] [autoit][/autoit] [autoit]

    Select
    Case $msg = $rhoch1
    _WinMovehoch()
    Case $msg = $rrunter1
    _WinMoverunter()
    Case $msg = $rlinks1
    _WinMovelinks()
    Case $msg = $rrechts1
    _WinMoverechts()
    Case $msg = $mitterot
    _WinMovemitte()
    Case $msg = $exit
    Exit
    EndSelect
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _Ende()
    Exit
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _WinMovehoch()
    _DeSelectAll()
    GUICtrlSetImage($rhoch1, "Bilddatein\rhoch2.gif")
    $pos = WinGetPos("Windowmover V 1.0")
    WinMove("Windowmover V 1.0", "", $pos[0], $pos[1] -30)
    _Check()
    EndFunc

    Func _WinMoverunter()
    _DeSelectAll()
    GUICtrlSetImage($rrunter1, "Bilddatein\rrunter2.gif")
    $pos = WinGetPos("Windowmover V 1.0")
    WinMove("Windowmover V 1.0", "", $pos[0], $pos[1] + 30)
    _Check()
    EndFunc

    Func _WinMovelinks()
    _DeSelectAll()
    GUICtrlSetImage($rlinks1, "Bilddatein\rlinks2.gif")
    $pos = WinGetPos("Windowmover V 1.0")
    WinMove("Windowmover V 1.0", "", $pos[0] -30 , $pos[1])
    _Check()
    EndFunc

    Func _WinMoverechts()
    _DeSelectAll()
    GUICtrlSetImage($rrechts1, "Bilddatein\rrechts2.gif")
    $pos = WinGetPos("Windowmover V 1.0")
    WinMove("Windowmover V 1.0", "", $pos[0] +30 , $pos[1])
    _Check()
    EndFunc

    Func _WinMovemitte()
    _DeSelectAll()
    $pos = WinGetPos("Windowmover V 1.0")
    WinMove("Windowmover V 1.0", "", 370, 220)
    _Check()
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _DeSelectAll()
    GUICtrlSetImage($rhoch1, "Bilddatein\rhoch1.gif")
    GUICtrlSetImage($rrunter1, "Bilddatein\rrunter1.gif")
    GUICtrlSetImage($rlinks1, "Bilddatein\rlinks1.gif")
    GUICtrlSetImage($rrechts1, "Bilddatein\rrechts1.gif")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _Check()
    $Pos1 = WinGetPos("Windowmover V 1.0")
    $Pos2 = WinGetPos("Krieg mich!")
    If $Pos1[0] = $Pos2[0] And $Pos1[1] = $Pos2[1] Then
    $punktzahl += 1
    GUISwitch($gui3)
    GUICtrlSetData($punktelabel,"Deine Punktzahl" & @CRLF & "ist:" & $punktzahl)
    GUISetState(@SW_HIDE, $gui2)

    Do
    $xpos = Random(5, 500, 1)
    Until Not Mod($xpos, 30)

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $ypos = Random(5, 500, 1)
    Until Not Mod($ypos, 30)

    $gui2 = GUICreate("Krieg mich!", 230, 210, $xpos, $ypos)
    GUISetBkColor(0x0)
    GUISetState(@SW_SHOW)
    EndIf
    EndFunc

    [/autoit]

    :)
    Alle Skripte und die bilder gibts im anhang

  • Also....von der Idee her nicht schlecht, jedoch find ich ist da noch was rauszuholen.
    Zueinem Grafisch, versuchs mal mit GDI+...
    Zum anderern ist die Steuerung noch nicht so perfekt, wenn man die Pfeiltaste (Tastatur) angeschlagen lässt, dann bewegt sich das Fenster nicht, sondern erst wenn man die Taste loslässt.
    :)

  • ey ich wollte nur mal ein altes skript reinstellen, was ich als anfänger geschrieben hab und da kannte ich das halt noch nicht
    und zu den tasten: bei mir muss ich sie nicht erst loslassen damit er "movt".

    [autoit]


    Func Ulam($n)
    Return 1
    EndFunc

    [/autoit]


    Rekursion FTW :D