jokke Posted September 9, 2007 Share Posted September 9, 2007 (edited) Hiya, im creating a, health-bar, mana-bar, xp-bar, and its very cool looking, but i have a problem with flickering. Code: expandcollapse popup#include <guiconstants.au3> Dim $a[4] Dim $xp = 0 GUICreate("Progress") $a[1]=GuiCtrlCreateGraphic(5, 155, 300,12) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x676964,0x680062) GUICtrlSetGraphic(-1,$GUI_GR_RECT, 2,2, 45,8) GUICtrlSetColor(-1,0x676964) $a[2]=GuiCtrlCreateGraphic(5, 40, 100,12) GUICtrlSetColor(-1,0) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x676964,0x00D600) GUICtrlSetGraphic(-1,$GUI_GR_RECT, 2,2, 50,8) GUICtrlSetColor(-1,0x676964) $a[3]=GuiCtrlCreateGraphic(5, 65, 150,12) GUICtrlSetColor(-1,0) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x676964,0x0000DD) GUICtrlSetGraphic(-1,$GUI_GR_RECT, 2,2, 50,8) GUICtrlSetColor(-1,0x676964) GuiSetState() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit $xp +=1 GUICtrlSetGraphic($a[1],$GUI_GR_COLOR, 0xffffff,0xffffff) GUICtrlSetGraphic($a[1],$GUI_GR_RECT, 2,2, 296,8) Sleep(10) GUICtrlSetGraphic($a[1],$GUI_GR_COLOR, 0x676964,0x680062) GUICtrlSetGraphic($a[1],$GUI_GR_RECT, 2,2, $xp*2.96,8) GUICtrlSetColor($a[1],0x676964) GUICtrlSetGraphic($a[2],$GUI_GR_COLOR, 0xffffff,0xffffff) GUICtrlSetGraphic($a[2],$GUI_GR_RECT, 2,2, 96,8) Sleep(10) GUICtrlSetGraphic($a[2],$GUI_GR_COLOR, 0x676964,0x00D600) GUICtrlSetGraphic($a[2],$GUI_GR_RECT, 2,2, $xp*0.96,8) GUICtrlSetColor($a[2],0x676964) GUICtrlSetGraphic($a[3],$GUI_GR_COLOR, 0xffffff,0xffffff) GUICtrlSetGraphic($a[3],$GUI_GR_RECT, 2,2, 146,8) Sleep(10) GUICtrlSetGraphic($a[3],$GUI_GR_COLOR, 0x676964,0x0000DD) GUICtrlSetGraphic($a[3],$GUI_GR_RECT, 2,2, $xp*1.45,8) GUICtrlSetColor($a[3],0x676964) If $xp > 100 Then $xp = 0 Sleep(50) WEnd If anyone know how i should go forth to remove flickering please hallow! (Without increasing the sleep) Edited September 9, 2007 by jokke UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt. Link to comment Share on other sites More sharing options...
dexxa Posted September 10, 2007 Share Posted September 10, 2007 adding sleep delay to the loop might work Link to comment Share on other sites More sharing options...
Rad Posted September 11, 2007 Share Posted September 11, 2007 It wont flicker if you don't constantly update the value. Its flickering because your resizing it, forcing it to redraw. If its expected to only downgrade/upgrade every time you get hit or whatever, then it shouldnt be a problem. But if you use this as a progress bar, you should split it into chunks instead of updating every pixel Link to comment Share on other sites More sharing options...
GtaSpider Posted September 11, 2007 Share Posted September 11, 2007 (edited) HelloTHIS IS NOT A GENERAL SUPPORT FORUM! Please use this Forum for Support: General Help and SupportMfg Spider Edited September 11, 2007 by GtaSpider www.AutoIt.de - Moderator of the German AutoIt Forum Link to comment Share on other sites More sharing options...
BrettF Posted September 12, 2007 Share Posted September 12, 2007 It looks great! good job Yes, like GtaSpider said, this is a general help and support forum, but since it needs fine tuning... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Luigi Posted October 14, 2012 Share Posted October 14, 2012 (edited) This is my script's version... expandcollapse popup; Autor: Luigi(Detefon) ; 14/10/2012 #include <guiconstants.au3> #include <StaticConstants.au3> ; Variable's name Global $valueCurrent = 120 Global $valueMax = 200 Global $x = 20 Global $y = 20 Global $width = 250 Global $height = 15 Global $text = "HP" ; The GUI must have the option $WS_EX_COMPOSITED (0x02000000) GUICreate("Luigi's HP Bar", 400, 400, -1, -1, Default, 0x02000000) $newBar= _barCreate($x, $y, $width, $height, $valueCurrent, $valueMax, $text) GUISetState() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit $valueCurrent += 5 If $valueCurrent > $valueMax Then $valueCurrent = 0 Sleep(50) _barUpdate($newBar, $valueCurrent) WEnd Func _barCreate($_x, $_y, $_width, $_height, $_valueCurrent, $_valueMax, $_text) Local $_hex[16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F"], $contador = 0 Local $_var[3] For $x = 0 To 2 Do $_var[$x] = $_hex[Random(0, 15, 1)] & $_hex[Random(0, 15, 1)] & $_hex[Random(0, 15, 1)] & $_hex[Random(0, 15, 1)] & $_hex[Random(0, 15, 1)] & $_hex[Random(0, 15, 1)] $contador += 1 If $contador > 256 Then Return SetError(-1, 1, 1) Until Not IsDeclared($_var[$x]) Next Assign($_var[1], GUICtrlCreateGraphic($_x - 1, $_y - 1, $_width + 2, $_height + 2), 2) Local $alt[3] $alt[0] = Int($_height / 3) $alt[2] = Int($_height / 3) $alt[1] = $_height - $alt[0] - $alt[2] GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0x0000ff) GUICtrlSetBkColor(-1, 0xD6D4D2) GUICtrlSetColor(-1, 0x897659) Local $percent = Int(($_valueCurrent / $_valueMax) * 100) Local $bar_a = Int($_width * ($percent / 100)) Local $bar_b = $_width - $bar_a GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xDE8D69, 0xDE8D69) GUICtrlSetGraphic(-1, $GUI_GR_RECT, 1, 1, $bar_a, $alt[0]) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xBE371C, 0xBE371C) GUICtrlSetGraphic(-1, $GUI_GR_RECT, 1, 1 + $alt[0], $bar_a, $alt[1]) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x540404, 0x540404) GUICtrlSetGraphic(-1, $GUI_GR_RECT, 1, 1 + $alt[0] + $alt[1], $bar_a, $alt[2]) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xD6D4D2, 0xD6D4D2) GUICtrlSetGraphic(-1, $GUI_GR_RECT, 1 + $bar_a, 1, $bar_b, $_height) $_text1 = GUICtrlCreateLabel($_text, $_x + 1, $_y, Default, $_height, 0x0200) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 9, 900, 0, "Lucida Console", 5) GUICtrlSetColor(-1, 0xffffff) Assign($_var[2], GUICtrlCreateLabel($_valueCurrent & "/" & $_valueMax, ($_width - 100 / 2) / 2, $_y + 2, 100, 13, 0x0200 + 0x01), 2) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, $_height / 2, 900, 0, "Lucida Console", 5) GUICtrlSetColor(-1, 0xffffff) ; $_x, $_y, $_width, $_height, $_valueCurrent, $_valueMax, $_text Assign($_var[0], $_var[1] & "," & $_var[2] & "," & $_x & "," & $_y & "," & $_width & "," & $_height & "," & $_valueCurrent & "," & $_valueMax, 2) Return $_var[0] EndFunc ;==>_barCreate Func _barUpdate($control, $value) $control = Eval($control) Local $data = StringSplit($control, ",") Local $alt[3] $alt[0] = Int($data[6] / 3) $alt[2] = Int($data[6] / 3) $alt[1] = $data[6] - $alt[0] - $alt[2] Local $percent = Int(($value / $data[8]) * 100) Local $bar_a = Int($data[5] * ($percent / 100)) Local $bar_b = $data[5] - $bar_a GUICtrlSetGraphic(Eval($data[1]), $GUI_GR_COLOR, 0xDE8D69, 0xDE8D69) GUICtrlSetGraphic(Eval($data[1]), $GUI_GR_RECT, 1, 1, $bar_a, $alt[0]) GUICtrlSetGraphic(Eval($data[1]), $GUI_GR_COLOR, 0xBE371C, 0xBE371C) GUICtrlSetGraphic(Eval($data[1]), $GUI_GR_RECT, 1, 1 + $alt[0], $bar_a, $alt[1]) GUICtrlSetGraphic(Eval($data[1]), $GUI_GR_COLOR, 0x540404, 0x540404) GUICtrlSetGraphic(Eval($data[1]), $GUI_GR_RECT, 1, 1 + $alt[0] + $alt[1], $bar_a, $alt[2]) GUICtrlSetGraphic(Eval($data[1]), $GUI_GR_COLOR, 0xD6D4D2, 0xD6D4D2) GUICtrlSetGraphic(Eval($data[1]), $GUI_GR_RECT, 1 + $bar_a, 1, $bar_b, $data[6]) GUICtrlSetGraphic(Eval($data[1]), $GUI_GR_REFRESH) GUICtrlSetData(Eval($data[2]), $value & "/" & $data[8]) EndFunc ;==>_barUpdate ; Webgrafia ; http://www.autoitscript.com/forum/topic/83454-pong/ ; http://www.autoitscript.com/forum/topic/53016-cool-looking-progress-bar-help-me-remove-flickering/ Edited October 14, 2012 by detefon Visit my repository Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 14, 2012 Moderators Share Posted October 14, 2012 detefon, In future, please do not resurrect a 5 year old thread that is even in the wrong section! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts