All pastes #393917 Raw Edit

Mine

public cpp v1 · immutable
·published 2007-03-13 22:27 UTC
rendered paste body
int tir_parabolic(int x_inici, int y_inici, double angle, double forca, int x_actual, int vent){	double v_x,v_y; // Velocitats inicials	double t; // Temps transcorregut		v_x = cos((double)angle)*(double)forca;	v_y = sin((double)angle)*(double)forca;	//t = ((float)x_actual-(float)x_inici)/v_x;	t = (-v_x - sqrt(v_x*v_x-(double)(2*vent*(x_inici-x_actual))))/(double)vent;		if (t < 0) 		t = (-v_x + sqrt(v_x*v_x-(double)(2*vent*(x_inici-x_actual))))/(double)vent;		printf("%d\n",(int)t);		if (v_x==0) {		return -1;	}	else {		return (int)(y_inici+(int)v_y*t-(int)(GRAVETAT/2.0)*(t*t));	}}void efectua_dispar(int x_inici, int y_inici, double angle, double forca, int* terreny, int ample, int alt, int vent, CTancs *tancs){	int i, j, tmp, t=0;	int x, y;	int taurell[ample][alt];	int radi = DISPAR_RADI;	int contador;		while (angle > PI) {		angle -= PI;	}	while (angle < 0) {		angle += PI;	}	if (angle < PI/2.0) {				for (i = x_inici; i < ample && j!=-1; i++ ) {			j = tir_parabolic(x_inici, terreny[x_inici]+10, angle, forca, i, vent);			if(j>=terreny[i] && j < alt){				dibuixa_pixel(i,j,COLOR_BLANC);				//TODO : Podriem dibuixar línees en lloc de punts, les			//       bales segueixen una trajectòria contínua :-)			} else if (j < terreny[i]){				j =- 1;			}			tmp = i+1;		}		y=terreny[tmp-1];	}	else {		for (i=x_inici; i >= 0 && j!=-1; i--) {			j=tir_parabolic(x_inici, terreny[x_inici]+10, angle, forca, i, vent);			if(j>=terreny[i] && j<alt){				dibuixa_pixel(i,j,COLOR_BLANC);			}			else if (j < terreny[i]) {				j =- 1;			}			tmp = i-1;		}		y=terreny[tmp+1];	}