Page 1 of 1

Food/water graphics?

Posted: Thu Oct 06, 2011 11:12 pm
by Kesa
This is the codes in the render.lua, but I forgot what was needed to make the codes go from displaying simple lines of color to graphics... heh I am still relearning again blah...So how can I change this into what is needed for lets say water_bar.bmp and food_bar.bmp to be shown?

Code: Select all

-- A subrenderer for the main inventory
function sys_render_mainsub(who)
	local sr = dsb_subrenderer_target()
	
	dsb_bitmap_clear(sr, base_background)
	dsb_bitmap_draw(gfx.inter_foodwater, sr, 6, 0, false)
	
	local baseval = dsb_get_food(who)
    local barlen = math.floor((192 * baseval) / 3072) - 1
   	local ccolor = adjust_bar(baseval, {148, 72, 0})
    dsb_bitmap_rect(sr, 28, 38, 30+barlen, 51, {0, 0, 0}, true)
	dsb_bitmap_rect(sr, 24, 34, 26+barlen, 47, ccolor, true)
        
    baseval = dsb_get_water(who)
    barlen = math.floor((192 * baseval) / 3072) - 1
    ccolor = adjust_bar(baseval, {0, 0, 255})
    dsb_bitmap_rect(sr, 28, 84, 30+barlen, 97, {0, 0, 0}, true)
	dsb_bitmap_rect(sr, 24, 80, 26+barlen, 93, ccolor, true)
end

-- Utility function for coloring the bar
function adjust_bar(val, default)
	local rv
	
    if (val < 512) then
        rv = {255, 0, 0}  
    elseif (val < 1024) then
        rv = {255, 255, 0}
    else
    	rv = default
    end

    return rv 	
end

Re: Food/water graphics?

Posted: Fri Oct 07, 2011 12:24 am
by Sophia
If you pass a dsb_bitmap_rect a bitmap instead of a color table (i.e., gfx.food_bar instead of {148, 72, 0}) it will tile that bitmap instead of drawing a solid colored rectangle. This is how we did it last time, I think.

Allegro doesn't let you tile bitmaps with any sort of transparency or masked (power pink) backgrounds so DSB doesn't either. The easiest way to get around this is to make a solid background color and make your tiled bitmap's background color the same as your main background color. This is also what we ended up doing last time.

I hope this helps. :)

Re: Food/water graphics?

Posted: Fri Oct 07, 2011 12:26 am
by Kesa
thnx so much Sophia

Re: Food/water graphics?

Posted: Sat Oct 08, 2011 8:20 am
by Bit
Probably I misunderstood the problem, but what's with masked_blit and subbitmaps in Allegro?

Re: Food/water graphics?

Posted: Sat Oct 08, 2011 7:20 pm
by Sophia
I don't know... what is with them? :shock:
(I don't understand what you're asking!)

Re: Food/water graphics?

Posted: Sun Oct 09, 2011 6:02 am
by Bit
Well, I thought those are able to handle transparency.

Re: Food/water graphics?

Posted: Sun Oct 09, 2011 9:55 pm
by Sophia
They are! But for dsb_bitmap_rect I'm using DRAW_MODE_COPY_PATTERN with rectfill, which isn't able to handle it. :(
I could work out something with masked_blit, but then I'd have to tile the bitmap myself. I already do it with the code to draw blue hazes, so I could adapt it... but I didn't feel like bothering. ;)

Re: Food/water graphics?

Posted: Mon Oct 10, 2011 1:24 am
by Bit
After all the time, I still didn't find hours left over to spend for working with DSB. And I'm sure that I'll be stuck within DM2-things for another while. It's a shame, I know - but I'm somewhat stubborn in my todo-list (Paul says nuts, probably even fits better).
If Kesa found a way, it's okay anyways.