Page 1 of 1

PostPosted: Wed Jan 04, 2006 7:45 pm
by exit_head
how does one go about drawing a bitmap?

draw.bitmap(1100+dice_value[1],0,20);
returns "undeclaired identifier"

i cant seem to find an example of simple bitmap drawing anywhere?

thanks

Nate

PS: can you only create ONE offscreen buffer at a time?

PostPosted: Wed Jan 04, 2006 9:47 pm
by Gazza
What language are you using?

In orbforms I do it like this :-

dice[0] = bmpFacea.id;
dice[1] = bmpFaceb.id;
dice[2] = bmpFaceb.id;
dice[3] = bmpFaceb.id;
dice[4] = bmpFaceb.id;
dice[5] = bmpFaceb.id;

draw.begin();
draw.bitmap(dice[n++], 0,0);
draw.end();

PostPosted: Wed Jan 04, 2006 10:12 pm
by exit_head
im using PocketC Architect, i still have the pocketC legacy headers but im trying to port it over to "pure" PocketC Architect(aka orbforms)

here is the whole func, it returns a "undeclaired identifier" at the draw.begin();

draw_dice(int slot){
draw.begin();
if(slot==1){draw.bitmap(1100+dice_value[1],0,20); return;}
if(slot==2){draw.bitmap(1100+dice_value[2],32,20); return;}
if(slot==3){draw.bitmap(1100+dice_value[3],64,20); return;}
if(slot==4){draw.bitmap(1100+dice_value[4],96,20); return;}
if(slot==5){draw.bitmap(1100+dice_value[5],128,20); return;}
draw.end();
//error report
alert("draw_dice() error! out of range!");
}

PostPosted: Thu Jan 05, 2006 5:13 am
by dewey
It looks like you haven't declared your Draw object. Is "draw" a global variable? Have you attached it?

PostPosted: Thu Jan 05, 2006 4:02 pm
by Gazza
Hi Nate,

If statements are expensive!

You could do this in one line,

draw.bitmap(1100+dice_value[slot],0,20); return

PostPosted: Thu Jan 05, 2006 6:23 pm
by misterx
yes, but your line is wrong...

draw.bitmap(1100+dice_value[slot],<b>slot*32</b>,20); return;

...

PostPosted: Thu Jan 05, 2006 7:29 pm
by exit_head
actually it have to be:

draw.bitmap(1100+dice_value[slot],slot*32-32,20); return;

i think thats it but i forget the order of operations.
but your right :) thatnks for the help.

PS: can you really only have one buffer?

PSS: i really dont get this. heres my code now:

draw_dice(int slot){
Draw.attachForm(GameForm);
Draw.begin();
draw.bitmap(1100+dice_value[slot],slot*32-32,20); return;
Draw.end();
//error report
alert("draw_dice() error! out of range!");
}

it stops at "Draw.attachForm(GameForm);" saying :missing identifier.
sorry if im being thick but this is my first oo programming

PostPosted: Thu Jan 05, 2006 10:17 pm
by exit_head
ok ok ok, i got it :) thanks every one for you help. btw is there any way i can draw a bitmap with the id instead of the bmp identifier?

Draw gameDraw;

draw_dice(int slot){
gameDraw.attachForm(GameForm);
gameDraw.begin();
if(slot==1){gameDraw.bitmap(bmpDice1,0,20); return;}
if(slot==2){gameDraw.bitmap(bmpDice2,32,20); return;}
if(slot==3){gameDraw.bitmap(bmpDice3,64,20); return;}
if(slot==4){gameDraw.bitmap(bmpDice4,96,20); return;}
if(slot==5){gameDraw.bitmap(bmpDice5,128,20); return;}
gameDraw.end();
//error report
alert("draw_dice() error! out of range!");
}

:) thanks again

PostPosted: Thu Jan 05, 2006 10:53 pm
by Gazza
Yep, I missed that! :oops:

PostPosted: Fri Jan 06, 2006 4:37 am
by dewey
Yes, you can have multiple offscreen buffers - limited only by available memory. In the example above, you aren't using an offscreen buffer at all. To use an offscreen buffer, create another Draw object (e.g. Draw offscreeDraw), and call offscreeDraw.create(). To draw it to the screen, call gameDraw.draw(offscreenDraw).