เกมจับคู่
#include<stdio.h>
#include<conio.h>
package {
  import flash.display.*;
  import flash.events.*;
  public class MatchingGame4 extends MovieClip {
    // game constants
    private static const boardWidth:uint = 8;    // จำำนวนขนำดของภำพ
จับผิด
   private static const boardHeight:uint = 6;          // จำำนวนขนำดของภำพ
จับผิด
    private static const cardHorizontalSpacing:Number = 52;
    private static const cardVerticalSpacing:Number = 52;
    private static const boardOffsetX:Number = 120;
    private static const boardOffsetY:Number = 45;
      public function MatchingGame4():void {
      // make a list of card numbers
      var cardlist:Array = new Array();
      for(var i:uint=0;i<boardWidth*boardHeight/2;i++) {
         cardlist.push(i);
         cardlist.push(i);
      }
        // create all the cards, position them, and assign a randomcard face to each
      for(var x:uint=0;x<boardWidth;x++) { // horizontal
         for(var y:uint=0;y<boardHeight;y++) { // vertical
           var c:Card = new Card(); // copy the movie clip
           c.stop(); // stop on first frame
           c.x = x*cardHorizontalSpacing+boardOffsetX;
           c.y = y*cardVerticalSpacing+boardOffsetY;
           var r:uint = Math.floor(Math.random()*cardlist.length); // get a random face
           c.cardface = cardlist[r]; // assign face to card
           cardlist.splice(r,1); // remove face from list
           c.gotoAndStop(c.cardface+2)
           c.addEventListener(MouseEvent.CLICK,clickCard); // have it listen for
clicks
           addChild(c); // show the card

   // player clicked on a card
   public function clickCard(event:MouseEvent) {
      var thisCard:Card = (event.currentTarget as Card); // what card?
      trace(thisCard.cardface);
   }
                                             นำงสำว กนิษฐำ เนตรสว่ำง เลข
ที่29 ม 6/3

เกมจับคู่1

  • 1.
    เกมจับคู่ #include<stdio.h> #include<conio.h> package { import flash.display.*; import flash.events.*; public class MatchingGame4 extends MovieClip { // game constants private static const boardWidth:uint = 8; // จำำนวนขนำดของภำพ จับผิด private static const boardHeight:uint = 6; // จำำนวนขนำดของภำพ จับผิด private static const cardHorizontalSpacing:Number = 52; private static const cardVerticalSpacing:Number = 52; private static const boardOffsetX:Number = 120; private static const boardOffsetY:Number = 45; public function MatchingGame4():void { // make a list of card numbers var cardlist:Array = new Array(); for(var i:uint=0;i<boardWidth*boardHeight/2;i++) { cardlist.push(i); cardlist.push(i); } // create all the cards, position them, and assign a randomcard face to each for(var x:uint=0;x<boardWidth;x++) { // horizontal for(var y:uint=0;y<boardHeight;y++) { // vertical var c:Card = new Card(); // copy the movie clip c.stop(); // stop on first frame c.x = x*cardHorizontalSpacing+boardOffsetX; c.y = y*cardVerticalSpacing+boardOffsetY; var r:uint = Math.floor(Math.random()*cardlist.length); // get a random face c.cardface = cardlist[r]; // assign face to card cardlist.splice(r,1); // remove face from list c.gotoAndStop(c.cardface+2) c.addEventListener(MouseEvent.CLICK,clickCard); // have it listen for clicks addChild(c); // show the card // player clicked on a card public function clickCard(event:MouseEvent) { var thisCard:Card = (event.currentTarget as Card); // what card? trace(thisCard.cardface); } นำงสำว กนิษฐำ เนตรสว่ำง เลข ที่29 ม 6/3