_Lexa98_
Осваивающий
- Сообщения
- 551
- Репутация
- 25
Написал скрипт питомца:
И получается так:
То есть картинка остаётся и поверх неё накладывается следующая.
Исправил, но теперь он при движении жутко мигает:
Управление:
INSERT - Вызов меню команд
END - Выход
Команды:
go - бежать
seat - стоять
Добавлено:
Кто-нибудь знает как?
Код:
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#NoTrayIcon
HotKeySet("{INSERT}", "Command")
HotKeySet("{END}", "close")
Global $nNewPos[2], $nCurrentPos[2], $aPos = 0, $w = 90, $h = 52
Global Const $STM_SETIMAGE = 0x172
$PngFile = @ScriptDir & '\RIGHT.png'
$PET = GUICreate("", $w, $h, 0, 0, $WS_POPUP, BitOr($WS_EX_LAYERED,$WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
GUISetBkColor ( 0x000000 )
$Pic = GUICtrlCreatePic("", 0, 0, 90, 52)
_SetPNGIntoPicControl($Pic, $PngFile)
GUISetState(@SW_SHOW)
;WinMove ( "PET", "", $nNewPos[0], $nNewPos[1], 81, 52, 100 )
Func _SetPNGIntoPicControl($iPic, $sPNGFile)
_GDIPlus_Startup()
Local $hImage = _GDIPlus_ImageLoadFromFile($sPNGFile)
Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap))
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
EndFunc
Func _go()
While 1
$nMSG = GUIGetMsg()
$aPos = MouseGetPos()
_newPos()
If $nCurrentPos[0] <> $nNewPos[0] Or $nCurrentPos[1] <> $nNewPos[1] Then
Sleep(30)
WinMove ( "PET", "", $nNewPos[0], $nNewPos[1] )
$nCurrentPos[0] = $nNewPos[0]
$nCurrentPos[1] = $nNewPos[1]
EndIf
WEnd
EndFunc
Func Command()
$com = InputBox ( "P.E.T.", "Command" )
If $com = "seat" Then
While 1
Sleep (100)
WEnd
EndIf
If $com = "go" Then
_go()
EndIf
EndFunc
Func _newPos()
If $nCurrentPos[0] > $aPos[0] + 100 Then
$nNewPos[0] = $nCurrentPos[0] - 5
WinMove($PET, '', $nNewPos[0], $nNewPos[1], 90, 52)
$PngFile = @ScriptDir & '\LEFT.png'
_SetPNGIntoPicControl($Pic, $PngFile)
EndIf
If $nCurrentPos[0] < $aPos[0] - 100 Then
$nNewPos[0] = $nCurrentPos[0] + 5
WinMove($PET, '', $nNewPos[0], $nNewPos[1], 90, 52)
$PngFile = @ScriptDir & '\RIGHT.png'
_SetPNGIntoPicControl($Pic, $PngFile)
EndIf
If $nCurrentPos[1] > $aPos[1] + 100 Then
$nNewPos[1] = $nCurrentPos[1] - 5
WinMove($PET, '', $nNewPos[0], $nNewPos[1], 52, 90)
$PngFile = @ScriptDir & '\UP.png'
_SetPNGIntoPicControl($Pic, $PngFile)
EndIf
If $nCurrentPos[1] < $aPos[1] - 100 Then
$nNewPos[1] = $nCurrentPos[1] + 5
WinMove($PET, '', $nNewPos[0], $nNewPos[1], 52, 90)
$PngFile = @ScriptDir & '\DOWN.png'
_SetPNGIntoPicControl($Pic, $PngFile)
EndIf
EndFunc
Func close()
Exit
EndFunc
While 1
Sleep(100)
WEnd
И получается так:
То есть картинка остаётся и поверх неё накладывается следующая.
Исправил, но теперь он при движении жутко мигает:
Код:
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#NoTrayIcon
HotKeySet("{INSERT}", "Command")
HotKeySet("{END}", "close")
Global $nNewPos[2], $nCurrentPos[2], $aPos = 0, $w = 90, $h = 52
Global Const $STM_SETIMAGE = 0x172
$PngFile = @ScriptDir & '\RIGHT.png'
$PET = GUICreate("", $w, $h, 0, 0, $WS_POPUP, BitOr($WS_EX_LAYERED,$WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
GUISetBkColor ( 0x000000 )
$Pic = GUICtrlCreatePic("", 0, 0, 90, 52)
_SetPNGIntoPicControl($Pic, $PngFile)
GUISetState(@SW_SHOW)
;WinMove ( "PET", "", $nNewPos[0], $nNewPos[1], 81, 52, 100 )
Func _SetPNGIntoPicControl($iPic, $sPNGFile)
_GDIPlus_Startup()
Local $hImage = _GDIPlus_ImageLoadFromFile($sPNGFile)
Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap))
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
EndFunc
Func _go()
While 1
$nMSG = GUIGetMsg()
$aPos = MouseGetPos()
_newPos()
If $nCurrentPos[0] <> $nNewPos[0] Or $nCurrentPos[1] <> $nNewPos[1] Then
Sleep(30)
WinMove ( "PET", "", $nNewPos[0], $nNewPos[1] )
$nCurrentPos[0] = $nNewPos[0]
$nCurrentPos[1] = $nNewPos[1]
EndIf
WEnd
EndFunc
Func Command()
$com = InputBox ( "P.E.T.", "Command" )
If $com = "seat" Then
While 1
Sleep (100)
WEnd
EndIf
If $com = "go" Then
_go()
EndIf
EndFunc
Func _newPos()
If $nCurrentPos[0] > $aPos[0] + 100 Then
$nNewPos[0] = $nCurrentPos[0] - 5
WinMove($PET, '', $nNewPos[0], $nNewPos[1], 90, 52)
$PngFile = @ScriptDir & '\LEFT.png'
GUICtrlDelete ($Pic)
$Pic = GUICtrlCreatePic("", 0, 0, 90, 52)
_SetPNGIntoPicControl($Pic, $PngFile)
EndIf
If $nCurrentPos[0] < $aPos[0] - 100 Then
$nNewPos[0] = $nCurrentPos[0] + 5
WinMove($PET, '', $nNewPos[0], $nNewPos[1], 90, 52)
$PngFile = @ScriptDir & '\RIGHT.png'
GUICtrlDelete ($Pic)
$Pic = GUICtrlCreatePic("", 0, 0, 90, 52)
_SetPNGIntoPicControl($Pic, $PngFile)
EndIf
If $nCurrentPos[1] > $aPos[1] + 100 Then
$nNewPos[1] = $nCurrentPos[1] - 5
WinMove($PET, '', $nNewPos[0], $nNewPos[1], 52, 90)
$PngFile = @ScriptDir & '\UP.png'
GUICtrlDelete ($Pic)
$Pic = GUICtrlCreatePic("", 0, 0, 90, 52)
_SetPNGIntoPicControl($Pic, $PngFile)
EndIf
If $nCurrentPos[1] < $aPos[1] - 100 Then
$nNewPos[1] = $nCurrentPos[1] + 5
WinMove($PET, '', $nNewPos[0], $nNewPos[1], 52, 90)
$PngFile = @ScriptDir & '\DOWN.png'
GUICtrlDelete ($Pic)
$Pic = GUICtrlCreatePic("", 0, 0, 90, 52)
_SetPNGIntoPicControl($Pic, $PngFile)
EndIf
EndFunc
Func close()
Exit
EndFunc
While 1
Sleep(100)
WEnd
Управление:
INSERT - Вызов меню команд
END - Выход
Команды:
go - бежать
seat - стоять
Добавлено:
Сообщение автоматически объединено:
Кто-нибудь знает как?