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.

2D All the way! / Loading and Displaying Sprites

Author
Message
Tiggster
20
Years of Service
User Offline
Joined: 26th Jan 2004
Location: Indiana, USA
Posted: 26th Jan 2004 09:37
Hey everyone,

I'm reading through the Beginners Guide to DarkBASIC Game Programming and I'm running into a little trouble in chapter 11. I can't get the LoadSprite application to work. This is the first example from chapter 11.

`----------------------------------------------------------
`Beginner's Guide To DarkBASIC Game Programming
`Copyright (C)2002 Jonathan S. Harbour and Joshua R. Smith
`Chapter 11 - LoadSprite Program
`----------------------------------------------------------

`Initialize the program
SET DISPLAY MODE 640, 480, 32
HIDE MOUSE
`CLS
SYNC ON

`Load the source bitmap file
LOAD BITMAP "F15.bmp", 1

`Grab image 1 from bitmap
GET IMAGE 1,0,0,300,300

`Draw the sprite
SPRITE 1,170,90,1
SYNC

`Wait for keypress
WAIT KEY

END

Its supposed to display a sprite, but all I get is a blank window. I'm using DBPro with all the latest patches. Is there something more that I need to do in DBPro? This was the pro version of this demo though.

I modified a second program from the same chapter and stipped out everything I could and still get it to display. Here is its code:

SET DISPLAY MODE 640,480,32
HIDE MOUSE
SYNC ON

LOAD BITMAP "F15.bmp", 1
GET IMAGE 1,0,0,300,300

LOAD BITMAP "background.bmp", 0

DO
SPRITE 1,170,90,1
SYNC
LOOP

END

If I take the background bitmap command out, it doesn't display the sprite, and if doesn't display if I take out the loop. What exactly is the trick here? I'm kind of at a loss.

Any help or suggestions would be greatly appreciated.

Steve
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 26th Jan 2004 16:51
I don't know what's wrong with it, I don't have DBPro, but if you change this.......

LOAD BITMAP "F15.bmp", 1
GET IMAGE 1,0,0,300,300

To just one line like this......

Load Image "F15.bmp",1

It might fix it.

Pincho.

the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 26th Jan 2004 19:18 Edited at: 26th Jan 2004 19:18
It's because when you use the load bitmap or create bitmap commands it sets the current bitmap to the number of the new bitmap.
The screen is bitmap 0 so in order to see anything you either need to delete the bitmap or use SET CURRENT BITMAP 0 to see anything on the screen bitmap.

Like pincho says you should use the load image command if all you want to do with the image is use it as a sprite. One thing also not in your code is the LOAD/GET IMAGE texture flag which is used to stop dbpro scaleing and filtering the image for texture use which causes grapfical glitches if used on a sprite. To use it just put ",1" at the end of LOAD/GET IMAGE commands,
GET IMAGE 1,0,0,300,300
becomes
GET IMAGE 1,0,0,300,300,1
You can read more about the texture flag in the dbp command help for LOAD IMAGE.

Login to post a reply

Server time is: 2024-05-13 07:14:49
Your offset time is: 2024-05-13 07:14:49