Code: Select all
SCREEN 800,600
While 1
n=HPBar(350,295,100,n,100)
n=n+(RightKey()-LeftKey())
DrawScreen
Wend
// x,y = koordinaatit
// w = leveys
// s = nykyinen arvo
// m = maksimi arvo
Function HPBar(x#,y#,w#,s#,m#)
If s > m Then s = m
n# = (w/100*s/m)*100
For a = -1 To 3
Color 160-(Abs(a)*19),160-(Abs(a)*19),160-(Abs(a)*19)
Line x-(a>-1 And a<3),y+a,x+w+(a>-1 And a<3),y+a
Next a
If s > 0 Then
For i = -1 To 3
Color 60-(Abs(i)*6),60-(Abs(i)*6),160-(Abs(i)*19)
Line x-(i>-1 And i<3),y+i,x+n+(i>-1 And i<3),y+i
Next i
EndIf
Return Int(s/m*100)
EndFunction
EDIT:
Nytpä ois uus koodi jossa HP MP ja Exp:
Code: Select all
SCREEN 800,600
While 1
n=HPBar(10,10,100,n,100)
o=ManaBar(10,20,100,o,100)
e=ExpBar(10,30,100,e,100)
ä=(RightKey()-LeftKey())
n=n+(ä)
o=o+(ä)
e=e+(ä)
DrawScreen
Wend
// x,y = koordinaatit
// w = leveys
// s = nykyinen arvo
// m = maksimi arvo
Function HPBar(x#,y#,w#,s#,m#)
If s > m Then s = m
n# = (w/100*s/m)*100
For a = -1 To 3
Color 160-(Abs(a)*19),160-(Abs(a)*19),160-(Abs(a)*19)
Line x-(a>-1 And a<3),y+a,x+w+(a>-1 And a<3),y+a
Next a
If s > 0 Then
For i = -1 To 3
Color 250-(Abs(i)*6),60-(Abs(i)*6),60-(Abs(i)*19)
Line x-(i>-1 And i<3),y+i,x+n+(i>-1 And i<3),y+i
Next i
EndIf
Return Int(s/m*100)
EndFunction
Function ManaBar(x#,y#,w#,s#,m#)
If s > m Then s = m
o# = (w/100*s/m)*100
For a = -1 To 3
Color 160-(Abs(a)*19),160-(Abs(a)*19),160-(Abs(a)*19)
Line X-(A>-1 And a<3),y+a,x+w+(a>-1 And a<3),y+a
Next a
If s > 0 Then
For i = -1 To 3
Color 60-(Abs(i)*6),60-(Abs(i)*6),250-(Abs(i)*19)
Line x-(i>-1 And i<3),y+i,x+o+(i>-1 And i<3),y+i
Next i
EndIf
Return Int(s/m*100)
EndFunction
Function ExpBar(x#,y#,w#,s#,m#)
If s > m Then s = m
e# = (w/100*s/m)*100
For a = -1 To 3
Color 160-(Abs(a)*19),160-(Abs(a)*19),160-(Abs(a)*19)
Line x-(a>-1 And a<3),y+a,x+w+(a>-1 And a<3),y+a
Next a
If s > 0 Then
For i = -1 To 3
Color 100-(Abs(i)*6),60-(Abs(i)*6),250-(Abs(i)*19)
Line x-(i>-1 And i<3),y+i,x+e+(i>-1 And i<3),y+i
Next i
EndIf
Return Int(s/m*100)
EndFunction
EDIT2:
Nyt jos ton ja tän sais risteytettyy:
Code: Select all
exp = 0
lvl = 1
exptonxt = 100
Repeat
exp = exp + KeyDown(57)
If exp >= exptonxt Then
exptonxt = exptonxt * 2
lvl = lvl + 1
exp = 0
EndIf
Text 10, 10, "Ekspaa: " + exp
Text 10, 30, "Seuraava leveli @: " + exptonxt
Text 10, 50, "Lvl: " + lvl
Color 255, 0, 0
Box 10, 70, (Float(exp)/Float(exptonxt))*100,10, 1
Color 255, 255, 255
Box 10, 70, 100, 10, 0
DrawScreen
Forever