xdmisterx |
|
| Non chiedetemi a cosa serva perchè non lo so neanche io xD. A parte gli scherzi, potrebbe essere usata come base per qualche gioco o...non so xD. In poche parole ci sono due quadrati che si muovono sulla gui(viva le gdi+), una viene mossa dall'utente tramite il mouse, mentre l'altra cerca di raggiungerlo. Per regolare la velocità del "nemico", impostare il valore della variabile $step. CODICE ;game over -by Misterx #include <GuiConstants.au3> #include <GdiPlus.au3> #include <Misc.au3>
HotKeySet("{esc}","esci")
Opt("MouseCoordMode",2)
Global $title = "Game Over - by Misterx", $step = 1.5
$gui = GUICreate($title,500,500,-1,-1,0x80000000) GUISetCursor(3)
GUISetState()
$win = WinGetPos($title) _MouseTrap($win[0],$win[1],$win[0]+500,$win[1]+500)
_GDIPlus_Startup() $hwnd = _GDIPlus_GraphicsCreateFromHWND($gui) $enemy = _GDIPlus_BrushCreateSolid(0xFFFF0000) $gamer = _GDIPlus_BrushCreateSolid(0xFF00A9FF)
$bitmap = _GDIPlus_BitmapCreateFromGraphics(500,500,$hwnd) $buffer = _GDIPlus_ImageGetGraphicsContext($bitmap) _GDIPlus_GraphicsClear($hwnd)
_GDIPlus_GraphicsFillRect($hwnd,0,0,20,20,$enemy) _GDIPlus_GraphicsFillRect($hwnd,480,480,20,20,$gamer)
Dim $posn[2] = [0,0] While 1 Sleep(10) ;posizione del giocatore $pos = MouseGetPos() _GDIPlus_GraphicsClear($hwnd,0xFF94FFFF) $hwnd = _GDIPlus_GraphicsCreateFromHWND($gui) _GDIPlus_GraphicsFillRect($hwnd,$pos[0]-10,$pos[1]-10,20,20,$gamer) ;posizione del nemico If $pos[0] > $posn[0] Then $posn[0] += $step ElseIf $pos[0] < $posn[0] Then $posn[0] -= $step EndIf If $pos[1] > $posn[1] Then $posn[1] += $step ElseIf $pos[1] < $posn[1] Then $posn[1] -= $step EndIf _GDIPlus_GraphicsFillRect($hwnd,$posn[0]-10,$posn[1]-10,20,20,$enemy) ;~ ToolTip($pos[0] &"-"& $pos[1]& @CRLF & $posn[0] &"-"& $posn[1]) Switch GUIGetMsg() Case $gui_event_close Exit EndSwitch WEnd
Func esci() Exit EndFunc ciao
|
| |