MikeFez Posted July 14, 2006 Posted July 14, 2006 (edited) I am completely changing this project. I am now making a pong game that tracks the motion of two objects and that controlls the paddles. Please tell me what you think of it. I'm still using rysiora's camera script to do this. Movement Tracker Pong= The player can choose which object to follow for player one and two, and you can begin tracking! So far there is no pong, i'm in the process of making it!*NOTE- When using the script, TAB pauses it and ESC closes it**NOTE- The script still need some workMovement Tracker Pongexpandcollapse popup#include <GUIConstants.au3> $destination = @TempDir & "\mySplash.bmp" FileInstall("C:\Documents and Settings\Mike\My Documents\Scripts\Projects\Pongsplash.bmp", $destination);source must be literal string SplashImageOn("Splash Screen", $destination , 500 , 200 , -1 , -1 , 1 ) Sleep(1000); Set to 3 later SplashOff() Global $Paused Global $DISPSIZE HotKeySet("{ESC}", "Terminate") HotKeySet("{TAB}", "TogglePause") MsgBox ( 0, "Attention!", "Please make sure the webcam is not in use by any other applications, as it might result in errors.") $WM_CAP_START = 0x400 $WM_CAP_UNICODE_START = $WM_CAP_START +100 $WM_CAP_PAL_SAVEA = $WM_CAP_START + 81 $WM_CAP_PAL_SAVEW = $WM_CAP_UNICODE_START + 81 $WM_CAP_UNICODE_END = $WM_CAP_PAL_SAVEW $WM_CAP_ABORT = $WM_CAP_START + 69 $WM_CAP_DLG_VIDEOCOMPRESSION = $WM_CAP_START + 46 $WM_CAP_DLG_VIDEODISPLAY = $WM_CAP_START + 43 $WM_CAP_DLG_VIDEOFORMAT = $WM_CAP_START + 41 $WM_CAP_DLG_VIDEOSOURCE = $WM_CAP_START + 42 $WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10 $WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11 $WM_CAP_DRIVER_GET_CAPS = $WM_CAP_START + 14 $WM_CAP_DRIVER_GET_NAMEA = $WM_CAP_START + 12 $WM_CAP_DRIVER_GET_NAMEW = $WM_CAP_UNICODE_START + 12 $WM_CAP_DRIVER_GET_VERSIONA = $WM_CAP_START + 13 $WM_CAP_DRIVER_GET_VERSIONW = $WM_CAP_UNICODE_START + 13 $WM_CAP_EDIT_COPY = $WM_CAP_START + 30 $WM_CAP_END = $WM_CAP_UNICODE_END $WM_CAP_FILE_ALLOCATE = $WM_CAP_START + 22 $WM_CAP_FILE_GET_CAPTURE_FILEA = $WM_CAP_START + 21 $WM_CAP_FILE_GET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 21 $WM_CAP_FILE_SAVEASA = $WM_CAP_START + 23 $WM_CAP_FILE_SAVEASW = $WM_CAP_UNICODE_START + 23 $WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25 $WM_CAP_FILE_SAVEDIBW = $WM_CAP_UNICODE_START + 25 $WM_CAP_FILE_SET_CAPTURE_FILEA = $WM_CAP_START + 20 $WM_CAP_FILE_SET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 20 $WM_CAP_FILE_SET_INFOCHUNK = $WM_CAP_START + 24 $WM_CAP_GET_AUDIOFORMAT = $WM_CAP_START + 36 $WM_CAP_GET_CAPSTREAMPTR = $WM_CAP_START + 1 $WM_CAP_GET_MCI_DEVICEA = $WM_CAP_START + 67 $WM_CAP_GET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 67 $WM_CAP_GET_SEQUENCE_SETUP = $WM_CAP_START + 65 $WM_CAP_GET_STATUS = $WM_CAP_START + 54 $WM_CAP_GET_USER_DATA = $WM_CAP_START + 8 $WM_CAP_GET_VIDEOFORMAT = $WM_CAP_START + 44 $WM_CAP_GRAB_FRAME = $WM_CAP_START + 60 $WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61 $WM_CAP_PAL_AUTOCREATE = $WM_CAP_START + 83 $WM_CAP_PAL_MANUALCREATE = $WM_CAP_START + 84 $WM_CAP_PAL_OPENA = $WM_CAP_START + 80 $WM_CAP_PAL_OPENW = $WM_CAP_UNICODE_START + 80 $WM_CAP_PAL_PASTE = $WM_CAP_START + 82 $WM_CAP_SEQUENCE = $WM_CAP_START + 62 $WM_CAP_SEQUENCE_NOFILE = $WM_CAP_START + 63 $WM_CAP_SET_AUDIOFORMAT = $WM_CAP_START + 35 $WM_CAP_SET_CALLBACK_CAPCONTROL = $WM_CAP_START + 85 $WM_CAP_SET_CALLBACK_ERRORA = $WM_CAP_START + 2 $WM_CAP_SET_CALLBACK_ERRORW = $WM_CAP_UNICODE_START + 2 $WM_CAP_SET_CALLBACK_FRAME = $WM_CAP_START + 5 $WM_CAP_SET_CALLBACK_STATUSA = $WM_CAP_START + 3 $WM_CAP_SET_CALLBACK_STATUSW = $WM_CAP_UNICODE_START + 3 $WM_CAP_SET_CALLBACK_VIDEOSTREAM = $WM_CAP_START + 6 $WM_CAP_SET_CALLBACK_WAVESTREAM = $WM_CAP_START + 7 $WM_CAP_SET_CALLBACK_YIELD = $WM_CAP_START + 4 $WM_CAP_SET_MCI_DEVICEA = $WM_CAP_START + 66 $WM_CAP_SET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 66 $WM_CAP_SET_OVERLAY = $WM_CAP_START + 51 $WM_CAP_SET_PREVIEW = $WM_CAP_START + 50 $WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52 $WM_CAP_SET_SCALE = $WM_CAP_START + 53 $WM_CAP_SET_SCROLL = $WM_CAP_START + 55 $WM_CAP_SET_SEQUENCE_SETUP = $WM_CAP_START + 64 $WM_CAP_SET_USER_DATA = $WM_CAP_START + 9 $WM_CAP_SET_VIDEOFORMAT = $WM_CAP_START + 45 $WM_CAP_SINGLE_FRAME = $WM_CAP_START + 72 $WM_CAP_SINGLE_FRAME_CLOSE = $WM_CAP_START + 71 $WM_CAP_SINGLE_FRAME_OPEN = $WM_CAP_START + 70 $WM_CAP_STOP = $WM_CAP_START + 68 const $a = 110*4 const $c = 131*4 const $qn =(1000/4) #include <GUIConstants.au3> $avi = DllOpen("avicap32.dll") $user = DllOpen("user32.dll") ; Load Camera $Main = GUICreate("Camera",455,290,0,0, $WS_DLGFRAME) $cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,$WS_VISIBLE), "int", 15, "int", 15, "int", 320, "int", 240, "hwnd", $Main, "int", 1) $track1 = GUICtrlCreateButton ("Track Player 1", 345,15,100) $track2 = GUICtrlCreateButton ("Track Player 2", 345,45,100) $START = GUICtrlCreateButton ("Start Pong", 345,105,100) $Quit = GUICtrlCreateButton ("Quit", 345,167.5,100) $ABOUT = GUICtrlCreateButton ("About", 345,230,100) AutoItSetOption ( "MouseCoordMode" ,0) AutoItSetOption ( "PixelCoordMode" ,0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0) GUISetState(@SW_SHOW) GUISetState () ; Setup Do $msg = GUIGetMsg() if $msg = $track1 then MsgBox ( 0, "Instructions", "To track Player 1's color, Place the mouse over the color you would like to track and press enter to exit this Message Box.") $Mousecol = MouseGetPos ( ) $P1col = PixelGetColor ( $Mousecol[0] , $Mousecol[1] ) MsgBox(0,"Player 1's color is", Hex($P1col, 6)) GUICtrlDelete ( $track1 ) endif if $msg = $track2 then MsgBox ( 0, "Instructions", "To track Player 2's color, Place the mouse over the color you would like to track and press enter to exit this Message Box.") $Mousecol = MouseGetPos ( ) $P2col = PixelGetColor ( $Mousecol[0] , $Mousecol[1] ) MsgBox(0,"Player 2's color is", Hex($P2col, 6)) GUICtrlDelete ( $track2 ) endif if $msg = $ABOUT then MsgBox ( 0, "About", "Tracking Program and GUI programmed by MikeFez. Camera script by rysiora.") endif if $msg = $Quit then Terminate() endif Until $msg = $START WinSetOnTop("Camera", "", 1) GUICtrlDelete ( $START ) GUICtrlDelete ( $Quit ) GUICtrlDelete ( $ABOUT) GUISetState() ; Find Players While 1 Sleep (1) ; Find Player 1 $coord = PixelSearch( 15, 15, 320, 240, $P1col, 5 ) If Not @error Then MouseMove($coord[0], $coord[1], 0) ToolTip("Player1 Found", 0, 0) beep(($a*2), $qn) EndIf ; Find Player 2 $coord2 = PixelSearch( 15, 15, 320, 240, $P2col, 5 ) If Not @error Then MouseMove($coord2[0], $coord2[1], 0) ToolTip("Player2 Found", 0, 0) beep(($c*2), $qn) EndIf $ball=GUICreate("", 20, 31, 10, 10,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD)) GUICtrlCreatePic(@Systemdir & "\oobe\images\wpaflag.jpg",40,40, 10,10) WEnd ; Detect Goal While 2 WEnd ; ----------- Pause and Exit Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Pong is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() ;DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_CALLBACK_FRAME, "int", 0, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_END, "int", 0, "int", 0) DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0) ;DllClose($avi) DllClose($user) Exit 0 EndFunc Edited August 23, 2006 by MikeFez
rakudave Posted July 14, 2006 Posted July 14, 2006 respect! that's awsome!!! Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table
MikeFez Posted July 14, 2006 Author Posted July 14, 2006 Yay! I love your pangaea desktops by the way, I have it on my startup
Skrip Posted July 14, 2006 Posted July 14, 2006 Wow man, good job! [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]
MikeFez Posted July 14, 2006 Author Posted July 14, 2006 (edited) I'm acually working on an Itoy or whatever that plastation thing is called. Its really difficult, but I'm planning on making 9 sections of the screen like a tick-tack-toe board and when the finger moves into that area something will happen... like if your playing Sonic the Hedgehog these would be the controls1|2|34|5|67|8|91= Jump left2= Jump3= Jump right4= Move left5= Stay still6= Move right7= That crouch-spin thing left8= Crouch9= That crouch-spin thing rightEDIT-Does anyone know of a way to make it scan the image instead of pixlesearch? Is there a way to make it scan the box itself, no matter where it is placedIts going to be really difficult though Edited July 14, 2006 by MikeFez
erifash Posted July 15, 2006 Posted July 15, 2006 (edited) This is neat! You could probably make something like the Eye Toy for the PS2. Just imagine playing Pong with green and orange highlighters for the paddles! EDIT: Completely skipped the last (previous) post! Sorry. Edited July 15, 2006 by erifash My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver
NELyon Posted July 15, 2006 Posted July 15, 2006 wow, i just have to say this is crazy awesome! now if only i had a webcam...
MikeFez Posted July 15, 2006 Author Posted July 15, 2006 Yep, it would be cool. Right now I'm making it detect how far the highlighter varies from the x and y axis because no matter where you movie it it detects change... I'm sure It will work if I split it into 9 sections like I said, you stay in one section and it continues up or whatever... I just have to find the size and create 9 different portions... but once again, I need a yes or no answer: Is it possible to pixle search on the window no matter where it is, either by finding the title and only searching that window or something else.
erifash Posted July 15, 2006 Posted July 15, 2006 (edited) Is it possible to pixle search on the window no matter where it is, either by finding the title and only searching that window or something else.Yes, if I understood you correctly (it's 2:13 am right now) you could just use WinGetPos(). Look at some of the Win*() functions in the help file. EDIT: You will probably need to set the window on top too. Check out WinSetOnTop(). Edited July 15, 2006 by erifash My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver
MikeFez Posted July 15, 2006 Author Posted July 15, 2006 (edited) Yes, if I understood you correctly (it's 2:13 am right now) you could just use WinGetPos(). Look at some of the Win*() functions in the help file. EDIT: You will probably need to set the window on top too. Check out WinSetOnTop().Exactly! Thanks, I'll have an upgraded version of the script soon... also, the sound one that make 4 sounds is acting weird on my comp suddenly, I dont know why. I'm going to be working on a 2 player pong script also, and another script so you choose an item and place it directy infront of the camera and it automatically begins to detect it.I can also use GUIGetCursorInfo Edited July 15, 2006 by MikeFez
MikeFez Posted July 15, 2006 Author Posted July 15, 2006 (edited) HUGE UPDATE! I am turning this project into a pong project. I deleted all my other scripts and am currently working on this one. I have an updated GUI, The player can choose which object to follow for player one and two, and you can begin tracking... if anyone finds any bugs please tell me! I edited my first post to include the pong script, right now it only recognises player one and two and beeps 1 of 2 sounds when it sees them, like player 1= high beep, player 2= low beep. Edited July 15, 2006 by MikeFez
rakudave Posted July 16, 2006 Posted July 16, 2006 (edited) yeah, sounds cool! btw: i'm glad to hear that my script is being used... ^^ Edited July 16, 2006 by rakudave Pangaea Ruler new, UDF: _GUICtrlCreateContainer(), Pangaea Desktops, Pangaea Notepad, SuDoku, UDF: Table
MikeFez Posted July 16, 2006 Author Posted July 16, 2006 (edited) I've updated it again, I changed my first post so you can see it there. This pong script is really hard, I might need to look at other people's to see how to make mine... dont worry, you'll get credit. EDIT- I added a splash screen at the beginning, I hope I dont need to upload it. Someone tell me if they are having issues because of it, and I'll take it off untill the final release. Also, in the next release I'll add the option for one player also, so 2 people dont need to play... One question though, Should I make it so the camera is the actual pong field and the objects you choose to use are the paddles, or should I make it in a seperate screen? Or even give the option for one or the other? Edited July 16, 2006 by MikeFez
Paulie Posted July 16, 2006 Posted July 16, 2006 this is very nice! just goes to show how limitless autoit is anywhere from installing WinZip to playing highlighter-pong on a webcam
MikeFez Posted July 16, 2006 Author Posted July 16, 2006 Yep! I still wanna know from people weither or not you play pong on a seperate screen or the camera is the pong screen, and the highlighters or whatever you choose is the paddle.
Paulie Posted July 16, 2006 Posted July 16, 2006 Yep! I still wanna know from people weither or not you play pong on a seperate screen or the camera is the pong screen, and the highlighters or whatever you choose is the paddle.i like the idea of the camera being the screen, cause then like you can make it read things likeRed= pong ballGreen= paddle 1Orange= paddle 2Blue = blockersso if there is like a blue object in the background, it bouces off it, like bumpers,Play Pong with living room funiture!!!
MikeFez Posted July 16, 2006 Author Posted July 16, 2006 This pong is so hard... I wish it was easier to make a pong game but it incorporates alot of geometry and lets just say that I didnt do to well with run and rise and stuff... I'm going to try to incorporate this pong onto my GUI and remove the paddles and stuff
Paulie Posted July 16, 2006 Posted July 16, 2006 This pong is so hard... I wish it was easier to make a pong game but it incorporates alot of geometry and lets just say that I didnt do to well with run and rise and stuff... I'm going to try to incorporate this pong onto my GUI and remove the paddles and stuffwell, don't put too much on your plate at once, thats a common mistake, too many people get discouraged from finishing projects because they step back and look at the whole huge picture and think:"How the hell am I gonna do all this?"but if you take it in small chunks, just focus on the task at hand, and handle problems as they arise, then it's done before you know it, and it keeps you mind off the "what will doing this do to the program as a whole" mentalityand as soon as you get stuck, or finish a basic beta version, post it here and people can(and will) help you to make it better.and eventually, you end up with a fun/usefull game/tool that is great and shows autoit's true potential
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now