SlideShare a Scribd company logo
1 of 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

More Related Content

Similar to เกมจับคู่1

There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docxThere are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
AustinIKkNorthy
 
public class Game extends JPanel implements KeyListener{ public in.pdf
public class Game extends JPanel implements KeyListener{     public in.pdfpublic class Game extends JPanel implements KeyListener{     public in.pdf
public class Game extends JPanel implements KeyListener{ public in.pdf
360transfashion
 
Here is the game description- Here is the sample game- Goal- Your goal (1).pdf
Here is the game description- Here is the sample game- Goal- Your goal (1).pdfHere is the game description- Here is the sample game- Goal- Your goal (1).pdf
Here is the game description- Here is the sample game- Goal- Your goal (1).pdf
trishulinoverseas1
 
Here is the game description- Here is the sample game- Here is the req.pdf
Here is the game description- Here is the sample game- Here is the req.pdfHere is the game description- Here is the sample game- Here is the req.pdf
Here is the game description- Here is the sample game- Here is the req.pdf
trishulinoverseas1
 
c++ code#include iostream#include string#include stdlib.h.pdf
c++ code#include iostream#include string#include stdlib.h.pdfc++ code#include iostream#include string#include stdlib.h.pdf
c++ code#include iostream#include string#include stdlib.h.pdf
apexjaipur
 
import javautilLinkedList import javautilQueue import .pdf
import javautilLinkedList import javautilQueue import .pdfimport javautilLinkedList import javautilQueue import .pdf
import javautilLinkedList import javautilQueue import .pdf
ADITIEYEWEAR
 
Goal- Your goal in this assignment is to write a Java program that sim.pdf
Goal- Your goal in this assignment is to write a Java program that sim.pdfGoal- Your goal in this assignment is to write a Java program that sim.pdf
Goal- Your goal in this assignment is to write a Java program that sim.pdf
aaicommunication34
 
Magic Game ClassesMagicAnimalTriviaTrivia.cppMagic Game Classe.docx
Magic Game ClassesMagicAnimalTriviaTrivia.cppMagic Game Classe.docxMagic Game ClassesMagicAnimalTriviaTrivia.cppMagic Game Classe.docx
Magic Game ClassesMagicAnimalTriviaTrivia.cppMagic Game Classe.docx
croysierkathey
 
FaceUp card game In this assignment we will implement a made.pdf
FaceUp card game In this assignment we will implement a made.pdfFaceUp card game In this assignment we will implement a made.pdf
FaceUp card game In this assignment we will implement a made.pdf
abifancystore
 
Answerimport java.util.Random; class DeckMaster { public sta.pdf
Answerimport java.util.Random; class DeckMaster { public sta.pdfAnswerimport java.util.Random; class DeckMaster { public sta.pdf
Answerimport java.util.Random; class DeckMaster { public sta.pdf
ankurbhargava44
 
i have a runable code below that works with just guessing where the .pdf
i have a runable code below that works with just guessing where the .pdfi have a runable code below that works with just guessing where the .pdf
i have a runable code below that works with just guessing where the .pdf
armcomputers
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdf
asif1401
 
blackjackrevised2BlackJack.hBLACKJACK#ifndef _BLACKJA.docx
blackjackrevised2BlackJack.hBLACKJACK#ifndef _BLACKJA.docxblackjackrevised2BlackJack.hBLACKJACK#ifndef _BLACKJA.docx
blackjackrevised2BlackJack.hBLACKJACK#ifndef _BLACKJA.docx
AASTHA76
 
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
PiersRCoThomsonw
 

Similar to เกมจับคู่1 (19)

There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docxThere are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
 
Code em Poker
Code em PokerCode em Poker
Code em Poker
 
AI For Texam Hold'em poker
AI For Texam Hold'em pokerAI For Texam Hold'em poker
AI For Texam Hold'em poker
 
public class Game extends JPanel implements KeyListener{ public in.pdf
public class Game extends JPanel implements KeyListener{     public in.pdfpublic class Game extends JPanel implements KeyListener{     public in.pdf
public class Game extends JPanel implements KeyListener{ public in.pdf
 
Convolution separable by using cuda.docx
Convolution separable by using cuda.docxConvolution separable by using cuda.docx
Convolution separable by using cuda.docx
 
Here is the game description- Here is the sample game- Goal- Your goal (1).pdf
Here is the game description- Here is the sample game- Goal- Your goal (1).pdfHere is the game description- Here is the sample game- Goal- Your goal (1).pdf
Here is the game description- Here is the sample game- Goal- Your goal (1).pdf
 
Here is the game description- Here is the sample game- Here is the req.pdf
Here is the game description- Here is the sample game- Here is the req.pdfHere is the game description- Here is the sample game- Here is the req.pdf
Here is the game description- Here is the sample game- Here is the req.pdf
 
c++ code#include iostream#include string#include stdlib.h.pdf
c++ code#include iostream#include string#include stdlib.h.pdfc++ code#include iostream#include string#include stdlib.h.pdf
c++ code#include iostream#include string#include stdlib.h.pdf
 
TilePUzzle class Anderson, Franceschi public class TilePu.docx
 TilePUzzle class Anderson, Franceschi public class TilePu.docx TilePUzzle class Anderson, Franceschi public class TilePu.docx
TilePUzzle class Anderson, Franceschi public class TilePu.docx
 
import javautilLinkedList import javautilQueue import .pdf
import javautilLinkedList import javautilQueue import .pdfimport javautilLinkedList import javautilQueue import .pdf
import javautilLinkedList import javautilQueue import .pdf
 
Goal- Your goal in this assignment is to write a Java program that sim.pdf
Goal- Your goal in this assignment is to write a Java program that sim.pdfGoal- Your goal in this assignment is to write a Java program that sim.pdf
Goal- Your goal in this assignment is to write a Java program that sim.pdf
 
Magic Game ClassesMagicAnimalTriviaTrivia.cppMagic Game Classe.docx
Magic Game ClassesMagicAnimalTriviaTrivia.cppMagic Game Classe.docxMagic Game ClassesMagicAnimalTriviaTrivia.cppMagic Game Classe.docx
Magic Game ClassesMagicAnimalTriviaTrivia.cppMagic Game Classe.docx
 
FaceUp card game In this assignment we will implement a made.pdf
FaceUp card game In this assignment we will implement a made.pdfFaceUp card game In this assignment we will implement a made.pdf
FaceUp card game In this assignment we will implement a made.pdf
 
Answerimport java.util.Random; class DeckMaster { public sta.pdf
Answerimport java.util.Random; class DeckMaster { public sta.pdfAnswerimport java.util.Random; class DeckMaster { public sta.pdf
Answerimport java.util.Random; class DeckMaster { public sta.pdf
 
i have a runable code below that works with just guessing where the .pdf
i have a runable code below that works with just guessing where the .pdfi have a runable code below that works with just guessing where the .pdf
i have a runable code below that works with just guessing where the .pdf
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdf
 
blackjackrevised2BlackJack.hBLACKJACK#ifndef _BLACKJA.docx
blackjackrevised2BlackJack.hBLACKJACK#ifndef _BLACKJA.docxblackjackrevised2BlackJack.hBLACKJACK#ifndef _BLACKJA.docx
blackjackrevised2BlackJack.hBLACKJACK#ifndef _BLACKJA.docx
 
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
 
Software Visualization - Promises & Perils
Software Visualization - Promises & PerilsSoftware Visualization - Promises & Perils
Software Visualization - Promises & Perils
 

More from JAy YourJust'one

งานย อยท _ 6 ต__งคำถาม java
งานย อยท _ 6 ต__งคำถาม javaงานย อยท _ 6 ต__งคำถาม java
งานย อยท _ 6 ต__งคำถาม java
JAy YourJust'one
 
ซัมซุงนัดต้นปีเปิดตัว
ซัมซุงนัดต้นปีเปิดตัวซัมซุงนัดต้นปีเปิดตัว
ซัมซุงนัดต้นปีเปิดตัว
JAy YourJust'one
 
เกมจับคู่5
เกมจับคู่5เกมจับคู่5
เกมจับคู่5
JAy YourJust'one
 
เกมจับคู่4
เกมจับคู่4เกมจับคู่4
เกมจับคู่4
JAy YourJust'one
 
เกมจับคู่4
เกมจับคู่4เกมจับคู่4
เกมจับคู่4
JAy YourJust'one
 
เกมจับคู่2
เกมจับคู่2เกมจับคู่2
เกมจับคู่2
JAy YourJust'one
 
แต่งกลอนภุชงคประยาตฉัน11
แต่งกลอนภุชงคประยาตฉัน11แต่งกลอนภุชงคประยาตฉัน11
แต่งกลอนภุชงคประยาตฉัน11
JAy YourJust'one
 
ฮาร์ดไดรฟ์ปลอม
ฮาร์ดไดรฟ์ปลอมฮาร์ดไดรฟ์ปลอม
ฮาร์ดไดรฟ์ปลอม
JAy YourJust'one
 
Samsung nc215 โน้ตบุ๊คพลังงานแสงอาทิตย์
Samsung nc215 โน้ตบุ๊คพลังงานแสงอาทิตย์Samsung nc215 โน้ตบุ๊คพลังงานแสงอาทิตย์
Samsung nc215 โน้ตบุ๊คพลังงานแสงอาทิตย์
JAy YourJust'one
 
การค้นหาข่าวสารในแวดวง I
การค้นหาข่าวสารในแวดวง Iการค้นหาข่าวสารในแวดวง I
การค้นหาข่าวสารในแวดวง I
JAy YourJust'one
 

More from JAy YourJust'one (16)

ย อย6
ย อย6ย อย6
ย อย6
 
งานย อยท _ 6 ต__งคำถาม java
งานย อยท _ 6 ต__งคำถาม javaงานย อยท _ 6 ต__งคำถาม java
งานย อยท _ 6 ต__งคำถาม java
 
Java
JavaJava
Java
 
It
ItIt
It
 
ซัมซุงนัดต้นปีเปิดตัว
ซัมซุงนัดต้นปีเปิดตัวซัมซุงนัดต้นปีเปิดตัว
ซัมซุงนัดต้นปีเปิดตัว
 
เกมจับคู่5
เกมจับคู่5เกมจับคู่5
เกมจับคู่5
 
เกมจับคู่4
เกมจับคู่4เกมจับคู่4
เกมจับคู่4
 
เกมจับคู่4
เกมจับคู่4เกมจับคู่4
เกมจับคู่4
 
เกมจับคู่2
เกมจับคู่2เกมจับคู่2
เกมจับคู่2
 
แต่งกลอนภุชงคประยาตฉัน11
แต่งกลอนภุชงคประยาตฉัน11แต่งกลอนภุชงคประยาตฉัน11
แต่งกลอนภุชงคประยาตฉัน11
 
3
33
3
 
2
22
2
 
ฮาร์ดไดรฟ์ปลอม
ฮาร์ดไดรฟ์ปลอมฮาร์ดไดรฟ์ปลอม
ฮาร์ดไดรฟ์ปลอม
 
Samsung nc215 โน้ตบุ๊คพลังงานแสงอาทิตย์
Samsung nc215 โน้ตบุ๊คพลังงานแสงอาทิตย์Samsung nc215 โน้ตบุ๊คพลังงานแสงอาทิตย์
Samsung nc215 โน้ตบุ๊คพลังงานแสงอาทิตย์
 
Fdf
FdfFdf
Fdf
 
การค้นหาข่าวสารในแวดวง I
การค้นหาข่าวสารในแวดวง Iการค้นหาข่าวสารในแวดวง I
การค้นหาข่าวสารในแวดวง I
 

เกมจับคู่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