⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 np_core.h

📁 需要clanlib 库 这个改进版的 在linux 很好玩 但是一定要有clanlib
💻 H
字号:
#ifndef NP_CORE_H#define NP_CORE_H// Include necessary CL header files#include <ClanLib/display.h>#include <ClanLib/core.h>#include <ClanLib/sound.h>#include <string>using namespace std;enum NP_unit_face {blank, cow, chicken, frog, panda, monkey, bad};const string NP_unit_face_string[] = {"blank", "cow", "chicken", "frog", "panda", "monkey", "bad"};enum NP_unit_state {normal, dying, dropping, dead};const int UNIT_HEIGHT = 48;const int UNIT_WIDTH = 48;const int BOARD_HEIGHT = 12;const int BOARD_WIDTH = 6;class NP_board;class NP_unit {    public:        NP_unit();        NP_unit(CL_ResourceManager *resources, NP_unit_face _face, int _x, int _y);        ~NP_unit();        NP_unit_face get_face();        NP_unit_state get_state();        void set_state(NP_unit_state _state);        int get_x();        int get_y();        bool can_move(NP_board &b, int dx, int dy);        bool move(NP_board &b, int dx, int dy);        bool drop(NP_board &b);        bool move_to(NP_board &b, int _x, int _y);        void stick_to(NP_board &b);        void update(NP_board &b);        void draw(NP_board &b);        void draw(int x, int y);    private:        NP_unit_face face;        NP_unit_state state;        int x, y;        int real_x, real_y;        int dest_x, dest_y;        CL_Sprite sprite_normal;        CL_Sprite sprite_dying;        CL_Sprite sprite;        CL_SoundBuffer sample_dying;};class NP_block {    public:        NP_block();        NP_block(CL_ResourceManager *resources, int style, NP_unit_face face[2], int _x, int _y);        ~NP_block();        void enable();        void disable();        void rotate(NP_board &b);        bool can_move(NP_board &b, int dx, int dy);        bool move(NP_board &b, int dx, int dy);        void stick_to(NP_board &b);        void update(NP_board &b);        void draw(NP_board &b);        void draw(int x, int y);    private:        NP_unit unit[2];        int style;        int x, y;        bool enabled;};enum NP_board_state {waiting, adding_bad_units, start, falling, adjusting, eliminating, game_over};class NP_board {    public:        friend class NP_block;        friend class NP_unit;        NP_board();        NP_board(CL_ResourceManager *_resources, //pointer to the resources                int _base_x, //upper left corner of the board                int _base_y, //upper left corner of the board                int _next_x, //upper left corner of next block                int _next_y, //upper left corner of next block                int _speed, //game speed                int _num_bad_units, //bad units                int _seed //random number seed                );        ~NP_board();        void reset_game(int _seed);        void start_game();        int get_speed();        void set_speed(int speed);        void block_rotate();        void block_move_down();        void block_move_left();        void block_move_right();        void add_bad_units(int num);        void update();        void draw();        //signals        CL_Signal_v1 <int> sig_get_score;        CL_Signal_v1 <int> sig_send_bad_units;        CL_Signal_v0 sig_game_over;    private:        CL_ResourceManager *resources;        int last_rand;        int base_x, base_y;        int next_x, next_y;        int num_bad_units;        int combo;        int cnt_eliminated;        NP_unit_face board[BOARD_HEIGHT][BOARD_WIDTH];        NP_unit unit_board[BOARD_HEIGHT][BOARD_WIDTH];        NP_block block;        NP_block next_block;        NP_board_state state;        NP_board_state next_state;        bool block_active;        NP_unit_face next_face[2];        int speed;        CL_Slot slot_timer;        CL_Timer timer;        CL_SoundBuffer sample_combo[5];        int myrand();        int to_bad_units(int x);        int to_score(int x);        void adjust();        void eliminate();        void on_timer();        NP_board_state get_state();        void new_block(NP_unit_face face[2]);        void add_bad_units_actual();};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -