Sceenshot :
Nhạc nền: Sakurairo Maukoro - Mika Nakashima (Xe đạp - Thùy Chi)
Mã nguồn:
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <Sound.au3>
Opt("GUIOnEventMode", 1)
Global $nPI = 3.1415926535897932384626433832795
Global Const $nTau = ACos(-1) * 2
Global $vNTdll = DllOpen("ntdll.dll")
Global $tPrecSleep = DllStructCreate("int64 time;")
Global $pPrecSleep = DllStructGetPtr($tPrecSleep)
;###-v-SETTINGS-v-###
Global $nFPS = 100
Global $iWidth = 800
Global $iHeight = 600
Global $iARGB_Snow = 0xFFFFFFFF
Global $iFlakeCount = 200
Global $iMinFallingSpeed = 20, $iMaxFallingSpeed = 50
Global $iMinOscillations = 2, $iMaxOscillations = 5
Global $iMinOscillationDist = 10, $iMaxOscillationDist = 50
Global $iMinRadius = 1, $iMaxRadius = 3
Global $iBlastRadius = 200
Global $iBlastAccell = 300
Global $nAirFriction = 0.95
;###-^-SETTINGS-^-###
Global $aFlakes[$iFlakeCount + 1][8] = [[$iFlakeCount]]
Global $hDC_Window, $hDC_Bitmap, $hBitmap, $hGraphics, $hOldObj, $hBrush_Snow
Global $nSleepTime = 1000 / $nFPS
For $i = 1 To $aFlakes[0][0]
$aFlakes[$i][0] = Random(10, $iWidth - 10, 1)
$aFlakes[$i][1] = Random(-$iHeight, 0, 1)
$aFlakes[$i][2] = 0
$aFlakes[$i][3] = 0
$aFlakes[$i][4] = Random($iMinRadius, $iMaxRadius, 1)
$aFlakes[$i][5] = Random($iMinFallingSpeed, $iMaxFallingSpeed)
$aFlakes[$i][6] = Random($iMinOscillations, $iMaxOscillations, 1)
$aFlakes[$i][7] = Random($iMinOscillationDist, $iMaxOscillationDist) * (-1) ^ Random(1, 2, 1)
Next
$hWnd = GUICreate("I ♥ U", $iWidth, $iHeight)
$Sound = _SoundPlay(_SoundOpen("Sakurairo Maukoro - Mika Nakashima.mp3"))
GUISetState()
$hDC_Window = _WinAPI_GetDC($hWnd)
$hDC_Bitmap = _WinAPI_CreateCompatibleDC($hDC_Window)
$hBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Window, $iWidth, $iHeight)
$hOldObj = _WinAPI_SelectObject($hDC_Bitmap, $hBitmap)
_GDIPlus_Startup()
Global $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC_Bitmap)
_GDIPlus_GraphicsSetClipRect($hGraphics, 0, 0, $iWidth, $iHeight)
_GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
$hBrush_Snow = _GDIPlus_BrushCreateSolid($iARGB_Snow)
$hImage2 = _GDIPlus_BitmapCreateFromFile("GDIPlus_Image.bmp")
_GDIPlus_GraphicsDrawImage($hGraphics, $hImage2, 0, 0)
$nT_Sleep = TimerInit() + $nSleepTime
_Redraw()
OnAutoItExitRegister("_Shutdown")
GUIRegisterMsg($WM_PAINT, "_Redraw")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_Click")
While 1
DllStructSetData($tPrecSleep, "time", -10000 * ($nSleepTime - TimerDiff($nT_Sleep)))
DllCall($vNTdll, "dword", "ZwDelayExecution", "int", 0, "ptr", $pPrecSleep)
$nFrameTime = TimerDiff($nT_Sleep)
$nT_Sleep = TimerInit()
$nFPS_Cur = 1000 / $nFrameTime
_GDIPlus_GraphicsClear($hGraphics)
_GDIPlus_GraphicsDrawImage($hGraphics, $hImage2, 0, 0)
;_GDIPlus_GraphicsDrawString($hGraphics,"Yagami Raito" ,0,500,"VNF-Comic Sans",30)
$tLeft = 295
$tTop = 490
$iGlow = 4 ; <== Amount of Glow min = 1 Max about 5
$hFamily = _GDIPlus_FontFamilyCreate("VNF-Comic Sans")
$hFont = _GDIPlus_FontCreate($hFamily, 40)
$hLayout = _GDIPlus_RectFCreate(0, 0, 800, 150)
$hStringFormat = _GDIPlus_StringFormatCreate()
_GDIPlus_StringFormatSetAlign($hStringFormat, 1)
Local $i = 1
$hBrush3 = _GDIPlus_BrushCreateSolid("0x" & Hex($iGlow, 2) & "ff0000"); <====== Glow (Transparency)
For $x = 0 To 360 Step 6
DllStructSetData($hLayout, "Y", $tTop + ((18 - $i)) * Sin($x * $nPI / 180))
DllStructSetData($hLayout, "X", $tLeft + ((18 - $i)) * Cos($x * $nPI / 180))
$hStringFormat = _GDIPlus_StringFormatCreate()
_GDIPlus_GraphicsDrawStringEx($hGraphics, "I ♥ U", $hFont, $hLayout, $hStringFormat, $hBrush3)
Next
DllStructSetData($hLayout, "Y", $tTop)
DllStructSetData($hLayout, "X", $tLeft)
$hStringFormat = _GDIPlus_StringFormatCreate()
$hBrush3 = _GDIPlus_BrushCreateSolid("0xfFff0000")
_GDIPlus_GraphicsDrawStringEx($hGraphics, "I ♥ U", $hFont, $hLayout, $hStringFormat, $hBrush3)
For $i = 1 To $aFlakes[0][0]
$aFlakes[$i][1] += ($aFlakes[$i][5] + $aFlakes[$i][3]) / $nFPS_Cur
$aFlakes[$i][0] += (Sin($aFlakes[$i][1] / $iHeight * $nTau * $aFlakes[$i][6]) * $aFlakes[$i][7] + $aFlakes[$i][2]) / $nFPS_Cur
$aFlakes[$i][2] *= $nAirFriction
$aFlakes[$i][3] *= $nAirFriction
If $aFlakes[$i][1] > $iHeight Or $aFlakes[$i][0] < -20 Or $aFlakes[$i][0] > $iWidth + 20 Then
$aFlakes[$i][0] = Random(10, $iWidth - 10, 1)
$aFlakes[$i][1] = Random(-$iHeight, 0, 1)
$aFlakes[$i][2] = 0
$aFlakes[$i][3] = 0
$aFlakes[$i][4] = Random($iMinRadius, $iMaxRadius, 1)
$aFlakes[$i][5] = Random($iMinFallingSpeed, $iMaxFallingSpeed)
$aFlakes[$i][6] = Random($iMinOscillations, $iMaxOscillations, 1)
$aFlakes[$i][7] = Random($iMinOscillationDist, $iMaxOscillationDist)
EndIf
_GDIPlus_GraphicsFillEllipse($hGraphics, $aFlakes[$i][0] - $aFlakes[$i][4] / 2, $aFlakes[$i][1] - $aFlakes[$i][4] / 2, $aFlakes[$i][4] * 2, $aFlakes[$i][4] * 2, $hBrush_Snow)
Next
_WinAPI_BitBlt($hDC_Window, 0, 0, $iWidth, $iHeight, $hDC_Bitmap, 0, 0, $SRCCOPY)
WEnd
Func _Click()
Local $tMousePos = _WinAPI_GetMousePos(True, $hWnd)
For $i = 1 To $aFlakes[0][0]
$iX_Dist = ($aFlakes[$i][0] - $aFlakes[$i][4]) - DllStructGetData($tMousePos, "X")
$iY_Dist = ($aFlakes[$i][1] - $aFlakes[$i][4]) - DllStructGetData($tMousePos, "Y")
$iDist = Sqrt($iX_Dist ^ 2 + $iY_Dist ^ 2)
If $iDist = 0 Then ContinueLoop
If $iDist < $iBlastRadius Then
$aFlakes[$i][2] = (1 - $iDist / $iBlastRadius) * ($iX_Dist / $iDist) * $iBlastAccell
$aFlakes[$i][3] = (1 - $iDist / $iBlastRadius) * ($iY_Dist / $iDist) * $iBlastAccell
EndIf
Next
EndFunc ;==>_Click
Func _Redraw()
_WinAPI_BitBlt($hDC_Window, 0, 0, $iWidth, $iHeight, $hDC_Bitmap, 0, 0, $SRCCOPY)
EndFunc ;==>_Redraw
Func _Close()
Exit
EndFunc ;==>_Close
Func _Shutdown()
_WinAPI_SelectObject($hDC_Bitmap, $hOldObj)
_WinAPI_ReleaseDC($hWnd, $hDC_Window)
_WinAPI_DeleteDC($hDC_Bitmap)
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_BrushDispose($hBrush_Snow)
_GDIPlus_Shutdown()
DllClose($vNTdll)
EndFunc ;==>_Shutdown
Tập tin đính kèm :
GDIPlus_Image.bmp
Sakurairo Maukoro - Mika Nakashima.mp3