|
Post by lamptonworm on Apr 13, 2016 11:20:24 GMT
Hi all,
I'm after ideas on how to do health/energy bars in AGD - thinking about a global var for health then using a custom char and a repeat loop to draw the bar, any other approaches come to mind?
Cheers, LW.
|
|
|
Post by andrewvanbeck on Apr 14, 2016 9:30:10 GMT
I'd do the same, like make 8 characters for the bar and use the appropriate one at the end of a string. I'd stick with using characters - there are probably a few ways to do it, but they might rely on PUTBLOCK or additional sprites, or even custom ASM code - none of which is ideal... characters are straightforward and quick, and you probably won't need to have lower case letters, so the benefits are stacked in it's favour. At least until the new version of AGD arrives, that might have some drawing commands for us.
|
|
|
Post by alessandro on Apr 14, 2016 12:16:23 GMT
I already did this in Cronopios Y Famas and Cousin Horace (level 3). No fussing around with PUTBLOCK etc., this is a safe and reliable method.
Basically, the health value is assigned to a variable which lower and higher values are also the COLUMN values of the health bar. The bar itself is part of the frontend screen, which surrounds the window area, and is reloaded from memory whenever needed. A possible variation could imply using a text line from within AGD, made with a specifically redefined character in the game font, which could also be used to show energy being replenished when the character performs a certain action, or dies and the player has another life left. See any of the two games above to have an idea of what I am talking about; download links can be found in the AGD Releases forum section.
The following code is taken from Cronopios Y Famas and refers to the code pertaining to an enemy character sprite:
IF COLLISION 0 ; collision with the player sprite IF A = 0 ; delay to avoid player sprite health being immediately depleted LET LINE 5 LET COLUMN H ; the rightmost part of the health bar is also the current health value COLOUR 71 MESSAGE 1 ; overwrites the rightmost character of the bar with a space (thus deleting it) BEEP 50 DELAY 5 SUBTRACT 1 TO H ; health value is diminished by one IF H = 9 ; if the health value reaches the leftmost part of the bar, it has been depleted KILL ; and the player character is killed ENDIF ENDIF ENDIF
|
|
|
Post by lamptonworm on Apr 15, 2016 11:47:11 GMT
Thanks both!
|
|