Jump to content

Trying to Make a Game....


Recommended Posts

Hi....

I'm attempting to make a shooting game (like Duck Hunt) I'm trying to implemet different things....

But first: My questions:

How can I get the centre of an image (a gif), to follow the mouse??? I have done a search but nothing turned up well....

Thanks,

Link to comment
Share on other sites

#include <GUIConstants.au3>


$Main = GUICreate("Game",800,600)

GUICtrlCreateButton("Press ESC to close",300,200,200,200)

$ImageWidth = 68
$ImageHeight = 71
$ImageFile = @Systemdir & "\oobe\images\merlin.gif"

$Crosshair = GUICreate("Crosshair", 68, 71, 10, 10,$WS_POPUP,$WS_EX_LAYERED,$Main)
GUICtrlCreatePic($ImageFile,0,0, $ImageWidth,$ImageHeight)

GUISetState(@SW_SHOW,$Main)
GUISetState(@SW_SHOW,$Crosshair)

While GUIGetMsg() <> $GUI_EVENT_CLOSE
    UpdateCrosshair()
    Sleep(10)
WEnd

Func UpdateCrosshair()
    $Mouse = MouseGetPos()
    If Not @error Then
        WinMove($Crosshair,"",$Mouse[0]-($ImageWidth/2), $Mouse[1]-($ImageHeight/2))
    EndIf
EndFunc

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...