View source for How to make a health bar - EDukeWiki

# View source for How to make a health bar

← How to make a health bar

You do not have permission to edit this page, for the following reasons:

- The action you have requested is limited to users in the group: Users.
- You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page.

[[File:Health_bar.jpg]] <code><pre> gamevar temp 0 2 gamevar temp2 0 2 gamevar xvar 0 2 define BARSCALE 10 onevent EVENT_DISPLAYREST { setvar xvar 0 // set starting x coordinate getactor[THISACTOR].extra temp // get the player's health. ifvarg temp 0 { // only proceed if the player has any health. setvarvar temp2 temp // save a copy for later. divvar temp BARSCALE // make each column worth 10 hp. modvar temp2 BARSCALE // gets the remainder of the division so that... ifvarg temp2 0 { addvar temp 1 // ...we can round up. each column will only disappear when all 10 hp are gone. } whilevarn temp 0 { // repeat for each column rotatesprite xvar 182 65536 0 NOTCHON 0 8 16 0 0 xdim ydim // draws one column at (xvar,182) addvar xvar 5 // move to the right subvar temp 1 // next column } } } endevent </pre></code>

Return to How to make a health bar.

Retrieved from "http://wiki.eduke32.com/wiki/How_to_make_a_health_bar"