Hey Leute,
habe heute den ganzen Tag an einem kleinen Spiel gesessen und wollte mal Wissen was ihr davon haltet^^
Es hat noch einige Fehler xD
Ich beschäftige mich mit AutoIt seit etwa 1 Woche (vorher schon ne Zeit lang C++).
Hier das Script:
Spoiler anzeigen
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $pPos1 = 256
Global $pPos2 = 192
Global $gPos1 = 0
Global $gPos2 = 0
Global $hoehe = 32
Global $breite = 16
Global $richtung = 0
Global $anim = 1
Global $score = 0
Global $rnd[5]
$rnd[0] = 0
$rnd[1] = Random(1, 10, 1)
$rnd[2] = Random(1, 10, 1)
$rnd[3] = Random(1, 10, 1)
$rnd[4] = Random(1, 10, 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Spiel", 593, 487, 201, 126)
$scorelabel = GUICtrlCreateLabel ( "Punkte: " & $score, 15, 3, 200, 15)
$gold = GUICtrlCreatePic(@ScriptDir & "\Spiel BMP's\gold.bmp", $gPos1, $gPos2, 10, 10, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$player = GUICtrlCreatePic(@ScriptDir & "\Spiel BMP's\down.bmp", $pPos1, $pPos2, $breite, $hoehe, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
$pic = GUICtrlCreatePic(@ScriptDir & "\Spiel BMP's\grundflaeche.bmp", 0, 20, 593, 467, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$gPos1 = Random(6, 580, 1)
$gPos2 = Random(25, 460, 1)
GUICtrlSetPos($gold, $gPos1, $gPos2)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
If _isPressed (27) Then
_right()
ElseIf _isPressed (25) Then
_left()
ElseIf _isPressed (26) Then
_up()
ElseIf _isPressed (28) Then
_down()
Else
If $richtung = 1 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\left.bmp")
ElseIf $richtung = 2 Then
$hoehe = 32
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\right.bmp")
ElseIf $richtung = 3 Then
$hoehe = 32
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\up.bmp")
ElseIf $richtung = 4 Then
$hoehe = 32
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\down.bmp")
EndIf
EndIf
[/autoit] [autoit][/autoit] [autoit]If $pPos1 <= 5 Then
$pPos1 = 6
ElseIf $pPos2 <= 25 Then
$pPos2 = 26
ElseIf $pPos1 >= 571 Then
$pPos1 = 570
ElseIf $pPos2 >= 450 Then
$pPos2 = 449
EndIf
[/autoit] [autoit][/autoit] [autoit]If $pPos1 = $gPos1 And $pPos2 = $gPos2 Then
$score +=1
GUICtrlSetData($scorelabel, "Punkte: " & $score)
$gPos1 = Random(6, 580, 1)
$gPos2 = Random(25, 460, 1)
GUICtrlSetPos($gold, $gPos1, $gPos2)
ElseIf $pPos1 = ($gPos1+$rnd[1]) And $pPos2 = ($gPos2+$rnd[2]) Then
$score +=1
GUICtrlSetData($scorelabel, "Punkte: " & $score)
$gPos1 = Random(6, 580, 1)
$gPos2 = Random(25, 460, 1)
GUICtrlSetPos($gold, $gPos1, $gPos2)
ElseIf $pPos1 = ($gPos1-$rnd[1]) And $pPos2 = ($gPos2-$rnd[2]) Then
$score +=1
GUICtrlSetData($scorelabel, "Punkte: " & $score)
$gPos1 = Random(6, 580, 1)
$gPos2 = Random(25, 460, 1)
GUICtrlSetPos($gold, $gPos1, $gPos2)
ElseIf $pPos1 = ($gPos1+$rnd[1]) And $pPos2 = ($gPos2+$rnd[2]) Then
$score +=1
GUICtrlSetData($scorelabel, "Punkte: " & $score)
$gPos1 = Random(6, 580, 1)
$gPos2 = Random(25, 460, 1)
GUICtrlSetPos($gold, $gPos1, $gPos2)
ElseIf $pPos1 = ($gPos1-$rnd[1]) And $pPos2 = ($gPos2-$rnd[2]) Then
$score +=1
GUICtrlSetData($scorelabel, "Punkte: " & $score)
$gPos1 = Random(6, 580, 1)
$gPos2 = Random(25, 460, 1)
GUICtrlSetPos($gold, $gPos1, $gPos2)
ElseIf ($pPos1+$rnd[3]) = $gPos1 And ($pPos2+$rnd[4]) = $gPos2 Then
$score +=1
GUICtrlSetData($scorelabel, "Punkte: " & $score)
$gPos1 = Random(6, 580, 1)
$gPos2 = Random(25, 460, 1)
GUICtrlSetPos($gold, $gPos1, $gPos2)
ElseIf ($pPos1-$rnd[3]) = $gPos1 And ($pPos2-$rnd[4]) Then
$score +=1
GUICtrlSetData($scorelabel, "Punkte: " & $score)
$gPos1 = Random(6, 580, 1)
$gPos2 = Random(25, 460, 1)
GUICtrlSetPos($gold, $gPos1, $gPos2)
ElseIf ($pPos1+$rnd[3]) = $gPos1 And ($pPos2+$rnd[4]) Then
$score +=1
GUICtrlSetData($scorelabel, "Punkte: " & $score)
$gPos1 = Random(6, 580, 1)
$gPos2 = Random(25, 460, 1)
GUICtrlSetPos($gold, $gPos1, $gPos2)
ElseIf ($pPos1-$rnd[3]) = $gPos1 And ($pPos2-$rnd[4]) Then
$score +=1
GUICtrlSetData($scorelabel, "Punkte: " & $score)
$gPos1 = Random(6, 580, 1)
$gPos2 = Random(25, 460, 1)
GUICtrlSetPos($gold, $gPos1, $gPos2)
EndIf
[/autoit] [autoit][/autoit] [autoit]WEnd
[/autoit] [autoit][/autoit] [autoit]Func _left()
[/autoit] [autoit][/autoit] [autoit]$richtung = 1
GUICtrlSetPos($player, $pPos1-1, $pPos2)
If $anim = 1 Then
$hoehe = 32
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\left.bmp")
$anim +=1
ElseIf $anim = 6 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\left1.bmp")
$anim +=1
ElseIf $anim = 9 Then
$hoehe = 30
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\left2.bmp")
$anim +=1
ElseIf $anim = 12 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\left3.bmp")
$anim +=1
ElseIf $anim = 15 Then
$hoehe = 32
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\left4.bmp")
$anim +=1
ElseIf $anim = 18 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\left5.bmp")
$anim +=5
ElseIf $anim = 21 Then
$hoehe = 30
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\left6.bmp")
$anim +=1
ElseIf $anim = 24 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\left7.bmp")
$anim = 0
Else
$anim +=1
EndIf
$pPos1 = $pPos1-1
EndFunc
Func _right()
$hoehe = 30
$richtung = 2
GUICtrlSetPos($player, $pPos1+1, $pPos2)
If $anim = 1 Then
$hoehe = 32
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\right.bmp")
$anim +=1
ElseIf $anim = 6 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\right1.bmp")
$anim +=1
ElseIf $anim = 9 Then
$hoehe = 30
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\right2.bmp")
$anim +=1
ElseIf $anim = 12 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\right3.bmp")
$anim +=1
ElseIf $anim = 15 Then
$hoehe = 32
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\lright4.bmp")
$anim +=1
ElseIf $anim = 18 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\right5.bmp")
$anim +=5
ElseIf $anim = 21 Then
$hoehe = 30
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\right6.bmp")
$anim +=1
ElseIf $anim = 24 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\right7.bmp")
$anim = 0
Else
$anim +=1
EndIf
$pPos1 = $pPos1+1
EndFunc
Func _up()
$hoehe = 29
$richtung = 3
GUICtrlSetPos($player, $pPos1, $pPos2-1)
If $anim = 1 Then
$hoehe = 32
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\up.bmp")
$anim +=1
ElseIf $anim = 6 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\up1.bmp")
$anim +=1
ElseIf $anim = 9 Then
$hoehe = 30
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\up2.bmp")
$anim +=1
ElseIf $anim = 12 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\up3.bmp")
$anim +=1
ElseIf $anim = 15 Then
$hoehe = 32
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\up4.bmp")
$anim +=1
ElseIf $anim = 18 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\up5.bmp")
$anim +=5
ElseIf $anim = 21 Then
$hoehe = 30
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\up6.bmp")
$anim +=1
ElseIf $anim = 24 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\up7.bmp")
$anim = 0
Else
$anim +=1
EndIf
$pPos2 = $pPos2-1
EndFunc
Func _down()
$hoehe = 29
$richtung = 4
GUICtrlSetPos($player, $pPos1, $pPos2+1)
If $anim = 1 Then
$hoehe = 32
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\down.bmp")
$anim +=1
ElseIf $anim = 6 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\down1.bmp")
$anim +=1
ElseIf $anim = 9 Then
$hoehe = 30
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\down2.bmp")
$anim +=1
ElseIf $anim = 12 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\down3.bmp")
$anim +=1
ElseIf $anim = 15 Then
$hoehe = 32
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\down4.bmp")
$anim +=1
ElseIf $anim = 18 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\down5.bmp")
$anim +=5
ElseIf $anim = 21 Then
$hoehe = 30
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\down6.bmp")
$anim +=1
ElseIf $anim = 24 Then
$hoehe = 31
GUICtrlSetImage($player,@ScriptDir & "\Spiel BMP's\down7.bmp")
$anim = 0
Else
$anim +=1
EndIf
$pPos2 = $pPos2+1
EndFunc
ZitatBisherige Bugs:
- Münzen werden eingesammelt sobald man auf der selben X-Position wie die Münze ist
- Bei Mausbewegung läuft die Figur schneller
Und im Anhang sind die dazugehörigen Bilder (müssen in den selben Ordner wie das Script)