[REQUEST FOR TUT] GUI

Can someone help me understand how the ingame hp bar mp bar exp bar n hotkey bar and buttons and everything can be moved the positions.

Which engine are you using?

try these

Sub handleKeyPress
Sub DrawGUIbar
Sub DrawGUI
Sub DrawHotbar
Sub DrawText
SubDrawCharacter
Sub DrawNPC
Sub DrawPlayer
Sub InitiliaseGUI

try these, you can modify the GUI x,y on these sub and can also other gfx stuff like player frames, hotbar position etc

Install vb6 (you can’t use visual studios) and go to “Public Sub GuiLocation()”

All the locations are in that sub.

@solidlink need abit more detail thanks

@mohenjo-daro can u give me an example of how to move the GUI

If you want to move the bars (hp, exp, mp, gold, etc.) then you go to GUILocation() and change these 2 lines

'Stats
GUI(GUI_STATS).X = 0
GUI(GUI_STATS).Y = 0

Those will change the bar area position.

That’s an easy to understand part of the code. A more complicated part is

 ' Shop
 GUI(GUI_SHOP).X = (frmMain.ScaleWidth - GUI(GUI_SHOP).Width) * 0.5
 GUI(GUI_SHOP).Y = (frmMain.ScaleHeight - GUI(GUI_SHOP).Height) * 0.5

This code will place the shop menu in the center of the screen. It gets the form size and the menu and centers them ( X/2 - Y/2 = c[X - Y] / 2 which will center)


 ' Options
 GUI(GUI_OPTIONS).X = frmMain.ScaleWidth - 232
 GUI(GUI_OPTIONS).Y = frmMain.ScaleHeight - GUI(GUI_OPTIONS).Height - (frmMain.ScaleHeight - 
 BTN(1).Y + btnOffset)

This code will make sure the option menu is always in the lower right corner of the screen. 232 is the option menu width and offset from the side of the screen.

BTN(1).Y is in that code to keep your menus above your buttons so that you don’t have a menu blocking you from clicking a button). The offset is to keep the menus slightly above your buttons.


Thanks to deminizer for asking me to explain these to him in chat, showed me I should explain them instead of saying where to look 🙂

Thx so much now i’ve got it

No problem 🙂

To change the button locations

' Loop through the locations
For i = btnCount To 1 Step -1 ' Rows are done in order, columns are reversed: enum order is right to left and top to bottom
    If i = btnCount Then
        BTN(btnEnabled(i)).X = frmMain.ScaleWidth - BTN(btnEnabled(i)).Width - btnOffset
    Else
        If btnCount - i <= (btnCount / rows) * (tempRows + 1) Then
            BTN(btnEnabled(i)).X = BTN(btnEnabled(i + 1)).X - BTN(btnEnabled(i)).Width - btnOffset
        Else
            BTN(btnEnabled(i)).X = frmMain.ScaleWidth - BTN(btnEnabled(i)).Width - btnOffset
            tempRows = tempRows + 1
        End If
    End If

    BTN(btnEnabled(i)).Y = frmMain.ScaleHeight - BTN(btnEnabled(i)).Height - btnOffset - ((tempRows) * (BTN(btnEnabled(i)).Height + btnOffset))
Next

This sub is in GUILoction as well. This will align the buttons to the lower right corner. The button sizes can be changed, but I suggest making them all similar heights (they use the current button height when placing the rows/assigning heights).

Log in to reply