Jump to content

how to make gravity


Recommended Posts

Here is something.. It's definitely not seem correct or visually logic but you'll get it (I hope):

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>

Global Const $iStep = 2
Global Const $iPlayerHeight = 15, $iPlayerWidth = 10

Global $hGUI, $Graphic, $Label
Global $aPlatforms[3][4] = [[25, 25, 75, 27], [75, 75, 125, 77], [125, 125, 175, 127]]
Global $aRects[3]
Global $tPoint = DllStructCreate($tagPOINT)

$hGUI = GUICreate('Test', 200, 200)
$Graphic = GUICtrlCreateGraphic(0, 0, 200, 200)

GUICtrlSetBkColor($Graphic, 0xFFFFFF)
GUICtrlSetGraphic($Graphic, $GUI_GR_COLOR, 0xFF0000)

For $i = 0 To UBound($aRects)-1
    $aRects[$i] = DllStructCreate($tagRECT)
    
    For $j = 1 To 4
        DllStructSetData($aRects[$i], $j, $aPlatforms[$i][$j-1])
    Next
    
    GUICtrlSetGraphic($Graphic, $GUI_GR_MOVE, $aPlatforms[$i][0], $aPlatforms[$i][3])
    GUICtrlSetGraphic($Graphic, $GUI_GR_LINE, $aPlatforms[$i][2], $aPlatforms[$i][3])
Next

GUISetState()
$Label = GUICtrlCreateLabel('P', 25, 10, $iPlayerWidth, $iPlayerHeight)
GUICtrlSetBkColor($Label, 0x00FF00)

DllStructSetData($tPoint, 'X', 25)
DllStructSetData($tPoint, 'y', 25)


$aSize = WinGetClientSize($hGUI)

While DllStructGetData($tPoint, 'X') < $aSize[0] And DllStructGetData($tPoint, 'Y') < $aSize[1]
    
    For $i = 0 To UBound($aRects)-1
        If _WinAPI_PtInRect($aRects[$i], $tPoint) Then
            DllStructSetData($tPoint, 'X', DllStructGetData($tPoint, 'X')+$iStep)
            GUICtrlSetPos($Label, DllStructGetData($tPoint, 'X'), DllStructGetData($tPoint, 'Y'))
            ExitLoop
        EndIf
    Next
    
    If $i = UBound($aRects) Then
;~      DllStructSetData($tPoint, 'X', DllStructGetData($tPoint, 'X')+$iStep)
        DllStructSetData($tPoint, 'Y', DllStructGetData($tPoint, 'Y')+$iStep)
        GUICtrlSetPos($Label, DllStructGetData($tPoint, 'X'), DllStructGetData($tPoint, 'Y'))
    EndIf
    
    Sleep(10)
WEnd

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

GUIDelete()
Edited by Authenticity
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...