Sign in to follow this  
Followers 0
jpam

using tiles

7 posts in this topic

hi

i made this litle code for using tiles as background

butt how do i make this like a udf ? :lmao:

can someone point me to the right direction?

jpam

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

GUICreate("Tiles",800,600)

GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")

GUISetState()

$calc_w = Round(800/167)

$calc_h = Round(600/167)

$total = $calc_w*$calc_h

$w = 0

$h = 0

$i2 = 0

For $i = 0 To $calc_h

Do

GUICtrlCreatePic(@ScriptDir & "\bgtile.jpg",$w,$h,167,167)

$w = $w+167

$i2 = $i2+1

Until $i2 = $calc_w

$w = 0

$i2 = 0

$h = $h+167

Next

While 1

Sleep(1000)

WEnd

Func _exit()

Exit

EndFunc

post-5777-1161170516_thumb.jpg

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

got it!

my first udf :lmao:

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

GUICreate("Tiles",640,480)

GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")

GUISetState()

;funcion _tile(gui_height,guiwidth,image_height,image_width,path_to_image _file)

_tile(640,480,167,167,@ScriptDir & "\bgtile.jpg")

Func _tile($gui_w,$gui_h,$pic_w,$pic_h,$path)

$calc_w = Round($gui_w/$pic_w)

$calc_h = Round($gui_w/$pic_h)

$total = $calc_w*$calc_h

$w=0

$h=0

$i2=0

For $i=0 To $calc_h

Do

GUICtrlCreatePic($path,$w,$h,$pic_w,$pic_h)

$w=$w+$pic_w

$i2=$i2+1

Until $i2=$calc_w

$w=0

$i2=0

$h=$h+$pic_h

Next

EndFunc

While 1

Sleep(1000)

WEnd

Func _exit()

Exit

EndFunc

Edited by jpam

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

First of all, use [autoit ] and [/autoit] tags around your code without the spaces

Secondly, use tabs to make your code more readable

eg

If $var = 6 Then
    MsgBox(0,"Title","Hello")
EndIfoÝ÷ Ú+^®ØZ«­¢+Ù%ÀÌØíÙÈôØQ¡¸)5Í  ½à À°ÅÕ½ÐíQ¥Ñ±ÅÕ½Ðì°ÅÕ½Ðí!±±¼ÅÕ½Ðì¤)¹%oÝ÷ ÚØb­ÙrÓ~­¢Ö¥Éè¶ët¶¬¶²¢ë!¢é]v+nW­êbrÛ«zÆÞq«¬zØ^ɪÞi¶
èºwAyú+{*.¦-yÛazç_!ƦzêpØm+ºÚ"µÍ[ÈÕRU[PÊ   ÌÍÜÔXË ÌÍÙÝZUË    ÌÍÙÝZR  ÌÍÝ[UË  ÌÍÝ[R
B   ÌÍÚU[ÖHÝ[
    ÌÍÙÝZUÈÈ  ÌÍÝ[UÊB ÌÍÚU[ÖHHÝ[
    ÌÍÙÝZRÈ    ÌÍÝ[R
BØØ[  ÌÍÞH ÌÍÞHHÜ  ÌÍÚHHÈ  ÌÍÚU[ÖÜ    ÌÍÚZHHÈ ÌÍÚU[ÖBÕRPÝÜX]TXÊ   ÌÍÜÔXË ÌÍÞ  ÌÍÞK ÌÍÝ[UË  ÌÍÝ[R
BÕRPÝÙ]Ý]JLK    ÌÍÑÕRWÑTÐPJB  ÌÍÞ
ÏH ÌÍÝ[UÂ^ ÌÍÞH ÌÍÞH
ÏH ÌÍÝ[R^[[ÈÏOIÝÑÕRU[PÈ
Edited by RazerM

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

Thanks RazerM

i can learn from that

$total was not used i know, i created it for calculating the number of pictures it used for the background in diferent resolutions.

after $total was a msgbox that i deleted

thanks for the info RazerM

jpam

Share this post


Link to post
Share on other sites

hi

RazorM

i have i problem with your udf

trying to update with guictrlsetimage to load another tile pic without recreating the first controls :lmao:

can't get it right

can you help me please !

jpam

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Like so:

#include <GUIConstants.au3>
GUICreate("Tiles Example", 600, 500)
$tiles = GUITileBg("bgtile.jpg", 600, 500, 100, 100)
GUITilesDelete($tiles)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func GUITileBg($sPic, $guiW, $guiH, $tileW, $tileH)
    Local $iTilesX = Round($guiW / $tileW)
    Local $iTilesY = Round($guiH / $tileH)
    Local $tiles[$iTilesX + 1][$iTilesY + 1]
    Local $x = 0, $y = 0
    For $i = 0 To $iTilesX
        For $ii = 0 To $iTilesY
            $tiles[$i][$ii] = GUICtrlCreatePic($sPic, $x, $y, $tileW, $tileH)
            GUICtrlSetState(-1, $GUI_DISABLE)
            $x += $tileW
        Next
        $x = 0
        $y += $tileH
    Next
    Return $tiles
EndFunc   ;==>GUITileBg

Func GUITilesDelete($tiles)
    For $x = 0 To UBound($tiles, 1) - 1
        For $y = 0 To UBound($tiles, 2) - 1
            GUICtrlDelete($tiles[$x][$y])
        Next
    Next
EndFunc   ;==>GUITileDelete
Edited by RazerM

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

RazorM

:geek::):ph34r:

youre my Hero :ph34r:

i am such an idioot :lmao:

Thanks RazorM

jpam

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