Advertisement

direct input keyboard repeat rate

Started by September 21, 2000 04:22 PM
12 comments, last by DiscoStoo 24 years, 3 months ago
No offense taken bitblt, it was just the first thing that came into my head. This was also tainted by the fact that i''m a total newbie, lol.

Sincerely,
Jonathan
A.K.A. -- Fourth Horseman
Sincerely,JonathanA.K.A. -- Fourth Horseman
Oh, alsom maybe you could help me with something then, lol. I got this massive problem. I am working on a little dumb game right now just to get experience and I had to come up with a way to scroll the screen. BUT I AM NOT USING AN ISOMETRIC ENGINE! I came up with this. The problem though is that if you keep on cycling to the right after about 20 seconds my comp starts to MASSIVELY slow down and animation for BOBs start to take 10 times as long to complete -- serious. I need help, what''s my problem ? my logic ?

-------------- START CODE HERE --------------

int Game_Main(void *parms)
{

int xBackCoord = 0;
int yBackCoord = 0;
#define SCREEN_WIDTH = 640
#define SCREEN_HEIGHT = 480

// test if man is close to positive x edge
if (man.x >= (SCREEN_WIDTH/4)) {
xBackCoord += (SCREEN_WIDTH/4);
man.x = (SCREEN_WIDTH/4);
}

// load background image
Load_Bitmap_File(&bitmap8bit, "DUNGEON2.BMP");
Create_Bitmap(&background_bmp,xBackCoord,yBackCoord,640,480);
Load_Image_Bitmap(&background_bmp, &bitmap8bit,0,0,BITMAP_EXTRACT_MODE_ABS);
Set_Palette(bitmap8bit.palette);
Unload_Bitmap_File(&bitmap8bit);

// return success
return(1);

} // end Game_Main


------------- FINISH CODE HERE --------------

This is just a portion of the code, but it''s all the info required to see if there''s a prob.




Sincerely,
Jonathan
A.K.A. -- Fourth Horseman
Sincerely,JonathanA.K.A. -- Fourth Horseman
Advertisement
maybe this isnt correct but why do you load the BMP each time?
No, that''s not it, but here''s the entire code anyways:

------------- START CODE HERE -----------------

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
DD_Fill_Surface(lpddsback, 0);

// lock back buffer and copy background into it
DD_Lock_Back_Surface();

// draw background
Draw_Bitmap(&background_bmp, back_buffer, back_lpitch,0);

// unlock back surface
DD_Unlock_Back_Surface();

// read keyboard
DI_Read_Keyboard();

// animate the man
Animate_BOB(&man);

// let player move the man
// allow player to move
if (keyboard_state[DIK_RIGHT])
man.x+=12;
else
if (keyboard_state[DIK_LEFT])
man.x-=12;

if (keyboard_state[DIK_UP])
man.y-=12;
else
if (keyboard_state[DIK_DOWN])
man.y+=12;

int chk_mveloop = 0;

// test if man is close to positive x edge
if (man.x >= (SCREEN_WIDTH - (SCREEN_WIDTH/8))) {
xBackCoord += (SCREEN_WIDTH - (SCREEN_WIDTH/8));
yBackCoord = 0;
man.x = (SCREEN_WIDTH - (SCREEN_WIDTH/8));
chk_mveloop++;
}

if (chk_mveloop >= 5) {
Draw_Text_GDI("chk_mveloop is more than or equal to 5.",10, 20,RGB(0,255,255), lpddsback);
};


// load background image
if (chk_mveloop = 2) {
Load_Bitmap_File(&bitmap8bit, "DUNGEON2.BMP");
Create_Bitmap(&background_bmp,xBackCoord,yBackCoord,640,480);
Load_Image_Bitmap(&background_bmp, &bitmap8bit,0,0,BITMAP_EXTRACT_MODE_ABS);

};

// draw the man
Draw_BOB(&man, lpddsback);

// flip the surfaces
DD_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);

// stop all sounds
Stop_All_Sounds();

// do a screen transition
Screen_Transitions(SCREEN_DARKNESS,NULL,0);

} // end if

// return success
return(1);

} // end Game_Main

----------------- END CODE HERE ------------------

Thanks.

Sincerely,
Jonathan
A.K.A. -- Fourth Horseman
Sincerely,JonathanA.K.A. -- Fourth Horseman

This topic is closed to new replies.

Advertisement