Card and Deck base

Amuseum

Veteran
Veteran
Joined
Oct 27, 2015
Messages
71
Reaction score
66
First Language
English Chinese
Primarily Uses
RMXP
Card and Deck base


Introduction


Provides base classes to build your own cards, decks, and card game.


Features


-- Prototype classes which your own card game can inherit from.


-- Paint cards to the screen.


Long-term


-- Plugin commands


-- Demo card games


-- Animation?


How to use


Set this plugin above your own card game plugin.


See post #9


Script


CardDeck.js


Casino.js


Screenshots


carddeck text.png


carddeck event.png


pokara face.png


video demonstrations in second post and third post


Changelog
 
Last edited by a moderator:

Amuseum

Veteran
Veteran
Joined
Oct 27, 2015
Messages
71
Reaction score
66
First Language
English Chinese
Primarily Uses
RMXP
Draw Poker simulator to demonstrate rendering cards to the screen. see my sig to play it at my testing ground.
 
Last edited by a moderator:

Amuseum

Veteran
Veteran
Joined
Oct 27, 2015
Messages
71
Reaction score
66
First Language
English Chinese
Primarily Uses
RMXP
Finally polished the cards to look like real playing cards. Every symbol, number, and face-card picture and colored border is placed during runtime with customized algorithms. only the card back is static and imported as is. you can and should define your own algorithm of creating the card images; or precreate them as static images and import directly.





pokara face2.png

pokara face2.png
 
Last edited by a moderator:

Amuseum

Veteran
Veteran
Joined
Oct 27, 2015
Messages
71
Reaction score
66
First Language
English Chinese
Primarily Uses
RMXP
Another card game but the cards look different. This is a puzzle game. The goal is to eliminate all cards from the board by matching pairs of cards by color or by shape.
 

kiddeath95

Lead Trainie
Veteran
Joined
Mar 12, 2014
Messages
104
Reaction score
14
First Language
English
Primarily Uses
Can you have more than one deck of cards? Maybe something like Yugioh or Magic?
 

Amuseum

Veteran
Veteran
Joined
Oct 27, 2015
Messages
71
Reaction score
66
First Language
English Chinese
Primarily Uses
RMXP
you make as many decks as you need. the original purpose was to collect, store, and play cards. it could be simple like SW:KOTOR or FF8. or full blown like Pokemon CCG.


the poker game actually has two decks: the main deck and your hand which draws cards from the main deck. IOW each zone is a separate deck. the Deck class includes functions to move cards between decks.
 

kiddeath95

Lead Trainie
Veteran
Joined
Mar 12, 2014
Messages
104
Reaction score
14
First Language
English
Primarily Uses
Sweet, i will check this out later and play around with it once you have the script up for use!
 
Last edited by a moderator:

Amuseum

Veteran
Veteran
Joined
Oct 27, 2015
Messages
71
Reaction score
66
First Language
English Chinese
Primarily Uses
RMXP
I'll share the files now so you can play with it and give feedback. There's still more stuff to add (like tapping cards sideways and plugin commands), but this should provide a good base for simple card games.

CardDeck.js

Casino.js

CardDeck.js is the core file. Casino implements the card games that I've demonstrated in this thread, which you may use as a sample.

You want to inherit from Card_Base and Deck_Base for your own cards. The two functions you want to overwrite for your child class are initFront and initBack. These define how your cards look like. The default for these functions either fill the card with a single color or loads an image in 'img/card' folder. Look in Casino.js to see how I redefined them differently for Poker and Matches cards.

To draw the cards into the windows, I create as many Sprite_Buttons as will be displayed on the screen. First, buttons have inherent clickHandlers capability to handle mouse and tap inputs. Adding them as children to the window will automatically paint them onto the screen, as long as you set their visibility and bitmap properly.

Secondly, throughout the game, I will assign and update these button's bitmap variable to the appropriate card's _frontImage or _backImage, based on user's input and game conditions. for ex

Window_CasinoPokara.prototype.onCardClicked = function(index) { if ( ! this._isDeal) { // flip card when allowed to change cards var card = this._hand.cardList[index]; card.flip(); this._buttons[index].bitmap = card._bitmap; }};first I called 'card.flip()' to apply the card._bitmap to the correct side. then 'button.bitmap = card._bitmap' to assign the correct bitmap to the button which will be drawn onto the screen.That's only one way. You may find other ways to display the cards. For instance, since Card_Base already inherits from Sprite_Button, you can directly add the cards as children to the window. However, you would then have to handle each card's x, y positions, visibility and clickHandlers. This method may be better if the amount of cards on the table fluctuates and cards move frequently between zones.

In my poker game, I abstract each zone as separate decks. There are two decks used in the game: the main 'deck' and the player's 'hand'. When a player draws cards, it copies cards from the 'deck' to the 'hand'. The Deck_Base class keep a counter of the current index for which card is considered the top card to deal out. This is just a shortcut for dealing games and may not be appropriate for all types of card games. Other games may want to actually move cards between decks, not copy them.
 

kiddeath95

Lead Trainie
Veteran
Joined
Mar 12, 2014
Messages
104
Reaction score
14
First Language
English
Primarily Uses
Could you create a demo using these two scripts so others may be able to understand how to use this script. I'll be sure to be checking this out later tonight! This will be awesome!!
 

Amuseum

Veteran
Veteran
Joined
Oct 27, 2015
Messages
71
Reaction score
66
First Language
English Chinese
Primarily Uses
RMXP
Could you create a demo using these two scripts so others may be able to understand how to use this script. I'll be sure to be checking this out later tonight! This will be awesome!!
You can play the card games in my testing ground in my sig. Go to your room in the 2nd floor and click the green table.
 

SheWolf

The Blood Moon She-Wolf
Veteran
Joined
May 4, 2015
Messages
30
Reaction score
38
First Language
Portuguese
Primarily Uses
Other
All of this seems very promising, and I'm actually looking forward to use this on my game. Do you have any special terms of use for this base? Would be good to know if you're against commercial or not.
Regardless, I can already see good trading card games being made with this. Great job!
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

My sister is a saint. Specifically Saint Peter. Because shes my best friend until other ppl are around then shes all "nope, dont know him, dont like him."
Making it a rule that I don't do any world building for my new game before the actual gameplay is concrete and working. I have 16 years of lore to work with anyway.
Cheesy power metal makes everything better. No matter what you do, you'll feel heroic doing it.
Starting to really like the first of my madness areas. I think the eyes looking at them really helps to sell the place. :LZSexcite:

Forum statistics

Threads
95,698
Messages
931,109
Members
126,043
Latest member
rpgteck
Top