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

📄 libfbx-2d.c

📁 libfxb是linux下只写操作framebuffer的一个轻量级的库。
💻 C
字号:
/* *  libfbx-2d.c -- 2D Movement and Animation Functions *  (C)opyright 2000-2001 U4X Labs * *  Written by: Kenneth Mills <ken@u4x.org> *              Tue Dec 12 15:32:09 CST 2000 * *  Updated by: Paul Mundt    <lethal@u4x.org> *              Wed Dec 20 20:43:15 EST 2000 * *              Michael Bourgeous <nitrogen@u4x.org> *              Fri Dec 22 22:53:03 MST 2000 * *  $Id: libfbx-2d.c,v 1.8 2001/01/01 08:46:17 lethal Exp $ * *       libfbx-2d.c has functions to assist programmers in animating *  images and other objects using libfbx. * *  See ChangeLog for modifications, CREDITS for credits. *  			 *  All source herein is copyright U4X Labs and its original author.  *  Any code modifications or additions are (C)opyright the original  *  author and U4X Labs respectively. * *  libfbx is free software; you can redistribute it and/or modify it  *  under the terms of the GNU Lesser General Public License as  *  published by the Free Software Foundation; either version 2.1 of  *  the License, or (at your option) any later version. * *  libfbx is distributed in the hope that it will be useful, but  *  WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  *  GNU Lesser General Public License for more details. * *  You should have received a copy of the GNU Lesser General Public *  License along with libfbx; if not, write to the Free Software  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *  USA */#include <libfbx/libfbx.h>#include <math.h>/* * Function:    fb_move_object()  * Arguments:   Speed, radians, x, y coords. * Returns:     None. * Description: Moves a vector along a 2d plane */void fb_move_object(float speed, float radians, float *x, float *y){		*x += speed * cos(radians);	*y += speed * sin(radians);}/* * Function:    fb_get_rad() * Arguments:   Beginning and ending x, y coords. * Returns:	Radian from first to second point. * Description: Determines a radian from two specific points. */float fb_get_rad(float x1, float y1, float x2, float y2){	float rad, slope, t;	t = 0.01745;		if ((fabs((x2-x1)))>=(fabs((y2-y1)))) { //x		slope = (y1 - y2) / (x1 - x2);		if (x1<=x2)			rad=(slope < 0.78539)? t * slope : 5.49778 + (t * slope); //right		else			rad = 2.35619 + (t * slope); //left	} else { //y		slope=(x1 - x2) / (y1 - y2);		rad=(y1<=y2)? 3.92699 + (t * slope) /*down*/: 0.78539 + (t * slope); //up	}	return rad;}/* * Function:    fb_get_angle() * Arguments:   Beginning and ending x, y coords. * Returns:     Angle. * Description: Measures angle between first and second *              x, y points. */float fb_get_angle(float x1, float y1, float x2, float y2){	return (fb_get_rad(x1, y1, x2, y2) / (PI / 180.0));}

⌨️ 快捷键说明

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