亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ball.c

?? Microwindows genesis was with the NanoGUI project, and is now the primary distribution for both th
?? C
字號:
/* * 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. *//* ball.c contains functions related to the ball. */#include <math.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <nano-X.h>#include <nxcolors.h>#include "nbreaker.h"/* Called whenever a ball is lost, either by it falling off the bottom of the * screen, or the player pressing the "suicide key". */void lost_ball(nbstate *state){	/* Decrement the balls count and if there are none left: */	if(!state->numballs--) {		/* Go to the "game lost" state and update the high score if		 * appropriate: */		state->state = STATE_GAMELOST;		/* Update the high score and save it if necessary: */		save_hiscore(state);		/* This could probably be done better by just drawing the		 * splash- set_level_active() redraws the entire game area: */		set_level_active(state);		return;	}	/* Erase the balls line at the top of the screen: */	draw_background(state, 0, state->scores.h, state->canvaswidth,			state->ball.s->h + (BALLS_BORDER * 2));	/* Draw the balls again, but with one less than there was before: */	draw_balls(state);	/* Copy the balls row to the output window: */	draw_canvas(state, 0, state->scores.h, state->canvaswidth,				state->ball.s->h + (BALLS_BORDER * 2));	/* Park the new ball and erase the old one: */	park_ball(state);	move_ball(state);	/* Redraw the bat. This is a bit of a hack because sometimes when the	 * ball falls below the top of the bat on its way to the bottom of the	 * screen it can clip the bat and erase a bit of it. This redraws the	 * bat to hide that: */	draw_bat(state);	/* Copy the redrawn bat to the output window: */	draw_canvas(state, state->batx - (state->batwidths[state->bat] / 2),			state->canvasheight - state->batheight,			state->batwidths[state->bat], state->batheight);}/* Park the ball. This means make it sit on the middle of the bat and stay * there until a mouse button is clicked or the space bar pressed. */void park_ball(nbstate *state){	state->ball.parked = 1; /* Set the parked flag. */	/* Set the ball position: */	state->ball.x = state->batx - (state->ball.s->w / 2);	state->ball.y = state->canvasheight -					state->batheight - state->ball.s->h;	/* Set the ball direction to "straight up": */	state->ball.d = 0;}/* Given the current ball position and the direction and velocity of movement, * calculate the next ball position and put it in the passed coords * structure. This uses floating point math for accuracy and convenience, but * it could probably be converted to fixed point math without too much * difficulty. */void calc_new_ball_coords(nbstate *state, coords *c){	c->x = state->ball.x + sin(state->ball.d) * state->ball.v;	c->y = state->ball.y - cos(state->ball.d) * state->ball.v;}/* If the specified angle (in radians) has strayed outside the range 0 to * 2 * PI, add 2 * PI to or subtract 2 * PI from it to get it back into the * correct range. */static double normalise_angle(double d){	if(d < 0) return d + (2 * M_PI);	else if(d > (2 * M_PI)) d -= (2 * M_PI);	return d;}/* Check if the ball will collide with something if it is moved to the * specified coordinates. If so, the direction is changed and 1 is returned * to indicate that the caller should recalculate the new coordinates and * try again. If there was no collision it returns 0. If something exceptional * happens (eg. the last brick is destroyed or the last ball is lost) it * returns 2 to indicate that the caller should give up trying to move the * ball. */int check_ball_collision(nbstate *state, coords *c){	int i, bc;	grid *g = state->grid;	/* Check for a collision with the top of the game area: */	if(c->y < state->ball.s->h + (2 * BALLS_BORDER) + state->scores.h) {		/* Bounce the ball back down and ask the caller to try again: */		state->ball.d = normalise_angle(M_PI - state->ball.d);		return 1;	}	/* Check for a collision with the bottom of the game area: */	if(c->y > state->canvasheight - state->ball.s->h) {		/* If the solidfloor cheat is active, bounce the ball back up		 * and ask the caller to try again: */		if(state->flags.sf) {			state->ball.d = normalise_angle(M_PI - state->ball.d);			return 1;		} else {			/* Otherwise destroy the ball, move the new ball to			 * the parked position (park_ball() is called by			 * lost_ball()) and ask the caller to give up trying			 * to move the ball: */			lost_ball(state);			move_ball(state);			return 2;		}	}	/* Check for a collision with the left hand side of the game area: */	if(c->x < 0) {		/* Bounce the ball back and ask the caller to try again: */		state->ball.d = normalise_angle((2 * M_PI) - state->ball.d);		return 1;	}	/* Check for a collision with the right hand side of the game area: */	if(c->x > state->canvaswidth - state->ball.s->w) {		/* Bounce the ball back and ask the caller to try again: */		state->ball.d = normalise_angle((2 * M_PI) - state->ball.d);		return 1;	}	/* Check for a collision with the bat: */	if(c->y > state->canvasheight - state->batheight - state->ball.s->h &&			c->x > state->batx -			(state->batwidths[state->bat] / 2) - state->ball.s->w &&			c->x < state->batx +			(state->batwidths[state->bat] / 2)) {		/* If the collision happened with the side of the bat instead		 * of the top, we don't care so just tell the caller there		 * was no collision: */		if(state->ball.y > state->canvasheight - state->batheight -				state->ball.s->h)			return 0;		/* If the StickyBat power-up is active, park the ball: */		if(state->powertimes.stickybat) {			park_ball(state);			move_ball(state);			return 2;		} else {			/* Otherwise bounce it back up and ask the caller to			 * try again: */			state->ball.d = normalise_angle(((c->x +						(state->ball.s->w / 2)						- state->batx) /						state->batwidths[state->bat] /						2) * M_PI);			return 1;		}	}	/* Check for collisions with the bricks: */	bc = 0; /* No collisions have happened yet. */	/* For each brick in the grid: */	for(i = 0; i < state->width * state->height; i++) {		/* If there is a brick in this grid position and the ball		 * intersects it:  */		if(g->b && c->y + state->ball.s->h > g->y && c->y < g->y +				state->brickheight && c->x + state->ball.s->w				> g->x && c->x < g->x + state->brickwidth) {			/* Perform the brick collision actions, and if			 * something exceptional happens (ie. we destroy the			 * last brick), return straight away asking the caller			 * to give up trying to move the ball: */			if(brick_collision(state, g)) return 2;			/* Unless the NoBounce cheat is active, bounce the			 * ball off the brick. Only do this on the first brick			 * collision we find. */			if(!state->flags.nb && !bc) {				bc = 1;				/* Bounce off the left face: */				if(state->ball.x + state->ball.s->w < g->x) {					state->ball.d = normalise_angle((2 *							M_PI) - state->ball.d);				/* Bounce off the right face: */				} else if(state->ball.x >= g->x +						state->brickwidth) {					state->ball.d = normalise_angle((2 *							M_PI) - state->ball.d);				/* Bounce off the upper face: */				} else if(state->ball.y + state->ball.s->h								< g->y) {					state->ball.d = normalise_angle(M_PI -								state->ball.d);				/* Bounce off the lower face: */				} else if(state->ball.y >= g->y +							state->brickheight) {					state->ball.d = normalise_angle(M_PI -								state->ball.d);				} else {					/* This shouldn't happen, but I don't					 * trust the above algorithm 100%. */					fprintf(stderr, "Internal error: "						"couldn't figure out brick "						"collision face\n");				}			}		}		g++; /* Increment to the next grid position. */	}	/* If a brick collision occured, ask the caller to try again: */	if(bc) return 1;	return 0; /* Otherwise tell the caller that no collision occured. */}/* Move the ball to from the position specified by state->ball.lx and * state->ball.ly to state->ball.x and state->ball.y, and update the relevant * area of the output window. */void move_ball(nbstate *state){	int x, w, y, h;	/* Check that the ball really has moved: */	if(state->ball.lx == state->ball.x && state->ball.ly == state->ball.y)		return;	/* Calculate the position and dimensions of the rectangle which	 * encloses both the old ball and the new ball so we know what area	 * to copy to the output window later. FIXME: this is quite inefficient	 * when doing stuff like parking the ball, where the old ball position	 * could be at the other side of the screen to the place we want to	 * move it to. It is however OK in the common case of only moving the	 * ball a few pixels at a time. */	if(state->ball.x < state->ball.lx) {		x = (int)state->ball.x;		w = state->ball.lx - x + state->ball.s->w;	} else {		x = state->ball.lx;		w = (int)state->ball.x - x + state->ball.s->w;	}	if(state->ball.y < state->ball.ly) {		y = (int)state->ball.y;		h = state->ball.ly - y + state->ball.s->h;	} else {		y = state->ball.ly;		h = (int)state->ball.y - y + state->ball.s->h;	}	/* Draw the background where the old ball image is to erase it: */	draw_background(state, state->ball.lx, state->ball.ly,			state->ball.s->w, state->ball.s->h);	/* Redraw any powers that are under that position: */	redraw_powers(state, state->ball.lx, state->ball.ly, state->ball.s->w,							state->ball.s->h);	/* Draw the ball in the new position and update ball.lx and ball.ly: */	draw_ball(state);	/* Draw the modified area of the canvas to the output window: */	draw_canvas(state, x, y, w, h);}/* Redraw the ball in its current position, including copying it to the output * window. */void redraw_ball(nbstate *state){	/* Erase the ball area to the background: */	draw_background(state, (int)state->ball.x, (int)state->ball.y,			state->ball.s->w, state->ball.s->h);	/* Redraw any powers we may have erased: */	redraw_powers(state, (int)state->ball.x, (int)state->ball.y,			state->ball.s->w, state->ball.s->h);	/* Redraw the ball: */	draw_ball(state);	/* Copy it to the output window: */	draw_canvas(state, state->ball.lx, state->ball.ly, state->ball.s->w,			state->ball.s->h);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区国产| 日韩欧美精品在线视频| 日韩国产精品久久久久久亚洲| 精品少妇一区二区三区日产乱码| av电影天堂一区二区在线观看| 日韩福利电影在线| 亚洲老妇xxxxxx| 国产欧美va欧美不卡在线| 欧美日韩国产综合草草| 99久久精品免费| 极品少妇xxxx精品少妇偷拍| 亚洲国产人成综合网站| 亚洲人成网站影音先锋播放| 久久亚洲精精品中文字幕早川悠里 | 国产视频一区在线播放| 91精品国产欧美日韩| 色综合网站在线| 成人自拍视频在线| 国产精品一二三| 国产原创一区二区| 毛片av一区二区三区| 婷婷六月综合亚洲| 亚洲一本大道在线| 亚洲精品v日韩精品| 中文字幕欧美国产| 久久久久久夜精品精品免费| 欧美成人一区二区| 欧美一级理论性理论a| 欧美另类变人与禽xxxxx| 色综合久久久久久久久久久| 99在线精品一区二区三区| 国产成人亚洲精品青草天美| 国产美女在线观看一区| 久久99精品国产麻豆婷婷| 免费高清视频精品| 另类小说欧美激情| 国产在线看一区| 国产一区二区三区免费播放| 国产精品亚洲第一| 国产成人aaaa| 成人av网址在线观看| 99在线精品观看| 99久久精品一区二区| 色综合视频一区二区三区高清| 波多野结衣视频一区| 99精品视频一区二区| 91蜜桃视频在线| 欧美在线|欧美| 69精品人人人人| 欧美不卡视频一区| www久久久久| 中文字幕精品—区二区四季| 国产精品萝li| 一区二区三区在线观看国产| 日韩成人伦理电影在线观看| 裸体歌舞表演一区二区| 国产精选一区二区三区| 成人h动漫精品一区二区| 色综合久久88色综合天天6 | 韩国av一区二区三区四区 | 国产精品综合av一区二区国产馆| 国产一区91精品张津瑜| 成人精品鲁一区一区二区| 99久久婷婷国产综合精品 | 欧美日韩日日夜夜| 日韩精品资源二区在线| 亚洲国产成人午夜在线一区| 亚洲精选在线视频| 婷婷激情综合网| 国产高清久久久| 一本一道波多野结衣一区二区| 欧美影视一区在线| 欧美成人a视频| 成人欧美一区二区三区白人| 亚洲电影视频在线| 国内成+人亚洲+欧美+综合在线| 成人18视频在线播放| 欧美人牲a欧美精品| 国产午夜亚洲精品午夜鲁丝片| 亚洲影视在线播放| 国精产品一区一区三区mba桃花 | 国产一区二区不卡老阿姨| 99久久久无码国产精品| 日韩一区二区免费在线电影| 国产精品视频看| 午夜免费欧美电影| 国产91高潮流白浆在线麻豆| 欧美日韩另类一区| 日本一区二区动态图| 天堂影院一区二区| 成a人片国产精品| 91精品国产91久久久久久最新毛片 | 欧美一区二区视频在线观看| 中文一区二区完整视频在线观看| 亚洲3atv精品一区二区三区| 丰满岳乱妇一区二区三区| 欧美日本国产视频| 亚洲欧洲日产国产综合网| 韩国v欧美v亚洲v日本v| 欧美日韩免费一区二区三区 | 亚洲黄色性网站| 国产成人亚洲综合a∨婷婷图片| 欧美日韩国产片| 日韩一区欧美一区| 国产成人丝袜美腿| 日韩一区二区三区精品视频| 亚洲国产美女搞黄色| k8久久久一区二区三区| 久久女同精品一区二区| 日本v片在线高清不卡在线观看| 91丨porny丨首页| 国产色一区二区| 国产在线精品一区二区夜色 | 免费久久99精品国产| 欧美在线免费播放| 亚洲欧美视频一区| 99天天综合性| 国产精品三级电影| 国产成人综合在线| 欧美精品一区二区三区高清aⅴ | 国产精品免费免费| 国产精品综合二区| 久久综合久久综合久久综合| 久久99蜜桃精品| 日韩欧美美女一区二区三区| 日韩精品一级中文字幕精品视频免费观看| 亚洲欧洲av一区二区三区久久| 久久国产精品72免费观看| 欧美亚洲国产一区在线观看网站| 国产精品美女一区二区三区| 国产aⅴ精品一区二区三区色成熟| 欧美α欧美αv大片| 精品一区二区在线播放| 精品少妇一区二区三区| 激情六月婷婷综合| 精品区一区二区| 国模一区二区三区白浆| 久久久国产综合精品女国产盗摄| 国产精品一区在线观看乱码| 久久美女艺术照精彩视频福利播放| 黑人巨大精品欧美一区| 久久久久久免费网| 国产成人99久久亚洲综合精品| 国产精品素人一区二区| 成人精品小蝌蚪| 亚洲人妖av一区二区| 在线观看亚洲精品| 午夜精品久久久久久久久| 91精品国产91久久久久久一区二区| 男女男精品网站| 精品国产精品网麻豆系列| 国产一区二区导航在线播放| 国产精品久久一级| 一本到不卡精品视频在线观看| 亚洲中国最大av网站| 欧美一区二区精美| 国产精品77777| 日韩理论在线观看| 欧美日本一区二区三区| 卡一卡二国产精品| 久久精品人人做人人爽人人| 97久久人人超碰| 亚瑟在线精品视频| 精品福利一二区| 9l国产精品久久久久麻豆| 亚洲午夜电影在线观看| 精品日韩欧美一区二区| 成人毛片在线观看| 亚洲国产一二三| 久久综合av免费| 91免费在线看| 免费美女久久99| 国产精品久久久久桃色tv| 欧美日韩在线一区二区| 狠狠网亚洲精品| 亚洲女与黑人做爰| 日韩三级视频在线观看| 成人中文字幕合集| 天天综合色天天综合色h| 国产欧美日本一区二区三区| 欧美日韩一区二区三区在线看| 精品一区二区三区视频| 亚洲色图欧洲色图婷婷| 日韩午夜激情av| 99久久99久久精品国产片果冻| 午夜精品久久久久久久99水蜜桃 | 日韩**一区毛片| 国产精品久久久久久久久动漫 | 色综合久久久久综合体桃花网| 免费在线看成人av| 18涩涩午夜精品.www| 制服丝袜亚洲色图| 99久久久免费精品国产一区二区| 麻豆一区二区三区| 亚洲日本va午夜在线电影| 久久久久国产免费免费| 欧美精品aⅴ在线视频| 成人app在线| 国产在线麻豆精品观看| 天天色综合天天|