Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Health Bars-The Easy Way  (Read 732 times)

0 Members and 1 Guest are viewing this topic.

King Tetiro

Leader of Phoenix Heart
Health Bars-The Easy Way
« on: July 02, 2007, 12:00:25 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3549
Health Bars-The Easy Way

For this tutorial, I will be using
VerticalBarBackBorder -Background Bar-Make this as high as the the maximum of you Health in the game-So if you have 80MAX HP, your sprite needs to be at least 80 pixels high
VerticalBarBorder-The Health Bar-Make this only 1 Pixel high
HorizontalBarBackBorder-Background Bar-Make this as wide as the the maximum of you Health in the game-So if you have 80MAX HP, your sprite needs to be at least 80 pixels wide
HorizontalBarBorder-The Health Bar-Make this only 1 Pixel wide
VerticalBarBack-Background Bar-Make this only 1 Pixel high
VerticalBar-The Health Bar-Make this only 1 Pixel high
HorizontalBarBack-Background Bar-Make this only 1 Pixel wide
HorizontalBar-The Health Bar-Make this only 1 Pixel wide
global.HP
global.maxHP
Hud Object (This is where you put the code IN THE DRAW EVENT!)


Horizontal Bar

Right let's start with the basics. This is what you do. say you want it to be at point 0,0

For the sake of the code, My sprite's height is 8 pixels but you can change it to whatever

You would put this code in.
Quote
draw_sprite_stretched(HorizontalBarBack,-1,view_xview+0,view_yview+0,global.maxHP,8)
draw_sprite_stretched(HorizontalBar,-1,view_xview+0,view_yview+0,global.HP,8)

That's easy.

Vertical Bar

Now let's get a vertical bar. This is what you do. say you want it to be at point 0,0

This time, My sprite's width  8 pixels but you can change it to whatever

You would put this code in.
Quote
draw_sprite_stretched(VerticalBarBack,-1,view_xview+0,view_yview+0,8,global.maxHP)
draw_sprite_stretched(VerticalBar,-1,view_xview+0,view_yview+0,8,global.HP)

That's also easy.

Horizontal Bar With Border

Right now it's going to get harder. Let's add a border. This time, you must work out what the MAX HP is and add a number to the end to get your width of the background. For this, I have chosen global.maxHP to go no more than 100 and I will give it a border of 2 pixels so it will be 104 X 10 pixels. This is what you do. say you want it to be at point 0,0

For the sake of the code, My sprite's height is 8 pixels but you can change it to whatever

You would put this code in.
Quote
draw_sprite_stretched(HorizontalBarBackBorder,-1,view_xview+0,view_yview+0,104,10)
draw_sprite_stretched(HorizontalBarBorder,-1,view_xview+2,view_yview+2,global.HP,8)

That's okay.

Vertical Bar With Border

Now let's get a vertical bar. This is what you do. say you want it to be at point 0,0

This time, My sprite's width  8 pixels and my background's 10 X 104 Pixels but you can change it to whatever

You would put this code in.
Quote
draw_sprite_stretched(VerticalBarBackBorder,-1,view_xview+0,view_yview+0,10,104)
draw_sprite_stretched(VerticalBarBorder,-1,view_xview+0,view_yview+0,8,global.HP)

This is hard to understand.

And that's it. Anything in red can be changed. Changing anything else can ruin your bar. ENJOY!! I will do the rest of the highlighting later.
Logged
  • Phoenix Heart
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.036 seconds with 39 queries.