Food/water graphics?

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
Kesa
Journeyman
Posts: 67
Joined: Fri Sep 10, 2010 11:44 pm

Food/water graphics?

Post 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
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Food/water graphics?

Post 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. :)
User avatar
Kesa
Journeyman
Posts: 67
Joined: Fri Sep 10, 2010 11:44 pm

Re: Food/water graphics?

Post by Kesa »

thnx so much Sophia
User avatar
Bit
Arch Master
Posts: 1064
Joined: Mon Mar 03, 2008 10:53 am
Location: Nuts trees

Re: Food/water graphics?

Post by Bit »

Probably I misunderstood the problem, but what's with masked_blit and subbitmaps in Allegro?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Food/water graphics?

Post by Sophia »

I don't know... what is with them? :shock:
(I don't understand what you're asking!)
User avatar
Bit
Arch Master
Posts: 1064
Joined: Mon Mar 03, 2008 10:53 am
Location: Nuts trees

Re: Food/water graphics?

Post by Bit »

Well, I thought those are able to handle transparency.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Food/water graphics?

Post 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. ;)
User avatar
Bit
Arch Master
Posts: 1064
Joined: Mon Mar 03, 2008 10:53 am
Location: Nuts trees

Re: Food/water graphics?

Post 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.
Post Reply