🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Now I can't load a background.
I have fixed the problem of loading a bitmap up on the screen by drawing a background. But now the background doesn''t draw, but the bitmap does. It simply quits. Any help would be appreciated. Here is the code (I am using the "tricks..." console template.)
// all your initialization code goes here...
// load background image
Load_Bitmap_File(&bitmap8bit, "background.bmp");
Create_Bitmap(&background,0,0,800,600);
Load_Image_Bitmap(&background, &bitmap8bit,0,0,BITMAP_EXTRACT_MODE_ABS);
Set_Palette(bitmap8bit.palette);
Unload_Bitmap_File(&bitmap8bit);
// load the ship
Load_Bitmap_File (&bitmap8bit, "ship.bmp");
Create_BOB (&ship,252,296 , 256, 96, 2, BOB_ATTR_SINGLE_FRAME | BOB_ATTR_VISIBLE | BOB_ATTR_WRAPAROUND, DDSCAPS_SYSTEMMEMORY);
Set_Anim_Speed_BOB (&ship, 1);
Load_Frame_BOB (&ship, &bitmap8bit, 0, 0, 0, BITMAP_EXTRACT_MODE_ABS);
Unload_Bitmap_File (&bitmap8bit);
// set position
Set_Pos_BOB (&ship, 252, 296);
// return success
return(1);
} // end Game_Init
int Game_Main(void *parms)
{
// this is the workhorse of your game it will be called
// continuously in real-time this is like main() in C
// all the calls for you game go here!
int index; // looping var
// start the timing clock
Start_Clock();
// clear the drawing surface
DDraw_Fill_Surface(lpddsback, 0);
// read keyboard and other devices here
DInput_Read_Keyboard();
// game logic here...
if (keyboard_state[DIK_RIGHT])
{
ship.xv = 4;
}
if (keyboard_state[DIK_LEFT])
{
ship.xv = -4;
}
if (keyboard_state [DIK_UP])
{
ship.yv = -4;
}
if (keyboard_state [DIK_DOWN])
{
ship.yv = 4;
}
Move_BOB (&ship);
Draw_BOB (&ship, lpddsback);
ship.xv = 0;
ship.yv = 0;
;
// flip the surfaces
DDraw_Flip();
// sync to 30ish fps
Wait_Clock(30);
// check of user is trying to exit
if (KEY_DOWN(VK_ESCAPE) || keyboard_state[DIK_ESCAPE])
{
PostMessage(main_window_handle, WM_DESTROY,0,0);
} // end if
// return success
return(1);
} // end Game_Main
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement