Hey zusammen
Dieser Thread ist ab jetzt für euch da um mir oder auch den anderen Godlikerz usern fragen ob AutoIt zu stellen. Egal ob ihr Probleme beim Programm habt oder ähnliches ich tue was ich kann um euch zu helfen.
Lieben Gruß euer JuJu
Hey zusammen
Dieser Thread ist ab jetzt für euch da um mir oder auch den anderen Godlikerz usern fragen ob AutoIt zu stellen. Egal ob ihr Probleme beim Programm habt oder ähnliches ich tue was ich kann um euch zu helfen.
Lieben Gruß euer JuJu
Also,
Wie kann ich Eine Datei in einem anderen fenster öffnen.
Ich meine das ungefähr so:
ICh habe eine *.exe Datei wenn ich die starte äffnet sich ein Fenster mit diesen Datei
die ich haben will.
Hoffe du kannst mir helfen^^
Zitat von Markiska;2596Also,
Wie kann ich Eine Datei in einem anderen fenster öffnen.
Ich meine das ungefähr so:
ICh habe eine *.exe Datei wenn ich die starte äffnet sich ein Fenster mit diesen Datei
die ich haben will.
Hoffe du kannst mir helfen^^
Ich versteh da nur Baaaaahhnhof.. bitte ebschreibt das nochmal genauer
Also,
ich hab das so was mit php zusammen gescryptet und jetzt wenn ich das starte öffnet ich das im browser.
Jetzt will ich aber sone blabla.exe habe wo sich das drine öffnet (im extra Fenster).
Hoffe das es alle verstanden habe^^
Zitat von Markiska;2600Also,
ich hab das so was mit php zusammen gescryptet und jetzt wenn ich das starte öffnet ich das im browser.
Jetzt will ich aber sone blabla.exe habe wo sich das drine öffnet (im extra Fenster).
Hoffe das es alle verstanden habe^^
Also nochmal..
Du hast ein php Script, und möchtest das in ner exe ausführen, sozusagen in nem kleinen Browser?
Könnte ich dir schnell in c# hinbasteln wenn du willst...
Das geht nicht mit php.
Php ist nicht dazu gedacht, .exe'n auszuführen. Es geht einfach nicht..
[Edit]
Ich nehm alles zurück es geht doch o.o
Zitat von Keksii;2605Das geht nicht mit php.
Php ist nicht dazu gedacht, .exe'n auszuführen. Es geht einfach nicht..[Edit]
Ich nehm alles zurück es geht doch o.o
Das war anders gemeint, habs schon egmacht, ist erledigt...
Er meinte das anders...
Er wollte eine .exe, in der sozusagen eine Webseite angezeigt wird, dies hab ich nu in C# gemacht, weil ich da weiß wie es geht xD
(Mit einem Webbrowser der halt die Zielurl anzeigt)
Wie kann man Tabs einbauen xD?
Kannste vllt sowas in deinen Source hinzufügen und Releasen ?^^
Oder du schreibst mir einfach den Source Code in Icq^^
Wäre echt nett.
Lg xSayHellox
P.S :
Ich gehe auf einen Link und da muss man sich einloggen ich gebe dir Account daten ein und nichts passiert.
Der Browser bleibt immer noch auf der gleich Seite
Tja Tabs beim Webbrowser..
Daran bin ich dann auch gescheitert..
Einbauen geht ja noch..
Aber gescheit steuern nichtmehr ;)
Ich habe von Jiyan erfahren wie es funktioniert.
Es funktioner mit dem Command:
GuiCtrlCreateTab
Und am besten lädt man sich Koda runter dann sieht man wo der fehler ist etc.
Naja ausprobiert habe ich es noch nicht.
Ich werde jetzt vllt erstmal Real Basic austesten
Lg xSayHellox
ok ähm ich nehm jetzt das zb
Zitat
MsgBox (1,"hallo","hallo welt" )
MsgBox (1,"hallo","hallo welt" )
so wie bekommnt man das jetzt hin das wenn man auf abbrechen der wirklich
abbricht ?
mfg
Mit der If-Schleife...
Schau mal meine guide an mit dem auslesen von Checkboxen, Radio Buttons und MsgBoxes^^
Dazu kann ich euch die AutoIt Dokumentation epfehlen
zb diese Seite davon Function MsgBox
ich scheck das jetzt nicht ganz xD
alsou ich möchte tetris am laufen haben ( gibt ihr irgentwo n source ) bekomm ich ja auch noch
so nun will ich die cancel und OK ding rein bekommen der Post Link vor dir verrät mir schon mal die ID von cancel und OK usw ...
aber wenn ich das mit der id abändere von dir Drago dann klappt beides nicht
hier mal mein code
[SIZE="2"]
MsgBox ( 1,"Tetris"," Viel Glück bei Tetris ( 0.1 ) by Aêry ")
If $Msg = 2 Then
Exit
Endif
If $Msg = 1 Then --- und weiter ? ---
#NoTrayIcon
$Sound1 = Soundplay("1.mp3")
Sleep(800)
#include <GUIConstants.au3>
AutoItSetOption("MustDeclareVars", 1)
Global Const $BOARD_WIDTH = 10
Global Const $BOARD_HEIGHT = 20
Global Const $EMPTY_COLOUR = -1
Global Const $TOWER_COLOUR = 0xff0000
Global Const $BOX_COLOUR = 0x00ff00
Global Const $PYRAMID_COLOUR = 0xffff00
Global Const $LLEANER_COLOUR = 0xffa500
Global Const $RLEANER_COLOUR = 0xff00ff
Global Const $LKNIGHT_COLOUR = 0x40e0d0
Global Const $RKNIGHT_COLOUR = 0xff1493
Global $g_lblGameBoard[$BOARD_WIDTH][$BOARD_HEIGHT]
Global $g_lblPreviewBoard[4][4]
Global $g_aBoard[$BOARD_WIDTH][$BOARD_HEIGHT]
Global $g_aGameShape[4][4], $g_aPreShape[4][4]
Global $g_nShapeX, $g_nShapeY
Global $g_nGameTick
Global $g_lblScore
Global $g_btnMoveLeft, $g_btnMoveRight
Global $g_btnRotate, $g_btnDrop
Global $g_btnStart
Global $g_bGameStarted = False
Global $msg
GUICreate("AutoIT Tetris", 490, 560)
_DrawGameBoard()
_DrawPreviewBoard()
$g_lblScore = GUICtrlCreateLabel("SCORE: 0", 305, 200, 165, 20)
GUICtrlSetFont(-1, 10, 800)
GUISetBkColor(0x000000)
$g_btnMoveLeft = GUICtrlCreateButton("Links (or <-)", 280, 280, 100, 25)
$g_btnMoveRight = GUICtrlCreateButton("Rechts (or ->)", 390, 280, 100, 25)
$g_btnRotate = GUICtrlCreateButton("Drehen (or down)", 280, 320, 100, 25)
$g_btnDrop = GUICtrlCreateButton("Drop (or Space)", 390, 320, 100, 25)
$g_btnStart = GUICtrlCreateButton("START (or ENTER)", 350, 400, 100, 35)
GUICtrlSetState(-1, $GUI_FOCUS)
GUISetState(@SW_SHOW)
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
SoundPlay("2.wav")
ExitLoop
Case $msg = $g_btnStart
GUICtrlSetState($g_btnStart, $GUI_DISABLE)
_NewGame()
Case $msg = $g_btnMoveLeft
_MoveShape(-1, 0)
Case $msg = $g_btnMoveRight
_MoveShape(1, 0)
Case $msg = $g_btnRotate
_RotateShape()
Case $msg = $g_btnDrop
AdlibDisable()
AdlibEnable("_MoveShapeDown", 25)
EndSelect
WEnd
GUIDelete()
Func _NewShape()
Local $nShape, $i, $j
For $i = 0 To 3
For $j = 0 To 3
$g_aGameShape[$i][$j] = $EMPTY_COLOUR
Next
Next
$g_nShapeX = ($BOARD_WIDTH/2)-2
$g_nShapeY = -1
If Not $g_bGameStarted Then
$nShape = Random(1, 7, 1)
; Block types
; 1 2 3 4 5 6 7
; X
; X XX X XX XX XX XX
; X XX XXX XX XX X X
; X X X
Switch $nShape
Case 1
; Tower
$g_aGameShape[1][0] = $TOWER_COLOUR
$g_aGameShape[1][1] = $TOWER_COLOUR
$g_aGameShape[1][2] = $TOWER_COLOUR
$g_aGameShape[1][3] = $TOWER_COLOUR
$g_nShapeY = 0
Case 2
; Box
$g_aGameShape[1][1] = $BOX_COLOUR
$g_aGameShape[1][2] = $BOX_COLOUR
$g_aGameShape[2][1] = $BOX_COLOUR
$g_aGameShape[2][2] = $BOX_COLOUR
case 3
; Pyramid
$g_aGameShape[1][1] = $PYRAMID_COLOUR
$g_aGameShape[0][2] = $PYRAMID_COLOUR
$g_aGameShape[1][2] = $PYRAMID_COLOUR
$g_aGameShape[2][2] = $PYRAMID_COLOUR
case 4
; Left Leaner
$g_aGameShape[0][1] = $LLEANER_COLOUR
$g_aGameShape[1][1] = $LLEANER_COLOUR
$g_aGameShape[1][2] = $LLEANER_COLOUR
$g_aGameShape[2][2] = $LLEANER_COLOUR
case 5
; Right Leaner
$g_aGameShape[2][1] = $RLEANER_COLOUR
$g_aGameShape[1][1] = $RLEANER_COLOUR
$g_aGameShape[1][2] = $RLEANER_COLOUR
$g_aGameShape[0][2] = $RLEANER_COLOUR
case 6
; Left Knight
$g_aGameShape[1][1] = $LKNIGHT_COLOUR
$g_aGameShape[2][1] = $LKNIGHT_COLOUR
$g_aGameShape[2][2] = $LKNIGHT_COLOUR
$g_aGameShape[2][3] = $LKNIGHT_COLOUR
case 7
; Right Knight
$g_aGameShape[2][1] = $RKNIGHT_COLOUR
$g_aGameShape[1][1] = $RKNIGHT_COLOUR
$g_aGameShape[1][2] = $RKNIGHT_COLOUR
$g_aGameShape[1][3] = $RKNIGHT_COLOUR
EndSwitch
Else
For $i = 0 To 3
For $j = 0 To 3
$g_aGameShape[$i][$j] = $g_aPreShape[$i][$j]
Next
Next
If $g_aGameShape[1][0] = $TOWER_COLOUR Then $g_nShapeY = 0
EndIf
For $i = 0 To 3
For $j = 0 To 3
$g_aPreShape[$i][$j] = $EMPTY_COLOUR
Next
Next
$nShape = Random(1, 7, 1)
Switch $nShape
Case 1
$g_aPreShape[1][0] = $TOWER_COLOUR
$g_aPreShape[1][1] = $TOWER_COLOUR
$g_aPreShape[1][2] = $TOWER_COLOUR
$g_aPreShape[1][3] = $TOWER_COLOUR
Case 2
$g_aPreShape[1][1] = $BOX_COLOUR
$g_aPreShape[1][2] = $BOX_COLOUR
$g_aPreShape[2][1] = $BOX_COLOUR
$g_aPreShape[2][2] = $BOX_COLOUR
case 3
$g_aPreShape[1][1] = $PYRAMID_COLOUR
$g_aPreShape[0][2] = $PYRAMID_COLOUR
$g_aPreShape[1][2] = $PYRAMID_COLOUR
$g_aPreShape[2][2] = $PYRAMID_COLOUR
case 4
$g_aPreShape[0][1] = $LLEANER_COLOUR
$g_aPreShape[1][1] = $LLEANER_COLOUR
$g_aPreShape[1][2] = $LLEANER_COLOUR
$g_aPreShape[2][2] = $LLEANER_COLOUR
case 5
$g_aPreShape[2][1] = $RLEANER_COLOUR
$g_aPreShape[1][1] = $RLEANER_COLOUR
$g_aPreShape[1][2] = $RLEANER_COLOUR
$g_aPreShape[0][2] = $RLEANER_COLOUR
case 6
$g_aPreShape[1][1] = $LKNIGHT_COLOUR
$g_aPreShape[2][1] = $LKNIGHT_COLOUR
$g_aPreShape[2][2] = $LKNIGHT_COLOUR
$g_aPreShape[2][3] = $LKNIGHT_COLOUR
case 7
$g_aPreShape[2][1] = $RKNIGHT_COLOUR
$g_aPreShape[1][1] = $RKNIGHT_COLOUR
$g_aPreShape[1][2] = $RKNIGHT_COLOUR
$g_aPreShape[1][3] = $RKNIGHT_COLOUR
EndSwitch
For $i = 0 To 3
For $j = 0 To 3
If $g_aPreShape[$i][$j] = $EMPTY_COLOUR Then
GUICtrlSetBkColor($g_lblPreviewBoard[$i][$j], $GUI_BKCOLOR_TRANSPARENT)
Else
GUICtrlSetBkColor($g_lblPreviewBoard[$i][$j], $g_aPreShape[$i][$j])
EndIf
Next
Next
EndFunc
Func _MoveShapeLeft()
_MoveShape(-1, 0)
EndFunc
Func _MoveShapeRight()
_MoveShape(1, 0)
EndFunc
Func _MoveShapeDown()
_MoveShape(0, 1)
EndFunc
Func _DropShape()
AdlibDisable()
AdlibEnable("_MoveShapeDown", 25)
EndFunc
Func _MoveShape($nMoveX, $nMoveY)
Local $nCollision, $i, $j
Local $bFilled, $x, $y
Local $sScoreText, $nScore
If _CollisionTest($nMoveX, $nMoveY) Then
If $nMoveY = 1 Then
If $g_nShapeY < 1 Then
AdlibDisable()
MsgBox(0, "AutoIT Tetris", "GAME OVER!")
GUICtrlSetState($g_btnStart, $GUI_ENABLE)
HotKeySet("{LEFT}")
HotKeySet("{RIGHT}")
HotKeySet("{DOWN}")
HotKeySet("{SPACE}")
Return
Else
For $i = 0 To 3
For $j = 0 To 3
If $g_aGameShape[$i][$j] <> $EMPTY_COLOUR Then
$g_aBoard[$g_nShapeX+$i][$g_nShapeY+$j] = $g_aGameShape[$i][$j]
EndIf
Next
Next
For $j = 0 To ($BOARD_HEIGHT-1)
$bFilled = True
For $i = 0 To ($BOARD_WIDTH-1)
If $g_aBoard[$i][$j] = $EMPTY_COLOUR Then
$bFilled = False
ExitLoop
EndIf
Next
If $bFilled Then
$sScoreText = GUICtrlRead($g_lblScore)
$nScore = Number(StringRight($sScoreText, StringLen($sScoreText)-7))+10
If Mod($nScore, 50) = 0 Then
$g_nGameTick -= 10
EndIf
GUICtrlSetData($g_lblScore, "SCORE: " & $nScore)
For $x = 0 To ($BOARD_WIDTH-1)
For $y = $j To 1 Step -1
$g_aBoard[$x][$y] = $g_aBoard[$x][$y-1]
Next
Next
_RedrawGameBoard()
EndIf
Next
AdlibDisable()
_NewShape()
_DrawGameShape()
AdlibEnable("_MoveShapeDown", $g_nGameTick)
EndIf
EndIf
Else
_DrawGameShape(True)
If $nMoveX <> 0 Then $g_nShapeX += $nMoveX
If $nMoveY <> 0 Then $g_nShapeY += $nMoveY
_DrawGameShape()
EndIf
EndFunc
Func _RotateShape()
Local $i, $j, $aTempShape[4][4]
For $i = 0 To 3
For $j = 0 To 3
$aTempShape[3-$j][$i] = $g_aGameShape[$i][$j]
Next
Next
For $i = 0 To 3
For $j = 0 To 3
If $aTempShape[$i][$j] <> $EMPTY_COLOUR Then
If ($g_nShapeX+$i) < 0 Or ($g_nShapeX+$i) > ($BOARD_WIDTH- 1) Or _
($g_nShapeY+$j) < 0 Or ($g_nShapeY+$j) > ($BOARD_HEIGHT-1) Then
Return
EndIf
EndIf
Next
Next
For $x = 0 To ($BOARD_WIDTH-1)
For $y = 0 To ($BOARD_HEIGHT-1)
If $x >= $g_nShapeX And $x < ($g_nShapeX+4) Then
If $y >= $g_nShapeY And $y < ($g_nShapeY+4) Then
If $g_aBoard[$x][$y] <> $EMPTY_COLOUR Then
If $aTempShape[$x-$g_nShapeX][$y-$g_nShapeY] <> $EMPTY_COLOUR Then
Return
EndIf
EndIf
EndIf
EndIf
Next
Next
_DrawGameShape(True)
For $i = 0 To 3
For $j = 0 To 3
$g_aGameShape[$i][$j] = $aTempShape[$i][$j]
Next
Next
_DrawGameShape()
EndFunc
Func _CollisionTest($nMoveX, $nMoveY)
Local $nNewX = $g_nShapeX+$nMoveX
Local $nNewY = $g_nShapeY+$nMoveY
Local $i, $j, $x, $y
For $i = 0 To 3
For $j = 0 To 3
If $g_aGameShape[$i][$j] <> $EMPTY_COLOUR Then
If ($nNewX+$i) < 0 Or ($nNewX+$i) > ($BOARD_WIDTH-1) Or _
($nNewY+$j) < 0 Or ($nNewY+$j) > ($BOARD_HEIGHT-1) Then
Return True
EndIf
EndIf
Next
Next
For $x = 0 To ($BOARD_WIDTH-1)
For $y = 0 To ($BOARD_HEIGHT-1)
If $x >= $nNewX And $x < ($nNewX+4) Then
If $y >= $nNewY And $y < ($nNewY+4) Then
If $g_aBoard[$x][$y] <> $EMPTY_COLOUR Then
If $g_aGameShape[$x-$nNewX][$y-$nNewY] <> $EMPTY_COLOUR Then
Return True
EndIf
EndIf
EndIf
EndIf
Next
Next
Return False
EndFunc
Func _DrawGameShape($bRemove = False)
Local $i, $j
For $i = 0 To 3
For $j = 0 To 3
If $g_aGameShape[$i][$j] <> $EMPTY_COLOUR Then
If $bRemove Then
GUICtrlSetBkColor($g_lblGameBoard[$g_nShapeX+$i][$g_nShapeY+$j], $GUI_BKCOLOR_TRANSPARENT)
Else
GUICtrlSetBkColor($g_lblGameBoard[$g_nShapeX+$i][$g_nShapeY+$j], $g_aGameShape[$i][$j])
EndIf
EndIf
Next
Next
EndFunc
Func _DrawGameBoard()
Local $i, $j
Local $x, $y
$x = 20
$y = 20
For $i = 0 To $BOARD_WIDTH-1
For $j = 0 To $BOARD_HEIGHT-1
GUICtrlCreateLabel("", $x, $y, 25, 25)
$g_lblGameBoard[$i][$j] = GUICtrlCreateLabel("", $x+1, $y+1, 23, 23)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$y = $y+26
Next
$x = $x+26
$y = 20
Next
EndFunc
Func _DrawPreviewBoard()
Local $i, $j
Local $x, $y
$x = 340
$y = 40
GUICtrlCreateLabel("Next Shape:", $x, 20, 104, 18)
For $i = 0 To 3
For $j = 0 To 3
GUICtrlCreateLabel("", $x, $y, 25, 25)
$g_lblPreviewBoard[$i][$j] = GUICtrlCreateLabel("", $x+1, $y+1, 23, 23)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$y = $y+26
Next
$x = $x+26
$y = 40
Next
EndFunc
Func _RedrawGameBoard()
Local $i, $j
For $i = 0 To $BOARD_WIDTH-1
For $j = 0 To $BOARD_HEIGHT-1
If $g_aBoard[$i][$j] = $EMPTY_COLOUR Then
GUICtrlSetBkColor($g_lblGameBoard[$i][$j], $GUI_BKCOLOR_TRANSPARENT)
Else
GUICtrlSetBkColor($g_lblGameBoard[$i][$j], $g_aBoard[$i][$j])
EndIf
Next
Next
EndFunc
Func _NewGame()
Local $i, $j
AdlibDisable()
HotKeySet("{LEFT}", "_MoveShapeLeft")
HotKeySet("{RIGHT}", "_MoveShapeRight")
HotKeySet("{DOWN}", "_RotateShape")
HotKeySet("{SPACE}", "_DropShape")
$g_bGameStarted = False
For $i = 0 To $BOARD_WIDTH-1
For $j = 0 To $BOARD_HEIGHT-1
$g_aBoard[$i][$j] = $EMPTY_COLOUR
GUICtrlSetBkColor($g_lblGameBoard[$i][$j], $GUI_BKCOLOR_TRANSPARENT)
Next
Next
_NewShape()
$g_bGameStarted = True
_DrawGameShape()
$g_nGameTick = 500
AdlibEnable("_MoveShapeDown", $g_nGameTick)
EndFunc
Alles anzeigen
[/SIZE]
Hoffe mir antwortet jemand schnell :P
mfg Aêry
ganz einfach, du amchst den Tetris Code in die 2. If schleife rein ;)
MsgBox ( 1,"Tetris"," Viel Glück bei Tetris ( 0.1 ) by Aêry ")
If $Msg = 2 Then
Exit
Endif
If $Msg = 1 Then
#NoTrayIcon
$Sound1 = Soundplay("1.mp3")
Sleep(800)
#include <GUIConstants.au3>
AutoItSetOption("MustDeclareVars", 1)
Global Const $BOARD_WIDTH = 10
Global Const $BOARD_HEIGHT = 20
Global Const $EMPTY_COLOUR = -1
Global Const $TOWER_COLOUR = 0xff0000
Global Const $BOX_COLOUR = 0x00ff00
Global Const $PYRAMID_COLOUR = 0xffff00
Global Const $LLEANER_COLOUR = 0xffa500
Global Const $RLEANER_COLOUR = 0xff00ff
Global Const $LKNIGHT_COLOUR = 0x40e0d0
Global Const $RKNIGHT_COLOUR = 0xff1493
Global $g_lblGameBoard[$BOARD_WIDTH][$BOARD_HEIGHT]
Global $g_lblPreviewBoard[4][4]
Global $g_aBoard[$BOARD_WIDTH][$BOARD_HEIGHT]
Global $g_aGameShape[4][4], $g_aPreShape[4][4]
Global $g_nShapeX, $g_nShapeY
Global $g_nGameTick
Global $g_lblScore
Global $g_btnMoveLeft, $g_btnMoveRight
Global $g_btnRotate, $g_btnDrop
Global $g_btnStart
Global $g_bGameStarted = False
Global $msg
GUICreate("AutoIT Tetris", 490, 560)
_DrawGameBoard()
_DrawPreviewBoard()
$g_lblScore = GUICtrlCreateLabel("SCORE: 0", 305, 200, 165, 20)
GUICtrlSetFont(-1, 10, 800)
GUISetBkColor(0x000000)
$g_btnMoveLeft = GUICtrlCreateButton("Links (or <-)", 280, 280, 100, 25)
$g_btnMoveRight = GUICtrlCreateButton("Rechts (or ->)", 390, 280, 100, 25)
$g_btnRotate = GUICtrlCreateButton("Drehen (or down)", 280, 320, 100, 25)
$g_btnDrop = GUICtrlCreateButton("Drop (or Space)", 390, 320, 100, 25)
$g_btnStart = GUICtrlCreateButton("START (or ENTER)", 350, 400, 100, 35)
GUICtrlSetState(-1, $GUI_FOCUS)
GUISetState(@SW_SHOW)
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
SoundPlay("2.wav")
ExitLoop
Case $msg = $g_btnStart
GUICtrlSetState($g_btnStart, $GUI_DISABLE)
_NewGame()
Case $msg = $g_btnMoveLeft
_MoveShape(-1, 0)
Case $msg = $g_btnMoveRight
_MoveShape(1, 0)
Case $msg = $g_btnRotate
_RotateShape()
Case $msg = $g_btnDrop
AdlibDisable()
AdlibEnable("_MoveShapeDown", 25)
EndSelect
WEnd
GUIDelete()
Func _NewShape()
Local $nShape, $i, $j
For $i = 0 To 3
For $j = 0 To 3
$g_aGameShape[$i][$j] = $EMPTY_COLOUR
Next
Next
$g_nShapeX = ($BOARD_WIDTH/2)-2
$g_nShapeY = -1
If Not $g_bGameStarted Then
$nShape = Random(1, 7, 1)
; Block types
; 1 2 3 4 5 6 7
; X
; X XX X XX XX XX XX
; X XX XXX XX XX X X
; X X X
Switch $nShape
Case 1
; Tower
$g_aGameShape[1][0] = $TOWER_COLOUR
$g_aGameShape[1][1] = $TOWER_COLOUR
$g_aGameShape[1][2] = $TOWER_COLOUR
$g_aGameShape[1][3] = $TOWER_COLOUR
$g_nShapeY = 0
Case 2
; Box
$g_aGameShape[1][1] = $BOX_COLOUR
$g_aGameShape[1][2] = $BOX_COLOUR
$g_aGameShape[2][1] = $BOX_COLOUR
$g_aGameShape[2][2] = $BOX_COLOUR
case 3
; Pyramid
$g_aGameShape[1][1] = $PYRAMID_COLOUR
$g_aGameShape[0][2] = $PYRAMID_COLOUR
$g_aGameShape[1][2] = $PYRAMID_COLOUR
$g_aGameShape[2][2] = $PYRAMID_COLOUR
case 4
; Left Leaner
$g_aGameShape[0][1] = $LLEANER_COLOUR
$g_aGameShape[1][1] = $LLEANER_COLOUR
$g_aGameShape[1][2] = $LLEANER_COLOUR
$g_aGameShape[2][2] = $LLEANER_COLOUR
case 5
; Right Leaner
$g_aGameShape[2][1] = $RLEANER_COLOUR
$g_aGameShape[1][1] = $RLEANER_COLOUR
$g_aGameShape[1][2] = $RLEANER_COLOUR
$g_aGameShape[0][2] = $RLEANER_COLOUR
case 6
; Left Knight
$g_aGameShape[1][1] = $LKNIGHT_COLOUR
$g_aGameShape[2][1] = $LKNIGHT_COLOUR
$g_aGameShape[2][2] = $LKNIGHT_COLOUR
$g_aGameShape[2][3] = $LKNIGHT_COLOUR
case 7
; Right Knight
$g_aGameShape[2][1] = $RKNIGHT_COLOUR
$g_aGameShape[1][1] = $RKNIGHT_COLOUR
$g_aGameShape[1][2] = $RKNIGHT_COLOUR
$g_aGameShape[1][3] = $RKNIGHT_COLOUR
EndSwitch
Else
For $i = 0 To 3
For $j = 0 To 3
$g_aGameShape[$i][$j] = $g_aPreShape[$i][$j]
Next
Next
If $g_aGameShape[1][0] = $TOWER_COLOUR Then $g_nShapeY = 0
EndIf
For $i = 0 To 3
For $j = 0 To 3
$g_aPreShape[$i][$j] = $EMPTY_COLOUR
Next
Next
$nShape = Random(1, 7, 1)
Switch $nShape
Case 1
$g_aPreShape[1][0] = $TOWER_COLOUR
$g_aPreShape[1][1] = $TOWER_COLOUR
$g_aPreShape[1][2] = $TOWER_COLOUR
$g_aPreShape[1][3] = $TOWER_COLOUR
Case 2
$g_aPreShape[1][1] = $BOX_COLOUR
$g_aPreShape[1][2] = $BOX_COLOUR
$g_aPreShape[2][1] = $BOX_COLOUR
$g_aPreShape[2][2] = $BOX_COLOUR
case 3
$g_aPreShape[1][1] = $PYRAMID_COLOUR
$g_aPreShape[0][2] = $PYRAMID_COLOUR
$g_aPreShape[1][2] = $PYRAMID_COLOUR
$g_aPreShape[2][2] = $PYRAMID_COLOUR
case 4
$g_aPreShape[0][1] = $LLEANER_COLOUR
$g_aPreShape[1][1] = $LLEANER_COLOUR
$g_aPreShape[1][2] = $LLEANER_COLOUR
$g_aPreShape[2][2] = $LLEANER_COLOUR
case 5
$g_aPreShape[2][1] = $RLEANER_COLOUR
$g_aPreShape[1][1] = $RLEANER_COLOUR
$g_aPreShape[1][2] = $RLEANER_COLOUR
$g_aPreShape[0][2] = $RLEANER_COLOUR
case 6
$g_aPreShape[1][1] = $LKNIGHT_COLOUR
$g_aPreShape[2][1] = $LKNIGHT_COLOUR
$g_aPreShape[2][2] = $LKNIGHT_COLOUR
$g_aPreShape[2][3] = $LKNIGHT_COLOUR
case 7
$g_aPreShape[2][1] = $RKNIGHT_COLOUR
$g_aPreShape[1][1] = $RKNIGHT_COLOUR
$g_aPreShape[1][2] = $RKNIGHT_COLOUR
$g_aPreShape[1][3] = $RKNIGHT_COLOUR
EndSwitch
For $i = 0 To 3
For $j = 0 To 3
If $g_aPreShape[$i][$j] = $EMPTY_COLOUR Then
GUICtrlSetBkColor($g_lblPreviewBoard[$i][$j], $GUI_BKCOLOR_TRANSPARENT)
Else
GUICtrlSetBkColor($g_lblPreviewBoard[$i][$j], $g_aPreShape[$i][$j])
EndIf
Next
Next
EndFunc
Func _MoveShapeLeft()
_MoveShape(-1, 0)
EndFunc
Func _MoveShapeRight()
_MoveShape(1, 0)
EndFunc
Func _MoveShapeDown()
_MoveShape(0, 1)
EndFunc
Func _DropShape()
AdlibDisable()
AdlibEnable("_MoveShapeDown", 25)
EndFunc
Func _MoveShape($nMoveX, $nMoveY)
Local $nCollision, $i, $j
Local $bFilled, $x, $y
Local $sScoreText, $nScore
If _CollisionTest($nMoveX, $nMoveY) Then
If $nMoveY = 1 Then
If $g_nShapeY < 1 Then
AdlibDisable()
MsgBox(0, "AutoIT Tetris", "GAME OVER!")
GUICtrlSetState($g_btnStart, $GUI_ENABLE)
HotKeySet("{LEFT}")
HotKeySet("{RIGHT}")
HotKeySet("{DOWN}")
HotKeySet("{SPACE}")
Return
Else
For $i = 0 To 3
For $j = 0 To 3
If $g_aGameShape[$i][$j] <> $EMPTY_COLOUR Then
$g_aBoard[$g_nShapeX+$i][$g_nShapeY+$j] = $g_aGameShape[$i][$j]
EndIf
Next
Next
For $j = 0 To ($BOARD_HEIGHT-1)
$bFilled = True
For $i = 0 To ($BOARD_WIDTH-1)
If $g_aBoard[$i][$j] = $EMPTY_COLOUR Then
$bFilled = False
ExitLoop
EndIf
Next
If $bFilled Then
$sScoreText = GUICtrlRead($g_lblScore)
$nScore = Number(StringRight($sScoreText, StringLen($sScoreText)-7))+10
If Mod($nScore, 50) = 0 Then
$g_nGameTick -= 10
EndIf
GUICtrlSetData($g_lblScore, "SCORE: " & $nScore)
For $x = 0 To ($BOARD_WIDTH-1)
For $y = $j To 1 Step -1
$g_aBoard[$x][$y] = $g_aBoard[$x][$y-1]
Next
Next
_RedrawGameBoard()
EndIf
Next
AdlibDisable()
_NewShape()
_DrawGameShape()
AdlibEnable("_MoveShapeDown", $g_nGameTick)
EndIf
EndIf
Else
_DrawGameShape(True)
If $nMoveX <> 0 Then $g_nShapeX += $nMoveX
If $nMoveY <> 0 Then $g_nShapeY += $nMoveY
_DrawGameShape()
EndIf
EndFunc
Func _RotateShape()
Local $i, $j, $aTempShape[4][4]
For $i = 0 To 3
For $j = 0 To 3
$aTempShape[3-$j][$i] = $g_aGameShape[$i][$j]
Next
Next
For $i = 0 To 3
For $j = 0 To 3
If $aTempShape[$i][$j] <> $EMPTY_COLOUR Then
If ($g_nShapeX+$i) < 0 Or ($g_nShapeX+$i) > ($BOARD_WIDTH- 1) Or _
($g_nShapeY+$j) < 0 Or ($g_nShapeY+$j) > ($BOARD_HEIGHT-1) Then
Return
EndIf
EndIf
Next
Next
For $x = 0 To ($BOARD_WIDTH-1)
For $y = 0 To ($BOARD_HEIGHT-1)
If $x >= $g_nShapeX And $x < ($g_nShapeX+4) Then
If $y >= $g_nShapeY And $y < ($g_nShapeY+4) Then
If $g_aBoard[$x][$y] <> $EMPTY_COLOUR Then
If $aTempShape[$x-$g_nShapeX][$y-$g_nShapeY] <> $EMPTY_COLOUR Then
Return
EndIf
EndIf
EndIf
EndIf
Next
Next
_DrawGameShape(True)
For $i = 0 To 3
For $j = 0 To 3
$g_aGameShape[$i][$j] = $aTempShape[$i][$j]
Next
Next
_DrawGameShape()
EndFunc
Func _CollisionTest($nMoveX, $nMoveY)
Local $nNewX = $g_nShapeX+$nMoveX
Local $nNewY = $g_nShapeY+$nMoveY
Local $i, $j, $x, $y
For $i = 0 To 3
For $j = 0 To 3
If $g_aGameShape[$i][$j] <> $EMPTY_COLOUR Then
If ($nNewX+$i) < 0 Or ($nNewX+$i) > ($BOARD_WIDTH-1) Or _
($nNewY+$j) < 0 Or ($nNewY+$j) > ($BOARD_HEIGHT-1) Then
Return True
EndIf
EndIf
Next
Next
For $x = 0 To ($BOARD_WIDTH-1)
For $y = 0 To ($BOARD_HEIGHT-1)
If $x >= $nNewX And $x < ($nNewX+4) Then
If $y >= $nNewY And $y < ($nNewY+4) Then
If $g_aBoard[$x][$y] <> $EMPTY_COLOUR Then
If $g_aGameShape[$x-$nNewX][$y-$nNewY] <> $EMPTY_COLOUR Then
Return True
EndIf
EndIf
EndIf
EndIf
Next
Next
Return False
EndFunc
Func _DrawGameShape($bRemove = False)
Local $i, $j
For $i = 0 To 3
For $j = 0 To 3
If $g_aGameShape[$i][$j] <> $EMPTY_COLOUR Then
If $bRemove Then
GUICtrlSetBkColor($g_lblGameBoard[$g_nShapeX+$i][$g_nShapeY+$j], $GUI_BKCOLOR_TRANSPARENT)
Else
GUICtrlSetBkColor($g_lblGameBoard[$g_nShapeX+$i][$g_nShapeY+$j], $g_aGameShape[$i][$j])
EndIf
EndIf
Next
Next
EndFunc
Func _DrawGameBoard()
Local $i, $j
Local $x, $y
$x = 20
$y = 20
For $i = 0 To $BOARD_WIDTH-1
For $j = 0 To $BOARD_HEIGHT-1
GUICtrlCreateLabel("", $x, $y, 25, 25)
$g_lblGameBoard[$i][$j] = GUICtrlCreateLabel("", $x+1, $y+1, 23, 23)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$y = $y+26
Next
$x = $x+26
$y = 20
Next
EndFunc
Func _DrawPreviewBoard()
Local $i, $j
Local $x, $y
$x = 340
$y = 40
GUICtrlCreateLabel("Next Shape:", $x, 20, 104, 18)
For $i = 0 To 3
For $j = 0 To 3
GUICtrlCreateLabel("", $x, $y, 25, 25)
$g_lblPreviewBoard[$i][$j] = GUICtrlCreateLabel("", $x+1, $y+1, 23, 23)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$y = $y+26
Next
$x = $x+26
$y = 40
Next
EndFunc
Func _RedrawGameBoard()
Local $i, $j
For $i = 0 To $BOARD_WIDTH-1
For $j = 0 To $BOARD_HEIGHT-1
If $g_aBoard[$i][$j] = $EMPTY_COLOUR Then
GUICtrlSetBkColor($g_lblGameBoard[$i][$j], $GUI_BKCOLOR_TRANSPARENT)
Else
GUICtrlSetBkColor($g_lblGameBoard[$i][$j], $g_aBoard[$i][$j])
EndIf
Next
Next
EndFunc
Func _NewGame()
Local $i, $j
AdlibDisable()
HotKeySet("{LEFT}", "_MoveShapeLeft")
HotKeySet("{RIGHT}", "_MoveShapeRight")
HotKeySet("{DOWN}", "_RotateShape")
HotKeySet("{SPACE}", "_DropShape")
$g_bGameStarted = False
For $i = 0 To $BOARD_WIDTH-1
For $j = 0 To $BOARD_HEIGHT-1
$g_aBoard[$i][$j] = $EMPTY_COLOUR
GUICtrlSetBkColor($g_lblGameBoard[$i][$j], $GUI_BKCOLOR_TRANSPARENT)
Next
Next
_NewShape()
$g_bGameStarted = True
_DrawGameShape()
$g_nGameTick = 500
AdlibEnable("_MoveShapeDown", $g_nGameTick)
EndFunc
EndIf
Alles anzeigen
Hier meine errors :
ZitatAlles anzeigenC:\Dokumente und Einstellungen\name\Desktop\Beast World Editor Installer v2.au3(3,9) : WARNING: $Msg: possibly used before declaration.
If $Msg =
~~~~~~~~^
C:\Dokumente und Einstellungen\name\Desktop\Beast World Editor Installer v2.au3(86,1) : ERROR: missing EndIf.
Func
^
C:\Dokumente und Einstellungen\name\Desktop\Beast World Editor Installer v2.au3(7,17) : REF: missing EndIf.
If $Msg = 1 Then
~~~~~~~~~~~~~~~~^
C:\Dokumente und Einstellungen\name\Desktop\Beast World Editor Installer v2.au3(471,1) : ERROR: syntax error
EndIf
^
C:\Dokumente und Einstellungen\name\Desktop\Beast World Editor Installer v2.au3 - 2 error(s), 1 warning(s)
Edit // hatte das projekt noch unter nem anderem namen laufen natürlich alles gedeledet
Edit² // hab noch ebend mein name rausgeholt xD
Du hast ja auch die Msg nicht in die variable getan Du musst $Msg deklinieren:
[B][I][I][COLOR="Red"]$Msg[/COLOR][/I][/I][/B] = MsgBox ( 1,"Tetris"," Viel Glück bei Tetris ( 0.1 ) by Aêry ")
If [COLOR="Red"][I][B]$Msg[/B][/I][/COLOR] = 2 Then
Exit
Endif
If [B][I][COLOR="Red"]$Msg[/COLOR][/I][/B] = 1 Then
#NoTrayIcon
$Sound1 = Soundplay("1.mp3")
Sleep(800)
#include <GUIConstants.au3>
AutoItSetOption("MustDeclareVars", 1)
Global Const $BOARD_WIDTH = 10
Global Const $BOARD_HEIGHT = 20
Global Const $EMPTY_COLOUR = -1
Global Const $TOWER_COLOUR = 0xff0000
Global Const $BOX_COLOUR = 0x00ff00
Global Const $PYRAMID_COLOUR = 0xffff00
Global Const $LLEANER_COLOUR = 0xffa500
Global Const $RLEANER_COLOUR = 0xff00ff
Global Const $LKNIGHT_COLOUR = 0x40e0d0
Global Const $RKNIGHT_COLOUR = 0xff1493
Global $g_lblGameBoard[$BOARD_WIDTH][$BOARD_HEIGHT]
Global $g_lblPreviewBoard[4][4]
Global $g_aBoard[$BOARD_WIDTH][$BOARD_HEIGHT]
Global $g_aGameShape[4][4], $g_aPreShape[4][4]
Global $g_nShapeX, $g_nShapeY
Global $g_nGameTick
Global $g_lblScore
Global $g_btnMoveLeft, $g_btnMoveRight
Global $g_btnRotate, $g_btnDrop
Global $g_btnStart
Global $g_bGameStarted = False
Global $msg
GUICreate("AutoIT Tetris", 490, 560)
_DrawGameBoard()
_DrawPreviewBoard()
$g_lblScore = GUICtrlCreateLabel("SCORE: 0", 305, 200, 165, 20)
GUICtrlSetFont(-1, 10, 800)
GUISetBkColor(0x000000)
$g_btnMoveLeft = GUICtrlCreateButton("Links (or <-)", 280, 280, 100, 25)
$g_btnMoveRight = GUICtrlCreateButton("Rechts (or ->)", 390, 280, 100, 25)
$g_btnRotate = GUICtrlCreateButton("Drehen (or down)", 280, 320, 100, 25)
$g_btnDrop = GUICtrlCreateButton("Drop (or Space)", 390, 320, 100, 25)
$g_btnStart = GUICtrlCreateButton("START (or ENTER)", 350, 400, 100, 35)
GUICtrlSetState(-1, $GUI_FOCUS)
GUISetState(@SW_SHOW)
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
SoundPlay("2.wav")
ExitLoop
Case $msg = $g_btnStart
GUICtrlSetState($g_btnStart, $GUI_DISABLE)
_NewGame()
Case $msg = $g_btnMoveLeft
_MoveShape(-1, 0)
Case $msg = $g_btnMoveRight
_MoveShape(1, 0)
Case $msg = $g_btnRotate
_RotateShape()
Case $msg = $g_btnDrop
AdlibDisable()
AdlibEnable("_MoveShapeDown", 25)
EndSelect
WEnd
GUIDelete()
Func _NewShape()
Local $nShape, $i, $j
For $i = 0 To 3
For $j = 0 To 3
$g_aGameShape[$i][$j] = $EMPTY_COLOUR
Next
Next
$g_nShapeX = ($BOARD_WIDTH/2)-2
$g_nShapeY = -1
If Not $g_bGameStarted Then
$nShape = Random(1, 7, 1)
; Block types
; 1 2 3 4 5 6 7
; X
; X XX X XX XX XX XX
; X XX XXX XX XX X X
; X X X
Switch $nShape
Case 1
; Tower
$g_aGameShape[1][0] = $TOWER_COLOUR
$g_aGameShape[1][1] = $TOWER_COLOUR
$g_aGameShape[1][2] = $TOWER_COLOUR
$g_aGameShape[1][3] = $TOWER_COLOUR
$g_nShapeY = 0
Case 2
; Box
$g_aGameShape[1][1] = $BOX_COLOUR
$g_aGameShape[1][2] = $BOX_COLOUR
$g_aGameShape[2][1] = $BOX_COLOUR
$g_aGameShape[2][2] = $BOX_COLOUR
case 3
; Pyramid
$g_aGameShape[1][1] = $PYRAMID_COLOUR
$g_aGameShape[0][2] = $PYRAMID_COLOUR
$g_aGameShape[1][2] = $PYRAMID_COLOUR
$g_aGameShape[2][2] = $PYRAMID_COLOUR
case 4
; Left Leaner
$g_aGameShape[0][1] = $LLEANER_COLOUR
$g_aGameShape[1][1] = $LLEANER_COLOUR
$g_aGameShape[1][2] = $LLEANER_COLOUR
$g_aGameShape[2][2] = $LLEANER_COLOUR
case 5
; Right Leaner
$g_aGameShape[2][1] = $RLEANER_COLOUR
$g_aGameShape[1][1] = $RLEANER_COLOUR
$g_aGameShape[1][2] = $RLEANER_COLOUR
$g_aGameShape[0][2] = $RLEANER_COLOUR
case 6
; Left Knight
$g_aGameShape[1][1] = $LKNIGHT_COLOUR
$g_aGameShape[2][1] = $LKNIGHT_COLOUR
$g_aGameShape[2][2] = $LKNIGHT_COLOUR
$g_aGameShape[2][3] = $LKNIGHT_COLOUR
case 7
; Right Knight
$g_aGameShape[2][1] = $RKNIGHT_COLOUR
$g_aGameShape[1][1] = $RKNIGHT_COLOUR
$g_aGameShape[1][2] = $RKNIGHT_COLOUR
$g_aGameShape[1][3] = $RKNIGHT_COLOUR
EndSwitch
Else
For $i = 0 To 3
For $j = 0 To 3
$g_aGameShape[$i][$j] = $g_aPreShape[$i][$j]
Next
Next
If $g_aGameShape[1][0] = $TOWER_COLOUR Then $g_nShapeY = 0
EndIf
For $i = 0 To 3
For $j = 0 To 3
$g_aPreShape[$i][$j] = $EMPTY_COLOUR
Next
Next
$nShape = Random(1, 7, 1)
Switch $nShape
Case 1
$g_aPreShape[1][0] = $TOWER_COLOUR
$g_aPreShape[1][1] = $TOWER_COLOUR
$g_aPreShape[1][2] = $TOWER_COLOUR
$g_aPreShape[1][3] = $TOWER_COLOUR
Case 2
$g_aPreShape[1][1] = $BOX_COLOUR
$g_aPreShape[1][2] = $BOX_COLOUR
$g_aPreShape[2][1] = $BOX_COLOUR
$g_aPreShape[2][2] = $BOX_COLOUR
case 3
$g_aPreShape[1][1] = $PYRAMID_COLOUR
$g_aPreShape[0][2] = $PYRAMID_COLOUR
$g_aPreShape[1][2] = $PYRAMID_COLOUR
$g_aPreShape[2][2] = $PYRAMID_COLOUR
case 4
$g_aPreShape[0][1] = $LLEANER_COLOUR
$g_aPreShape[1][1] = $LLEANER_COLOUR
$g_aPreShape[1][2] = $LLEANER_COLOUR
$g_aPreShape[2][2] = $LLEANER_COLOUR
case 5
$g_aPreShape[2][1] = $RLEANER_COLOUR
$g_aPreShape[1][1] = $RLEANER_COLOUR
$g_aPreShape[1][2] = $RLEANER_COLOUR
$g_aPreShape[0][2] = $RLEANER_COLOUR
case 6
$g_aPreShape[1][1] = $LKNIGHT_COLOUR
$g_aPreShape[2][1] = $LKNIGHT_COLOUR
$g_aPreShape[2][2] = $LKNIGHT_COLOUR
$g_aPreShape[2][3] = $LKNIGHT_COLOUR
case 7
$g_aPreShape[2][1] = $RKNIGHT_COLOUR
$g_aPreShape[1][1] = $RKNIGHT_COLOUR
$g_aPreShape[1][2] = $RKNIGHT_COLOUR
$g_aPreShape[1][3] = $RKNIGHT_COLOUR
EndSwitch
For $i = 0 To 3
For $j = 0 To 3
If $g_aPreShape[$i][$j] = $EMPTY_COLOUR Then
GUICtrlSetBkColor($g_lblPreviewBoard[$i][$j], $GUI_BKCOLOR_TRANSPARENT)
Else
GUICtrlSetBkColor($g_lblPreviewBoard[$i][$j], $g_aPreShape[$i][$j])
EndIf
Next
Next
EndFunc
Func _MoveShapeLeft()
_MoveShape(-1, 0)
EndFunc
Func _MoveShapeRight()
_MoveShape(1, 0)
EndFunc
Func _MoveShapeDown()
_MoveShape(0, 1)
EndFunc
Func _DropShape()
AdlibDisable()
AdlibEnable("_MoveShapeDown", 25)
EndFunc
Func _MoveShape($nMoveX, $nMoveY)
Local $nCollision, $i, $j
Local $bFilled, $x, $y
Local $sScoreText, $nScore
If _CollisionTest($nMoveX, $nMoveY) Then
If $nMoveY = 1 Then
If $g_nShapeY < 1 Then
AdlibDisable()
MsgBox(0, "AutoIT Tetris", "GAME OVER!")
GUICtrlSetState($g_btnStart, $GUI_ENABLE)
HotKeySet("{LEFT}")
HotKeySet("{RIGHT}")
HotKeySet("{DOWN}")
HotKeySet("{SPACE}")
Return
Else
For $i = 0 To 3
For $j = 0 To 3
If $g_aGameShape[$i][$j] <> $EMPTY_COLOUR Then
$g_aBoard[$g_nShapeX+$i][$g_nShapeY+$j] = $g_aGameShape[$i][$j]
EndIf
Next
Next
For $j = 0 To ($BOARD_HEIGHT-1)
$bFilled = True
For $i = 0 To ($BOARD_WIDTH-1)
If $g_aBoard[$i][$j] = $EMPTY_COLOUR Then
$bFilled = False
ExitLoop
EndIf
Next
If $bFilled Then
$sScoreText = GUICtrlRead($g_lblScore)
$nScore = Number(StringRight($sScoreText, StringLen($sScoreText)-7))+10
If Mod($nScore, 50) = 0 Then
$g_nGameTick -= 10
EndIf
GUICtrlSetData($g_lblScore, "SCORE: " & $nScore)
For $x = 0 To ($BOARD_WIDTH-1)
For $y = $j To 1 Step -1
$g_aBoard[$x][$y] = $g_aBoard[$x][$y-1]
Next
Next
_RedrawGameBoard()
EndIf
Next
AdlibDisable()
_NewShape()
_DrawGameShape()
AdlibEnable("_MoveShapeDown", $g_nGameTick)
EndIf
EndIf
Else
_DrawGameShape(True)
If $nMoveX <> 0 Then $g_nShapeX += $nMoveX
If $nMoveY <> 0 Then $g_nShapeY += $nMoveY
_DrawGameShape()
EndIf
EndFunc
Func _RotateShape()
Local $i, $j, $aTempShape[4][4]
For $i = 0 To 3
For $j = 0 To 3
$aTempShape[3-$j][$i] = $g_aGameShape[$i][$j]
Next
Next
For $i = 0 To 3
For $j = 0 To 3
If $aTempShape[$i][$j] <> $EMPTY_COLOUR Then
If ($g_nShapeX+$i) < 0 Or ($g_nShapeX+$i) > ($BOARD_WIDTH- 1) Or _
($g_nShapeY+$j) < 0 Or ($g_nShapeY+$j) > ($BOARD_HEIGHT-1) Then
Return
EndIf
EndIf
Next
Next
For $x = 0 To ($BOARD_WIDTH-1)
For $y = 0 To ($BOARD_HEIGHT-1)
If $x >= $g_nShapeX And $x < ($g_nShapeX+4) Then
If $y >= $g_nShapeY And $y < ($g_nShapeY+4) Then
If $g_aBoard[$x][$y] <> $EMPTY_COLOUR Then
If $aTempShape[$x-$g_nShapeX][$y-$g_nShapeY] <> $EMPTY_COLOUR Then
Return
EndIf
EndIf
EndIf
EndIf
Next
Next
_DrawGameShape(True)
For $i = 0 To 3
For $j = 0 To 3
$g_aGameShape[$i][$j] = $aTempShape[$i][$j]
Next
Next
_DrawGameShape()
EndFunc
Func _CollisionTest($nMoveX, $nMoveY)
Local $nNewX = $g_nShapeX+$nMoveX
Local $nNewY = $g_nShapeY+$nMoveY
Local $i, $j, $x, $y
For $i = 0 To 3
For $j = 0 To 3
If $g_aGameShape[$i][$j] <> $EMPTY_COLOUR Then
If ($nNewX+$i) < 0 Or ($nNewX+$i) > ($BOARD_WIDTH-1) Or _
($nNewY+$j) < 0 Or ($nNewY+$j) > ($BOARD_HEIGHT-1) Then
Return True
EndIf
EndIf
Next
Next
For $x = 0 To ($BOARD_WIDTH-1)
For $y = 0 To ($BOARD_HEIGHT-1)
If $x >= $nNewX And $x < ($nNewX+4) Then
If $y >= $nNewY And $y < ($nNewY+4) Then
If $g_aBoard[$x][$y] <> $EMPTY_COLOUR Then
If $g_aGameShape[$x-$nNewX][$y-$nNewY] <> $EMPTY_COLOUR Then
Return True
EndIf
EndIf
EndIf
EndIf
Next
Next
Return False
EndFunc
Func _DrawGameShape($bRemove = False)
Local $i, $j
For $i = 0 To 3
For $j = 0 To 3
If $g_aGameShape[$i][$j] <> $EMPTY_COLOUR Then
If $bRemove Then
GUICtrlSetBkColor($g_lblGameBoard[$g_nShapeX+$i][$g_nShapeY+$j], $GUI_BKCOLOR_TRANSPARENT)
Else
GUICtrlSetBkColor($g_lblGameBoard[$g_nShapeX+$i][$g_nShapeY+$j], $g_aGameShape[$i][$j])
EndIf
EndIf
Next
Next
EndFunc
Func _DrawGameBoard()
Local $i, $j
Local $x, $y
$x = 20
$y = 20
For $i = 0 To $BOARD_WIDTH-1
For $j = 0 To $BOARD_HEIGHT-1
GUICtrlCreateLabel("", $x, $y, 25, 25)
$g_lblGameBoard[$i][$j] = GUICtrlCreateLabel("", $x+1, $y+1, 23, 23)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$y = $y+26
Next
$x = $x+26
$y = 20
Next
EndFunc
Func _DrawPreviewBoard()
Local $i, $j
Local $x, $y
$x = 340
$y = 40
GUICtrlCreateLabel("Next Shape:", $x, 20, 104, 18)
For $i = 0 To 3
For $j = 0 To 3
GUICtrlCreateLabel("", $x, $y, 25, 25)
$g_lblPreviewBoard[$i][$j] = GUICtrlCreateLabel("", $x+1, $y+1, 23, 23)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$y = $y+26
Next
$x = $x+26
$y = 40
Next
EndFunc
Func _RedrawGameBoard()
Local $i, $j
For $i = 0 To $BOARD_WIDTH-1
For $j = 0 To $BOARD_HEIGHT-1
If $g_aBoard[$i][$j] = $EMPTY_COLOUR Then
GUICtrlSetBkColor($g_lblGameBoard[$i][$j], $GUI_BKCOLOR_TRANSPARENT)
Else
GUICtrlSetBkColor($g_lblGameBoard[$i][$j], $g_aBoard[$i][$j])
EndIf
Next
Next
EndFunc
Func _NewGame()
Local $i, $j
AdlibDisable()
HotKeySet("{LEFT}", "_MoveShapeLeft")
HotKeySet("{RIGHT}", "_MoveShapeRight")
HotKeySet("{DOWN}", "_RotateShape")
HotKeySet("{SPACE}", "_DropShape")
$g_bGameStarted = False
For $i = 0 To $BOARD_WIDTH-1
For $j = 0 To $BOARD_HEIGHT-1
$g_aBoard[$i][$j] = $EMPTY_COLOUR
GUICtrlSetBkColor($g_lblGameBoard[$i][$j], $GUI_BKCOLOR_TRANSPARENT)
Next
Next
_NewShape()
$g_bGameStarted = True
_DrawGameShape()
$g_nGameTick = 500
AdlibEnable("_MoveShapeDown", $g_nGameTick)
EndFunc
EndIf
Alles anzeigen
Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!