|
Re: Change multiple bmaps for buttons
[Re: Dominator]
#284342
08/12/09 21:30
08/12/09 21:30
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
there's also pan_setbutton pan_setbutton(PANEL*, var num, var type, var x, var y, BMAP* bmapOn, BMAP* bmapOff, BMAP* bmapOver, BMAP* bmapOverOff, void* functionClick, void* functionLeave, void* functionOver); so you can change all the buttons at once, in one line of code
|
|
|
Re: Change multiple bmaps for buttons
[Re: Dominator]
#284347
08/12/09 22:16
08/12/09 22:16
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
well unfortunately you need to pass all the parameters if you're trying to just shorten that just create a simple function
function change_card(var hand, int card, BMAP* bmp_card){
pan_setbmap(hand, card, 1.0, bmp_card);
pan_setbmap(hand, card, 1.1, bmp_card);
pan_setbmap(hand, card, 1.2, bmp_card);
}
//then call
change_card(freds_hand, 1, jack_heart);
|
|
|
Re: Change multiple bmaps for buttons
[Re: Dominator]
#284372
08/13/09 03:34
08/13/09 03:34
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
change your for loops to
for(Count = 0; Count <= 24; Count++){
instead of all the if else use switch
switch(Number){
case 1:
//do case 1
break;
case 2: etc...
A7 can't return strings too well, you'll need to set it inside the function
str_cpy(passed_string, result);
you shouldn't be getting the name of the panel, just return it's pointer would it not be easier for you to have just 1 image of all the cards, then use a window to display the card, rather than having them all as seperate images? and use [ code ] [/code] tags, makes it easier to read hope this helps
|
|
|
Re: Change multiple bmaps for buttons
[Re: MrGuest]
#284376
08/13/09 05:25
08/13/09 05:25
|
Joined: Aug 2009
Posts: 19
Dominator
OP
Newbie
|
OP
Newbie
Joined: Aug 2009
Posts: 19
|
I have the different windows working now and they display the card pictures right. The last question I have is if I'm doing it in the shortest amount of lines possible.
PANEL* PlayersHand = { layer = 5; window(180,790,140,218,GameCards2,382,0); window(370,790,140,218,GameCards2,PictureX[1],0); window(560,790,140,218,GameCards2,PictureX[2],0); window(750,790,140,218,GameCards2,PictureX[3],0); window(940,790,140,218,GameCards2,PictureX[4],0); }
function main() { video_mode = 9; video_screen = 1; mouse_map = MousePointer; mouse_mode = 4; mouse_sync = 1; set (PlayingBackground, SHOW); set (OpponentsField, SHOW); set (PlayersField, SHOW); set (PlayersHand, SHOW);
} function GameStart() { Count = 0;
for (Count; Count <= 24; Count++) { if (Count <= 2) { CardCountUnc[Count] = 18; } else if (Count == 3) // Setup of unchanged card number array { CardCountUnc[Count] = 10; } else { CardCountUnc[Count] = 2; } }
Count = 0;
for (Count; Count <= 24; Count++) { CardCountCha[Count] = CardCountUnc[Count]; // Setup of changed card number array } random_seed(0); Count2 = 0; Count = 0; CardNumberZero = 1;
for (Count2; Count2 <= 4; Count2++) { while (CardNumberZero == 1) { CardDrawNumber = rand() % 24; // Deal out players hand
for (Count; Count <= 24; Count++) { if (CardDrawNumber == Count) { if (CardCountCha[Count] > 0) { PlayerHand[Count2] = CardDrawNumber; CardCountCha[Count]--; CardNumberZero = 0; ChangeCardImage(CardDrawNumber,Count2); } } } } CardNumberZero = 1; Count = 0; } } function ChangeCardImage(Number,HandNumber) { switch (Number) { case 0: PictureX[HandNumber] = 135; break; case 1: PictureX[HandNumber] = 263; break; case 2: PictureX[HandNumber] = 382; break; } }
Last edited by Dominator; 08/14/09 16:33. Reason: Figured out how to make ChangeCardImage more efficient
|
|
|
|