I'm currently working on a playing card game & I need to lay one image(playing card) partially over another. Whenever I try to do this the first image dissappears. Even if I try & place it some distance away the first image vanishes. (If I draw them all at once its fine, but trying to place extra images on the screen as the game progresses doesn't work....) How can I overcome this anybody?
dangerousbrian
I don't understand the problem, can you post a snippet of code to shows what your doing ?
Cls 0
WaitKey:Wait 1000
For x= 10 To 650 Step 160
DrawImage 53,x,20,0
Next x
Sync
WaitKey
x=15
;;;;works fine up to here;;;;;;;;shows backs of 5 cards
For y=3 To 7
DrawImage cards(y),x,25,0:Sync
x=x+160
WaitKey:Wait 2000
Next y
WaitKey
this bit shows some cards/no backs or just the odd face cards...
(by the way I think I'm getting the hang of arrays :) )
That seems OK so far. The problem might be else where. Perhaps when your grabbing the cards from the image ?.
Quote(by the way I think I'm getting the hang of arrays smile.gif )
phew :)
I don't think that's the problem. Although I prepared a large image to dissect I didn't use it. Ive actually loaded 53 seperate images which all display fine.. (52 face cards and the back of a card)
dangerousbrian
After looking again, yes this code is broken. It's a lovely logical error (you'll grow to love those in programming :) )
It's caused by Syncing after each image is drawn (That's a pretty big no-no)
As what you may not know is that there are actually two copies of the screen..
The Front buffer (the one we see) and the Back Buffer (a hidden copy we don't see)
When drawing computer gfx, we can't draw them directly to the Visible screen (the front buffer).. If you do, they flash and flicker really badly. (it's caused by how the display/monitor refresh the image) Thus everything is actually drawn offscreen first to the hidden, then the buffers are swapped (or in some cases transfered) from the Back buffer to the front buffer.
One of Sync's jobs in PlayBasic is swap Back/Front buffers.
Here's what i think is prolly happening..
As the following code draws each image, its swaping the Two buffers (front for back, then Back for front, etc etc)
So on one copy of the Screen, you have the ODD numbered images, and the others are on the second buffer.
QuoteFor y=3 To 7
DrawImage cards(y),x,25,0:Sync ; << dont do this !
x=x+160
WaitKey:Wait 2000
Next y
this is better
QuoteFor y=3 To 7
DrawImage cards(y),x,25,0
x=x+160
Next y
Sync
thanks Kevin, unfortunately I have to draw them one at a time & display them (The waitkey line was just a temp halt while I worked out the code for the player inputing a decision) I'll have to cls & redraw at each decision making point
dangerousbrian
Just have an infinite loop Brian and use flags to determine what to do next
Do
Cls 0
`Game Logic
Select CardFlag
Case 0
Text 10,10,"pick a card, any card..."
Case 1
Text 10,10,"You picked a card, push return to do something else..."
Case 2
Text 10,10,"That's it game over, push return to start over"
EndSelect
`Player Input
If EnterKey()=1
If HoldKey=0
HoldKey=1
CardFlag=CardFlag+1
If CardFlag>2 Then CardFlag=0
EndIf
Else
HoldKey=0
EndIf
Sync
Loop
H'mm that's a lot more elegant than the 200 lines of code I've just written! :)