I copied and pasted your code and got an runtime error at Flip();
here is my entire code
#include "engine.h"
//#include "Level1.h"
#include <math.h>
#define PI 3.141592654
void ChangeColor(float &, float &, float &, int );
static int count=2;
bool add=true;
int main(int argc, char** argv)
{
Initialize();
Graphics(800,600);
CreateWorld();
if(!CreateWorld())
{
MessageBoxA(0,"ERROR","FAILED TO CREATE WORLD",0);
goto exitapp;
}
TCamera cam=CreateCamera();
CameraClearColor(cam,Vec4(0,0,1,1));
MoveEntity(cam,Vec3(0,0,-5));
TLight light=CreateDirectionalLight();
RotateEntity(light,Vec3(65,45,0));
TBuffer buffer=CreateBuffer(800,600,BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL);
TBody body=CreateBodyBox();
SetBodyMass(body,1);
TMesh box1=CreateCube();
EntityParent(box1,body);
float red=0.0;
float green=0.0;
float blue=0.0;
DebugPhysics(true);
TBody ground=CreateBodyBox(10,0.1,10);
TMesh groundMesh=CreateCube();
ScaleEntity(groundMesh,Vec3(10,0.1,10));
EntityParent(groundMesh,ground);
TBody ground2=CreateBodyBox(10,0.1,10);
TMesh groundMesh2=CreateCube();
ScaleEntity(groundMesh2,Vec3(10,0.1,10));
EntityParent(groundMesh2,ground2);
EntityType(ground2,1);
PositionEntity(ground2,Vec3(10,-20,0));
RotateEntity(ground2,Vec3(0,0,45));
TBody ground3=CopyEntity(ground);
PositionEntity(ground3,Vec3(0,-25,0));
//SetFluidPlane(Vec4(0),1);
TBody box2=CreateBodyBox();
SetBodyMass(box2,1);
TMesh BoxMesh=CreateCube();
EntityParent(BoxMesh,box2);
PositionEntity(box2,Vec3(0.5,100,0.5));
EntityType(box2,1);
PositionEntity(ground,Vec3(0,-3,0));
EntityType(body,1);
EntityType(ground,1);
EntityType(ground3,1);
Collisions(1,1,1);
//DebugPhysics(true);
PositionEntity(cam,Vec3(0,5,-10));
RotateEntity(cam,Vec3(45,0,0));
float x=0;
float z=0;
dropBox:
{
for(int i=1; i<=100;i++)
{
body=CopyEntity(box2);
x=-5+((float)rand()/RAND_MAX)*10;
z=-5+((float)rand()/RAND_MAX)*10;
ScaleEntity(body,Vec3(x,1,z));
SetBodyMass(body,i);
PositionEntity(body,Vec3(x,i,z));
}
}
while(!KeyHit(KEY_ESCAPE))
{
if(KeyDown(KEY_SPACE))
{
if(count==24)
{
add=false;
}
else if(count==1)
{
add=true;
}
TurnEntity(ground,Vec3(0,0,-10));
ChangeColor(red, green, blue, count);
if (add)
count++;
else if(!add)
count--;
CameraClearColor(cam,Vec4(red,green,blue,1));
}
if(KeyHit(KEY_ENTER))
goto dropBox;
UpdateAppTime();
UpdateWorld();
SetBuffer(buffer);
RenderWorld();
SetBuffer(BackBuffer());
RenderLights(buffer);
Flip();
}
exitapp:
Terminate();
return 0;
}
void ChangeColor(float &red, float &green, float &blue, int count)
{
float x=PI/count;
red=sin(x+PI/2);
//green=cos(x+PI/2);
blue=sin(1.5*x);//==sin((PI/count)-PI);
/*
if(red<0)
red=0;
if(green<0)
green=0;
if(blue<0)
blue=0;
*/
}