PCA bitmap question

Discuss OrbForms Designer and PocketC Architect

Postby exit_head on Wed Jan 04, 2006 7:45 pm

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?
exit_head
 
Posts: 64
Joined: Tue May 04, 2004 3:50 am
Location: USA

Postby Gazza on Wed Jan 04, 2006 9:47 pm

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();
Gazza
 
Posts: 146
Joined: Sat Jan 12, 2002 1:56 am
Location: United Kingdom

Postby exit_head on Wed Jan 04, 2006 10:12 pm

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!");
}
exit_head
 
Posts: 64
Joined: Tue May 04, 2004 3:50 am
Location: USA

Postby dewey on Thu Jan 05, 2006 5:13 am

It looks like you haven't declared your Draw object. Is "draw" a global variable? Have you attached it?
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby Gazza on Thu Jan 05, 2006 4:02 pm

Hi Nate,

If statements are expensive!

You could do this in one line,

draw.bitmap(1100+dice_value[slot],0,20); return
Gazza
 
Posts: 146
Joined: Sat Jan 12, 2002 1:56 am
Location: United Kingdom

Postby misterx on Thu Jan 05, 2006 6:23 pm

yes, but your line is wrong...

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

...
misterx
 
Posts: 32
Joined: Mon Aug 02, 2004 5:12 pm
Location: Germany

Postby exit_head on Thu Jan 05, 2006 7:29 pm

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
exit_head
 
Posts: 64
Joined: Tue May 04, 2004 3:50 am
Location: USA

Postby exit_head on Thu Jan 05, 2006 10:17 pm

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
exit_head
 
Posts: 64
Joined: Tue May 04, 2004 3:50 am
Location: USA

Postby Gazza on Thu Jan 05, 2006 10:53 pm

Yep, I missed that! :oops:
Gazza
 
Posts: 146
Joined: Sat Jan 12, 2002 1:56 am
Location: United Kingdom

Postby dewey on Fri Jan 06, 2006 4:37 am

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).
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am


Return to OrbForms Designer and PocketC Architect

Who is online

Users browsing this forum: No registered users and 2 guests

cron