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 / Help Can't get Sprites to work...

Author
Message
MikeD
18
Years of Service
User Offline
Joined: 29th Mar 2006
Location:
Posted: 29th Mar 2006 10:36
Noobie here. I'm working through the book, "Beginner's Guide to DarkBASIC Game Programming. I've got to the chapter on sprites and I cannot get any of the examples to work! The simplest is in the snippet.

This one displays a black screen and does nothing more. If I run in a window I can also run task manager, which shows this process taking 50% of processor time and about 10MB of memory. No sprite though.

The other examples also don't work. One will display the sprite, but collisions are not detected. Another displays the sprite, but not the background image. (All is from the DPPro code on the CD and of course the F15.bmp is present in the same directory.

I'm using DNPro 5.9, but I get the same problems with the Trial version.


Has something changed since the book was published??

Mike
MikeD
18
Years of Service
User Offline
Joined: 29th Mar 2006
Location:
Posted: 29th Mar 2006 14:56
Dunno what happened to the source... Here it is:
MikeD
18
Years of Service
User Offline
Joined: 29th Mar 2006
Location:
Posted: 29th Mar 2006 16:36
Noobie here. I\'m working through the book, \"Beginner\'s Guide to DarkBASIC Game Programming. I\'ve got to the chapter on sprites and I cannot get any of the examples to work! The simplest is in the snippet:



This one displays a black screen and does nothing more. If I run in a window I can also run task manager, which shows this process taking 50% of processor time and about 10MB of memory. No sprite though.

The other examples also don\'t work. One will display the sprite, but collisions are not detected. Another displays the sprite, but not the background image. (All is from the DPPro code on the CD and of course the F15.bmp is present in the same directory.

I\'m using DNPro 5.9, but I get the same problems with the Trial version.


Has something changed since the book was published??

Mike
Yekoms
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location: Deep inside FUNCTION BlueSkys
Posted: 6th Apr 2006 15:10
Howdy,
I'm a newbee too, and also going thru the DarkBasic Beginners Guide while using DarkBasic Pro. I had the same problem when I got to the Sprite chapter. I also had to resort to the form to solve the problem, which was very helpful. I can't remember right off what solved the problem but will look thru my records to get you the answer. I'm now in the File Manager chapter.

Keep'em Movin
Yekoms
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location: Deep inside FUNCTION BlueSkys
Posted: 6th Apr 2006 15:49
Found it. It was back in December under the 2D All The Way Forum. If you do a search for "sprite" it should come up. Anywho, here is what the reply was:
It's because you're using Darkbasic Pro. All sprites in Pro (because of the DirectX) are actually 3D plains so you see the blue background because it's a 3D object.

Bitmap 0 is the screen. All other bitmap numbers are there but not seen automatically. To do a background in Pro you have to paste the image to the background. Since you're only using one single image for that bitmap use "load image" instead. This combines both the loading of the picture and the getting of the image at the same time.

It's also better to use "sync" in Pro. You must set the speed with "sync rate" and turn it on with "sync on"... once you do that everytime the computer sees "sync" it updates the screen.

+ Code Snippet
sync rate 0
sync on
sync ` This is only here because it needed another sync on my computer yours may not need it
hide mouse

load image "background.bmp",1
load image "F15.bmp",2
paste image 1,0,0
sprite 1,179,90,2
sync
wait key
[code/]

Hope this helps and hope you are enjoying it as much as I am.
Type ya later,
Yekoms

Keep'em Movin
Yekoms
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location: Deep inside FUNCTION BlueSkys
Posted: 6th Apr 2006 15:56
Must have forgotten the first statement. sorry....

Found it. It was back in December under the 2D All The Way Forum. If you do a search for "sprite" it should come up. Anywho, here is what the reply was:
It's because you're using Darkbasic Pro. All sprites in Pro (because of the DirectX) are actually 3D plains so you see the blue background because it's a 3D object.

Bitmap 0 is the screen. All other bitmap numbers are there but not seen automatically. To do a background in Pro you have to paste the image to the background. Since you're only using one single image for that bitmap use "load image" instead. This combines both the loading of the picture and the getting of the image at the same time.

It's also better to use "sync" in Pro. You must set the speed with "sync rate" and turn it on with "sync on"... once you do that everytime the computer sees "sync" it updates the screen.

[Code]
sync rate 0
sync on
sync ` This is only here because it needed another sync on my computer yours may not need it
hide mouse

load image "background.bmp",1
load image "F15.bmp",2
paste image 1,0,0
sprite 1,179,90,2
sync
wait key
[code/]

Hope this helps and hope you are enjoying it as much as I am.
Type ya later,
Yekoms

Keep'em Movin
MikeD
18
Years of Service
User Offline
Joined: 29th Mar 2006
Location:
Posted: 6th Apr 2006 17:41
Thanks

I'll try that later

I gave up and bought "Hands on DarkBASIC Pro Voume 1", which I'm working through.
Yekoms
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location: Deep inside FUNCTION BlueSkys
Posted: 6th Apr 2006 19:11
I got Vol 1 also but decided to finish the Beginners Guide B4 starting it as I only have 2 chapters left.

Keep'em Movin
MikeD
18
Years of Service
User Offline
Joined: 29th Mar 2006
Location:
Posted: 7th Apr 2006 11:26
You might find Vol 1 a bit frustrating. It is excellent, but it is very hands on. That means you almost have to start again. I decided not to follow the advice and have jsut read the book cover to cover and only done one or two of the activities. However I understand some aspects much better than after the other book.

I am trying to recreate 'Fly The Copter' and beginning to make progress. I'm still falling over because of undocumented 'features' though.

For example in another thread I posted about animated sprites. I may have found stumbled towards the answer, which is to do with the individual size of the sprites. If that is correct, it isn't mentioned in either book or the help:
16x16 works
32x32 works
64x64 works
128x128 works
50x50 does not
48x48 does not
That's all I've tried so far
MikeD
18
Years of Service
User Offline
Joined: 29th Mar 2006
Location:
Posted: 9th Apr 2006 19:38
OK got to the bottom of this. It is do do with the graphics card. A 16MByte Matrox M450 Dual head. I have no problems on another machine with a Radeon X300 card.
Me!
19
Years of Service
User Offline
Joined: 26th Jul 2005
Location:
Posted: 9th Apr 2006 21:16
for compatability it`s best to use textures/sprites/bitmaps etc in sizes of powers of 2, only newer cards can handle non power of two images afaik.



Dr Frankenstiens mum told him to make some new friends, not knowing where this was going to lead.

Login to post a reply

Server time is: 2024-09-24 19:29:27
Your offset time is: 2024-09-24 19:29:27