Jump to content

Having trouble with my script


cppman
 Share

Recommended Posts

Im trying to make $controlID move to the coordinates $x and $y.

could anyone help me out, to tell me how i could do this?

Global $Image, $Width, $Height, $StartX, $StartY
Func SpriteCreate($Image, $Width, $Height, $StartX, $StartY)
    Global $controlID
    $controlID = GUICtrlCreatePic($Image, $StartX, $StartY, $Width, $Height)
    If $controlID Then
        Return $controlID
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc

Func SpriteMove($controlID, $x, $y); move to x and y position

EndFunc

GUICreate("Game Sample", 500, 500, -1, -1)
GUISetBkColor(0x000000)
GUIsetState()
$Sprite = SpriteCreate("sprite.jpg", 25, 25, 15, 15)
sleep(1000)
SpriteMove($Sprite, 200, 15)
While 1
WEnd

yeah, i no, my functions should be after the while loop. but i did this so because i was in the middle of writing this udf and wanted to test it out real quick....

Edited by CHRIS95219
Link to comment
Share on other sites

#include <GuiConstants.au3>

Global $Image, $Width, $Height, $StartX, $StartY
Func SpriteCreate($Image, $Width, $Height, $StartX, $StartY)
    Global $controlID
    $controlID = GUICtrlCreatePic($Image, $StartX, $StartY, $Width, $Height)
    If $controlID Then
        Return $controlID
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc  ;==>SpriteCreate

Func SpriteMove($controlID, $x, $y); move to x and y position
    GUICtrlSetPos($controlID, $x, $y)
EndFunc  ;==>SpriteMove

GUICreate("Game Sample", 500, 500, -1, -1)
GUISetBkColor(0x000000)
GUISetState()
$Sprite = SpriteCreate("sprite.jpg", 25, 25, 15, 15)
Sleep(1000)
SpriteMove($Sprite, 200, 15)
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

example:

#include <GuiConstants.au3>

Global $Image, $Width, $Height, $StartX, $StartY
Func SpriteCreate($Image, $Width, $Height, $StartX, $StartY)
 Global $controlID
 $controlID = GUICtrlCreatePic($Image, $StartX, $StartY, $Width, $Height)
 If $controlID Then
  Return $controlID
 Else
  SetError(1)
  Return 0
 EndIf
EndFunc  ;==>SpriteCreate

Func SpriteMove($controlID, $x, $y); move to x and y position
 GUICtrlSetPos($controlID, $x, $y)
EndFunc  ;==>SpriteMove

GUICreate("Game Sample", 500, 500, -1, -1)
GUISetBkColor(0x000000)
GUISetState()
$Sprite = SpriteCreate("sprite.jpg", 25, 25, 15, 15)
For $x = 25 To 200
 SpriteMove($Sprite, $x, 15)
 Sleep ( 10 )
Next
 
While 1
 $msg = GUIGetMsg()
 If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

#include <GuiConstants.au3>

Global $Image, $Width, $Height, $StartX, $StartY
Func SpriteCreate($Image, $Width, $Height, $StartX, $StartY)
    Global $controlID
    $controlID = GUICtrlCreatePic($Image, $StartX, $StartY, $Width, $Height)
    If $controlID Then
        Return $controlID
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc  ;==>SpriteCreate

Func SpriteMove($controlID, $x, $y); move to x and y position
    GUICtrlSetPos($controlID, $x, $y)
EndFunc  ;==>SpriteMove

GUICreate("Game Sample", 500, 500, -1, -1)
GUISetBkColor(0x000000)
GUISetState()
$Sprite = SpriteCreate("sprite.jpg", 25, 25, 15, 15)
$y = 25
For $x = 25 To 200
    SpriteMove($Sprite, $x, $y)
    Sleep ( 10 )
    $y = $y + 1
Next
    
;~ Sleep(1000)
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • Moderators

Hey Chris... FYI... Take a look at your signature, your returning a decimal value but calling it a Hex value in the variable name

While 1
    Local $Mouse = MouseGetPos()
    Local $MouseX = $Mouse[0]
    Local $MouseY = $Mouse[1]
    Local $ColorHex = PixelGetColor($MouseX, $MouseY)
    TrayTip("information", "Mouse X Position: " & $MouseX & @CRLF & "Mouse Y Position: " & $MouseY & @CRLF & "Hex Color: 0x" & Hex($ColorHex, 6), 0)
    Sleep(10)
WEnd
would fix it :o.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Hey Chris... FYI... Take a look at your signature, your returning a decimal value but calling it a Hex value in the variable name

While 1
    Local $Mouse = MouseGetPos()
    Local $MouseX = $Mouse[0]
    Local $MouseY = $Mouse[1]
    Local $ColorHex = PixelGetColor($MouseX, $MouseY)
    TrayTip("information", "Mouse X Position: " & $MouseX & @CRLF & "Mouse Y Position: " & $MouseY & @CRLF & "Hex Color: 0x" & Hex($ColorHex, 6), 0)
    Sleep(10)
WEnd
would fix it :o.
oh, woops. thanks for pointing that out...
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...