This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

mjrb4 presents ...


Card Demo

Click and drag the cards around, press the green button to create a new random card and hold the right mouse button down to filp the card over.

This may be of help to anyone wanting to implement card games in Greenfoot... Though remember to copy all the images (in resources/cards) over to your project (as well as the Card source code) if you want to use this in your own scenarios.

As an aside, this could also be used as a demo of enums (enumerations.) Have a look in the Card class to see why!

- Got rid of the button and added a deck instead.
- You can create a normal deck, or specify the numbers of sets of different suits you want. You can also specify whether or not you want to include jokers.
- When the deck is empty, it just shows an outline.
- Press space to refill the deck and get rid of the cards.
- The card that you're dragging or have dragged last now appears on top of all the others.
- Added a couple more methods to Deck and Card that may come in useful.

13063 views / 1652 in the last 7 days

7 votes | 0 in the last 7 days

Tags: mouse demo with-source

This scenario is a member of: Reusable actors & support classes

open in greenfoot
Your browser does not support the canvas tag.


i like it
A new version of this scenario was uploaded on Thu Apr 23 12:46:04 UTC 2009
A new version of this scenario was uploaded on Thu Apr 23 19:33:18 UTC 2009


This is a great asset! I was going to make a weekend project out of creating my own, but this does an excellent job - very modular, well-commented and useful. Thanks!!


FYI - add showNum = 0 to the dealCard() method in deck, otherwise showing cards won't function correctly.

Want to leave a comment? You must first log in.

Who likes this?

395khb12 MrCohen ananaz ThatOneGuy 4xtra bourne spaceblue