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

📄 nbreaker.h

📁 Microwindows genesis was with the NanoGUI project, and is now the primary distribution for both th
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * NanoBreaker, a Nano-X Breakout clone by Alex Holden. * * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ *  * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. *  * The Original Code is NanoBreaker. *  * The Initial Developer of the Original Code is Alex Holden. * Portions created by Alex Holden are Copyright (C) 2002 * Alex Holden <alex@alexholden.net>. All Rights Reserved. *  * Contributor(s): *  * Alternatively, the contents of this file may be used under the terms * of the GNU General Public license (the  "[GNU] License"), in which case the * provisions of [GNU] License are applicable instead of those * above.  If you wish to allow use of your version of this file only * under the terms of the [GNU] License and not to allow others to use * your version of this file under the MPL, indicate your decision by * deleting  the provisions above and replace  them with the notice and * other provisions required by the [GNU] License.  If you do not delete * the provisions above, a recipient may use your version of this file * under either the MPL or the [GNU] License. *//* nbreaker.h is the main header file, included by all of the other * NanoBreaker source files. */#ifndef NBREAKER_H#define NBREAKER_H/* Define this to include code which dumps (almost) the entire game state when * F10 is pressed. */#define NB_DEBUG/* Define this to make it possible to activate the power-ups and power-downs * at any time by pressing F3-F8. */#define DEBUG_POWERS/* Define this to explicitly destroy every Nano-X resource and free every piece * of malloc()ed memory on exit (technically not necessary, but it can be * useful with a debugging malloc for tracking down memory leaks). */#define THOROUGH_CLEANUP/* The default game directory: */#define DEFAULT_GAME_DIR "/usr/share/nbreaker"/* The default name of the game file: */#define DEFAULT_GAME_FILE "default.nbk"/* Whether to tile backgrounds by default: */#define DEFAULT_BACKGROUND_TILED 1/* The default number of points when a normal brick is destroyed: */#define DEFAULT_NORMALPOINTS 1/* The default number of points when a small bonus brick is destroyed: */#define DEFAULT_SMALLBONUSPOINTS 5/* The default number of points when a medium bonus brick is destroyed: */#define DEFAULT_MEDIUMBONUSPOINTS 25/* The default number of points when a large bonus brick is destroyed: */#define DEFAULT_LARGEBONUSPOINTS 150/* The default number of points when a huge bonus brick is destroyed: */#define DEFAULT_HUGEBONUSPOINTS 1000/* The default number of points gained when a power-up is caught: */#define DEFAULT_POWERUPPOINTS 20/* The default number of points lost when a power-down is caught: */#define DEFAULT_POWERDOWNPOINTS -10/* The default number of balls given at the start of the game: */#define DEFAULT_STARTBALLS 5/* The default number of extra balls given when a level is completed: */#define DEFAULT_NEWLEVELBALLS 2/* The default width of the bricks: */#define DEFAULT_BRICK_WIDTH 40/* The default height of the bricks: */#define DEFAULT_BRICK_HEIGHT 20/* The default height of the bat: */#define DEFAULT_BAT_HEIGHT 25/* The default width of the normal width bat: */#define DEFAULT_NORMALBAT_WIDTH 60/* The default width of the small width bat: */#define DEFAULT_SMALLBAT_WIDTH 40/* The default width of the large width bat: */#define DEFAULT_LARGEBAT_WIDTH 80/* The default number of seconds that power-ups last for: */#define DEFAULT_POWERUP_TIME 30/* The default number of seconds that power-downs last for: */#define DEFAULT_POWERDOWN_TIME 20/* The default width of the brick area: */#define DEFAULT_WIDTH 15/* The default height of the brick area: */#define DEFAULT_HEIGHT 15/* The default width of power-up and power-down boxes: */#define DEFAULT_POWER_WIDTH 80/* The default height of power-up and power-down boxes: */#define DEFAULT_POWER_HEIGHT 35/* The default width and height of the ball graphic: */#define DEFAULT_BALL_SIZE 20/* The default bat velocity when it is moved with the cursors: */#define DEFAULT_BAT_VELOCITY 10/* The default period (in ms) between animation frames: */#define DEFAULT_ANIMATE_PERIOD 20/* The default slow ball velocity: */#define DEFAULT_SLOW_BALL_VELOCITY 4/* The default normal ball velocity: */#define DEFAULT_NORMAL_BALL_VELOCITY 8/* The default fast ball velocity: */#define DEFAULT_FAST_BALL_VELOCITY 12/* The default power box velocity: */#define DEFAULT_POWER_VELOCITY 10/* The rate to fade new screens in at: */#define DEFAULT_FADERATE 10/* The name of the file (in the game directory) to store the high score in: */#define HISCORE_FILE "hiscore"/* The font to use for the score text: */#define SCORE_FONT GR_FONT_SYSTEM_VAR/* The foreground colour to use when drawing the score text: */#define SCORE_FGCOLOUR GR_COLOR_WHITE/* The background colour to use when drawing the score text: */#define SCORE_BGCOLOUR GR_COLOR_BLACK/* The grey shade to use as the alpha level for the score text background: */#define SCORE_ALPHACOLOUR GR_COLOR_GREY40/* The space in pixels to leave around the score text: */#define SCORE_BORDER 4/* The space in pixels to leave around the balls row under the score text: */#define BALLS_BORDER 4/* The maximum allowable length of a cheat sequence: */#define MAXCHEATLEN 16/* -------------- No user configurable parameters below here. --------------- *//* The number of different bat sizes: */#define NUMBATS 3/* The number of different power types: */#define NUMPOWERS 6/* The number of different cheats: */#define NUMCHEATS 5/* Used to represent the new ball coordinates when it is moved in animate(). */typedef struct {	double x;	double y;} coords;/* A sprite structure (manipulated by the routines in sprite.c): */struct _sprite {	/* The name of the file this sprite was loaded from, or NULL if it was	 * drawn manually: */	char *fname;	/* The width and height of the sprite: */	int w;	int h;	/* The IDs of the pixmap and alpha channels containing this sprites	 * image data: */	GR_PIXMAP_ID p;	GR_ALPHA_ID a;	/* The number of times this sprite has been loaded (a reference count	 * used to decide when nobody is using it any more so that it can	 * really be destroyed): */	int usage;	/* Each sprite is doubly linked into the list of sprites (arguably a	 * singly linked list might make more sense since they aren't often	 * destroyed): */	struct _sprite *next;	struct _sprite *prev;};typedef struct _sprite sprite;/* A brick structure. Each brick described by a "Brick" line in the game file * is stored as one of these: */struct _brick {	/* The sprite containing the image data for this brick: */	sprite *s;	/* This bricks identifier (the letter used to represent it in the	 * game file): */	char identifier;	/* The flags associated with this brick (immutable, bonuses, etc.): */	int flags;	/* The bricks are stored in a list so they can be destroyed when	 * switching levels: */	struct _brick *next;};typedef struct _brick brick;/* A grid entry. The brick area in each level is stored as an array of * state->width * state->height grid structures, and so is the current brick * area when the game is being played: */typedef struct {	/* The brick located at this position or NULL if it is empty. */	brick *b;	/* The window coordinates of this brick. It is precalculated and stored	 * in the grid to save CPU time when doing the collision detection: */	int x;	int y;	/* The number of times this brick has been hit (used by the current	 * game grid to determine how many times a brick which needs multiple	 * hits to destroy has been hit): */	int hits;	/* The ID of the power-up or power-down hidden behind this brick	 * (released when the brick is destroyed), or 0 if there isn't one: */	int power;} grid;/* A level. This structure contains all the information used to describe a * game level: */struct _level {	/* The list of bricks specific to this level: */	brick *bricks;	/* The name of the file to use as the background image: */	char *backgroundname;	/* Whether the background image file should be tiled: */	int backgroundtiled;	/* The number of non-immutable bricks in this level (used to determine	 * when all the bricks have been destroyed and we can move on to the	 * next level): */	int numbricks;	/* The grid that describes the brick area: */	grid *grid;	/* The levels are stored in a singly linked list: */	struct _level *next;};typedef struct _level level;/* A power-up or power-down. This represents one of those floating boxes that * appear when you destroy a brick with a power behind it, and you have to * catch in order to activate it: */struct _power {	/* The type of power (WideBat, PowerBall, FastMotion, etc.): */	int type;	/* The current coordinates of the power box: */	int x;	int y;	/* The current powers are stored in a singly linked list: */	struct _power *next;};typedef struct _power power;/* Various information associated with the scores bar: */typedef struct {	/* The current score: */	int s;	/* The high score: */	int hi;	/* The high score in the high score file (used to determine whether	 * we need to write the current high score out or not): */	int fhi;	/* The pixmap used to draw the score text onto before blending it onto	 * the canvas: */	GR_PIXMAP_ID p;	/* The alpha channel used when blending the score text onto the	 * canvas: */	GR_ALPHA_ID a;	/* The height of the score area (depends on the height of the font and	 * the border, but the width is always the full canvas width): */	int h;} scores_t;/* Various information associated with the ball: */typedef struct {	/* The current coordinates. They are stored as doubles to make sure we	 * get smooth straight movement. */	double x;	double y;	/* The current ball direction in radians (0 == north, PI / 2 == east,	 * PI == south, * PI * 1.5 == west): */	double d;	/* The current velocity of the ball: */	int v;	/* The coordinates of the last ball position (used when determining	 * the area that needs to be redrawn when the ball is moved): */	int lx;	int ly;	/* Whether the ball is parked (ie. stuck to the bat and not moving): */	int parked;	/* The sprite containing the ball image: */	sprite *s;	/* The SlowMotion velocity: */	int sv;	/* The normal velocity: */	int nv;	/* The FastMotion velocity: */	int fv;} ball_t;/* Various boolean flags: */typedef struct {	/* Whether the SolidFloor cheat is active: */	unsigned int sf : 1;	/* Whether the NoBounce cheat is active: */	unsigned int nb : 1;	/* Whether the NoPowerDown cheat is active: */	unsigned int npd : 1;	/* Whether the NoPowerUpTimeOut cheat is active: */	unsigned int nputo : 1;	/* Whether the game is paused: */	unsigned int paused : 1;	/* Whether the left cursor is currently pressed: */	unsigned int left : 1;	/* Whether the right cursor is currently pressed: */	unsigned int right : 1;} flags_t;/* The timers which are used to count (in seconds) how long is left until each * of the power-ups and power-downs deactivate (0 means currently inactive): */typedef struct {	int widebat;	int slowmotion;	int stickybat;	int powerball;	int narrowbat;	int fastmotion;

⌨️ 快捷键说明

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