Jump to content

Erase or Delete graphics


Recommended Posts

I'm trying to create a simple GDI that makes a person and an environment around him. I would like him to be able to walk left and right and maybe even jump up. This would be like a 2-D side scrolling game. My first problem so far is that when I try to increase or decrease all the x coordinates(move left and right,) it doesn't delete the first graphic of the person. It is like an etch-or-sketch in the shape of a person. If there is some sort of function to delete all the graphics and then create the new one with the new coordinates that would be very helpful. I will post the script so far and if anybody has suggestions for this problem, or any other part of my idea, that would be very helpful.

Thank You

#include <WindowsConstants.au3>

#include <WinAPI.au3>

#Include <GDIPlus.au3>

#include <GUIConstantsEx.au3>

#include <misc.au3>

Opt('MustDeclareVars', 1)

func main()

local $hGraphic, $hGUI, $hPen, $leg1X1, $leg1Y1, $leg1X2, $leg1Y2, $leg2X1, $leg2Y1, $leg2X2, $leg2Y2, $bodyX1, $bodyY1, $bodyX2, $bodyY2

local $arm1X1, $arm1Y1, $arm1X2, $arm1Y2, $arm2X1, $arm2Y1, $arm2X2, $arm2Y2, $headX, $headY, $headWID, $headHEI

$leg1X1 = @desktopwidth/2

$leg1Y1 = @desktopheight-300

$leg1X2 = $leg1X1 - 30

$leg1y2 = $leg1Y1 + 80

$leg2X1 = $leg1X1

$leg2Y1 = $leg1Y1

$leg2X2 = $leg2x1 + 30

$leg2Y2 = $leg2Y1 + 80

$bodyX1 = $leg1X1

$bodyY1 = $leg1Y1

$bodyX2 = $leg1X1

$bodyY2 = $leg1Y1 - 100

$arm1X1 = $leg1X1

$arm1Y1 = $bodyY2

$arm1X2 = $leg1X1 - 75

$arm1Y2 = $arm1Y1 + 25

$arm2X1 = $leg1X1

$arm2Y1 = $arm1Y1

$arm2X2 = $leg1X1 + 75

$arm2Y2 = $arm1Y1 + 25

$headX = $bodyX2 - 20

$headY = $bodyY2 - 40

$headWID= 40

$headHEI= 40

$hGUI = GUICreate("Game",@DesktopWidth,@DesktopHeight)

GUISetBkColor(0xFF0000) ;i like red backgrounds

GUISetState()

_GDIPlus_Startup ()

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

$hPen = _GDIPlus_PenCreate()

Do

while 1

if _IsPressed("45") then exit

_GDIPlus_GraphicsDrawLine($hGraphic, $leg1X1, $leg1Y1, $leg1X2, $leg1Y2, $hPen)

_GDIPlus_GraphicsDrawLine($hGraphic, $leg2X1, $leg2Y1, $leg2X2, $leg2Y2, $hPen)

_GDIPlus_GraphicsDrawLine($hgraphic, $bodyX1, $bodyY1, $bodyX2, $bodyY2, $hPen)

_GDIPlus_GraphicsDrawLine($hgraphic, $arm1X1, $arm1Y1, $arm1X2, $arm1Y2, $hPen)

_GDIPlus_GraphicsDrawLine($hgraphic, $arm2X1, $arm2Y1, $arm2X2, $arm2Y2, $hPen)

_GDIPlus_GraphicsDrawEllipse($hgraphic, $headX, $headY, $headWID, $headHEI, $hPen)

if _IsPressed("25") Then ;left arrow

$leg1X1 -= 1

$leg1X2 -= 1

$leg2x1 -= 1

$leg2X2 -= 1

$bodyX1 -= 1

$bodyX2 -= 1

$arm1X1 -= 1

$arm1X2 -= 1

$arm2X1 -= 1

$arm2X2 -= 1

$headX -= 1

sleep(7)

EndIf

if _IsPressed("26") Then ;up arrow

$leg1Y1 -= 1

$leg1Y2 -= 1

$leg2Y1 -= 1

$leg2Y2 -= 1

$bodyY1 -= 1

$bodyY2 -= 1

$arm1Y1 -= 1

$arm1Y2 -= 1

$arm2Y1 -= 1

$arm2Y2 -= 1

$headY -= 1

sleep(7)

EndIf

if _IsPressed("27") Then ;right arrow

$leg1X1 += 1

$leg1X2 += 1

$leg2x1 += 1

$leg2X2 += 1

$bodyX1 += 1

$bodyX2 += 1

$arm1X1 += 1

$arm1X2 += 1

$arm2X1 += 1

$arm2X2 += 1

$headX += 1

sleep(7)

EndIf

if _IsPressed("28") Then ; down arrow

$leg1Y1 += 1

$leg1Y2 += 1

$leg2Y1 += 1

$leg2Y2 += 1

$bodyY1 += 1

$bodyY2 += 1

$arm1Y1 += 1

$arm1Y2 += 1

$arm2Y1 += 1

$arm2Y2 += 1

$headY += 1

sleep(7)

EndIf

WEnd

Until GUIGetMsg() = $GUI_EVENT_CLOSE

_GDIPlus_PenDispose ($hPen)

_GDIPlus_GraphicsDispose ($hGraphic)

_GDIPlus_Shutdown ()

endFunc

main()

Link to comment
Share on other sites

Hello AutoITphil,

First, Welcome to the AutoIt Forums :graduated:

Second, Please paste code in the code or autoit tags, it helps to make your post look cleaner. To post in autoit tags just place your code between [autoit ];place code here[/autoit ], just don't include the trailing spaces in each of the brackets as I have left for show.

Realm

Edit: Typos

2nd Edit: Removed Example and advice since it was not correct. Solution is further down in the posts.

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

_GDIPlus_GraphicsDrawLine doesn't create a control, idiot.

My bad I was not thinking clearly.

@AngelofDeath, What have I done to you for all this hatred? Instead of Calling me an idiot, why don't you take the time to attempt to help this guy out? Not to long ago you were asking the same question, and someone pointed a solution to you, why could'nt take as much time to to share it, as you did to call me out with such disgrace?

phil he found a which is to redraw the window with _WinAPI_RedrawWindow()

Realm

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

AutoITphil,

No need to apologize, sorry my first post was misleading, I was'nt thinking clear, and have'nt worked with gdi functions since earlier this year.

Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

Reply from PM

hi Realm, it's AutoITphil. You helped me with that post from a few days ago, and I was trying to fix my code, but I can't seem to figure out the functions and how to order them. My problem is still that the first GDI won't delete when I draw to redraw it with different coordinates. Again, any help you could provide will be greatly appreciated.

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#Include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <misc.au3>

Opt('MustDeclareVars', 1)

func main()
    local $hGraphic, $hGUI, $hPen, $leg1X1, $leg1Y1, $leg1X2, $leg1Y2, $leg2X1, $leg2Y1, $leg2X2, $leg2Y2, $bodyX1, $bodyY1, $bodyX2, $bodyY2
    local $arm1X1, $arm1Y1, $arm1X2, $arm1Y2, $arm2X1, $arm2Y1, $arm2X2, $arm2Y2, $headX, $headY, $headWID, $headHEI
    $leg1X1 = @desktopwidth/2
    $leg1Y1 = @desktopheight-300
    $leg1X2 = $leg1X1 - 30
    $leg1y2 = $leg1Y1 + 80
    $leg2X1 = $leg1X1
    $leg2Y1 = $leg1Y1
    $leg2X2 = $leg2x1 + 30
    $leg2Y2 = $leg2Y1 + 80
    $bodyX1 = $leg1X1
    $bodyY1 = $leg1Y1
    $bodyX2 = $leg1X1
    $bodyY2 = $leg1Y1 - 100
    $arm1X1 = $leg1X1
    $arm1Y1 = $bodyY2
    $arm1X2 = $leg1X1 - 75
    $arm1Y2 = $arm1Y1 + 25
    $arm2X1 = $leg1X1
    $arm2Y1 = $arm1Y1
    $arm2X2 = $leg1X1 + 75
    $arm2Y2 = $arm1Y1 + 25
    $headX  = $bodyX2 - 20
    $headY  = $bodyY2 - 40
    $headWID= 40
    $headHEI= 40



    $hGUI = GUICreate("Game",@DesktopWidth,@DesktopHeight)
    GUISetBkColor(0xFF0000) ;i like red backgrounds
    GUISetState()

    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate()

Do
while 1
  if _IsPressed("45") then exit
    _GDIPlus_GraphicsDrawLine($hGraphic, $leg1X1, $leg1Y1, $leg1X2, $leg1Y2, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $leg2X1, $leg2Y1, $leg2X2, $leg2Y2, $hPen)
    _GDIPlus_GraphicsDrawLine($hgraphic, $bodyX1, $bodyY1, $bodyX2, $bodyY2, $hPen)
    _GDIPlus_GraphicsDrawLine($hgraphic, $arm1X1, $arm1Y1, $arm1X2, $arm1Y2, $hPen)
    _GDIPlus_GraphicsDrawLine($hgraphic, $arm2X1, $arm2Y1, $arm2X2, $arm2Y2, $hPen)
    _GDIPlus_GraphicsDrawEllipse($hgraphic, $headX, $headY, $headWID, $headHEI, $hPen)
    if _IsPressed("25") Then ;left arrow
        $leg1X1 -= 1
        $leg1X2 -= 1
        $leg2x1 -= 1
        $leg2X2 -= 1
        $bodyX1 -= 1
        $bodyX2 -= 1
        $arm1X1 -= 1
        $arm1X2 -= 1
        $arm2X1 -= 1
        $arm2X2 -= 1
        $headX  -= 1

        sleep(7)
    EndIf
    if _IsPressed("26") Then ;up arrow
        $leg1Y1 -= 1
        $leg1Y2 -= 1
        $leg2Y1 -= 1
        $leg2Y2 -= 1
        $bodyY1 -= 1
        $bodyY2 -= 1
        $arm1Y1 -= 1
        $arm1Y2 -= 1
        $arm2Y1 -= 1
        $arm2Y2 -= 1
        $headY  -= 1
        sleep(7)
    EndIf
    if _IsPressed("27") Then ;right arrow
        $leg1X1 += 1
        $leg1X2 += 1
        $leg2x1 += 1
        $leg2X2 += 1
        $bodyX1 += 1
        $bodyX2 += 1
        $arm1X1 += 1
        $arm1X2 += 1
        $arm2X1 += 1
        $arm2X2 += 1
        $headX  += 1
        sleep(7)
    EndIf
    if _IsPressed("28") Then ; down arrow
        $leg1Y1 += 1
        $leg1Y2 += 1
        $leg2Y1 += 1
        $leg2Y2 += 1
        $bodyY1 += 1
        $bodyY2 += 1
        $arm1Y1 += 1
        $arm1Y2 += 1
        $arm2Y1 += 1
        $arm2Y2 += 1
        $headY  += 1
        sleep(7)
    EndIf
WEnd
Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_PenDispose ($hPen)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()

endFunc

main()

I tried to use your advice, but there is clearly something I didn't understand.

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#Include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <misc.au3>

Opt('MustDeclareVars', 1)

func main()
    local $hGraphic, $hGUI, $hPen, $leg1X1, $leg1Y1, $leg1X2, $leg1Y2, $leg2X1, $leg2Y1, $leg2X2, $leg2Y2, $bodyX1, $bodyY1, $bodyX2, $bodyY2
    local $arm1X1, $arm1Y1, $arm1X2, $arm1Y2, $arm2X1, $arm2Y1, $arm2X2, $arm2Y2, $headX, $headY, $headWID, $headHEI
    Local $arm1, $arm2, $leg1, $leg2, $body, $head
    $leg1X1 = @desktopwidth/2
    $leg1Y1 = @desktopheight-300
    $leg1X2 = $leg1X1 - 30
    $leg1y2 = $leg1Y1 + 80
    $leg2X1 = $leg1X1
    $leg2Y1 = $leg1Y1
    $leg2X2 = $leg2x1 + 30
    $leg2Y2 = $leg2Y1 + 80
    $bodyX1 = $leg1X1
    $bodyY1 = $leg1Y1
    $bodyX2 = $leg1X1
    $bodyY2 = $leg1Y1 - 100
    $arm1X1 = $leg1X1
    $arm1Y1 = $bodyY2
    $arm1X2 = $leg1X1 - 75
    $arm1Y2 = $arm1Y1 + 25
    $arm2X1 = $leg1X1
    $arm2Y1 = $arm1Y1
    $arm2X2 = $leg1X1 + 75
    $arm2Y2 = $arm1Y1 + 25
    $headX  = $bodyX2 - 20
    $headY  = $bodyY2 - 40
    $headWID= 40
    $headHEI= 40



    $hGUI = GUICreate("Game",@DesktopWidth,@DesktopHeight)
    GUISetBkColor(0xFF0000) ;i like red backgrounds
    GUISetState()

    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hPen = _GDIPlus_PenCreate()

Do
while 1
  if _IsPressed("45") then exit
    $leg1 = _GDIPlus_GraphicsDrawLine($hGraphic, $leg1X1, $leg1Y1, $leg1X2, $leg1Y2, $hPen) ;;;;;;;TRIED CHANGING THINGS HERE
    $leg2 = _GDIPlus_GraphicsDrawLine($hGraphic, $leg2X1, $leg2Y1, $leg2X2, $leg2Y2, $hPen);;;;;;;;;;;;
    $body = _GDIPlus_GraphicsDrawLine($hgraphic, $bodyX1, $bodyY1, $bodyX2, $bodyY2, $hPen);;;;;;;;;;;;;
    $arm1 = _GDIPlus_GraphicsDrawLine($hgraphic, $arm1X1, $arm1Y1, $arm1X2, $arm1Y2, $hPen);;;;;;;;;;;
    $arm2 = _GDIPlus_GraphicsDrawLine($hgraphic, $arm2X1, $arm2Y1, $arm2X2, $arm2Y2, $hPen)
    $head = _GDIPlus_GraphicsDrawEllipse($hgraphic, $headX, $headY, $headWID, $headHEI, $hPen);;;;;;;;;;;;;;
    if _IsPressed("25") Then ;left arrow
        _GDIPlus_GraphicsClear($arm1)
        _GDIPlus_GraphicsClear($arm2)
        _GDIPlus_GraphicsClear($leg1)
        _GDIPlus_GraphicsClear($leg2)
        _GDIPlus_GraphicsClear($head)
        _GDIPlus_GraphicsClear($body)
        $leg1X1 -= 1
        $leg1X2 -= 1
        $leg2x1 -= 1
        $leg2X2 -= 1
        $bodyX1 -= 1
        $bodyX2 -= 1
        $arm1X1 -= 1
        $arm1X2 -= 1
        $arm2X1 -= 1
        $arm2X2 -= 1
        $headX  -= 1
        $leg1 = _GDIPlus_GraphicsDrawLine($hGraphic, $leg1X1, $leg1Y1, $leg1X2, $leg1Y2, $hPen);;;;;;;;;;;AND HERE
        $leg2 = _GDIPlus_GraphicsDrawLine($hGraphic, $leg2X1, $leg2Y1, $leg2X2, $leg2Y2, $hPen);;;;;;;;;;;;;;;
        $body = _GDIPlus_GraphicsDrawLine($hgraphic, $bodyX1, $bodyY1, $bodyX2, $bodyY2, $hPen);;;;;;;;;;;;;;;
        $arm1 = _GDIPlus_GraphicsDrawLine($hgraphic, $arm1X1, $arm1Y1, $arm1X2, $arm1Y2, $hPen);;;;;;;;;;;;;;;;;;
        $arm2 = _GDIPlus_GraphicsDrawLine($hgraphic, $arm2X1, $arm2Y1, $arm2X2, $arm2Y2, $hPen);;;;;;;;;;;;;;;;
        $head = _GDIPlus_GraphicsDrawEllipse($hgraphic, $headX, $headY, $headWID, $headHEI, $hPen);;;;;;;;;;;;;;;;;

        sleep(7)
    EndIf
    if _IsPressed("26") Then ;up arrow
        _WinAPI_RedrawWindow($arm1)
        _WinAPI_RedrawWindow($arm2)
        _WinAPI_RedrawWindow($body)
        _WinAPI_RedrawWindow($leg1)
        _WinAPI_RedrawWindow($leg2)
        _WinAPI_RedrawWindow($head)
        $leg1Y1 -= 1
        $leg1Y2 -= 1
        $leg2Y1 -= 1
        $leg2Y2 -= 1
        $bodyY1 -= 1
        $bodyY2 -= 1
        $arm1Y1 -= 1
        $arm1Y2 -= 1
        $arm2Y1 -= 1
        $arm2Y2 -= 1
        $headY  -= 1
        sleep(7)
    EndIf
    if _IsPressed("27") Then ;right arrow
        _WinAPI_RedrawWindow($arm1)
        _WinAPI_RedrawWindow($arm2)
        _WinAPI_RedrawWindow($body)
        _WinAPI_RedrawWindow($leg1)
        _WinAPI_RedrawWindow($leg2)
        _WinAPI_RedrawWindow($head)
        $leg1X1 += 1
        $leg1X2 += 1
        $leg2x1 += 1
        $leg2X2 += 1
        $bodyX1 += 1
        $bodyX2 += 1
        $arm1X1 += 1
        $arm1X2 += 1
        $arm2X1 += 1
        $arm2X2 += 1
        $headX  += 1
        sleep(7)
    EndIf
    if _IsPressed("28") Then ; down arrow_WinAPI_RedrawWindow($arm1)
        _WinAPI_RedrawWindow($arm2)
        _WinAPI_RedrawWindow($body)
        _WinAPI_RedrawWindow($leg1)
        _WinAPI_RedrawWindow($leg2)
        _WinAPI_RedrawWindow($head)
        $leg1Y1 += 1
        $leg1Y2 += 1
        $leg2Y1 += 1
        $leg2Y2 += 1
        $bodyY1 += 1
        $bodyY2 += 1
        $arm1Y1 += 1
        $arm1Y2 += 1
        $arm2Y1 += 1
        $arm2Y2 += 1
        $headY  += 1
        sleep(7)
    EndIf
WEnd
Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_PenDispose ($hPen)
    _GDIPlus_GraphicsDispose ($hGraphic)
    _GDIPlus_Shutdown ()

endFunc

main()

Hey AutoItphil,

I replied here so that other members that may face the same dilemma, may also find a similar solution.

Hope you don't mind, but I modified your current script a bit, but it is moving the graphic and clearing the old graphics as you wish.

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#Include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <misc.au3>

Opt('MustDeclareVars', 1)
Opt("GUIOnEventMode", 1)

Global $hGraphic, $hGUI, $hPen, $leg1X1, $leg1Y1, $leg1X2, $leg1Y2, $leg2X1, $leg2Y1, $leg2X2, $leg2Y2, $bodyX1, $bodyY1, $bodyX2, $bodyY2, $w, $h
Global $arm1X1, $arm1Y1, $arm1X2, $arm1Y2, $arm2X1, $arm2Y1, $arm2X2, $arm2Y2, $headX, $headY, $headWID, $headHEI, $redraw = 0, $hBitmap, $hBuffer
$w = @DesktopWidth
$h = @DesktopHeight
main()

func main()

    Local $msg = 0
    $leg1X1 = @desktopwidth/2
    $leg1Y1 = @desktopheight-300
    $leg1X2 = $leg1X1 - 30
    $leg1y2 = $leg1Y1 + 80
    $leg2X1 = $leg1X1
    $leg2Y1 = $leg1Y1
    $leg2X2 = $leg2x1 + 30
    $leg2Y2 = $leg2Y1 + 80
    $bodyX1 = $leg1X1
    $bodyY1 = $leg1Y1
    $bodyX2 = $leg1X1
    $bodyY2 = $leg1Y1 - 100
    $arm1X1 = $leg1X1
    $arm1Y1 = $bodyY2
    $arm1X2 = $leg1X1 - 75
    $arm1Y2 = $arm1Y1 + 25
    $arm2X1 = $leg1X1
    $arm2Y1 = $arm1Y1
    $arm2X2 = $leg1X1 + 75
    $arm2Y2 = $arm1Y1 + 25
    $headX  = $bodyX2 - 20
    $headY  = $bodyY2 - 40
    $headWID= 40
    $headHEI= 40

    $hGUI = GUICreate("Game",@DesktopWidth,@DesktopHeight)
    GUISetBkColor(0xFF0000) ;i like red backgrounds
    GUISetState()

    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($w, $h, $hGraphic)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    $hPen = _GDIPlus_PenCreate()
    _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    AdlibRegister("_ReDraw", 20)
    GUIRegisterMsg(0x000F, "_ReFresh") ;$WM_PAINT = 0x000F
    OnAutoItExitRegister("_Exit")

    _GDIPlus_GraphicsDrawLine($hGraphic, $leg1X1, $leg1Y1, $leg1X2, $leg1Y2, $hPen)
    _GDIPlus_GraphicsDrawLine($hGraphic, $leg2X1, $leg2Y1, $leg2X2, $leg2Y2, $hPen)
    _GDIPlus_GraphicsDrawLine($hgraphic, $bodyX1, $bodyY1, $bodyX2, $bodyY2, $hPen)
    _GDIPlus_GraphicsDrawLine($hgraphic, $arm1X1, $arm1Y1, $arm1X2, $arm1Y2, $hPen)
    _GDIPlus_GraphicsDrawLine($hgraphic, $arm2X1, $arm2Y1, $arm2X2, $arm2Y2, $hPen)
    _GDIPlus_GraphicsDrawEllipse($hgraphic, $headX, $headY, $headWID, $headHEI, $hPen)

    While 1

        if _IsPressed("45") then exit

        if _IsPressed("25") Then ;left arrow
            $leg1X1 -= 1
            $leg1X2 -= 1
            $leg2x1 -= 1
            $leg2X2 -= 1
            $bodyX1 -= 1
            $bodyX2 -= 1
            $arm1X1 -= 1
            $arm1X2 -= 1
            $arm2X1 -= 1
            $arm2X2 -= 1
            $headX  -= 1
            $redraw = 1
            sleep(7)
        EndIf
        if _IsPressed("26") Then ;up arrow
            $leg1Y1 -= 1
            $leg1Y2 -= 1
            $leg2Y1 -= 1
            $leg2Y2 -= 1
            $bodyY1 -= 1
            $bodyY2 -= 1
            $arm1Y1 -= 1
            $arm1Y2 -= 1
            $arm2Y1 -= 1
            $arm2Y2 -= 1
            $headY  -= 1
            $redraw = 1
            sleep(7)
        EndIf
        if _IsPressed("27") Then ;right arrow
            $leg1X1 += 1
            $leg1X2 += 1
            $leg2x1 += 1
            $leg2X2 += 1
            $bodyX1 += 1
            $bodyX2 += 1
            $arm1X1 += 1
            $arm1X2 += 1
            $arm2X1 += 1
            $arm2X2 += 1
            $headX  += 1
            $redraw = 1
            sleep(7)
        EndIf
        if _IsPressed("28") Then ; down arrow
            $leg1Y1 += 1
            $leg1Y2 += 1
            $leg2Y1 += 1
            $leg2Y2 += 1
            $bodyY1 += 1
            $bodyY2 += 1
            $arm1Y1 += 1
            $arm1Y2 += 1
            $arm2Y1 += 1
            $arm2Y2 += 1
            $headY  += 1
            $redraw = 1
            sleep(7)
        EndIf
    WEnd

EndFunc

Func _ReDraw()
    If $redraw Then
        _WinAPI_RedrawWindow($hGUI)
        _GDIPlus_GraphicsDrawLine($hGraphic, $leg1X1, $leg1Y1, $leg1X2, $leg1Y2, $hPen)
        _GDIPlus_GraphicsDrawLine($hGraphic, $leg2X1, $leg2Y1, $leg2X2, $leg2Y2, $hPen)
        _GDIPlus_GraphicsDrawLine($hgraphic, $bodyX1, $bodyY1, $bodyX2, $bodyY2, $hPen)
        _GDIPlus_GraphicsDrawLine($hgraphic, $arm1X1, $arm1Y1, $arm1X2, $arm1Y2, $hPen)
        _GDIPlus_GraphicsDrawLine($hgraphic, $arm2X1, $arm2Y1, $arm2X2, $arm2Y2, $hPen)
        _GDIPlus_GraphicsDrawEllipse($hgraphic, $headX, $headY, $headWID, $headHEI, $hPen)
        $redraw = 0
    EndIf
EndFunc

Func _ReFresh()
    Return "GUI_RUNDEFMSG"
EndFunc

Func _Exit()
    GUIRegisterMsg(0x000F, "")
    AdlibUnRegister("_ReDraw")
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
    Exit
EndFunc

Realm

Edit: I Never have worked with GDI to move and erase graphics before, so this was an exciting and fun adventure for myself. I ended up borrowing some advice from member 'UEZ' from this post here:

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

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