Page 1 of 1

PureCardDraw and ClearScreen()

Posted: Wed Oct 10, 2007 12:24 am
by RTEK
I had been looking at the PureCardDraw.pbi and the accompanying test program posted by NetMaestro back in 2005.
http://www.purebasic.fr/english/viewtopic.php?t=18418

If I compile and run the program, the cards are drawn on the screen - no problem here. What I am trying
to figure out is how do I remove the cards from the screen or clear the screen.

From the Help Manual, I know that there is the command "clearscreen(color)" available. But if I try to put clearscreen(rgb(0,128,0)) or clearscreen(32768) after the last ImageGadget instruction in the test program I get error messages saying:

POLINK: error: Unresolved external symbol '_PB_DirectX_PrimaryBuffer'
POLINK: error: Unresolved external symbol '_PB_Screen_Depth'
POLINK: error: Unresolved external symbol '_PB_Sprite_SpriteFX'
POLINK: error: Unresolved external symbol '_PB_Sprite_GetTrueRGBColor'
POLINK: error: Unresolved external symbol '_PB_Sprite_CurrentBitmap'
POLINK: fatal error: 5 unresolved external(s).

I placed the clearscreen command after the last ImageGadget instruction because I already know that drawing the cards is working - I wanted to see them cleared immediately from the screen in my test.

I did some preliminary search in the forum but the codes I ran into shows a syntax of clearscreen(x, y, z) which I think is pre-PB4.

What am I doing wrong here? Are additional coded needed?

Any help will be highly appreciated. Thanks!

Posted: Wed Oct 10, 2007 12:49 am
by Kaeru Gaman
But if I try to put clearscreen(rgb(0,128,0)) or clearscreen(32768) after the last ImageGadget instruction in the test program I get error messages
do you have a screen or an imagegadget?

some Screen-commands may cause POLINK-Errors, when you didn't use InitSprite()

ClearScreen(col) is a Screen command, so it needs the screen-lib initiated, and a screen opened.
if you are working with Images and Gadgets, it's the wrong approach.

...for saying more I need more information about your code...

Posted: Wed Oct 10, 2007 1:08 am
by RTEK
Here's the code I referred to:

Code: Select all

IncludeFile "PureCardDraw.pbi" 

InitCards(RGB(0,128,0)) 

OpenWindow(0, 0, 0, 1000, 700, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
SetWindowColor(0,RGB(0,128,0)) 
CreateGadgetList(WindowID(0)) 

 For i=1 To 13 
   ImageGadget(#PB_Any,75*i-65,60,0,0,GetCard(i,#Clubs)) 
   ImageGadget(#PB_Any,75*i-65,160,0,0,GetCard(i,#Diamonds)) 
   ImageGadget(#PB_Any,75*i-65,260,0,0,GetCard(i,#Hearts)) 
   ImageGadget(#PB_Any,75*i-65,360,0,0,GetCard(i,#Spades)) 
   ImageGadget(#PB_Any,75*i-65,460,0,0,GetCard(i,#Back)) 
 Next 
ImageGadget(#PB_Any,10,560,0,0,GetCard(1,#PlaceHolder)) 
ImageGadget(#PB_Any,85,560,0,0,GetCard(2,#PlaceHolder)) 

;****************************
ClearScreen(32768)    ;Everything else is as posted by Netmaestro.
                      ;For PureCardDraw.pbi code please refer to 
                      ;http://www.purebasic.fr/english/viewtopic.php?t=18418 
;****************************
Repeat 
  Event.l = WaitWindowEvent() 
Until Event = #PB_Event_CloseWindow 
I tried adding InitSprite() as you mentioned (not shown here) - it did make the POLINK errors go away. The compiler now says "There is no current screen." So maybe ClearScreen() is not what I need here. How would I clear the card graphics from the window in this code?

Posted: Wed Oct 10, 2007 1:16 am
by Kaeru Gaman
yap. this is no screen, but a window.

I wonder what you want to do.
you create Imagegadgets for each card, but want them to disappear right away?

ok... you already have the images you need from the include.
you don't need a Gadget for each and every Card,
just that much ImageGadgets for the Cards you want to display at once.

e.g. when you want to make a Poker, you only need 5 ImageGadgets per player.

you can place the Gadgets in the beginning where you want your cards to be shown on the window.

later at every state of your mainloop you can assign an Image to each Gadget by

Code: Select all

SetGadgetState( *Nr of the Gadget here*, GetCard(Nr,Color))
when you want to free the place, just assign an Image-ID of an empty image.

PS:
ok, a bit more information, and then I goto sleep. it's 0230h here.

A Gadget is a Container, carrying information to be displayed and interacting with the user by clicks.
it is not the information itself, just a container for it.
when you placed a gadget once, you can display any information in it
you want, and also change the content at any time in your program.

The Image in opposide is "the Information" (exactly, an object carrying the bitmap information)

now, the information is already present...
you have all 52 cards and one back provided by the include.
there is no need to create any Gadget at all to make your program have the images...
you just need Gadgets to display them.

Posted: Wed Oct 10, 2007 1:37 am
by RTEK
I wonder what you want to do.
you create Imagegadgets for each card, but want them to disappear right away?
I am not making any specific application using PB right now. I just wanted to find out how to erase any graphics from a window. ImageGadget command draws the cards on the window as expected. Since I know that, instead of adding a button to call an erase or clear function I just tried to put the command that I thought would do that right after the drawing function - if on running the program the screen is empty - the erase/clear function works.
e.g. when you want to make a Poker, you only need 5 ImageGadgets per player.
With poker, I agree that you would only need 5 ImageGadgets per player. But let's say the game is blackjack where each player will start with 2 cards and they can draw 1 or more cards until they either bust or stand. At the end of the round, they might have 3 or more cards in their hand onscreen. At the beginning of the next round the extra cards should not be visible - only 2 per hand should be shown.

I can use loops and HideGadget() to do that or as you said just point to an empty image but thoughted that clearscreen() or another command/function could make it easier. Now I think I'm mistaken on that point.

Posted: Wed Oct 10, 2007 1:45 am
by Kaeru Gaman
At the end of the round, they might have 3 or more cards in their hand onscreen
what is the maximum number of cards you can have?
this is the number of gadgets you need.
At the beginning of the next round the extra cards should not be visible - only 2 per hand should be shown.
you need different images in the 2 gadgets anyways, so you have to alter all of your gadgets.
assign an empty image to the rest of your gadget row.

I just wanted to find out how to erase any graphics from a window.
there is no grafix in a window, but containers.
hide the container or empty it.
I just tried to put the command that I thought would do that right after the drawing function
well no. in fact you did not use any drawing function at all.
you just used placement instructions for the containers and put information (images) into them.

Posted: Wed Oct 10, 2007 1:49 am
by RTEK
Got it.

Thanks for your help!

Posted: Wed Oct 10, 2007 1:50 am
by Kaeru Gaman
RTEK wrote:Got it.

Thanks for your help!
you're welcome :D