Sign in to follow this  
Followers 0
cppman

Catch The Clown!

12 posts in this topic

#1 ·  Posted (edited)

Completely rewrote it :D. Better scoring technique and collision detection.

*added countdown + timer.

#include <GUIConstants.au3>
$pos = MouseGetPos()
Global Const $COLOR_BLACK  = 0x000000
Global Const $COLOR_WHITE  = 0xFFFFFF
Global Const $CLOWN_WIDTH  = 32
Global Const $CLOWN_HEIGHT = 32
Global       $CLOWN_CURX   = 250
Global       $CLOWN_CURY   = 250
Global       $CLOWN_IMAGE  = "clown.bmp"
Global       $CLOWN_HSPEEd  = 1.5
Global       $CLOWN_VSPEED  = 1
Global       $MOUSE_X      = $pos[0]
Global       $MOUSE_Y      = $pos[1]
Global       $CUR_SCORE    = 0
Global       $CUR_TIMELEFT = 15
GUICreate("Catch The Clown! (Updated)", 500, 500)
GUISetBkColor( $COLOR_BLACK )
$CLOWN = GUICtrlCreatePic($CLOWN_IMAGE, $CLOWN_CURX, $CLOWN_CURY, $CLOWN_WIDTH, $CLOWN_HEIGHT)
$score_lb = GUICtrlCreateLabel("Score: " & $CUR_SCORE, 0, 0, 500)
$time_time = GUICtrlCreateLabel("Time Remaining: " & $CUR_TIMELEFT & " seconds.", 0, 25, 500, 500)
GUICtrlSetColor($score_lb, $COLOR_WHITE)
GUICtrlSetColor($time_time, $COLOR_WHITE)
GUICtrlSetBkCOlor($CLOWN, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkCOlor($score_lb, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetBkCOlor($time_time, $GUI_BKCOLOR_TRANSPARENT)
GUISetState()
;Add Timing
_CreateTimer("Count", 1) ;1 second
While (GUIGetMsg() <> -3)
    if (_IsClicked()) Then 
        ;Get whether we are at a positive or negative speed
        if (StringInStr(String($CLOWN_HSPEED), "-")) Then
            $CLOWN_HSPEED += -.05
        Else
            $CLOWN_HSPEED += .05
        EndIf
        
        if (StringInStr(String($CLOWN_VSPEED), "-")) Then
            $CLOWN_VSPEED += -.05
        Else
            $CLOWN_VSPEED += .05
        EndIf
        
        $CUR_SCORE += 1
    EndIf
    if ($CLOWN_CURX >= (500-$CLOWN_WIDTH)) then 
        SoundPlay("bounce.wav", 0)
        $CLOWN_HSPEED *= -1
    EndIf
    if ($CLOWN_CURX <= 0) then 
        SoundPlay("bounce.wav", 0)
        $CLOWN_HSPEED *= -1
    EndIf
    
    if ($CLOWN_CURY >= 500-$CLOWN_HEIGHT) then 
        SoundPlay("bounce.wav", 0)
        $CLOWN_VSPEED *= -1
    EndIf
        
    if ($CLOWN_CURY <= 0) then 
        SoundPlay("bounce.wav", 0)
        $CLOWN_VSPEED *= -1
    EndIf
    
    $CLOWN_CURX += $CLOWN_HSPEED
    $CLOWN_CURY += $CLOWN_VSPEED
    ControlMove("Catch The Clown! (Updated)", "", $CLOWN, $CLOWN_CURX, $CLOWN_CURY)
WEnd

Func _IsClicked()
    if (GUIGetMsg() == $CLOWN) Then
        GUICtrlSetData($score_lb, "Score: " & $CUR_SCORE)
        SoundPlay("click.wav", 0)
        Return True
    Else
        Return False
    EndIf
EndFunc

Func _CreateTimer($function, $time)
    AdLibEnable($function, $time*1000)
EndFunc

Func _DeleteTimer()
    AdLibDisable()
EndFunc

Func GameOver()
    GUICtrlDelete($CLOWN)
    GUICtrlDelete($score_lb)
    GUICtrlDelete($time_time)
    GUICtrlCreateLabel("Game Over!" & @CRLF & "Score: " & $CUR_SCORE, 50, 100, 500, 500)
    GUICtrlSetFont(-1, 30)
    GUICtrlSetColor(-1, $COLOR_WHITE)
    While (GUIGetMsg() <> -3)
    WEnd
    _DeleteTimer()
    Exit
EndFunc

Func Count()
    $CUR_TIMELEFT -= 1
    GUICtrlSetData($time_time, "Time Remaining: " & $CUR_TIMELEFT & " seconds.")
    if ($CUR_TIMELEFT <= 0) Then
        GameOver()
    EndIf
    if ($CUR_TIMELEFT < 10) Then
        GUICtrlSetColor($time_time, 0x00FF00)
    EndIf
    if ($CUR_TIMELEFT < 5) Then
        GUICtrlSetColor($time_time, 0xFF0000)
    EndIf
    
EndFunc

the needed files:

Edited by CHRIS95219

Share this post


Link to post
Share on other sites



I got 14949. Is that bad? The game isn't bad either


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

lol, thanks.. my highscore is 10440(something like that), and thats cuz im used to it, so i guess its pretty good. :D

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

EDIT: Good job.

Edited by gamepin126

Share this post


Link to post
Share on other sites

EDIT: Good job.

yeah cool

i got 15441

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hi,

I got 962 with a bot :D

Edit: 954

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Hi,

I got 962 with a bot :party:

Edit: 954

So long,

Mega

so lol,

i got an error with using my bot :D:P :

If $msg = $clown then ClownClick() 
Error: Recursion level has been exceede - Autoit will quit to prevent stack overflow

That's because i changed $count to 10000 :D

HotKeySet ("{ESC}","exitps")

ProcessWait ("clown.exe")

while 1 
$coord = PixelSearch( 0, 0, 1280, 1280, 0xFF0000 )
If Not @error Then
    MouseClick ("Left", $coord[0]+10,$coord[1]+10,1,1)
EndIf
WEnd

func exitps()
exit 0
EndFunc

credit to the poster of the script

p.s. i got 1140 as my score :)

Edited by D.Peeters

Share this post


Link to post
Share on other sites

2030

...with bot

Share this post


Link to post
Share on other sites

26092.....nice game


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

I got 8997 all by myself... 2nd try :P Am I good or what?! :)

Nice game btw... But get some other sound! Don't copy sound and picture from game maker...

Share this post


Link to post
Share on other sites

wow, this post came back to haunt me :)... This game was a bit cheap(i thought), rewrote it with the new collision technique i learned :D.

@Rallert > I used GM's sound and art was because I was trying to replicate it :P

check first post for new code!

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