Sign in to follow this  
Followers 0
Andreik

A little help with GDI +

4 posts in this topic

I want to make a square to move in the direction keystrokes. Maybe it would be more suggestive pictures to explain what I want to do.

I think that the best method is GDI+.

If someone has an idea how to do this?


When the words fail... music speaks

Share this post


Link to post
Share on other sites



GDI+ Is fun >_<

#include <GDIPlus.au3>
#include <misc.au3>

Global Const $width=500, $height=400
Global $rw=50,$rh=50; Rect size
Global $x=$width/2-$rw/2,$y=$height/2-$rh/2
Global $user32=DllOpen("user32.dll")

Opt("GUIOnEventMode",1)
$hwnd=GUICreate("GDI+",$width,$height)
GUISetState()
GUISetOnEvent(-3,"close")


_GDIPlus_Startup()
$graphics=_GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap=_GDIPlus_BitmapCreateFromGraphics($width,$height,$graphics)
$backbuffer=_GDIPlus_ImageGetGraphicsContext($bitmap)
$pen=_GDIPlus_PenCreate(0xFFFF0000,4)

Do
    _GDIPlus_GraphicsCLear($backbuffer)
    
    If _IsPressed("25",$user32) Then
        $x-=3
    EndIf
    If _IsPressed("26",$user32) Then
        $y-=3
    EndIf
    If _IsPressed("27",$user32) Then
        $x+=3
    EndIf
    If _IsPressed("28",$user32) Then
        $y+=3
    EndIf
    
    
    _GDIPlus_GraphicsDrawRect($backbuffer,$x,$y,$rw,$rh,$pen)
    _GDIPlus_GraphicsDrawLine($backbuffer,$x+$rw/2,0,$x+$rw/2,$y,$pen)
    _GDIPlus_GraphicsDrawLine($backbuffer,0,$y+$rh/2,$x,$y+$rh/2,$pen)
    _GDIplus_GraphicsDrawLine($backbuffer,$width,$y+$rh/2,$x+$rw,$y+$rh/2,$pen)
    _GDIPlus_GraphicsDrawLine($backbuffer,$x+$rw/2,$height,$x+$rw/2,$y+$rh,$pen)
    
    
    _GDIPlus_GraphicsDrawImageRect($graphics,$bitmap,0,0,$width,$height)
    Sleep(10)
Until False




Func close()
    _GDIPlus_PenDispose($pen)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_Shutdown()
    Exit
EndFunc

:)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Yeah. GDI+ is funny with monoceres and Malkey. :)

Thanks, your example work fine. It`s exactly what I want. >_<

Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
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
Sign in to follow this  
Followers 0