watch sexy videos at nza-vids!

Blog tải phim sex, hình sex , ảnh sex, truyện sex online trên điện thoại

Mã nguồn C++ game

Code C++ game

Mã nguồn C++ game “CON SNAKE”
img

Game viết trên Visual C++ 2005, phong cách hướng đối tượng, khai thác class Console để quản lý cửa sổ console.

#pragma once
#include "Console.h"
#include 
#include 
using namespace std;

// Xác định kích thước màn hình console
#define WIDTH 80
#define HEIGHT 40
#define RIGHTWIDTH 20 // Kích thước vùng bên phải (ghi điểm, level)

#define SNAKE
CHAR '@'

const int DNORTH = 1;
const int D
EAST  = 2;
const int DSOUTH = 3;
const int D
WEST  = 4;

//Tốc độ khởi đầu (level 1), số mili giây chờ giữa 2 lần di chuyển
#define startSpeed 333

struct POSITION
{
    int X,Y;
};

class Snake
{
    bool playing; // Trạng thái đang chơi hoặc tạm ngưng
    int destroyTime; // Thời gian để hủy thân con rắn (khi đụng tường hoặc cắn thân)
    int snakeLength; // Chiều dài con rắn
    int sleepTime; // Thời gian giữa 2 lần di chuyển
    char B[WIDTH][HEIGHT]; // Toàn bộ màn hình console
    int rTop, rLeft, rRight, rBottom; // Đánh dấu vùng hoạt động của con rắn
    Console con;
    Snake(void);
    queue  snakeBody; //Lưu tọa độ thân con rắn
    POSITION snakeHead; // Đầu con rắn
    int level;
    int upLevel;
    int score;
    POSITION posScore, posLevel, posUpLevel, posPause;
    static Snake
 _instance;
    int moveTo(int direction); // Di chuyển theo hướng
    int eat(int direction);
    int curDirect; //Hướng hiện tại
    void buzz(); // Rung cửa sổ console
    void prepareGame(); // Chuẩn bị game
    void newGame();
    void printScore(); // In điểm
    void printLevel(); // In level
    bool playGame();
    void randMouse(); // phát sinh mồi (chuột) ngẫu nhiên trên màn hình
    void destroySnake(); // Hủy con rắn
    void printUpLevel(); // In số mồi cần phải ăn để lên cấp
    void levelUp();
    void endGame();
    void pauseGame();
    void unpauseGame();

public:
    void run();
    static Snake* getInstance();
    ~Snake(void);
};


Tải về ngay :
http://upvn.mobi/?id=17695
http://upwap.ru/2113146
http://izing.us/76283
http://mup5.com/51213

Trở lại
Nhận xét bài viết

Bình luận