Git Product home page Git Product logo

bryant1410 / javascript-playing-cards Goto Github PK

View Code? Open in Web Editor NEW

This project forked from atomantic/javascript-playing-cards

0.0 2.0 0.0 217 KB

A playing card JavaScript and CSS library for creating standard deck games. Looking for developers to create game pack extensions to add onto this. The library is wrapped to allow it to act as a plugin for jquery (or another framework)

Home Page: http://atomantic.github.com/JavaScript-Playing-Cards

License: Other

HTML 31.26% JavaScript 59.70% CSS 9.03%

javascript-playing-cards's Introduction

License

JavaScript & CSS:
@author Adam Eivy (antic | atomantic)
@link http://adameivy.com/JavaScript-Playing-Cards/

@license Copyright (c) 2010 Adam Eivy (antic | atomantic) Dual licensed under the MIT and GPL licenses:

Card Face images: @author David Bellot
@link http://david.bellot.free.fr/svg-cards/
@license http://creativecommons.org/licenses/by-sa/2.5/

What it does

The library comes in multiple parts. You can either just use the playingCard.js library, which has no UI rendering (just creates deck objects with the standard methods) or you can add on the playingCards.ui.js library, which adds the ability to render the cards to the page.

Note: This library was really just something that I wanted to build for the sake of proving out that a deck of cards could be implemented in JavaScript and CSS. I had no real-world use-case for it. Since throwing this out on Github, several people have started using this as a foundation for making games. That's awesome--but I haven't been working on this. I welcome pull-requests, but I also am not actively updating this codebase. The code is pretty simple and could probably stand some updating with newer standards (as it is several years old). You might be better off using this as a reference point / proof-of-concept :)

If I were to re-write this for a particular game/use-case, I'd probably change the API a bit. Additionally, I'd add methods for managing hands/players, which is not part of the existing library.

On the flip-side, since you obviously like playing cards, you might be interested in my hand-painted, beetle-themed playing card deck, which I'll be releasing to Kickstarter ~Aug 1, 2015: http://bit.ly/beetledeck

Usage

If you are only using playingCards.js:

var cardDeck = new playingCards(); // will create a new deck object

If you are including jQuery, the playingCards.ui.js and playingCards.ui.css:

$('#cardTable').playingCards(); // will lay out a random deck on the cardTable element

override defaults for playingCards() and for card() by adding new properties to the following objects:

playingCards.defaults

playingCards.card.defaults

Example Implementation

For a rough example of implementation, look at the code for the demo page: https://github.com/atomantic/JavaScript-Playing-Cards/blob/master/index.html

API Docs (simple version)

  • init() - builds the deck (and shuffles it), automatically called when initializing an instance
  • shuffle() - shuffle the deck
  • orderByRank() - orders the existin cards by rank
  • orderBySuit() - calls init() again (TODO: this should probably order the existing cards in the deck by suit, but I was lazy)
  • spread($destinationElement, slowly) - (ui only) lay out the cards in the DOM, optionally with a slow placement
  • count() - return the number of cards remaining in the deck
  • addCard() - return a card from the drawn pile back to the top of the deck
  • draw() - draw a card from the top of the deck (stored in the draw pile)

Demo

The repository holds a demo in index.html, which is published on the github project page: Demo

javascript-playing-cards's People

Contributors

atomantic avatar leonkunert avatar bitdeli-chef avatar bryant1410 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.