Sign in to follow this  
Followers 0
ludocus

Watch Out!

32 posts in this topic

#1 ·  Posted (edited)

here it is..

Watch Out!

a nice and addictive game...

press Escape to exit

you begin with 6 lives, every time you come into a next level you get 1 live extra..

if all lives are gone then you're game over..

the point is to avoid the white rectangle with your mouse..

MiscConstants is needed:

MiscConstants.au3

Old (lame) small window Watch Out:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=icoontjes\ICO\VistaICO_Toolbar_Icons\Symbol-Error.ico
#AutoIt3Wrapper_outfile=Watch Out!.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <MiscConstants.au3>
$setspeed=10
$fireatmouse=false
global $toptobottom=false, $lefttoright=false, $righttoleft=false, $bottomtotop=false
global $nextgameover=false, $bkcolor=''
global $level[11]=[2, 3, 2, 2, 1, 2, 1, 2, 1, 2]
global $tk[11]=[25, 40, 50, 75, 90, 100, 120, 130, 150, 160]
Opt("GUIOnEventMode", 1)
$p = 0
HotKeySet('{ESC}', '_close')

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Watch Out!", 633, 447, -1, -1, $WS_POPUPWINDOW)
WinSetOnTop($Form1, '', 1)
$tekst = GUICtrlCreateLabel('Score: 0', 0, 0, 100, 50)
GUISetBkColor(0x000000)
GUICtrlSetFont(-1, 12, 800, 'Arial')
GUICtrlSetColor(-1, 0xFFFFFF)
$lives = GUICtrlCreateLabel('||||||', 300, 0, 100, 25)
GUICtrlSetFont(-1, 15, 800, 'Arial')
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, '_close')
$wpos = WinGetPos($Form1)
_MouseTrap($wpos[0], $wpos[1]+10, $wpos[0]+$wpos[2], $wpos[1]+$wpos[3]-10 )
_BeginGame()
HotKeySet('{PAUSE}', '_pause')
#EndRegion ### END Koda GUI section ###
$count=1
GUICtrlSetData($tekst, 'Created by ludocus')
Sleep(1000)
GUICtrlSetData($tekst, 'Press esc to exit..')
Sleep(2000)
GUICtrlSetData($tekst, 'Press break to pause..')
Sleep(2000)
_SetLabel()
$graph = GUICtrlCreateGraphic(0, 0, 100, 100)
GUICtrlSetBkColor(-1, $bkcolor)
GUICtrlSetColor(-1, 0)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 350, 200, 50, 80)
$speed=$setspeed
While 1
    if _NextLvl() then
        if $p >= 10 then
            GUICtrlSetData($tekst, 'Gratz.. Winner!!')
            msgbox(32, 'Congratz!', 'Your the winner of all!!!')
            $p=0
            $count=0
            sleep(2000)
            _SetLabel()
        Else
            GUICtrlSetData($lives, GUICtrlRead($lives)&'|')
            GUICtrlSetData($tekst, 'LEVEL '&$p+2)
            sleep(2000)
            _SetLabel()
            $speed=$speed+$level[$p]
            $p = $p + 1
            $nextgameover=false
        EndIf
    EndIf
    
    GUICtrlSetData($tekst, 'Score: '&$count)
    $count = $count + 1
    $pnum = Random(1, 4, 1)
    $wpos = WinGetPos($Form1)
    $mpos = MouseGetPos()
    global $toptobottom=false, $lefttoright=false, $righttoleft=false, $bottomtotop=false
    if $pnum = 1 Then
        $toptobottom=True
        $num = 0
        $i = Random(0, 633, 1)
        if $fireatmouse=True Then $i = MouseGetPos(1)-$wpos[0]-30
    ElseIf $pnum = 2 Then
        $i = 0
        $lefttoright=True
        $num = Random(0, 447, 1)
        if $fireatmouse=True Then $num = MouseGetPos(1)-$wpos[1]-30
    ElseIf $pnum = 3 Then
        $i = 733
        $righttoleft=True
        $num = Random(0, 447, 1)
        if $fireatmouse=True Then $num = MouseGetPos(1)-$wpos[1]-30
    ElseIf $pnum = 4 Then
        $bottomtotop=True
        $num = Random(0, 633, 1)
        $i = 547
        if $fireatmouse=True Then $i = MouseGetPos(1)-$wpos[0]-30
    EndIf
    While 1
    $wpos = WinGetPos($Form1)
    $mpos = MouseGetPos()
    if $mpos[0] > $wpos[0]+$wpos[2] or $mpos[1] > $wpos[1]+$wpos[3] then _Cheater()
    if $mpos[0] < $wpos[0] or $mpos[1] < $wpos[1] then _Cheater()
    if not WinActive($Form1) then WinActivate($Form1)
    if $lefttoright=true then
        if $i >= 733 then exitloop
        GUICtrlSetPos($graph, $i, $num)
        $i = $i + $speed
    ElseIf $righttoleft=true then 
        if $i <= -100 then exitloop
        GUICtrlSetPos($graph, $i, $num)
        $i = $i - $speed
    ElseIf $toptobottom=true Then
        if $num >= 547 then exitloop
        GUICtrlSetPos($graph, $i, $num)
        $num = $num + $speed
    ElseIf $bottomtotop=true Then
        if $num <= -100 then exitloop
        GUICtrlSetPos($graph, $i, $num)
        $num = $num - $speed
    EndIf
    sleep(10)
    if _ObjectHit($i, $num) then
        if $nextgameover = true then _SetGameOver()
        GUICtrlSetData($tekst, 'Dead..')
        sleep(1000)
        GUICtrlSetData($lives, _Create(StringLen(GUICtrlRead($lives))-1))
        if StringLen(GUICtrlRead($lives))=0 then $nextgameover=true
    EndIf
    WEnd
WEnd

Func _Cheater()
    msgbox(262144+16, 'Cheater!!', 'Cheaters are not tolerated.. '&@CRLF&'Goodbye....')
    exit
EndFunc


Func _BeginGame()
    $bkcolor=0xFFFFFF
    $1 = GUICtrlCreateLabel('Choose color:', 100, 100, 180, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $2 = GUICtrlCreateLabel('F1  --', 100, 130, 60, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xE2CC32)
    $3 = GUICtrlCreateLabel('F2  --', 100, 160, 60, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFF0000)
    $4 = GUICtrlCreateLabel('F3  --', 100, 190, 60, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0x00FF00)
    $5 = GUICtrlCreateLabel('F4  --', 100, 220, 60, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $6 = GUICtrlCreateLabel('(m) Fire at mouse: off', 100, 280, 230, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $7 = GUICtrlCreateLabel('(s) Speed: '&$setspeed, 100, 320, 230, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $8 = GUICtrlCreateLabel('Press space to start..', 300, 360, 230, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $9 = GUICtrlCreateLabel('Press break to pause..', 300, 390, 230, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $10 = GUICtrlCreateLabel('Press escape to exit..', 300, 420, 230, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $graph = GUICtrlCreateGraphic(160, 135, 100, 100)
    GUICtrlSetBkColor(-1, 0xffffff)
    GUICtrlSetColor(-1, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, 350, 200, 50, 80)
    While 1
        if _IsPressed($VK_F1) then 
            GUICtrlSetBkColor($graph, 0xE2CC32)
            $bkcolor=0xE2CC32
            sleep(100)
        EndIf
        if _IsPressed($VK_F2) then
            GUICtrlSetBkColor($graph, 0xFF0000)
            $bkcolor=0xFF0000
            sleep(100)
        EndIf
        if _IsPressed($VK_F3) then 
            GUICtrlSetBkColor($graph, 0x00FF00)
            $bkcolor=0x00FF00
            sleep(100)
        EndIf
        if _IsPressed($VK_F4) then
            GUICtrlSetBkColor($graph, 0xFFFFFF)
            $bkcolor=0xFFFFFF
            sleep(100)
        EndIf
        if _IsPressed($VK_SPACE) then exitloop
        if _IsPressed($VK_M) then
            if $fireatmouse=False Then
                $fireatmouse=True
                GUICtrlSetData($6, '(m) Fire at mouse: on')
            Else
                $fireatmouse=False
                GUICtrlSetData($6, '(m) Fire at mouse: off')
            EndIf
            sleep(100)
        EndIf
        If _IsPressed($VK_S) Then
            $setspeed=$setspeed+1
            GUICtrlSetData($7, '(s) Speed: '&$setspeed)
            if $setspeed=20 then 
                $setspeed=1
                GUICtrlSetData($7, '(s) Speed: '&$setspeed)
            EndIf
            
            sleep(100)
        EndIf
    WEnd
    GUICtrlDelete($1)
    GUICtrlDelete($2)
    GUICtrlDelete($3)
    GUICtrlDelete($4)
    GUICtrlDelete($5)
    GUICtrlDelete($6)
    GUICtrlDelete($7)
    GUICtrlDelete($8)
    GUICtrlDelete($9)
    GUICtrlDelete($10)
    GUICtrlDelete($graph)
    
EndFunc


Func _Create($count)
    global $sReturn=''
    for $i = 1 to $count
        $sReturn &='|'
    Next
    return $sReturn
EndFunc

Func _SetGameOver()
    $speed=$setspeed
    $nextgameover=false
    GUICtrlSetData($tekst, 'Game over.. Score: '&$count)
    sleep(2000)
    GUICtrlSetData($lives, '||||||')
    $count = 0
    $p = 0
    _SetLabel()
EndFunc


Func _NextLvl()
    if $p = 0 Then
        if $count = $tk[$p] then return 1
    Else
        if $count = ($tk[$p]+$tk[($p-1)]) then return 1
    EndIf
    
    return 0
EndFunc


Func _SetLabel()
    GUICtrlSetData($tekst, 'The game begins in: 3')
    Sleep(1000)
    GUICtrlSetData($tekst, 'The game begins in: 2')
    Sleep(1000)
    GUICtrlSetData($tekst, 'The game begins in: 1')
    Sleep(1000)
EndFunc

Func _close()
    Exit
EndFunc

Func _ObjectHit($Ctrl, $num)
    $win = WinGetPos($Form1)
    $pos = MouseGetPos()
    if $pos[0] >= $Ctrl+$win[0] and $pos[0] <= ($Ctrl+$win[0]+100) Then
        if $pos[1] >= $num+$win[1] and $pos[1] <= ($num+$win[1]+100) Then
            return 1
        EndIf
    EndIf
EndFunc

Func _pause()
    _MouseTrap()
    $label = GUICtrlCreateLabel('Paused', 633/2, 447/2, 400, 200)
    GUICtrlSetFont(-1, 30, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $label2 = GUICtrlCreateLabel('Press space to continue', 200, 400, 400, 25)
    GUICtrlSetFont(-1, 15, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    WinSetOnTop($Form1, '', 0)
    Do
        sleep(100)
    Until WinActive($Form1) and _IsPressed($VK_SPACE)
    $wpos = WinGetPos($Form1)
    _MouseTrap($wpos[0], $wpos[1]+10, $wpos[0]+$wpos[2], $wpos[1]+$wpos[3]-10 )
    WinSetOnTop($Form1, '', 1)
    GUICtrlDelete($label)
    GUICtrlDelete($label2)
EndFunc

New, Full Screen Watch Out:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=C:\Documents and Settings\Ludo\Bureaublad\icoontjes\vista icons\ICO\VistaICO_Toolbar_Icons\Symbol-Error.ico
#AutoIt3Wrapper_outfile=Watch Out!.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <MiscConstants.au3>
#include <File.au3>
#include <StaticConstants.au3>
;ClipPut(_ChooseColor(2))
;exit
$rank = 0
;easy = 10
;medium = 20
;hard = 30
;impossible = 50
$setspeed=20
$fireatmouse=false
global $toptobottom=false, $lefttoright=false, $righttoleft=false, $bottomtotop=false
global $nextgameover=false, $bkcolor='', $highscorefile=@AppDataDir&'\Watch Out Highscores.txt'
If not FileExists($highscorefile) then FileWrite($highscorefile, '1: MrPowner=100'&@CRLF&'2: DieHard=50'&@CRLF&'3: Noob=25'&@CRLF&'4: Loser=10')
global $level[11]=[2, 3, 2, 2, 1, 2, 1, 2, 1, 2]
global $tk[11]=[25, 40, 50, 75, 90, 100, 120, 130, 150, 160]
Opt("GUIOnEventMode", 1)
$p = 0
HotKeySet('{ESC}', '_close')

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Watch Out!", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUPWINDOW)
WinSetOnTop($Form1, '', 1)
$tekst = GUICtrlCreateLabel('Score: 0', 0, 0, 100, 50)
GUISetBkColor(0x000000)
GUICtrlSetFont(-1, 12, 800, 'Arial')
GUICtrlSetColor(-1, 0xFFFFFF)
$lives = GUICtrlCreateLabel('||||||', 300, 0, 100, 25)
GUICtrlSetFont(-1, 15, 800, 'Arial')
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, '_close')
$wpos = WinGetPos($Form1)
_MouseTrap($wpos[0], $wpos[1]+10, $wpos[0]+$wpos[2], $wpos[1]+$wpos[3]-10 )
_BeginGame()
HotKeySet('{PAUSE}', '_pause')
#EndRegion ### END Koda GUI section ###
$count=1
GUICtrlSetData($tekst, 'Created by ludocus')
Sleep(1000)
GUICtrlSetData($tekst, 'Press esc to exit..')
Sleep(2000)
GUICtrlSetData($tekst, 'Press break to pause..')
Sleep(2000)
_SetLabel()
$graph = GUICtrlCreateGraphic(0, 0, 100, 100)
GUICtrlSetBkColor(-1, $bkcolor)
GUICtrlSetColor(-1, 0)
GUICtrlSetGraphic(-1, $GUI_GR_RECT, 350, 200, 50, 80)
$speed=$setspeed
While 1
    if _NextLvl() then
        if $p >= 10 then
            GUICtrlSetData($tekst, 'Gratz.. Winner!!')
            msgbox(32, 'Congratz!', 'You are the winner of all!!!')
            $p=0
            $count=0
            sleep(2000)
            _SetLabel()
        Else
            GUICtrlSetData($lives, GUICtrlRead($lives)&'|')
            GUICtrlSetData($tekst, 'LEVEL '&$p+2)
            sleep(2000)
            _SetLabel()
            $speed=$speed+$level[$p]
            $p = $p + 1
            $nextgameover=false
        EndIf
    EndIf
    
    GUICtrlSetData($tekst, 'Score: '&$count)
    $count = $count + 1
    $pnum = Random(1, 4, 1)
    ;$wpos = WinGetPos($Form1)
    $mpos = MouseGetPos()
    global $toptobottom=false, $lefttoright=false, $righttoleft=false, $bottomtotop=false
    if $pnum = 1 Then
        $toptobottom=True
        $num = 0
        $i = Random(0, @DesktopWidth, 1)
        if $fireatmouse=True Then $i = MouseGetPos(0)+30
    ElseIf $pnum = 2 Then
        $i = 0
        $lefttoright=True
        $num = Random(0, @DesktopHeight, 1)
        if $fireatmouse=True Then $num = MouseGetPos(1)-30
    ElseIf $pnum = 3 Then
        $i = @DesktopWidth
        $righttoleft=True
        $num = Random(0, @DesktopHeight, 1)
        if $fireatmouse=True Then $num = MouseGetPos(1)-30
    ElseIf $pnum = 4 Then
        $bottomtotop=True
        $num = @DesktopHeight
        $i = Random(0, @DesktopWidth, 1)
        if $fireatmouse=True Then $i = MouseGetPos(0)+30
    EndIf
    
    While 1
    ;$wpos = WinGetPos($Form1)
    $mpos = MouseGetPos()
    ;if $mpos[0] > $wpos[0]+$wpos[2] or $mpos[1] > $wpos[1]+$wpos[3] then _Cheater()
    ;if $mpos[0] < $wpos[0] or $mpos[1] < $wpos[1] then _Cheater()
    if not WinActive($Form1) then WinActivate($Form1)
    if $lefttoright=true then
        if $i >= @DesktopWidth+100 then exitloop
        GUICtrlSetPos($graph, $i, $num)
        $i = $i + $speed
    ElseIf $righttoleft=true then 
        if $i <= -100 then exitloop
        GUICtrlSetPos($graph, $i, $num)
        $i = $i - $speed
    ElseIf $toptobottom=true Then
        if $num >= @DesktopHeight+100 then exitloop
        GUICtrlSetPos($graph, $i, $num)
        $num = $num + $speed
    ElseIf $bottomtotop=true Then
        if $num <= -100 then exitloop
        GUICtrlSetPos($graph, $i, $num)
        $num = $num - $speed
    EndIf
    sleep(10)
    if _ObjectHit($i, $num) then
        if $nextgameover = true then _SetGameOver()
        GUICtrlSetData($tekst, 'Dead..')
        sleep(1000)
        GUICtrlSetData($lives, _Create(StringLen(GUICtrlRead($lives))-1))
        if StringLen(GUICtrlRead($lives))=0 then $nextgameover=true
    EndIf
    WEnd
WEnd

Func _Cheater()
    msgbox(262144+16, 'Cheater!!', 'Cheaters are not tolerated.. '&@CRLF&'Goodbye....')
    exit
EndFunc


Func _BeginGame()
    $bkcolor=0xFFFFFF
    $1 = GUICtrlCreateLabel('Choose color:', 100, 100, 180, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $2 = GUICtrlCreateLabel('F1  --', 100, 130, 60, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0x1115B9)
    $3 = GUICtrlCreateLabel('F2  --', 100, 160, 60, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFF0000)
    $4 = GUICtrlCreateLabel('F3  --', 100, 190, 60, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0x00FF00)
    $5 = GUICtrlCreateLabel('F4  --', 100, 220, 60, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $6 = GUICtrlCreateLabel('(m) Fire at mouse: off', 100, 280, 230, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $7 = GUICtrlCreateLabel('(s) Speed: '&$setspeed, 100, 320, 230, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $8 = GUICtrlCreateLabel('Press space to start..', 300, 360, 230, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $9 = GUICtrlCreateLabel('Press break to pause..', 300, 390, 230, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $10 = GUICtrlCreateLabel('Press escape to exit..', 300, 420, 230, 20)
    GUICtrlSetFont(-1, 12, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $11 =  GUICtrlCreateLabel('Highscores:', 690, 80, 180, 30)
    GUICtrlSetFont(-1, 16, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $12 = GUICtrlCreateListView('Rank:|Name:|Score:', 585, 140, 350, 449)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 46)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150)
    GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150)
    GUICtrlSetFont(-1, 10, 400, 'Arial')
    GUICtrlSetColor(-1, 0x1115B9)
    ;0x6ABBF7
    GUICtrlSetBkColor(-1, 0xE22F1B)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE)
    $graph = GUICtrlCreateGraphic(160, 135, 100, 100)
    GUICtrlSetBkColor(-1, 0xffffff)
    GUICtrlSetColor(-1, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, 350, 200, 50, 80)
    $load = _Load()
    _GUICtrlListView_BeginUpdate($12)
    For $i = 1 to $load[0]
        $currentview = GUICtrlCreateListViewItem($load[$i], $12)
        ;0x80C6F9
        GUICtrlSetBkColor(-1, 0xEA8D26)
    Next
    _GUICtrlListView_EndUpdate($12)
    
    
    While 1
        if _IsPressed($VK_F1) then 
            GUICtrlSetBkColor($graph, 0x1115B9)
            $bkcolor=0x1115B9
            sleep(100)
        EndIf
        if _IsPressed($VK_F2) then
            GUICtrlSetBkColor($graph, 0xFF0000)
            $bkcolor=0xFF0000
            sleep(100)
        EndIf
        if _IsPressed($VK_F3) then 
            GUICtrlSetBkColor($graph, 0x00FF00)
            $bkcolor=0x00FF00
            sleep(100)
        EndIf
        if _IsPressed($VK_F4) then
            GUICtrlSetBkColor($graph, 0xFFFFFF)
            $bkcolor=0xFFFFFF
            sleep(100)
        EndIf
        if _IsPressed($VK_SPACE) then exitloop
        if _IsPressed($VK_M) then
            if $fireatmouse=False Then
                $fireatmouse=True
                GUICtrlSetData($6, '(m) Fire at mouse: on')
            Else
                $fireatmouse=False
                GUICtrlSetData($6, '(m) Fire at mouse: off')
            EndIf
            sleep(100)
        EndIf
        If _IsPressed($VK_S) Then
            $setspeed=$setspeed+1
            GUICtrlSetData($7, '(s) Speed: '&$setspeed)
            if $setspeed>=50 then 
                $setspeed=1
                GUICtrlSetData($7, '(s) Speed: '&$setspeed)
            EndIf
            
            sleep(100)
        EndIf
    WEnd
    GUICtrlDelete($1)
    GUICtrlDelete($2)
    GUICtrlDelete($3)
    GUICtrlDelete($4)
    GUICtrlDelete($5)
    GUICtrlDelete($6)
    GUICtrlDelete($7)
    GUICtrlDelete($8)
    GUICtrlDelete($9)
    GUICtrlDelete($10)
    GUICtrlDelete($11)
    GUICtrlDelete($12)
    GUICtrlDelete($graph)
    
EndFunc


Func _Create($count)
    global $sReturn=''
    for $i = 1 to $count
        $sReturn &='|'
    Next
    return $sReturn
EndFunc

Func _SetGameOver()
    $speed=$setspeed
    $nextgameover=false
    GUICtrlSetData($tekst, 'Game over.. Score: '&$count)
    WinSetOnTop($Form1, '', 0)
    $name = InputBox('Highscore', 'What is your name?', '', '', 100, 100, -1, -1)
    _Highscore($count, $name)
    WinSetOnTop($Form1, '', 1)
    sleep(2000)
    GUICtrlSetData($lives, '||||||')
    $count = 0
    $p = 0
    _SetLabel()
EndFunc


Func _NextLvl()
    if $p = 0 Then
        if $count = $tk[$p] then return 1
    Else
        if $count = ($tk[$p]+$tk[($p-1)]) then return 1
    EndIf
    
    return 0
EndFunc


Func _SetLabel()
    GUICtrlSetData($tekst, 'The game begins in: 3')
    Sleep(1000)
    GUICtrlSetData($tekst, 'The game begins in: 2')
    Sleep(1000)
    GUICtrlSetData($tekst, 'The game begins in: 1')
    Sleep(1000)
EndFunc

Func _close()
    Exit
EndFunc

Func _ObjectHit($Ctrl, $num)
    $win = WinGetPos($Form1)
    $pos = MouseGetPos()
    if $pos[0] >= $Ctrl+$win[0] and $pos[0] <= ($Ctrl+$win[0]+100) Then
        if $pos[1] >= $num+$win[1] and $pos[1] <= ($num+$win[1]+100) Then
            return 1
        EndIf
    EndIf
EndFunc

Func _pause()
    _MouseTrap()
    $label = GUICtrlCreateLabel('Paused', 633/2, 447/2, 400, 200)
    GUICtrlSetFont(-1, 30, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    $label2 = GUICtrlCreateLabel('Press space to continue', 200, 400, 400, 25)
    GUICtrlSetFont(-1, 15, 800, 'Arial')
    GUICtrlSetColor(-1, 0xFFFFFF)
    WinSetOnTop($Form1, '', 0)
    Do
        sleep(100)
    Until WinActive($Form1) and _IsPressed($VK_SPACE)
    $wpos = WinGetPos($Form1)
    _MouseTrap($wpos[0], $wpos[1]+10, $wpos[0]+$wpos[2], $wpos[1]+$wpos[3]-10 )
    WinSetOnTop($Form1, '', 1)
    GUICtrlDelete($label)
    GUICtrlDelete($label2)
EndFunc

Func _Load()
    $reda = FileRead($highscorefile)
    $new1 = StringReplace($reda, ': ', '|')
    $new2 = StringReplace($new1, '=', '|')
    $return = StringSplit($new2, @CRLF, 1)
    return $return
EndFunc

Func _Highscore($score, $name)
    $write = 'niks'
    $write1 = 'niks'
    If not FileExists($highscorefile) then FileWrite($highscorefile, '1: MrPowner=100'&@CRLF&'2: DieHard=50'&@CRLF&'3: Noob=25'&@CRLF&'4: Loser=10')
    $totalfile = FileRead($highscorefile)
    if $totalfile = '' Then 
        FileWrite($highscorefile, '1: MrPowner=100'&@CRLF&'2: DieHard=50'&@CRLF&'3: Noob=25'&@CRLF&'4: Loser=10')
        $totalfile = FileRead($highscorefile)
    EndIf
    $line = StringSplit($totalfile, @CRLF, 1)
    $izb = $line[$line[0]]
    $lbp = StringSplit($izb, '=', 1)
    $lastscore = $lbp[2]
    if $score < $lastscore then
        $write = $totalfile&@CRLF&($line[0]+1)&': '&$name&'='&$score
    Else
        For $i = 1 to $line[0]
            if $write = 'niks' and $write1 = 'niks' then
                $splitscore = StringSplit($line[$i], '=', 1)
                ;msgbox(0, $score, $splitscore[2])
                if $score >= $splitscore[2] Then
                    $split = StringSplit($totalfile, $line[$i], 1)
                    if $split[1]='' then
                        $write = $i&': '&$name&'='&$score&@CRLF&$line[$i]&$split[2]
                    Else
                        $write = $split[1]&$i&': '&$name&'='&$score&@CRLF&$line[$i]&$split[2]
                    EndIf
                    $rank=$i
                    $write1 = 'alles'
                    $i -= 1
                EndIf
                ;msgbox(0, $write1, $write)
            Else
                if $line[$i] = '' then exitloop
                $write = StringReplace($write, $line[$i], ($i+1)&StringRight($line[$i], StringLen($line[$i])-StringLen($i)))
                ;msgbox(0, $line[$i]&' = '&$i, $write)
            EndIf
        Next
    EndIf
    FileDelete($highscorefile)
    _FileCreate($highscorefile)
    ;_FileWriteToLine($highscorefile, 1, $write)
    FileWrite($highscorefile, $write)
    if $rank = 1 then Msgbox(0, 'Congratulations!', "You got a new highscore: "&$score)
EndFunc

Download compiled version here

Changes with update:

-Fullscreen

-Menu at start

-Highscores

-Some bug fixes..

Enjoy:)

Edited by ludocus

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Share this post


Link to post
Share on other sites

thnx :)

Share this post


Link to post
Share on other sites

I got level 6, and 144.. fun game!


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

I'll tell ya a cheat that worked for me:

Put you mouse in the top right corner, and you don't get hit very often... once a level maximum ^^


[u]My OpenSource Projects:[/u]- [BEEP] proMusiX- Search autorun.inf

Share this post


Link to post
Share on other sites

Nice game.. It is fun..


code

Share this post


Link to post
Share on other sites

I got 236. I just played the game normally until I got 200, then I just moved my mouse out of the game area and I never got hit.

Share this post


Link to post
Share on other sites

found out how to cheat.

Start the game - tap the windows key, and move your mouse outside the block. Bam. Cheat. Win.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

thnx.. :) I updated the top post..

new functions:

a begin screen

an ability to pause the game

ability to choose option to fire the brick at your mouse

ability to set the speed

ability to choose color of the brick.. :P

Share this post


Link to post
Share on other sites

Updated it again, try to cheat now :)

Share this post


Link to post
Share on other sites

It's in his signature. Pretty stupid including a file non of us particularly want.

ohh... I wasn't looking in his sig :)

ok then, if I add include, and remove "\" marks from script it works, but why does the window needs to be on top even if I pause the game?

p.s. good add to the game would be squares popping up from any side of the game window, not only from the left side :P

Share this post


Link to post
Share on other sites

Im very sorry for the miscconstants thingie..

@sandin

yeh that would be cool :)!

Share this post


Link to post
Share on other sites

updated the pause thing and the always on top thing... :)

Share this post


Link to post
Share on other sites

I did it!,

the brick now comes from the top, bottom, left or right!

enjoy!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0