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

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

?? ball.c

?? 一個嵌入式操作系統(microwindows)的源代碼
?? 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一区二区三区免费野_久草精品视频
亚洲欧美在线观看| 欧美午夜视频网站| 国产亚洲女人久久久久毛片| 国产精品正在播放| 欧美国产激情二区三区 | 欧美妇女性影城| 亚洲成人先锋电影| 日韩亚洲欧美高清| 国产一区二区三区免费在线观看| 国产亚洲福利社区一区| 99riav一区二区三区| 亚洲综合视频网| 欧美videofree性高清杂交| 国产在线视视频有精品| 中文字幕色av一区二区三区| 欧美午夜精品电影| 久久99蜜桃精品| 中文一区二区在线观看| 欧美在线视频全部完| 蜜桃视频第一区免费观看| 中文字幕乱码亚洲精品一区| 欧美视频一二三区| 国产一区二区三区久久悠悠色av| 亚洲欧美日韩国产一区二区三区| 91精品免费在线观看| 国产成人av网站| 亚洲综合成人在线| 亚洲精品一区二区三区在线观看| 99麻豆久久久国产精品免费优播| 日日摸夜夜添夜夜添精品视频 | 国产欧美一区二区精品久导航| av福利精品导航| 日韩黄色片在线观看| 国产精品午夜电影| 91精品国产综合久久精品麻豆| 国产在线精品国自产拍免费| 一级精品视频在线观看宜春院| 日韩天堂在线观看| 色综合久久久久综合体桃花网| 奇米888四色在线精品| 亚洲激情中文1区| 国产欧美精品一区二区色综合 | 国产凹凸在线观看一区二区| 午夜精品免费在线| 自拍偷在线精品自拍偷无码专区| 欧美电视剧在线观看完整版| 在线免费不卡电影| 成人性视频网站| 国产一区二区三区四区五区美女 | 国产精品自拍在线| 五月激情六月综合| 亚洲欧美日韩在线不卡| 国产性天天综合网| 精品成人一区二区三区| 欧美一区二区三区在线观看| 在线免费观看日本一区| 成人av免费在线| 国产伦精品一区二区三区免费| 亚洲最新视频在线播放| 国产欧美日韩不卡| 久久午夜色播影院免费高清| 欧美一级午夜免费电影| 337p亚洲精品色噜噜| 欧美三级资源在线| 在线影院国内精品| av福利精品导航| 99久久国产综合色|国产精品| 国产电影一区在线| 国产一区 二区| 久久电影网电视剧免费观看| 日本aⅴ亚洲精品中文乱码| 午夜成人免费电影| 日韩 欧美一区二区三区| 午夜一区二区三区视频| 亚洲成人在线观看视频| 亚洲一区二区三区在线| 亚洲18女电影在线观看| 午夜欧美视频在线观看| 日韩在线一区二区三区| 蜜臀av亚洲一区中文字幕| 琪琪一区二区三区| 久久精品国产亚洲高清剧情介绍 | 亚洲综合图片区| 一区二区三区四区亚洲| 亚洲综合精品自拍| 亚洲国产精品久久久男人的天堂| 亚洲成人精品影院| 性做久久久久久免费观看欧美| 亚洲成人高清在线| 美女www一区二区| 国产乱理伦片在线观看夜一区| 国产在线视频一区二区| 成人美女视频在线观看18| 99精品国产热久久91蜜凸| 99精品久久99久久久久| 色爱区综合激月婷婷| 欧美日韩mp4| 久久久久久亚洲综合| 中文字幕在线不卡一区| 亚洲一级在线观看| 久久99精品国产麻豆婷婷| 国产成人鲁色资源国产91色综| av中文字幕亚洲| 777a∨成人精品桃花网| 久久久av毛片精品| 亚洲精品国产第一综合99久久 | 极品少妇xxxx精品少妇偷拍| 国产在线精品免费av| 色哟哟亚洲精品| 91精品国产综合久久精品麻豆| 久久久久久久久久久久久久久99 | 亚洲无线码一区二区三区| 蜜臀久久久久久久| av日韩在线网站| 欧美一级电影网站| 亚洲欧洲韩国日本视频| 日韩av电影免费观看高清完整版 | 亚洲综合久久久| 国内精品国产三级国产a久久| eeuss国产一区二区三区| 7777精品久久久大香线蕉| 国产欧美日韩视频一区二区 | 亚洲欧洲成人自拍| 日韩国产在线一| eeuss国产一区二区三区| 欧美电视剧在线观看完整版| 亚洲色图色小说| 韩国三级中文字幕hd久久精品| 99国产精品久久久久| 欧美精品一区二区三区一线天视频| 亚洲女与黑人做爰| 国产精品综合一区二区三区| 欧美三区在线视频| 亚洲视频小说图片| 国产一区二区伦理片| 欧美男生操女生| 亚洲欧美成人一区二区三区| 国产91露脸合集magnet| 日韩欧美亚洲另类制服综合在线| 夜夜嗨av一区二区三区| av一区二区三区四区| 2023国产精品| 日韩av电影免费观看高清完整版| 一本大道综合伊人精品热热| 国产日韩精品一区二区三区| 美女在线观看视频一区二区| 欧美日韩精品欧美日韩精品一| 亚洲视频每日更新| 成人97人人超碰人人99| 久久久美女毛片| 九九热在线视频观看这里只有精品| 欧美日韩视频一区二区| 亚洲激情av在线| 色综合久久久久网| 国产精品久久久久9999吃药| 国产精品一区二区三区网站| 久久日一线二线三线suv| 免费视频一区二区| 91精品国产美女浴室洗澡无遮挡| 一片黄亚洲嫩模| 欧美撒尿777hd撒尿| 亚洲一区二区三区四区的| 欧美中文字幕亚洲一区二区va在线 | 精品国产免费一区二区三区四区| 亚洲国产精品麻豆| 欧美日韩另类国产亚洲欧美一级| 亚洲一区二三区| 欧美日韩五月天| 日本欧美加勒比视频| 日韩一区二区三区在线| 美女精品一区二区| 久久综合99re88久久爱| 国产一区二区精品久久| 久久精品人人爽人人爽| 夫妻av一区二区| 亚洲视频一区在线观看| 在线精品视频免费播放| 亚洲成av人**亚洲成av**| 欧美日韩另类一区| 裸体一区二区三区| xnxx国产精品| 成人免费看黄yyy456| |精品福利一区二区三区| 在线欧美日韩精品| 青青草原综合久久大伊人精品优势| 日韩美女在线视频 | 99精品热视频| 一区二区三区四区视频精品免费 | 国产精品资源网站| 国产精品国产三级国产a| 91黄色免费版| 日产欧产美韩系列久久99| 久久日韩精品一区二区五区| 99视频精品全部免费在线| 亚洲电影视频在线| 久久免费精品国产久精品久久久久| 成人aaaa免费全部观看| 偷拍亚洲欧洲综合| 国产蜜臀97一区二区三区| 欧美中文字幕亚洲一区二区va在线 |