Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Sprite problem after switching to GDK

Author
Message
DavidD
18
Years of Service
User Offline
Joined: 6th May 2006
Location:
Posted: 31st May 2008 01:33
Hi,

This may have been answered, but I have searched thoroughly and haven't found it. I had a decent 2D game in development with DarkBasic Pro, and have recently switched to DarkGDK for the power of C. I'm teaching my Son to program, while getting back into the swing of things myself. Here's the problem, can't get a basic sprite to load with GDK. Code follows, any solutions would be greatly appreciated.




Originally, I thought maybe the compiler wasn't finding the .bmp file, but I have copied it to every directory I believe relevant, including the Debug and Release folders, and it still doesn't load. I have also tried the .bmp filename with no location (quotes only).
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 31st May 2008 02:06
Why are you doing dbGetImage()? It copies a portion of the current bitmap which, by default, should be the display, which wouldn't have an image at this point. You may be copying an empty screen over your image.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
DavidD
18
Years of Service
User Offline
Joined: 6th May 2006
Location:
Posted: 31st May 2008 02:11
GDK help files and examples use loadimage and getimage to prep the sprite command. At least that's my understanding:

dbSprite:
"...This command will set the position and image number of the specified sprite. Providing you are using a valid image number from a previous call to the dbGetImage command..."
waka324
16
Years of Service
User Offline
Joined: 31st Mar 2008
Location:
Posted: 31st May 2008 08:16
db sprite also creates the sprite from the specified image.

ie.

dbLoadImage("sprite.bmp",image_id);
dbSprite(sprite_id, x, y, image_id);

would create a sprite from sprite.bmp at cordinates x, and y.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 31st May 2008 08:41
Quote: "GDK help files and examples use loadimage and getimage to prep the sprite command. At least that's my understanding:"


I've never had to use a getimage function to prep an image for use with a sprite. It basically is there to overwrite a portion of your image. I don't think that's what you want. Have you actually tried commenting out the call to see if it makes a difference?

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 31st May 2008 08:47 Edited at: 31st May 2008 08:48
Try this


It works fine for me.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
DavidD
18
Years of Service
User Offline
Joined: 6th May 2006
Location:
Posted: 31st May 2008 15:56
Yes, your code segment works. But, it takes the entire image as the sprite. With getimage, I can specify only parts of the image to take as a sprite, and then I can make lots of sprites out of only one image.

I have got my code to work finally, but I had to switch to dbLoadBitmap to do so. The following is the code that actually works. It loads the image, and takes only a piece of the image to make the sprite (top left corner). So I guess the help file description of the language useage is incorrect.


Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 31st May 2008 17:47
Quote: "So I guess the help file description of the language useage is incorrect."


Where is it incorrect? It states that dbGetImage takes a portion of the current bitmap and copies it to the image. Since you hadn't loaded a bitmap and it apparently doesn't consider the display to be a bitmap you had nothing to copy. Of course, the screen at the time was blank.

If your bitmap is several images equally spaced you might consider using the dbCreateAnimatedSprite and use the set frame function to pick out one image.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office

Login to post a reply

Server time is: 2024-11-20 11:46:53
Your offset time is: 2024-11-20 11:46:53