//initializes the game
int Game_Init(HWND hwnd)
{
//set random number seed
srand(time(NULL));
int first, second, third,r;
first = 180;
second = 355;
third = 535;
StartGame = false;
spawn = false;
//create sprite handler object
result = D3DXCreateSprite(d3ddev, &sprite_handler);
if (result != D3D_OK)
return 0;
//load texture with "pink/magenta" as the transparent color
maincar_image = LoadTexture("maincar.png", D3DCOLOR_XRGB(255,0,255));
if (maincar_image == NULL)
return 0;
//load the background image
intro = LoadSurface("intro.png", NULL);
if (intro == NULL)
return 0;
back = LoadSurface("flatbackground.bmp", NULL);
if (back == NULL)
return 0;
//initialize the sprite's properties
maincar.x = (SCREEN_WIDTH / 2 - 50 );
maincar.y = SCREEN_HEIGHT-150;
maincar.width = 100; //location in the image file
maincar.height = 150; //location in the image file
maincar.curframe = 0;
maincar.lastframe = 1; //12
maincar.animdelay = 3;
maincar.animcount = 0;
maincar.movex = 3; //change this to any value and see the effect
srand((unsigned int)time(NULL));
r = rand() % 3 + 1;
if (r == 1)
{
car2[n].x = first;
}
if (r == 2)
{
car2[n].x = second;
}
if (r == 3)
{
car2[n].x = third;
}
car2[n].y = 0;
car2[n].width = 84; //location in the image file
car2[n].height = 148; //location in the image file
car2[n].curframe = 0;
car2[n].lastframe = 1; //12
car2[n].animdelay = 3;
car2[n].animcount = 0;
car2[n].movey = 1; //change this to any value and see the effect
}
//return okay
return 1;
}
//the main game loop
void Game_Run(HWND hwnd)
{
//make sure the Direct3D device is valid
if (d3ddev == NULL)
return;
//after short delay, ready for next frame?
//this keeps the game running at a steady frame rate
if (GetTickCount() - start >= 30) //big value slow animation effect
{
//reset timing
start = GetTickCount();