Icon Bar
Version: 1.0
Introduction
This is a really simple script I wrote for my game and I thought that it might be useful for some other people. Basically, it makes a bar out of two different icons, an empty and a full one. It splits the icons into halves and makes a bar out of them (think the Zelda life bar with full, half, and empty hearts).
Screenshots
http://farm3.static.flickr.com/2032/197 ... d27440.jpg[/IMG]
I probably should have chosen better icons, but it should be visible. See that the top one has three and a half lighter diamonds, the second has three, and the other two have none.
Demo
Okay, I just made a small demo, and changed the instructions to (hopefully) make them easier to understand. Until the demo's accepted to the DLM, I'll attach it to this post.
Script
Instructions
Copy and paste above main. To call it just use "draw_icon_bar(x, y, value, max, filled icon (optional), empty icon (optional)". Just make sure that you either name icons when you call it or that you have icons called "Filled" and "Empty", and remember that "value" and "max" are the number of half icons, so if you want 2 1/2 out of 5, use 5 and 10.
Compatibility
Unless you have another def in Window_Base called "draw_icon_bar," you shouldn't have problems. Just make sure that when you call it, the window has "self.contents" defined.
Author's Notes
If anyone has good icons for this script, it would be nice if you'd post them for other people to use. I'm afraid I'm a horrible artist, and the icons in the demo aren't mine (I actually can't remember where I got them ':|).
Terms and Conditions
Credit's really not needed. It took me all of five minutes. :D
Version: 1.0
Introduction
This is a really simple script I wrote for my game and I thought that it might be useful for some other people. Basically, it makes a bar out of two different icons, an empty and a full one. It splits the icons into halves and makes a bar out of them (think the Zelda life bar with full, half, and empty hearts).
Screenshots
http://farm3.static.flickr.com/2032/197 ... d27440.jpg[/IMG]
I probably should have chosen better icons, but it should be visible. See that the top one has three and a half lighter diamonds, the second has three, and the other two have none.
Demo
Okay, I just made a small demo, and changed the instructions to (hopefully) make them easier to understand. Until the demo's accepted to the DLM, I'll attach it to this post.
Script
Script
Spoiler
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This class is for all in-game windows.
#==============================================================================
class Window_Base
`#--------------------------------------------------------------------------
# * Draw icon bar
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# value : number of half-icons to draw filled
# max : number of half-icons to draw total
# filled : name of icon used as filled
# empty : name of icon used as empty
#-----------------------------------------------------------------------
def draw_icon_bar(x, y, value, max, filled = 'Filled', empty = 'Empty')
filled_icon = RPG::Cache.icon(filled)
empty_icon = RPG::Cache.icon(empty)
for i in 0...value
icon_x = (i / 2) * 32 + ((i % 2) * 12) + x
if i % 2 == 1
rectangle = Rect.new(12, 0, 12, 24)
else
rectangle = Rect.new(0, 0, 12, 24)
end
self.contents.blt(icon_x, y + 4, filled_icon, rectangle, 255)
end
for i in value...max
icon_x = (i / 2) * 32 + ((i % 2) * 12) + x
if i % 2 == 1
rectangle = Rect.new(12, 0, 12, 24)
else
rectangle = Rect.new(0, 0, 12, 24)
end
self.contents.blt(icon_x, y + 4, empty_icon, rectangle, 255)
end
end
end
# ** Window_Base
#------------------------------------------------------------------------------
# This class is for all in-game windows.
#==============================================================================
class Window_Base
`#--------------------------------------------------------------------------
# * Draw icon bar
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# value : number of half-icons to draw filled
# max : number of half-icons to draw total
# filled : name of icon used as filled
# empty : name of icon used as empty
#-----------------------------------------------------------------------
def draw_icon_bar(x, y, value, max, filled = 'Filled', empty = 'Empty')
filled_icon = RPG::Cache.icon(filled)
empty_icon = RPG::Cache.icon(empty)
for i in 0...value
icon_x = (i / 2) * 32 + ((i % 2) * 12) + x
if i % 2 == 1
rectangle = Rect.new(12, 0, 12, 24)
else
rectangle = Rect.new(0, 0, 12, 24)
end
self.contents.blt(icon_x, y + 4, filled_icon, rectangle, 255)
end
for i in value...max
icon_x = (i / 2) * 32 + ((i % 2) * 12) + x
if i % 2 == 1
rectangle = Rect.new(12, 0, 12, 24)
else
rectangle = Rect.new(0, 0, 12, 24)
end
self.contents.blt(icon_x, y + 4, empty_icon, rectangle, 255)
end
end
end
Expand to see the code.
Instructions
Copy and paste above main. To call it just use "draw_icon_bar(x, y, value, max, filled icon (optional), empty icon (optional)". Just make sure that you either name icons when you call it or that you have icons called "Filled" and "Empty", and remember that "value" and "max" are the number of half icons, so if you want 2 1/2 out of 5, use 5 and 10.
Compatibility
Unless you have another def in Window_Base called "draw_icon_bar," you shouldn't have problems. Just make sure that when you call it, the window has "self.contents" defined.
Author's Notes
If anyone has good icons for this script, it would be nice if you'd post them for other people to use. I'm afraid I'm a horrible artist, and the icons in the demo aren't mine (I actually can't remember where I got them ':|).
Terms and Conditions
Credit's really not needed. It took me all of five minutes. :D