Posts

Showing posts with the label Programming

Rolling Health Meter

Something I struggled to find on the internet was a decent working example of a rolling health meter, a'la Earthbound. For those not familiar, you have a HP value, and when you take damage, it isn't applied automatically -- instead, your HP instead ticks down to that value, like an odometer in a car. In Earthbound, this is not just a cosmetic effect, and as long as your HP is still ticking down, you're not dead yet, which then leads to other clever mechanics not usually seen in RPGs. What I had trouble finding was how to a) reduce and b) display the "rolling" effect -- what examples I found were cheap, and simply reduced HP by a fixed amount until the target HP was hit. What I wanted was one where the meter is quicker the more health you're gaining / losing, and slows to a crawl when nearing it's target. I figured it out, so here it is. It was done in Gamemaker's GML, but should translate relatively well to other languages. Calculating the num...

Gamemaker: Quirks

In working with Gamemaker Studio, while it's built-in language, GML, is very much like C# with training wheels on, it just does some things differently from other programming languages. An obvious example is that it doesn't need type declarations, and couldn't give less of a shit about line endings. The following would be required in C# and most programming languages: string name = "Joel"; int age = 32; In GML, you can get away with: name = "Joel" age = 32 While this is great and makes things quicker, it does kind of foster bad habits. A less obvious example is that Gamemaker Studio treats strings as non-0 indexed char arrays, which is surprising in itself, but also that index 0 will return the data for index 1, rather than an error. This was an infuriating quirk that messed with a text rendering script for like, ages. If I had the string "Peter Piper Picks Peppers" and tried to copy it out one character at a time from index 0...