First off, I found my first in-Hugo's-innards bug. Like, I've found library bugs or interpreter inconsistencies before, but this was the first bug that goes back to the engine code. Anyhow, it involves the dictionary-word total not being correctly reset between game restarts. It's not a huge bug, so it likely won't prompt a new Hugo release very soon but it's nice to add another reason to have a new official release (still, considering some projects I know of will use adding-to-the-dictionary-table intensively, a sooner fix will be appreciated regardless).
So, other than that, I figured I'd pad this post out with some utility routines I am considering adding to roodylib. I wrote them for my WIP, which should hopefully be ready for testing within a week or so.
The first routine would fall in the category of "auxiliary math routines." When I am doing games with windows and/or graphics, I find myself saying, well, I'd like it to do this if the screen has this aspect ratio and I'd like to do that if it has that aspect ratio. So, I'm like, ok, do this if the screenwidth is between this and that number. Anyhow, after wanting some approximation code for a while, I finally threw together a simple routine for such things:
routine IsNear(fir,sec,range)
{
if (abs(fir - sec) <= range)
return true
else
return false
}
So you'd do something like IsNear(display.linelength, 40, 10) to find out if the line length is within 10 spots of 40. Anyhow, I figure it'd be useful beyond screen stuff, sometimes.
The other routine I'm considering adding is a line-only version of CenterTitle, that only draws the text given to it center-justified. If the text is too long for the screen width, it just does a normal indentation to show that the text is special.
routine CenterLine(a)
{
print newline ! make sure we are at the start of a line
local l
l = string(_temp_string, a)
if l < display.linelength
print to (display.linelength / 2 - l/2);
else ! if we don't have enough line width to center it, we'll show the
Indent ! line's importance by indenting
print a
}
Centering when you don't have proportional text off is an uncertain gamble, but still, I thought there might be a demand for such a routine.
When roodylib is much more mature, I'll get around to adding switches or whatever so a lot of these routines are only compiled when they are wanted, but that's for another day.
No comments:
Post a Comment