git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@44 92316355-f0b4-4df1-b90c-862c8a59935fmaster
| @@ -24,6 +24,7 @@ ttyvaders_SOURCES = \ | |||||
| common.h \ | common.h \ | ||||
| explosions.c \ | explosions.c \ | ||||
| main.c \ | main.c \ | ||||
| math.c \ | |||||
| starfield.c \ | starfield.c \ | ||||
| weapons.c \ | weapons.c \ | ||||
| collide.c \ | collide.c \ | ||||
| @@ -3,7 +3,7 @@ | |||||
| * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> | ||||
| * All Rights Reserved | * All Rights Reserved | ||||
| * | * | ||||
| * $Id: common.h,v 1.8 2002/12/22 22:17:41 sam Exp $ | |||||
| * $Id: common.h,v 1.9 2002/12/22 22:36:42 sam Exp $ | |||||
| * | * | ||||
| * This program is free software; you can redistribute it and/or modify | * This program is free software; you can redistribute it and/or modify | ||||
| * it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
| @@ -185,3 +185,5 @@ void update_explosions( game *g, explosions *ex ); | |||||
| void ceo_alert( void ); | void ceo_alert( void ); | ||||
| int r00t( int a ); | |||||
| @@ -0,0 +1,37 @@ | |||||
| /* | |||||
| * ttyvaders Textmode shoot'em up | |||||
| * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> | |||||
| * All Rights Reserved | |||||
| * | |||||
| * $Id: math.c,v 1.1 2002/12/22 22:36:42 sam Exp $ | |||||
| * | |||||
| * This program is free software; you can redistribute it and/or modify | |||||
| * it under the terms of the GNU General Public License as published by | |||||
| * the Free Software Foundation; either version 2 of the License, or | |||||
| * (at your option) any later version. | |||||
| * | |||||
| * This program 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 General Public License for more details. | |||||
| * | |||||
| * You should have received a copy of the GNU General Public License | |||||
| * along with this program; if not, write to the Free Software | |||||
| * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
| */ | |||||
| #include "common.h" | |||||
| int r00t( int a ) | |||||
| { | |||||
| int x = a > 100000 ? 1000 : a > 1000 ? 100 : a > 10 ? 10 : 1; | |||||
| /* Newton's method. Three iterations are more than enough. */ | |||||
| x = (x * x + a) / x / 2; | |||||
| x = (x * x + a) / x / 2; | |||||
| x = (x * x + a) / x / 2; | |||||
| x = (x * x + a) / x / 2; | |||||
| return x; | |||||
| } | |||||
| @@ -3,7 +3,7 @@ | |||||
| * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> | * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> | ||||
| * All Rights Reserved | * All Rights Reserved | ||||
| * | * | ||||
| * $Id: weapons.c,v 1.8 2002/12/22 22:17:41 sam Exp $ | |||||
| * $Id: weapons.c,v 1.9 2002/12/22 22:36:42 sam Exp $ | |||||
| * | * | ||||
| * This program is free software; you can redistribute it and/or modify | * This program is free software; you can redistribute it and/or modify | ||||
| * it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
| @@ -21,7 +21,6 @@ | |||||
| */ | */ | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <math.h> | |||||
| #include "common.h" | #include "common.h" | ||||
| @@ -172,9 +171,9 @@ void update_weapons( game *g, weapons *wp ) | |||||
| /* Normalize and update speed */ | /* Normalize and update speed */ | ||||
| wp->vx[i] = (7 * wp->vx[i] | wp->vx[i] = (7 * wp->vx[i] | ||||
| + (dx * 48) / sqrt(dx*dx+dy*dy) ) / 8; | |||||
| + (dx * 48) / r00t(dx*dx+dy*dy) ) / 8; | |||||
| wp->vy[i] = (7 * wp->vy[i] | wp->vy[i] = (7 * wp->vy[i] | ||||
| + (dy * 24) / sqrt(dx*dx+dy*dy) ) / 8; | |||||
| + (dy * 24) / r00t(dx*dx+dy*dy) ) / 8; | |||||
| break; | break; | ||||
| case WEAPON_FRAGBOMB: | case WEAPON_FRAGBOMB: | ||||