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.

DarkBASIC Discussion / Bitmaps <> Sprites

Author
Message
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 13th Aug 2010 07:02
Alright so I have been tracking this bug for the last hour or so with very little to show for it.

The program is a space invaders clone. The error is a BOB DOES NOT EXIST error and the line is a line that checks for Sprite Collision. There is no use of the SPRITE EXIST command before it because there are other checks that work perfectly (I made 0 changes to this section of code when the bug started).

The change was adding in barriers. The theory: create a new bitmap, paste the appropriate images onto it for all of the barriers, use GET IMAGE to grab it, and then use it as a sprite in the main loop.

I tracked the bug to the subroutine that creates the barriers then commented out every line of code in it. Then, one line at a time I un-commented it and ran the program. The problem line is:

CREATE BITMAP 14,640,50

Bitmap 14 is not used anywhere else and I have changed the number from 5-14-1 in that order. No changes. For some reason, creating the bitmap is making the program unable to find sprites.

Please tell me its a simple fix (or at least a DBC has memory issues with bitmaps thing). I am all out of ideas.

Attempted fixes since identifying problem line of code:
Delete the bitmap immediately after creating it----FAIL
Use SET CURRENT BITMAP to ensure I am working on the main screen---FAIL
Change any commonly used variable names in FOR-NEXT loops to unique names----FAIL

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Aug 2010 08:27
Are you making the bitmap at the start of the program? Might make a difference.

BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 13th Aug 2010 08:34
Hmmm that seems to have done the trick. Any idea why that is?

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Aug 2010 08:55
No!
It was just an inkling.

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 14th Aug 2010 06:00
@BN2

A reminder:

Whenever you create a bitmap, the programs focus is set to that bitmap until you use SET CURRENT BITMAP <to whatever - usually 0>

Also, whenever you use GET IMAGE, you have to call a sync after it or it may not register as being captured.

The same with PASTE SPRITE - you may need a sync after calling it depending on the timing of the update.

DBC


Enjoy your day.
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 14th Aug 2010 06:20
Quote: "
Hmmm that seems to have done the trick. Any idea why that is?"


When you create a new bitmap it might have resetted all sprites and images, I think that happend to me one time while making a map editor.

Login to post a reply

Server time is: 2024-04-26 04:12:59
Your offset time is: 2024-04-26 04:12:59