BlazerV60 Posted December 1, 2009 Share Posted December 1, 2009 #include <GUIConstantsEx.au3> ;must #include <StaticConstants.au3> ;must #include <WindowsConstants.au3> ;must Global $Form1 = GUICreate("Ball Movement", 600, 500) ;must $x= -100 $y= -100 HotKeySet("{Up}", "North") Func North() $y = $y - 50 ShapeCreation() ;Calls the ShapeCreation function EndFunc HotKeySet("{Down}", "South") Func South() $y = $y + 50 ShapeCreation() ;Calls the ShapeCreation function EndFunc HotKeySet("{Right}", "East") Func East() $x = $x + 50 ShapeCreation() ;Calls the ShapeCreation function EndFunc HotKeySet("{Left}", "West") Func West() $x = $x - 50 ShapeCreation() ;Calls the ShapeCreation function EndFunc GUISetState(@SW_SHOW) ;must While 1 ;must $nMsg = GUIGetMsg() ;must Switch $nMsg ;must Case $GUI_EVENT_CLOSE ;must Exit ;must Func ShapeCreation() ;The ShapeCreation function $Ball = GUICtrlCreateGraphic($x, $y) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xff9933) ;The color of the shape GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 100, 100, 50, 50) ;The shape of the shape(Circle) (-1, $GUI_GR_ELLIPSE, X, Y, Height, Width) GUISetState() EndFunc EndSwitch ;must WEnd ;must Hey guys when I press my arrow keys to move my orange ball, it sometimes doesn't move or sometimes moves in the wrong direction. Can you fix it for me or tell me how to fix it, thanks =D. -Newbie Link to comment Share on other sites More sharing options...
martin Posted December 1, 2009 Share Posted December 1, 2009 Hey guys when I press my arrow keys to move my orange ball, it sometimes doesn't move or sometimes moves in the wrong direction. Can you fix it for me or tell me how to fix it, thanks =D. -NewbieNo. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
jvanegmond Posted December 1, 2009 Share Posted December 1, 2009 Your function definition is in a while loop. I what'd. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Malkey Posted December 1, 2009 Share Posted December 1, 2009 This is one way of doing it. expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> HotKeySet("{Up}", "North") HotKeySet("{Down}", "South") HotKeySet("{Right}", "East") HotKeySet("{Left}", "West") Global $Form1 = GUICreate("Ball Movement", 600, 500, -1, -1, $WS_SIZEBOX, 0x2000000) Global $x = -100, $y = -100, $Ball = GUICtrlCreateGraphic($x, $y), $aWinPos = WinGetPos("Ball Movement") ShapeCreation() GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_RESIZED $aWinPos = WinGetPos("Ball Movement") EndSwitch WEnd Func ShapeCreation() ;The ShapeCreation function ;GUICtrlDelete($Ball) ;Uncomment this line for one ball only $Ball = GUICtrlCreateGraphic($x, $y) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xFF9933) ;The color of the shape GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 100, 100, 50, 50) GUICtrlSetStyle(-1, $SS_NOTIFY) EndFunc ;==>ShapeCreation Func North() If $y > -100 Then $y -= 50 ShapeCreation() EndIf EndFunc ;==>North Func South() If $y < $aWinPos[3] - (Mod($aWinPos[3], 100) + 150) Then $y += 50 ShapeCreation() EndIf EndFunc ;==>South Func East() If $x < $aWinPos[2] - (Mod($aWinPos[2], 100) + 150) Then $x += 50 ShapeCreation() EndIf EndFunc ;==>East Func West() If $x > -100 Then $x -= 50 ShapeCreation() EndIf EndFunc ;==>West Link to comment Share on other sites More sharing options...
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