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.

Newcomers DBPro Corner / Loading sprite to screen

Author
Message
Kalktar
20
Years of Service
User Offline
Joined: 14th Jul 2004
Location:
Posted: 14th Jul 2004 14:22
Hi all! Im very very new to programming I'v recently purchased "The beginner's guide to DarkBasic programming" book and
I'm using DBPro for the compiler.

I'm on Chapter 11 trying to learn how to load sprites but something not working, when I try to run the program I get a blue screen. Can someone please take a look at the code and tell me what I'm doing wrong? The code is straight out of the book except "filename.bmp"
lol my bitmap size was 300x300

I'd appriciate any help

Thanks Kalk )
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 14th Jul 2004 15:06
Get image only copys from bitmap 0 or the objects in the screen. So It might be best to load it as an image and use

That book has alot of Dark Basic Classic usages in it. Or so I have heard.

Kalktar
20
Years of Service
User Offline
Joined: 14th Jul 2004
Location:
Posted: 14th Jul 2004 16:25
Wow! "load image" worked fine!! Thanks a ton
Ok sooo "get image" only grabs from bitmap 0 or objects from the screen ? I cant use "get image" to grab part of a bitmap and put it on screen using "sprite" command?? hmmm, Im a bit confused and have tons of questions, but I've just started to play with all the sprite commands. Guess I'll mess with them a bit and see if I can stay out of trouble. Really got my head going now not sure why/how I'd utilize "get image".

I get the impression the book I'm using may have a bit of misleading information in regaurds to DBPro. Thats ok now I know that may be an issue when I come across problems.

Once again thank you very much!
Kalk
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 14th Jul 2004 21:39
Yes, you can use get image to grab any portion of the screen that you might need to use, as in the following I used for my HexaPawn game code. (Also in DBC.)



In that case, I loaded a bitmap with all pieces of the images I needed, loaded one file, then grabbed them all to finally clear the screen for the game.
S.

Any truly great code should be indisguishable from magic.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 14th Jul 2004 22:17
A couple of things for DBPro:

Using LOAD BITMAP makes that bitmap the current one. You can switch to another by using SET CURRENT BITMAP. Bitmap 0 is the display.

GET IMAGE will grab an image from the current bitmap.

Sprites will draw to the current bitmap at sync time.

The simple fix for this is just to switch the current bitmap back to the display after you've grabbed your image.



*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 15th Jul 2004 00:11
So if sprites are drawn to the current bitmap. Why doesn't get image capture them from bitmap 0 when bitmap 0 is the current bitmap? But yes I was wrong about the grab image only working with bitmap 0 I just tested it out and IanM is correct. Thanks for the info that makes things more clear.

Kalktar
20
Years of Service
User Offline
Joined: 14th Jul 2004
Location:
Posted: 15th Jul 2004 00:38
HeHe I should have posted days ago instead of banging my head on the desk top. Yep all post code snippets work great. Thank you thank you! This leaves me thinking that writing code isnt as straight forward as originally thought? You can solve problems differently depending on how you approach it??
Ok I'm so really really far to the left on the learning curve !! I'm sure there will be many more strange questions from me.
I wonder if there may be a time when I actually can answer a question

Thanks
Kalk
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Jul 2004 04:06
Sprites cannot be captured *unless* you disable the backsave option for them.

Normal sprites work in this way:

- Sync
- Save the sprite background
- Draw the sprite
- Switch the display (so what was being displayed is what will be overwritten next time, and vice versa)
- Redraw the backgound
- Pass control back to the user-code

As you can see from this sequence, the background is returned back to its original state before you can get a chance to grab an image with a sprite.

If you switch off the backsave, then the saving and restoring of the background isn't done, so you can capture the sprites this way. The cost of this is that you have to take complete control over what is drawn on the bitmap.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 15th Jul 2004 05:33
I see thank you for the explaination.

Login to post a reply

Server time is: 2024-09-22 16:25:22
Your offset time is: 2024-09-22 16:25:22