Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,310 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
variable panels? #382225
09/06/11 03:36
09/06/11 03:36
Joined: Aug 2002
Posts: 164
Houston
Nicholas Offline OP
Member
Nicholas  Offline OP
Member

Joined: Aug 2002
Posts: 164
Houston
I am working on a keymap with bitmaps I need shown.
I am currently using panels with a =SHOW and &=~SHOW (to hide) command. I'd like to shorten it using C, but am not quite good enough to do it on my own.

this is what I have over and over again:
Code:
//button variable array. 
if(buttonz[1] ==1)  {pb_x.flags =SHOW;}
if(buttonz[1] ==0)  {pb_x.flags &=~SHOW;}



what I'd like to be able to do is use something like this:
Code:
if(buttonz[i] ==1)  {panel[i].flags =SHOW;}
if(buttonz[i] ==0)  {panel[i].flags &=~SHOW;}
i++;



I have found some examples I can use as a for(i) command, but I don't know how to do it with the panels, I really don't need it to be a panel, just a bitmap is what I need (with specific coordinates of course).
any help would be nice
:-)


Black holes are where God divided by zero.
Re: variable panels? [Re: Nicholas] #382226
09/06/11 04:23
09/06/11 04:23
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Quote:
I have found some examples I can use as a for(i) command, but I don't know how to do it with the panels

This gives you an array of panels:

// global declaration:
PANEL* my_panel_array[10];
...
// create them once:
for(i = 0; i < 10; i++) my_panel_array[i] = pan_create("",1);

Now you can access every panel and assign different bitmaps, positions and so on, f.i. my_panel_array[4].bmap = cookie_bmp;


Quote:
I really don't need it to be a panel, just a bitmap is what I need (with specific coordinates of course).

Have a look at draw_quad, you can draw bitmaps without the need for panels anywhere on the screen.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: variable panels? [Re: Superku] #382248
09/06/11 15:02
09/06/11 15:02
Joined: Aug 2002
Posts: 164
Houston
Nicholas Offline OP
Member
Nicholas  Offline OP
Member

Joined: Aug 2002
Posts: 164
Houston
Thanks, that helps quite a bit. Unfortunately it still means I have to define each bitmap accordingly. I have seen use of parameters in the title so would I be able to do something like this:

PANEL* my_panel_array[10](bitmap)
{bitmap1=bit_alpha; pos_x=456;pos_y=125;
bitmap2=bit_beta; pos_x=111;pos_y=222;}

then use
my_panel_array[4](4).flags=SHOW; //the array number and parameter number is ok to always have to be the same, but I'd have to be able to tell whats what inside the panel and have multiple bmps and positions defined

This way I could have just one panel array defined with all the bitmaps and locations predefined and just use the code to show or hide it.

If not, I'll still have to have all that code to define the bitmap and coordinates anyway. If I have to do it that way, I'll stick with the draw_quads and save myself from needing those panels at all since they only show in a while loop anyway.

thanks


Black holes are where God divided by zero.
Re: variable panels? [Re: Nicholas] #382254
09/06/11 15:45
09/06/11 15:45
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
I don't understand your post, sorry, but it seems to me as if you are looking for a bitmap array?
Imagine you have mybitmapname1.tga,mybitmapname2.tga,... Then you can easily create an array of bitmaps:

BMAP* bmp_array[10];
STRING* str_bitmap = "";
...
for(i = 0; i < 10; i++)
{
str_printf(str_bitmap,"mybitmapname%d.tga",(int)i); //untested, should work though
bmp_array[i] = bmap_create(str_bitmap);
}

Now you can draw the bitmaps in a for loop:
draw_quad(bmp_array[i], at position bitmap_position[i], ...);
where bitmap_position is an array of VECTORs.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: variable panels? [Re: Superku] #382261
09/06/11 17:38
09/06/11 17:38
Joined: Aug 2002
Posts: 164
Houston
Nicholas Offline OP
Member
Nicholas  Offline OP
Member

Joined: Aug 2002
Posts: 164
Houston
Excellent.
you forgot the "var i;", but the rest works great. Now I can setup a function to call whenever I need it to show.

function drawz(i,x,y,z)
{
draw_quad(bmp_array[i], vector(x,y,z),NULL,NULL,NULL,NULL,100,NULL);
}


thanks for the help. to shorten it more I was going to do something like this, but it's not working

var vec1[6]={20,30,40,50,60,70};
var vec2[6]={20,30,40,50,60,70};
var vec3[6]={20,30,40,50,60,70};

while(1){
for(i = 0; i < 4; i++)
{
if(buttonz[i]==1){drawz[i], vec1[i], vec2[i], vec3[i];}
}
wait(1);}

basically checking if the variable buttonz is set to 1 then executes the command. but it keeps saying subscript requires array or pointer type.

any ideas?
thanks again


Black holes are where God divided by zero.
Re: variable panels? [Re: Nicholas] #382262
09/06/11 17:53
09/06/11 17:53
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Quote:
you forgot the "var i;"

I didn't forget anything, I've just assumed you're clever enough to figure that out on your own.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: variable panels? [Re: Superku] #382278
09/06/11 19:23
09/06/11 19:23
Joined: Aug 2002
Posts: 164
Houston
Nicholas Offline OP
Member
Nicholas  Offline OP
Member

Joined: Aug 2002
Posts: 164
Houston
lol, I assumed that was it, and I obviously did figure it out ;-)
I just like having it in the post in case anyone else needing code like this doesn't think of it.
thanks for the help and I think I figured out my other issue with the xyz. I'll have to check when I get home


Black holes are where God divided by zero.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1