int Game_Init(void *parms)
{
// this function is where you do all the initialization 
// for your game

// start up DirectDraw (replace the parms as you desire)
DDraw_Init(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_BPP, WINDOWED_APP);

// initialize directinput
DInput_Init();

// acquire the keyboard 
DInput_Init_Keyboard();

// add calls to acquire other directinput devices here...

// initialize directsound and directmusic
DSound_Init();
DMusic_Init();

// hide the mouse
if (!WINDOWED_APP)
   ShowCursor(FALSE);

// seed random number generator
srand(Start_Clock());

Open_Error_File("ERROR.TXT");

// initialize math engine
Build_Sin_Cos_Tables();

// initialize the camera with 90 FOV, normalized coordinates
Init_CAM4DV1(&cam,      // the camera object
             CAM_MODEL_EULER, // the euler model
             &cam_pos,  // initial camera position
             &cam_dir,  // initial camera angles
             NULL,      // no target
             50.0,      // near and far clipping planes
             500.0,
             90.0,      // field of view in degrees
             WINDOW_WIDTH,   // size of final screen viewport
             WINDOW_HEIGHT);

// load the cube
Load_OBJECT4DV1_PLG(&obj, "cube2.plg",&vscale, &vpos, &vrot);

// set the position of the cube in the world
obj.world_pos.x = 0;
obj.world_pos.y = 0;
obj.world_pos.z = 100;

// return success
return(1);

} // end Game_Init
int Game_Init(void *parms)
{
// this function is where you do all the initialization 
// for your game

int index; // looping var

// start up DirectDraw (replace the parms as you desire)
DDraw_Init(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_BPP, WINDOWED_APP);

// initialize directinput
DInput_Init();

// acquire the keyboard 
DInput_Init_Keyboard();

// add calls to acquire other directinput devices here...

// initialize directsound and directmusic
DSound_Init();
DMusic_Init();

// hide the mouse
if (!WINDOWED_APP)
    ShowCursor(FALSE);

// seed random number generator
srand(Start_Clock());

Open_Error_File("ERROR.TXT");

// initialize math engine
Build_Sin_Cos_Tables();

// initialize the camera with 90 FOV, normalized coordinates
Init_CAM4DV1(&cam,      // the camera object
             CAM_MODEL_EULER, // the euler model
             &cam_pos,  // initial camera position
             &cam_dir,  // initial camera angles
             &cam_target,      // no target
             200.0,      // near and far clipping planes
             12000.0,
             120.0,      // field of view in degrees
             WINDOW_WIDTH,   // size of final screen viewport
             WINDOW_HEIGHT);

// load the master tank object
VECTOR4D_INITXYZ(&vscale,0.75,0.75,0.75);
Load_OBJECT4DV1_PLG(&obj_tank, "tank2.plg",&vscale, &vpos, &vrot);

// load player object for 3rd person view
VECTOR4D_INITXYZ(&vscale,0.75,0.75,0.75);
Load_OBJECT4DV1_PLG(&obj_player, "tank3.plg",&vscale, &vpos, &vrot);

// load the master tower object
VECTOR4D_INITXYZ(&vscale,1.0, 2.0, 1.0);
Load_OBJECT4DV1_PLG(&obj_tower, "tower1.plg",&vscale, &vpos, &vrot);

// load the master ground marker
VECTOR4D_INITXYZ(&vscale,3.0,3.0,3.0);
Load_OBJECT4DV1_PLG(&obj_marker, "marker1.plg",&vscale, &vpos, &vrot);

// position the tanks
for (index = 0; index < NUM_TANKS; index++)
    {
    // randomly position the tanks
    tanks[index].x = RAND_RANGE(-UNIVERSE_RADIUS, UNIVERSE_RADIUS);
    tanks[index].y = 0; // obj_tank.max_radius;
    tanks[index].z = RAND_RANGE(-UNIVERSE_RADIUS, UNIVERSE_RADIUS);
    tanks[index].w = RAND_RANGE(0,360);
    } // end for


// position the towers
for (index = 0; index < NUM_TOWERS; index++)
    {
    // randomly position the tower
    towers[index].x = RAND_RANGE(-UNIVERSE_RADIUS, UNIVERSE_RADIUS);
    towers[index].y = 0; // obj_tower.max_radius;
    towers[index].z = RAND_RANGE(-UNIVERSE_RADIUS, UNIVERSE_RADIUS);
    } // end for

// return success
return(1);

} // end Game_Init
Esempio n. 3
0
static void init()
{
    Build_Sin_Cos_Tables();
    RGB16Bit = RGB16Bit565;

    //glClearColor(0, 0, 0, 1);
    //glEnable(GL_CULL_FACE);
    //glCullFace(GL_BACK);

    //glEnable(GL_DEPTH_TEST);
    //glDepthFunc(GL_LESS);

    //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

    VECTOR4D cam_pos = {0, 40, 40, 1};
    VECTOR4D cam_dir = {0, 0, 0, 1};
    VECTOR4D cam_tar = { 0, 0, 0, 1};

    Init_CAM4DV1(&cam, CAM_MODEL_EULER, &cam_pos, &cam_dir, &cam_tar, 1.0f, 12000.0f, 90, WINDOW_WIDTH, WINDOW_HEIGHT);

    VECTOR4D vscale = { 1.0f, 1.0f, 1.0f, 1.0f };
    VECTOR4D vpos = { 0.0f, 0, 0, 1.0f };
    VECTOR4D vrot = { 0.0f, 180.0f, 0.0f, 1.0f };

    //Load_OBJECT4DV1_PLG(&obj, "model/towerg1.plg", &vScale, &vPos, &vRot);

    // load the master tank object
    VECTOR4D_INITXYZ(&vscale, 0.75, 0.75, 0.75);
    Load_OBJECT4DV1_PLG(&obj_tank, "model/tank2.plg", &vscale, &vpos, &vrot);

    // load player object for 3rd person view
    VECTOR4D_INITXYZ(&vscale, 0.75, 0.75, 0.75);
    Load_OBJECT4DV1_PLG(&obj_player, "model/tank3.plg", &vscale, &vpos, &vrot);

    // load the master tower object
    VECTOR4D_INITXYZ(&vscale, 1.0, 2.0, 1.0);
    Load_OBJECT4DV1_PLG(&obj_tower, "model/tower1.plg", &vscale, &vpos, &vrot);

    // load the master ground marker
    VECTOR4D_INITXYZ(&vscale, 3.0, 3.0, 3.0);
    Load_OBJECT4DV1_PLG(&obj_marker, "model/marker1.plg", &vscale, &vpos, &vrot);

    // position the tanks
    for (int index = 0; index < NUM_TANKS; index++)
    {
        // randomly position the tanks
        tanks[index].x = RAND_RANGE(-UNIVERSE_RADIUS, UNIVERSE_RADIUS);
        tanks[index].y = 0; // obj_tank.max_radius;
        tanks[index].z = RAND_RANGE(-UNIVERSE_RADIUS, UNIVERSE_RADIUS);
        tanks[index].w = RAND_RANGE(0, 360);
    } // end for


    // position the towers
    for (int index = 0; index < NUM_TOWERS; index++)
    {
        // randomly position the tower
        towers[index].x = RAND_RANGE(-UNIVERSE_RADIUS, UNIVERSE_RADIUS);
        towers[index].y = 0; // obj_tower.max_radius;
        towers[index].z = RAND_RANGE(-UNIVERSE_RADIUS, UNIVERSE_RADIUS);
    } // end for

    RGBAV1 ambient;
    ambient.a = 255;
    ambient.r = 128;
    ambient.g = 128;
    ambient.b = 128;

    RGBAV1 diffuse;
    diffuse.a = 255;
    diffuse.r = 255;
    diffuse.g = 255;
    diffuse.b = 255;

    RGBAV1 specular;
    specular.a = 255;
    specular.r = 255;
    specular.g = 255;
    specular.b = 255;


    VECTOR4D lightPos = {200, 200, 200, 1};
    VECTOR4D lightDir = { 1, 1, 1, 1 };

    //Init_Light_LIGHTV1(0, LIGHTV1_STATE_ON, LIGHTV1_ATTR_AMBIENT, ambient, diffuse, specular, &lightPos, &lightDir, 0, 0, 0, 0, 0, 0);
    Init_Light_LIGHTV1(0, LIGHTV1_STATE_ON, LIGHTV1_ATTR_INFINITE, ambient, diffuse, specular, &lightPos, &lightDir, 0, 0, 0, 0, 0, 0);
    //Init_Light_LIGHTV1(0, LIGHTV1_STATE_ON, LIGHTV1_ATTR_POINT, ambient, diffuse, specular, &lightPos, &lightDir, 1, 0, 0, 0, 0, 0);
    //Init_Light_LIGHTV1(0, LIGHTV1_STATE_ON, LIGHTV1_ATTR_SPOTLIGHT1, ambient, diffuse, specular, &lightPos, &lightDir, 1, 0, 0, 5, 20, 10);
    //Init_Light_LIGHTV1(0, LIGHTV1_STATE_ON, LIGHTV1_ATTR_SPOTLIGHT2, ambient, diffuse, specular, &lightPos, &lightDir, 1, 0, 0, 30, 60, 10);

    //LoadBmp();


    //indexBuffer = new GLuint[obj.num_polys * 3];
    //glGenVertexArrays(NumVAOs, VAOs);
    //glBindVertexArray(VAOs[VAO_1]);

    //glGenBuffers(NumBuffers, Buffers);
    //glBindBuffer(GL_ARRAY_BUFFER, Buffers[ArrayBuffer]);
    //glBufferData(GL_ARRAY_BUFFER, sizeof(POINT4D)* obj.num_vertices, NULL, GL_DYNAMIC_DRAW);
    //
    //glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, Buffers[ElementBuffer]);

    //glVertexAttribPointer(vPosition, 4, GL_FLOAT, GL_FALSE, 0, 0);
    //glEnableVertexAttribArray(vPosition);



    //ShaderInfo shaders[] = {
    //	{ GL_VERTEX_SHADER, "shader/common.vert" },
    //	{ GL_FRAGMENT_SHADER, "shader/common.frag" },
    //	{ GL_NONE, NULL }
    //};

    //GLuint program = LoadShaders(shaders);
    //glUseProgram(program);
}