Dr-match-it

A card matching game by the Pebble BoyZ


Project maintained by oplS15projects Hosted on GitHub Pages — Theme by mattgraham

Authors

Alex Li

Pat Quaratiello

Peter Welby

Overview

Dr. Match-It is a simple card-matching game implemented using the cards and rsound libraries.

Screenshot

screenshot of Dr. Match-It in action

Concepts Demonstrated

External Technology and Libraries

Favorite Lines of Code

Alex Li

This is the match checking procedure called to verify whether two cards are the same. I am particularly proud of this code as it pieces together alot of the code the group has created such as playing sounds, scrambling the cards, and the score system. The procedure makes extensive use of card library calls, as well as begin and set! to handle all matching cases.

(define (m c)
  (cond ((not c1)
         (begin(set! c1 c)
               (send board flip-card c)
               (play-flip-sound c)))
        ((not (send c face-down?))
         (set! c1 c))
        (c1
         (send board flip-card c)
         (if (and (equal? (send c1 get-suit) (send c get-suit))
                  (equal? (send c1 get-value) (send c get-value)))
             (begin (play-flip-sound c)
                    (send board pause .5)
                    (send board remove-cards (list c1 c))
                    (set! MAX (- MAX 1))
                    (set! c1 #f)
                    (if (= MAX 0)
                        (update-final-score (* 10 Multiplier))
                        (update-score (* 10 Multiplier)))
                    (set! Multiplier (+ Multiplier .5)))
             (begin (send board pause .5) (send board flip-cards (list c1 c))
                    (set! c1 #f)
                    (set! Multiplier 1))))
        (else (displayln "Error"))))

Patrick Quaratiello

These 5 lines of code are where the scramble function happens based on the number of failed matches. It is my favorite mostly because it is where everything else in the file is really used, but also because I was able to use begin and set!, two things we just recently were introduced to.

      (define scount 0)
      (define (shuffle-counter)
          (cond((equal? scount SHUFFLE-COUNT)
              (begin (pretty-shuffle deck) (set! scount (- scount scount))))
              (else (set! scount (+ scount 1)))))
         

Peter Welby

This expression uses duty cycle modulation in pulse waves to emulate a string-plucking effect from two appended pulse waves.

(rs-append (make-pulse pitch attack volume 0.5)
          (make-pulse pitch sustain (/ volume 2) 0.25))

How to Download and Run

Demo Day Release Available Here

Run main.rkt in Dr. Racket to start the game. Left-clicking on cards flips them. The game will continue until you successfully match all cards.