| Mirage Source http://web.miragesource.net/forums/ |
|
| picHPbar http://web.miragesource.net/forums/viewtopic.php?f=210&t=3094 |
Page 1 of 1 |
| Author: | Stomach Pulser [ Thu Nov 29, 2007 2:14 am ] |
| Post subject: | picHPbar |
OK. This tutorial is to teach you all how to make an HP bar in frmMirage. When the player looses hp, the picture will resize, and another picture underneath will be a different (I used a grayed-out) color. Also, I have added a label that tells you how much HP you have (12 / 62). Difficulty (1/5) C & P This is all Client side First place two picture bars of the same size, but differing colors in frmMirage and label them picFull and picOut. Choose whatever HP bar pictures you want now (make sure they are the same size). Inside each of those picture boxes add a label (lblFull and lblOut respectively). Set the captions of both to " 0 / 0" Now In modHandleData find: Code: ' :::::::::::::::::::::: ' :: Player hp packet :: ' :::::::::::::::::::::: replace that packet with: Code: ' :::::::::::::::::::::: ' :: Player hp packet :: ' :::::::::::::::::::::: If LCase(Parse(0)) = "playerhp" Then Dim hpbWidth As Integer hpbWidth = 154 Player(MyIndex).MaxHP = Val(Parse(1)) Call SetPlayerHP(MyIndex, Val(Parse(2))) If GetPlayerMaxHP(MyIndex) > 0 Then 'frmMirage.lblHP.Caption = Int(GetPlayerHP(MyIndex) / GetPlayerMaxHP(MyIndex) * 100) & "%" frmMirage.picFull.Width = Int(GetPlayerHP(MyIndex) / GetPlayerMaxHP(MyIndex) * hpbWidth) frmMirage.lblFull.Caption = GetPlayerHP(MyIndex) & " / " & GetPlayerMaxHP(MyIndex) frmMirage.lblOut.Caption = GetPlayerHP(MyIndex) & " / " & GetPlayerMaxHP(MyIndex) End If Exit Sub (I made it so that the default HP label doesn't show anymore) make sure that you change hpbwidth to the width of you HP bar (in pixels, not twips) Analysis: To resize the full HP bar we must get the current percentage of the players HP. such as .1, .92, or 1; then we multiply it by the width of the maxed out bar in order to make sure that the bar is resized properly. Next, we update both labels because once your full HP bar goes past a certain point, you wont see it anymore, so we added the bottom one in order to keep it visible (make sure that they are in the same place on both HP bars). Your Challenge: Add an MP, SP, and/or EXP bar(s). |
|
| Author: | Rezeyu [ Thu Nov 29, 2007 5:51 am ] |
| Post subject: | Re: picHPbar |
Meh, I had trouble adding HP bars when I first used them a long time ago, I'm glad someone finally did a tut on it, although I've already sorted out my own style for them. It's good seeing new tuts too, heh. |
|
| Author: | William [ Thu Nov 29, 2007 8:22 pm ] |
| Post subject: | Re: picHPbar |
I don't know if you mentioned twip, the noob killer |
|
| Author: | Stomach Pulser [ Fri Nov 30, 2007 4:14 am ] |
| Post subject: | Re: picHPbar |
Here is my version of the HP/MP/SP bars in action. (Although in my source I load the images onto the picture box when the game starts) (Shouldn't make a difference as the code above is the same as my code that updates the pictures) This is just to show people what the code does: SPOILER: (click to show)
|
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|