/* Copyright (C) 2005, 2010 - Cryptic Sea This file is part of Gish. Gish 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ void setupphysics(void) { int count; count=1; particletype[count].drag=0.995f; particletype[count].gravity=4.0f/(PHYSICSCYCLE*PHYSICSCYCLE); particletype[count].elasticity=1.2f; particletype[count].friction=1.2f; particletype[count].levelcollision=0; particletype[count].objectcollision=0; particletype[count].rendertype=0; count=2; particletype[count].drag=0.0f; particletype[count].gravity=0.0f; particletype[count].elasticity=1.2f; particletype[count].friction=1.2f; particletype[count].levelcollision=0; particletype[count].objectcollision=0; particletype[count].rendertype=0; count=3; particletype[count].drag=0.999f; particletype[count].gravity=4.0f/(PHYSICSCYCLE*PHYSICSCYCLE); particletype[count].elasticity=1.2f; particletype[count].friction=1.2f; particletype[count].levelcollision=0; particletype[count].objectcollision=0; particletype[count].rendertype=0; count=4; particletype[count].drag=0.995f; particletype[count].gravity=4.0f/(PHYSICSCYCLE*PHYSICSCYCLE); particletype[count].elasticity=1.2f; particletype[count].friction=0.2f; particletype[count].levelcollision=1; particletype[count].objectcollision=0; particletype[count].rendertype=0; count=5; particletype[count].drag=0.99f; particletype[count].gravity=4.0f/(PHYSICSCYCLE*PHYSICSCYCLE); particletype[count].elasticity=1.2f; particletype[count].friction=0.2f; particletype[count].levelcollision=1; particletype[count].objectcollision=0; particletype[count].rendertype=0; count=6; particletype[count].drag=0.999f; particletype[count].gravity=0.0f; particletype[count].elasticity=1.2f; particletype[count].friction=0.3f; particletype[count].levelcollision=1; particletype[count].objectcollision=0; particletype[count].rendertype=0; count=16; particletype[count].drag=0.999f; particletype[count].gravity=0.0f; particletype[count].elasticity=1.2f; particletype[count].friction=0.3f; particletype[count].levelcollision=0; particletype[count].objectcollision=0; particletype[count].rendertype=0; count=1; bondtype[count].elasticity=0.2f; bondtype[count].cycles=1; bondtype[count].compression=0.1f; bondtype[count].tension=1.9f; bondtype[count].rendertype=1; bondtype[count].rendersize=0.4f; count=2; bondtype[count].elasticity=0.02f; bondtype[count].cycles=31; bondtype[count].compression=0.1f; bondtype[count].tension=1.9f; bondtype[count].rendertype=1; bondtype[count].rendersize=0.4f; count=3; bondtype[count].elasticity=0.2f; bondtype[count].cycles=3; bondtype[count].compression=0.1f; bondtype[count].tension=1.9f; bondtype[count].rendertype=1; bondtype[count].rendersize=0.4f; count=4; bondtype[count].elasticity=0.5f; bondtype[count].cycles=1; bondtype[count].compression=0.0f; bondtype[count].tension=1.15f; bondtype[count].rendertype=1; bondtype[count].rendersize=0.4f; count=5; bondtype[count].elasticity=0.1f; bondtype[count].cycles=31; bondtype[count].compression=0.1f; bondtype[count].tension=1.9f; bondtype[count].rendertype=1; bondtype[count].rendersize=0.4f; count=6; bondtype[count].elasticity=0.2f; bondtype[count].cycles=15; bondtype[count].compression=0.75f; bondtype[count].tension=1.25f; bondtype[count].rendertype=1; bondtype[count].rendersize=0.4f; count=7; bondtype[count].elasticity=0.2f; bondtype[count].cycles=0; bondtype[count].compression=0.5f; bondtype[count].tension=1.5f; bondtype[count].rendertype=1; bondtype[count].rendersize=0.4f; count=8; bondtype[count].elasticity=0.002f; bondtype[count].cycles=0; bondtype[count].compression=0.5f; bondtype[count].tension=1.5f; bondtype[count].rendertype=1; bondtype[count].rendersize=0.4f; count=9; bondtype[count].elasticity=0.2f; bondtype[count].cycles=0; bondtype[count].compression=0.5f; bondtype[count].tension=1.5f; bondtype[count].rendertype=1; bondtype[count].rendersize=0.4f; count=16; bondtype[count].elasticity=0.1f; bondtype[count].cycles=31; bondtype[count].compression=0.5f; bondtype[count].tension=1.5f; bondtype[count].rendertype=1; bondtype[count].rendersize=0.4f; } void particlecollision(int particlenum) { float vec[3],vec2[3],vec3[3]; float intersectpoint[3]; float normal[3]; float scale; if (pointintersectlevel(intersectpoint,normal,&scale,particle[particlenum].position)) { subtractvectors(vec2,intersectpoint,particle[particlenum].position); scaleaddvectors(vec,particle[particlenum].position,normal,dotproduct(vec2,normal)); physicstemp.bond[physicstemp.numofbonds].part1=particlenum; physicstemp.bond[physicstemp.numofbonds].type=0; physicstemp.bond[physicstemp.numofbonds].cycles=3; physicstemp.bond[physicstemp.numofbonds].length=0.0f; physicstemp.bond[physicstemp.numofbonds].elasticity=0.2f; physicstemp.bond[physicstemp.numofbonds].friction=particle[particlenum].friction; if (collision.friction0.5f) { getlevellines(objectnum); for (count=0;count1.0f) force[0]=1.0f; if (force[1]>1.0f) force[1]=1.0f; physicstemp.bond[physicstemp.numofbonds].part1=object[objectnum].particle[part1]; physicstemp.bond[physicstemp.numofbonds].part2=object[objectnum].particle[part2]; physicstemp.bond[physicstemp.numofbonds].type=2; subtractvectors(vec,vec2,intersectpoint); physicstemp.bond[physicstemp.numofbonds].length=vectorlength(vec); copyvector(physicstemp.bond[physicstemp.numofbonds].normal,normal); physicstemp.bond[physicstemp.numofbonds].cycles=0; physicstemp.bond[physicstemp.numofbonds].elasticity=0.2f; physicstemp.bond[physicstemp.numofbonds].friction=object[objectnum].friction; if (collision.friction0.1f) { if (!object[objectnum].particlestick[count]) { object[objectnum].particlestick[count]=1; copyvector(object[objectnum].particlesticknormal[count],normal); copyvector(object[objectnum].particlestickposition[count],intersectpoint); physicstemp.bond[physicstemp.numofbonds].part1=object[objectnum].particle[count]; physicstemp.bond[physicstemp.numofbonds].part4=count; physicstemp.bond[physicstemp.numofbonds].type=1; physicstemp.bond[physicstemp.numofbonds].cycles=0; physicstemp.bond[physicstemp.numofbonds].length=0.0f; physicstemp.bond[physicstemp.numofbonds].elasticity=0.2f; physicstemp.bond[physicstemp.numofbonds].breakpoint=0.25f; if (fabs(normal[1])<0.707f) physicstemp.bond[physicstemp.numofbonds].breakpoint=0.2f; physicstemp.bond[physicstemp.numofbonds].objectnum[0]=objectnum; physicstemp.bond[physicstemp.numofbonds].blocknum=collision.blocknum; physicstemp.bond[physicstemp.numofbonds].blockx=collision.blockx; physicstemp.bond[physicstemp.numofbonds].blocky=collision.blocky; copyvector(physicstemp.bond[physicstemp.numofbonds].point,vec); copyvector(physicstemp.bond[physicstemp.numofbonds].normal,normal); physicstemp.numofbonds++; } } } } } } void objectcollisionobject(int objectnum) { int count,count2; int part1,part2; int objectcount; int particlenum; int particlelist[2]; float vec[3],vec2[3],vec3[3]; float intersectpoint[3]; float normal[3]; float force[2]; float scale; float friction; if (object[objectnum].type==3) for (count=0;count1.0f) force[0]=1.0f; if (force[1]>1.0f) force[1]=1.0f; physicstemp.bond[physicstemp.numofbonds].part1=rope[count2].part1; physicstemp.bond[physicstemp.numofbonds].part2=rope[count2].part2; physicstemp.bond[physicstemp.numofbonds].part3=particlenum; physicstemp.bond[physicstemp.numofbonds].type=4; subtractvectors(vec,vec2,intersectpoint); physicstemp.bond[physicstemp.numofbonds].length=vectorlength(vec); copyvector(physicstemp.bond[physicstemp.numofbonds].normal,normal); physicstemp.bond[physicstemp.numofbonds].cycles=0; physicstemp.bond[physicstemp.numofbonds].elasticity=0.2f; physicstemp.bond[physicstemp.numofbonds].friction=0.8f; physicstemp.bond[physicstemp.numofbonds].objectnum[0]=objectnum; physicstemp.bond[physicstemp.numofbonds].objectnum[1]=objectnum; physicstemp.bond[physicstemp.numofbonds].force[0]=force[1]; physicstemp.bond[physicstemp.numofbonds].force[1]=force[0]; physicstemp.bond[physicstemp.numofbonds].blocknum=0; physicstemp.bond[physicstemp.numofbonds].blockx=0; physicstemp.bond[physicstemp.numofbonds].blocky=0; physicstemp.numofbonds++; } } updateogg(); for (objectcount=0;objectcount175) && (object[objectcount].type!=2 || object[objectcount].timetolive>175)) if (object[objectnum].timetolive>40 && object[objectcount].timetolive>40) { subtractvectors(vec,object[objectnum].position,object[objectcount].position); if (vectorlength(vec)16) { object[objectcount].timetolive=16; if (level.gametype==12) { if (objectnum==0) game.score[0]++; if (objectnum==1) game.score[1]++; } } //subtractvectors(vec,intersectpoint,particle[particlenum].position); //scaleaddvectors(vec2,particle[particlenum].position,normal,dotproduct(vec,normal)); //copyvector(vec,intersectpoint); subtractvectors(vec,particle[object[objectcount].particle[part2]].position,particle[object[objectcount].particle[part1]].position); scale=vectorlength(vec); subtractvectors(vec,particle[object[objectcount].particle[part1]].position,intersectpoint); force[0]=vectorlength(vec)/scale; subtractvectors(vec,particle[object[objectcount].particle[part2]].position,intersectpoint); force[1]=vectorlength(vec)/scale; if (force[0]>1.0f) force[0]=1.0f; if (force[1]>1.0f) force[1]=1.0f; friction=object[objectnum].friction; if (friction>object[objectcount].friction) friction=object[objectcount].friction; physicstemp.bond[physicstemp.numofbonds].part1=object[objectcount].particle[part1]; physicstemp.bond[physicstemp.numofbonds].part2=object[objectcount].particle[part2]; physicstemp.bond[physicstemp.numofbonds].part3=particlenum; physicstemp.bond[physicstemp.numofbonds].type=4; subtractvectors(vec,particle[particlenum].position,intersectpoint); physicstemp.bond[physicstemp.numofbonds].length=vectorlength(vec); copyvector(physicstemp.bond[physicstemp.numofbonds].normal,normal); physicstemp.bond[physicstemp.numofbonds].cycles=0; if (object[objectnum].type==2 && object[objectcount].type==2) if (object[objectnum].size[0]<=0.5f && object[objectcount].size[0]<=0.5f) physicstemp.bond[physicstemp.numofbonds].cycles=3; physicstemp.bond[physicstemp.numofbonds].elasticity=0.2f; physicstemp.bond[physicstemp.numofbonds].friction=friction; physicstemp.bond[physicstemp.numofbonds].objectnum[0]=objectnum; physicstemp.bond[physicstemp.numofbonds].objectnum[1]=objectcount; physicstemp.bond[physicstemp.numofbonds].force[0]=force[1]; physicstemp.bond[physicstemp.numofbonds].force[1]=force[0]; physicstemp.bond[physicstemp.numofbonds].blocknum=0; physicstemp.bond[physicstemp.numofbonds].blockx=0; physicstemp.bond[physicstemp.numofbonds].blocky=0; physicstemp.numofbonds++; if ((object[objectnum].button&1)==1 && object[objectnum].type==1) if (object[objectcount].type!=1 || (object[objectcount].button&4)==0) { //if (!object[objectnum].particlestick[count]) { if (object[objectnum].particlestick[count]) { for (count2=0;count2=3 && object[objectcount].type<=5) physicstemp.bond[physicstemp.numofbonds].breakpoint*=1.5f; physicstemp.bond[physicstemp.numofbonds].friction=friction; physicstemp.bond[physicstemp.numofbonds].objectnum[0]=objectnum; physicstemp.bond[physicstemp.numofbonds].objectnum[1]=objectcount; physicstemp.bond[physicstemp.numofbonds].force[0]=force[1]; physicstemp.bond[physicstemp.numofbonds].force[1]=force[0]; physicstemp.bond[physicstemp.numofbonds].blocknum=0; physicstemp.bond[physicstemp.numofbonds].blockx=0; physicstemp.bond[physicstemp.numofbonds].blocky=0; physicstemp.numofbonds++; if (game.oldschool==2) if (object[objectcount].type==3) if (game.framenum-game.oldschoolsound>200) { playsound(22,object[objectnum].position,NULL,1.0f,0,1.0f,objectnum,1); game.oldschoolsound=game.framenum; } } } } } } } if (level.gametype>=10) for (objectcount=0;objectcount0.00000001f) { subtractvectors(vec,particle[part1].position,intersectpoint); force[0]=vectorlength(vec)/scale; subtractvectors(vec,particle[part2].position,intersectpoint); force[1]=vectorlength(vec)/scale; } else { force[0]=0.5f; force[1]=0.5f; } if (force[0]>1.0f) force[0]=1.0f; if (force[1]>1.0f) force[1]=1.0f; physicstemp.bond[physicstemp.numofbonds].part1=part1; physicstemp.bond[physicstemp.numofbonds].part2=part2; physicstemp.bond[physicstemp.numofbonds].part3=particlenum; physicstemp.bond[physicstemp.numofbonds].type=4; subtractvectors(vec,particle[particlenum].position,intersectpoint); physicstemp.bond[physicstemp.numofbonds].length=vectorlength(vec); copyvector(physicstemp.bond[physicstemp.numofbonds].normal,normal); physicstemp.bond[physicstemp.numofbonds].cycles=0; physicstemp.bond[physicstemp.numofbonds].elasticity=0.5f; physicstemp.bond[physicstemp.numofbonds].friction=1.0f; physicstemp.bond[physicstemp.numofbonds].objectnum[0]=-1; physicstemp.bond[physicstemp.numofbonds].objectnum[1]=-1; physicstemp.bond[physicstemp.numofbonds].force[0]=force[1]; physicstemp.bond[physicstemp.numofbonds].force[1]=force[0]; physicstemp.bond[physicstemp.numofbonds].blocknum=0; physicstemp.bond[physicstemp.numofbonds].blockx=0; physicstemp.bond[physicstemp.numofbonds].blocky=0; physicstemp.numofbonds++; } } } } } void bondsimulation2(void) { int count,count2; int part1,part2,part3; int blocknum; unsigned int x; float vec[3],vec2[3],vec3[3]; float bondnormal[3]; float veclength; float force[2]; float temp; float scale; for (count2=0;count20.0f) { scalevector2(vec,vec,physicstemp.bond[count2].elasticity); calculatefriction(vec,vec2,physicstemp.bond[count2].normal,physicstemp.bond[count2].friction); addvectors2(vec,vec,vec2); addvectors2(particle[part1].velocity,particle[part1].velocity,vec); if (particle[part1].type!=5) { addvectors2(physicstemp.bond[count2].forceapplied[0],physicstemp.bond[count2].forceapplied[0],vec); if (block[physicstemp.bond[count2].blocknum].breakpoint!=0.0f) { level.gridforce[physicstemp.bond[count2].blocky][physicstemp.bond[count2].blockx]+=vectorlength(vec)*particle[part1].mass; if (level.gridforce[physicstemp.bond[count2].blocky][physicstemp.bond[count2].blockx]>block[physicstemp.bond[count2].blocknum].breakpoint) physicstemp.bond[count2].type=-1; } } } } if (physicstemp.bond[count2].type==1) { part1=physicstemp.bond[count2].part1; subtractvectors2(bondnormal,physicstemp.bond[count2].point,particle[part1].position); scalevector2(vec,bondnormal,1.0f); veclength=(vectorlength(bondnormal)-physicstemp.bond[count2].length); scaleaddvectors2(vec,vec,particle[part1].prevvelocity,-1.0f); veclength=(vectorlength(bondnormal)-physicstemp.bond[count2].length)-dotproduct(bondnormal,particle[part1].prevvelocity)/vectorlength(bondnormal); scalevector2(vec,vec,physicstemp.bond[count2].elasticity); scalevector2(vec,vec,0.04f); addvectors2(particle[part1].velocity,particle[part1].velocity,vec); addvectors2(physicstemp.bond[count2].forceapplied[0],physicstemp.bond[count2].forceapplied[0],vec); if (block[physicstemp.bond[count2].blocknum].breakpoint!=0.0f) { level.gridforce[physicstemp.bond[count2].blocky][physicstemp.bond[count2].blockx]+=vectorlength(vec)*particle[part1].mass; if (level.gridforce[physicstemp.bond[count2].blocky][physicstemp.bond[count2].blockx]>block[physicstemp.bond[count2].blocknum].breakpoint || level.gridmod[physicstemp.bond[count2].blocky][physicstemp.bond[count2].blockx]!=0) { physicstemp.bond[count2].type=-1; object[physicstemp.bond[count2].objectnum[0]].particlestick[physicstemp.bond[count2].part4]=0; } } } if (physicstemp.bond[count2].type==2) { part1=physicstemp.bond[count2].part1; part2=physicstemp.bond[count2].part2; scalevector2(bondnormal,physicstemp.bond[count2].normal,-physicstemp.bond[count2].length*0.2f); scaleaddvectors2(bondnormal,bondnormal,particle[part2].prevvelocity,-physicstemp.bond[count2].force[1]); scaleaddvectors2(bondnormal,bondnormal,particle[part1].prevvelocity,-physicstemp.bond[count2].force[0]); copyvector(vec,bondnormal); if (dotproduct(vec,physicstemp.bond[count2].normal)<0.0f) { scalevector2(vec,vec,physicstemp.bond[count2].elasticity); calculatefriction(vec,vec2,physicstemp.bond[count2].normal,physicstemp.bond[count2].friction); addvectors2(vec,vec,vec2); scaleaddvectors2(particle[part1].velocity,particle[part1].velocity,vec,physicstemp.bond[count2].force[0]); scaleaddvectors2(particle[part2].velocity,particle[part2].velocity,vec,physicstemp.bond[count2].force[1]); addvectors2(physicstemp.bond[count2].forceapplied[0],physicstemp.bond[count2].forceapplied[0],vec); if (block[physicstemp.bond[count2].blocknum].breakpoint!=0.0f) { level.gridforce[physicstemp.bond[count2].blocky][physicstemp.bond[count2].blockx]+=vectorlength(vec)*particle[part1].mass; if (level.gridforce[physicstemp.bond[count2].blocky][physicstemp.bond[count2].blockx]>block[physicstemp.bond[count2].blocknum].breakpoint) physicstemp.bond[count2].type=-1; } } } if (physicstemp.bond[count2].type==4) { part1=physicstemp.bond[count2].part1; part2=physicstemp.bond[count2].part2; part3=physicstemp.bond[count2].part3; scalevector2(bondnormal,physicstemp.bond[count2].normal,-physicstemp.bond[count2].length*0.2f); scaleaddvectors2(bondnormal,bondnormal,particle[part3].prevvelocity,1.0f); scaleaddvectors2(bondnormal,bondnormal,particle[part2].prevvelocity,-physicstemp.bond[count2].force[1]); scaleaddvectors2(bondnormal,bondnormal,particle[part1].prevvelocity,-physicstemp.bond[count2].force[0]); veclength=physicstemp.bond[count2].elasticity/(particle[part1].mass*physicstemp.bond[count2].force[0]+particle[part2].mass*physicstemp.bond[count2].force[1]+particle[part3].mass); force[0]=veclength*particle[part3].mass; force[1]=veclength*(particle[part1].mass*physicstemp.bond[count2].force[0]+particle[part2].mass*physicstemp.bond[count2].force[1]); if (dotproduct(bondnormal,physicstemp.bond[count2].normal)*force[0]<0.0f) { scalevector2(vec,bondnormal,force[0]); calculatefriction(vec,vec2,physicstemp.bond[count2].normal,physicstemp.bond[count2].friction); addvectors2(vec,vec,vec2); scaleaddvectors2(particle[part1].velocity,particle[part1].velocity,vec,physicstemp.bond[count2].force[0]); scaleaddvectors2(particle[part2].velocity,particle[part2].velocity,vec,physicstemp.bond[count2].force[1]); addvectors2(physicstemp.bond[count2].forceapplied[0],physicstemp.bond[count2].forceapplied[0],vec); scalevector2(vec,bondnormal,-force[1]); calculatefriction(vec,vec2,physicstemp.bond[count2].normal,physicstemp.bond[count2].friction); addvectors2(vec,vec,vec2); addvectors2(particle[part3].velocity,particle[part3].velocity,vec); addvectors2(physicstemp.bond[count2].forceapplied[1],physicstemp.bond[count2].forceapplied[1],vec); } } if (physicstemp.bond[count2].type==5) { part1=physicstemp.bond[count2].part1; part2=physicstemp.bond[count2].part2; part3=physicstemp.bond[count2].part3; //scalevector(bondnormal,physicstemp.bond[count2].normal,-physicstemp.bond[count2].length*0.2f); scalevector2(vec,particle[part1].position,physicstemp.bond[count2].force[0]); scaleaddvectors2(vec,vec,particle[part2].position,physicstemp.bond[count2].force[1]); subtractvectors2(bondnormal,particle[part3].position,vec); scaleaddvectors2(bondnormal,bondnormal,particle[part3].prevvelocity,1.0f); scaleaddvectors2(bondnormal,bondnormal,particle[part2].prevvelocity,-physicstemp.bond[count2].force[1]*1.0f); scaleaddvectors2(bondnormal,bondnormal,particle[part1].prevvelocity,-physicstemp.bond[count2].force[0]*1.0f); veclength=physicstemp.bond[count2].elasticity/(particle[part1].mass*physicstemp.bond[count2].force[0]+particle[part2].mass*physicstemp.bond[count2].force[1]+particle[part3].mass); veclength*=0.2f; veclength*=0.2f; force[0]=veclength*particle[part3].mass; force[1]=veclength*(particle[part1].mass*physicstemp.bond[count2].force[0]+particle[part2].mass*physicstemp.bond[count2].force[1]); scalevector2(vec,bondnormal,force[0]); scaleaddvectors2(particle[part1].velocity,particle[part1].velocity,vec,physicstemp.bond[count2].force[0]); scaleaddvectors2(particle[part2].velocity,particle[part2].velocity,vec,physicstemp.bond[count2].force[1]); addvectors2(physicstemp.bond[count2].forceapplied[0],physicstemp.bond[count2].forceapplied[0],vec); scalevector2(vec,bondnormal,-force[1]); addvectors2(particle[part3].velocity,particle[part3].velocity,vec); addvectors2(physicstemp.bond[count2].forceapplied[1],physicstemp.bond[count2].forceapplied[1],vec); } } //stoptimer(1); } for (count2=0;count2physicstemp.bond[count2].breakpoint || (object[physicstemp.bond[count2].objectnum[0]].button&1)==0) { physicstemp.bond[count2].type=-1; object[physicstemp.bond[count2].objectnum[0]].particlestick[physicstemp.bond[count2].part4]=0; } } if (physicstemp.bond[count2].type==5) { part1=physicstemp.bond[count2].part1; part2=physicstemp.bond[count2].part2; part3=physicstemp.bond[count2].part3; scalevector(vec,particle[part1].position,physicstemp.bond[count2].force[0]); scaleaddvectors(vec,vec,particle[part2].position,physicstemp.bond[count2].force[1]); copyvector(object[physicstemp.bond[count2].objectnum[0]].particlestickposition[physicstemp.bond[count2].part4],vec); subtractvectors(bondnormal,particle[part3].position,vec); subtractvectors(vec,particle[part2].position,particle[part1].position); vec2[0]=-vec[1]; vec2[1]=vec[0]; vec2[2]=0.0f; normalizevector(object[physicstemp.bond[count2].objectnum[0]].particlesticknormal[physicstemp.bond[count2].part4],vec2); scaleaddvectors(bondnormal,bondnormal,particle[part3].prevvelocity,1.0f); scaleaddvectors(bondnormal,bondnormal,particle[part2].prevvelocity,-physicstemp.bond[count2].force[1]*1.0f); scaleaddvectors(bondnormal,bondnormal,particle[part1].prevvelocity,-physicstemp.bond[count2].force[0]*1.0f); veclength=vectorlength(bondnormal); if (fabs(veclength)>physicstemp.bond[count2].breakpoint || (object[physicstemp.bond[count2].objectnum[0]].button&1)==0 || (object[physicstemp.bond[count2].objectnum[0]].button&4)==4 || (object[physicstemp.bond[count2].objectnum[1]].button&4)==4) { physicstemp.bond[count2].type=-1; object[physicstemp.bond[count2].objectnum[0]].particlestick[physicstemp.bond[count2].part4]=0; } } blocknum=physicstemp.bond[count2].blocknum; if (block[blocknum].breakpoint!=0.0f) { if (level.gridforce[physicstemp.bond[count2].blocky][physicstemp.bond[count2].blockx]>block[blocknum].breakpoint) { level.gridmod[physicstemp.bond[count2].blocky][physicstemp.bond[count2].blockx]=1; if (blocknum>=240 && blocknum<248) level.gridmod[physicstemp.bond[count2].blocky][physicstemp.bond[count2].blockx]=2; setuplevellines(physicstemp.bond[count2].blockx-1,physicstemp.bond[count2].blocky-1,physicstemp.bond[count2].blockx+1,physicstemp.bond[count2].blocky+1); vec[0]=(float)physicstemp.bond[count2].blockx+0.5f; vec[1]=(float)physicstemp.bond[count2].blocky+0.5f; vec[2]=0.0f; playsound(0,vec,NULL,0.75f,0,0.5f/block[blocknum].breakpoint,-1,0); if (level.gametype==0) { game.score[0]+=10; createsprite(10,vec); } /* vec[0]=(float)physicstemp.bond[count2].blockx+0.5f; vec[1]=(float)physicstemp.bond[count2].blocky+0.5f; vec[2]=0.0f; createbox(vec,0.99f,0.99f,block[blocknum].breakpoint*4.0f,block[blocknum].friction); object[numofobjects-1].timetolive=200+(rand()&63); object[numofobjects-1].texturenum=blocknum-256; object[numofobjects-1].texcoord[0][0]=0.0f; object[numofobjects-1].texcoord[0][1]=0.0f; object[numofobjects-1].texcoord[1][0]=1.0f; object[numofobjects-1].texcoord[1][1]=0.0f; object[numofobjects-1].texcoord[2][0]=1.0f; object[numofobjects-1].texcoord[2][1]=1.0f; object[numofobjects-1].texcoord[3][0]=0.0f; object[numofobjects-1].texcoord[3][1]=1.0f; */ if (numofobjects<500) { vec[0]=(float)physicstemp.bond[count2].blockx+0.25f; vec[1]=(float)physicstemp.bond[count2].blocky+0.75f; vec[2]=0.0f; createbox(vec,0.49f,0.49f,block[blocknum].breakpoint,block[blocknum].friction); object[numofobjects-1].timetolive=200; object[numofobjects-1].texturenum=blocknum-256; object[numofobjects-1].texcoord[0][0]=0.0f; object[numofobjects-1].texcoord[0][1]=0.0f; object[numofobjects-1].texcoord[1][0]=0.5f; object[numofobjects-1].texcoord[1][1]=0.0f; object[numofobjects-1].texcoord[2][0]=0.5f; object[numofobjects-1].texcoord[2][1]=0.5f; object[numofobjects-1].texcoord[3][0]=0.0f; object[numofobjects-1].texcoord[3][1]=0.5f; vec[0]=(float)physicstemp.bond[count2].blockx+0.75f; vec[1]=(float)physicstemp.bond[count2].blocky+0.75f; vec[2]=0.0f; createbox(vec,0.49f,0.49f,block[blocknum].breakpoint,block[blocknum].friction); object[numofobjects-1].timetolive=200; object[numofobjects-1].texturenum=blocknum-256; object[numofobjects-1].texcoord[0][0]=0.0f+0.5f; object[numofobjects-1].texcoord[0][1]=0.0f; object[numofobjects-1].texcoord[1][0]=0.5f+0.5f; object[numofobjects-1].texcoord[1][1]=0.0f; object[numofobjects-1].texcoord[2][0]=0.5f+0.5f; object[numofobjects-1].texcoord[2][1]=0.5f; object[numofobjects-1].texcoord[3][0]=0.0f+0.5f; object[numofobjects-1].texcoord[3][1]=0.5f; vec[0]=(float)physicstemp.bond[count2].blockx+0.75f; vec[1]=(float)physicstemp.bond[count2].blocky+0.25f; vec[2]=0.0f; createbox(vec,0.49f,0.49f,block[blocknum].breakpoint,block[blocknum].friction); object[numofobjects-1].timetolive=200; object[numofobjects-1].texturenum=blocknum-256; object[numofobjects-1].texcoord[0][0]=0.0f+0.5f; object[numofobjects-1].texcoord[0][1]=0.0f+0.5f; object[numofobjects-1].texcoord[1][0]=0.5f+0.5f; object[numofobjects-1].texcoord[1][1]=0.0f+0.5f; object[numofobjects-1].texcoord[2][0]=0.5f+0.5f; object[numofobjects-1].texcoord[2][1]=0.5f+0.5f; object[numofobjects-1].texcoord[3][0]=0.0f+0.5f; object[numofobjects-1].texcoord[3][1]=0.5f+0.5f; vec[0]=(float)physicstemp.bond[count2].blockx+0.25f; vec[1]=(float)physicstemp.bond[count2].blocky+0.25f; vec[2]=0.0f; createbox(vec,0.49f,0.49f,block[blocknum].breakpoint,block[blocknum].friction); object[numofobjects-1].timetolive=200; object[numofobjects-1].texturenum=blocknum-256; object[numofobjects-1].texcoord[0][0]=0.0f; object[numofobjects-1].texcoord[0][1]=0.0f+0.5f; object[numofobjects-1].texcoord[1][0]=0.5f; object[numofobjects-1].texcoord[1][1]=0.0f+0.5f; object[numofobjects-1].texcoord[2][0]=0.5f; object[numofobjects-1].texcoord[2][1]=0.5f+0.5f; object[numofobjects-1].texcoord[3][0]=0.0f; object[numofobjects-1].texcoord[3][1]=0.5f+0.5f; } } level.gridforce[physicstemp.bond[count2].blocky][physicstemp.bond[count2].blockx]=0.0f; } } count2=0; while (count20.0f) if (dot2>0.0f) return(0); if (dot1<0.0f) return(0); normalizevector(normal,normal); vec[0]=vertex1[0]-startpoint[0]; vec[1]=vertex1[1]-startpoint[1]; vec[2]=0.0f; *scale=dotproduct(vec,normal); vec[0]=endpoint[0]-startpoint[0]; vec[1]=endpoint[1]-startpoint[1]; vec[2]=0.0f; *scale/=dotproduct(vec,normal); scaleaddvectors(intersectpoint,startpoint,vec,*scale); vec[0]=intersectpoint[0]-vertex1[0]; vec[1]=intersectpoint[1]-vertex1[1]; vec[2]=0.0f; vec2[0]=vertex2[0]-vertex1[0]; vec2[1]=vertex2[1]-vertex1[1]; vec2[2]=0.0f; if (dotproduct(vec,vec2)<0.0f) return(0); vec[0]=intersectpoint[0]-vertex2[0]; vec[1]=intersectpoint[1]-vertex2[1]; vec[2]=0.0f; vec2[0]=vertex1[0]-vertex2[0]; vec2[1]=vertex1[1]-vertex2[1]; vec2[2]=0.0f; if (dotproduct(vec,vec2)<0.0f) return(0); return(1); }