Variable Status Bar

Learn to use DS Game Maker by Example.

Variable Status Bar

Postby mumpyboor » February 3rd, 2015, 6:23 am

This tutorial uses direct pixel drawing functions to demonstrate a status bar which can be flipped veritcally and horizontally, expanded both in width and length, and moved around the screen.

Could be used for health and status bars like in an RPG or RTS.

The code is very crude, but it works.

Include 'ZG_Library.h' under Game Settings -> Coding.

The object calls PA_Init16cBG(screen, layer) to set up the screen for drawing.

There are three functions in the Library:

ZG_DrawBox(u8 x, u8 y, u8 width, u8 height, u8 screen, u8 color)

Draws a box of the selected color at (x,y) with dimensions width, height.
Default palette is as follows:
0 - black, 1 - white, 2 - red, 3 - green, 4 - blue, 5 - magenta, 6 - cyan, 7 - yellow, 8 - light gray, 9 - dark gray.

ZG_StatusBar(u8 x, u8 y, u8 width, u8 height, u8 screen, u8 color, float max, float percent, bool vertical, bool flip)

Draws a bar of selected color at x,y with dimensions width, height. Bar will fill to the fraction of width equal to (percent/max). Set flip to true to flip horizontally, set vertical to true to make it vertical.

ZG_StatusBarBox(u8 x, u8 y, u8 width, u8 height, u8 screen, u8 color, float max, float percent, u8 box_color, bool vertical, bool flip)

The real purpose of the library, to create a status bar with a 1 pixel thick box of 'box_color' around a status bar. The box will be length 'width' regardless of how full (percent/max) is.

In the dsgm file I have the object move the status bar around with the D-Pad.

Press A to fill and B to unfill.
Press X to fatten, Y to deflate.
Press R to lengthen, L to shorten.
Press select to flip horizontal, start to flip veritcal.

I also made it that at 60% it turns from green to yellow, at 30% from yellow to red.
Attachments
ZG_Library.h
(2.45 KiB) Downloaded 180 times
status_bar.dsgm
(2.31 KiB) Downloaded 186 times
mumpyboor
 
Posts: 6
Joined: January 13th, 2015, 9:19 pm

Re: Variable Status Bar

Postby nicklausw » February 4th, 2015, 1:08 am

Impressive. Way back when people were going insane over health bars and how to do them.
my stuff
pong - sms/gb
sudoku - sega master system

next project - something for the nes, perhaps?[/b]
User avatar
nicklausw
 
Posts: 1037
Joined: May 23rd, 2011, 10:25 pm
Location: The Capital Wasteland

Re: Variable Status Bar

Postby Buck_7 » February 4th, 2015, 6:00 pm

Nice work
User avatar
Buck_7
 
Posts: 1460
Joined: February 19th, 2011, 1:44 am


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

cron