Re: Cards Again

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Thu, 02 Dec 1999, you wrote:
> Hey Guys,
> Its me again. I'm having another problem. I can't figure out how to reomove
> a card (Playing cards) when it is displayed in my window. I've got the
> random selection thing working. I just can't figure this crap out
> AAUuuggghhh! Any help would be apreciated. thanks

First of all, do you mean you want to remove the drawn card from the deck, so
it won't be drawn again? or want to remove a card from the screen?
(1)
-----------------------------------------------------
-- function draw returns a hand of <<count>> cards
-----------------------------------------------------
function draw(integer count)
object hand
hand = {} -- empty
for i = 1 to count do      -- however many cards were requested
    x = rand(length(deck)) -- pick a card at random from remaining deck
    hand = append(hand, deck[x]) -- add that card to your hand
    deck = deck[1..x-1] & deck[x+1..length(deck)] -- remove card from deck
    if length(deck) < 1 then exit -- not enuf cards
    end if
end for
return hand
end function
(2)
If you're asking how to erase cards from the screen, you can call
repaintWindow(MainWindow) to erase the screen to the background color.
If you only want  to remove _one_ card, you'll have to erase the screen and
then re-draw all cards except the removed one. You can put your card
drawing routine in the window's onPaint event, so the cards will be redrawn
automagically whenever the window is repainted, moved or resized
Nobody said this stuff wasn't confusing :)

Irv

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu