Sprite Loading Problem
In the project I''m currently working on I can load a 64x64 sprite just fine but when I try to add a 32x32 sprite strange things start happening. The image get''s all skewed and melded with the image of my 64x64 sprite. It doesn''t make sense to me. I''ve checked over my code many times and I don''t think there is anything wrong with it. It''s the same exact process I followed when loading the 64x64 sprite.
Anyone know what might be causing this?
The only possible solution I can think of is to make sure you are not loading an image bigger then the file. That has sometimes caused the image to be skewed for me. I mean, if the image is 32x32, remember that you can only load coordinates 0-31.
Hope this helps
------------------------------
Jonathan Little
invader@hushmail.com
http://www.crosswinds.net/~uselessknowledge
Hope this helps
------------------------------
Jonathan Little
invader@hushmail.com
http://www.crosswinds.net/~uselessknowledge
January 21, 2000 09:10 AM
A strange one without all of the facts, are you using DirectDraw?
If you are then I hope your not using the same surface (or memory area) to load the two images. If you use separate surfaces do you create them all the same size i.e 64x64 or is the size dependant on the image that is being loaded in.
If you are loading both images in the same program i.e load 64x64, then load 32x32, try just loading the 32x32 image by its self.
If non of this helps post the code of your loading function.
Please respond if you get it sorted out. I hate it when people don''t respond, even if it''s just to say thanks.
BYE.
If you are then I hope your not using the same surface (or memory area) to load the two images. If you use separate surfaces do you create them all the same size i.e 64x64 or is the size dependant on the image that is being loaded in.
If you are loading both images in the same program i.e load 64x64, then load 32x32, try just loading the 32x32 image by its self.
If non of this helps post the code of your loading function.
Please respond if you get it sorted out. I hate it when people don''t respond, even if it''s just to say thanks.
BYE.
Yes this is the oddest thing I have ever seen. To answer you questions - Yes I am using direct draw and No I''m not using the same surface. I also create the surfaces dependent upon what size the image is.
Eventually I plan to load them into the same game but when I had problems I created a little "demo" program that would load just my 32x32 sprite. Well the same problems occured. The funny thing is that I can use the same program (with some SLIGHT modifications and it displays a 64x64 sprite just peachy. This problem is bothering me.
I can post my code here but if you really want to get the full effect maybe you should leave me an e-mail address and I can zip up the project and send it to you. Than you can see what''s going wrong with the program.
Odd stuff.
Anyways here is the code
////////////////////////////////////////////////////////////
int Game_Init()
{
// this is called once after the initial window is created and
// before the main event loop is entered, do all your initialization
// here
DDraw_Init(640,480,8);
if (MapLoad ("NLDEMO.FMP", lpdd)) {
MessageBox (NULL, "Map failed to load", "error", MB_OK);
exit (-1);
}
MapInitAnims();
Load_Bitmap_File(&bitmap8bit,"crawl.bmp");
Set_Palette(bitmap8bit.palette);
Create_BOB(&crawler,96,96,32,32,1,BOB_ATTR_VISIBLE / BOB_ATTR_SINGLE_FRAME,0);
int frame_index = 0;
for (int index = 0; index < 1; index++)
{
for (int index2 = 0; index2 < 1; index2++)
{
Load_Frame_BOB(&crawler,&bitmap8bit,frame_index,index,index2, BITMAP_EXTRACT_MODE_CELL);
frame_index++;
}
}
Unload_Bitmap_File(&bitmap8bit);
Load_Animation_BOB(&crawler,0,1,crawler_face_east);
Load_Animation_BOB(&crawler,1,1,crawler_face_west);
Set_Animation_BOB(&crawler,1);
Set_Anim_Speed_BOB(&crawler,4);
Set_Vel_BOB(&crawler,0,0);
Set_Pos_BOB(&crawler,30,290);
ShowCursor(FALSE);
// return success or failure or your own return code here
return(1);
} // end Game_Init
///////////////////////////////////////////////////////////
int Game_Main()
{
HDC myhdc;
// this is the main loop of the game, do all your processing
// here
// for now test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE)) {
Game_Shutdown ();
SendMessage(main_window_handle,WM_DESTROY,0,0);
exit (-1);
}
if (KEYDOWN(VK_LEFT) && (xmapoffset > 0)) xmapoffset -= 2;
if (KEYDOWN(VK_RIGHT) && (xmapoffset < 640)) xmapoffset += 2;
// Start_Clock();
// DDraw_Fill_Surface(lpddsback,0);
if (MapDrawBG(lpddsback, xmapoffset, ymapoffset)) MapRestore ();
if (lpddsback->GetDC(&myhdc) == DD_OK)
{
SetBkColor( myhdc, RGB( 50, 10, 50 ) );
SetTextColor( myhdc, RGB( 255, 255, 0 ) );
TextOut( myhdc, 0, 0, "Testing", 7);
lpddsback->ReleaseDC(myhdc);
}
RECT screen_rect = {0,0,screen_width,screen_height};
//lpddclipper = DDraw_Attach_Clipper(lpddsprimary,1,&screen_rect);
Animate_BOB(&crawler);
Draw_BOB(&crawler,lpddsback);
DDraw_Flip();
//Wait_Clock(30);
// return success or failure or your own return code here
return(1);
} // end Game_Main
Well there is the bulk of the code. If you need more just let me know.
Thank you very much
Eventually I plan to load them into the same game but when I had problems I created a little "demo" program that would load just my 32x32 sprite. Well the same problems occured. The funny thing is that I can use the same program (with some SLIGHT modifications and it displays a 64x64 sprite just peachy. This problem is bothering me.
I can post my code here but if you really want to get the full effect maybe you should leave me an e-mail address and I can zip up the project and send it to you. Than you can see what''s going wrong with the program.
Odd stuff.
Anyways here is the code
////////////////////////////////////////////////////////////
int Game_Init()
{
// this is called once after the initial window is created and
// before the main event loop is entered, do all your initialization
// here
DDraw_Init(640,480,8);
if (MapLoad ("NLDEMO.FMP", lpdd)) {
MessageBox (NULL, "Map failed to load", "error", MB_OK);
exit (-1);
}
MapInitAnims();
Load_Bitmap_File(&bitmap8bit,"crawl.bmp");
Set_Palette(bitmap8bit.palette);
Create_BOB(&crawler,96,96,32,32,1,BOB_ATTR_VISIBLE / BOB_ATTR_SINGLE_FRAME,0);
int frame_index = 0;
for (int index = 0; index < 1; index++)
{
for (int index2 = 0; index2 < 1; index2++)
{
Load_Frame_BOB(&crawler,&bitmap8bit,frame_index,index,index2, BITMAP_EXTRACT_MODE_CELL);
frame_index++;
}
}
Unload_Bitmap_File(&bitmap8bit);
Load_Animation_BOB(&crawler,0,1,crawler_face_east);
Load_Animation_BOB(&crawler,1,1,crawler_face_west);
Set_Animation_BOB(&crawler,1);
Set_Anim_Speed_BOB(&crawler,4);
Set_Vel_BOB(&crawler,0,0);
Set_Pos_BOB(&crawler,30,290);
ShowCursor(FALSE);
// return success or failure or your own return code here
return(1);
} // end Game_Init
///////////////////////////////////////////////////////////
int Game_Main()
{
HDC myhdc;
// this is the main loop of the game, do all your processing
// here
// for now test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE)) {
Game_Shutdown ();
SendMessage(main_window_handle,WM_DESTROY,0,0);
exit (-1);
}
if (KEYDOWN(VK_LEFT) && (xmapoffset > 0)) xmapoffset -= 2;
if (KEYDOWN(VK_RIGHT) && (xmapoffset < 640)) xmapoffset += 2;
// Start_Clock();
// DDraw_Fill_Surface(lpddsback,0);
if (MapDrawBG(lpddsback, xmapoffset, ymapoffset)) MapRestore ();
if (lpddsback->GetDC(&myhdc) == DD_OK)
{
SetBkColor( myhdc, RGB( 50, 10, 50 ) );
SetTextColor( myhdc, RGB( 255, 255, 0 ) );
TextOut( myhdc, 0, 0, "Testing", 7);
lpddsback->ReleaseDC(myhdc);
}
RECT screen_rect = {0,0,screen_width,screen_height};
//lpddclipper = DDraw_Attach_Clipper(lpddsprimary,1,&screen_rect);
Animate_BOB(&crawler);
Draw_BOB(&crawler,lpddsback);
DDraw_Flip();
//Wait_Clock(30);
// return success or failure or your own return code here
return(1);
} // end Game_Main
Well there is the bulk of the code. If you need more just let me know.
Thank you very much
January 22, 2000 06:13 AM
Yeah, maybe you should post the project to me, ca8roh@isis.sunderland.ac.uk.
See you.
See you.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement