Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: Hotshot on March 17, 2007

Title: Bload?
Post by: Hotshot on March 17, 2007
hey all,

When I try to load sprites in freebasic and it is crash!
Why does it crash as I got Bload from help files and copy paste it then run it then it crash when
the sprites on window screen!

I will be able show you on monday with picture of error saying somethings.

cheers
Title: Re: Bload?
Post by: rdc on March 17, 2007
You need to set a graphics screen before you use bload.
Title: Re: Bload?
Post by: Shockwave on March 17, 2007
Also you should post the code too.
Title: Re: Bload?
Post by: Clyde on March 17, 2007
Also a tip if you are using some versions of FBIDE, you can use the command Chdir Exepath to make sure the IDE looks in the 'program your creating's directory', and not that of the IDE.
Title: Re: Bload?
Post by: Hotshot on March 20, 2007
this is what I have got on here
Title: Re: Bload?
Post by: rdc on March 20, 2007
You will need to post the code. There is no way to tell what is going on from the screenie.
Title: Re: Bload?
Post by: Hotshot on March 21, 2007
Code: [Select]
Option Explicit
' Arrays
Dim floor(32*32*4) As Byte

' graphics init
SCreenres 640,480,16,2

Bload "floor01.bmp",@floor(0)    'bload floor01.bmp on address of array floor

Do   ' main loop

   Put(10,10), floor(0)        'put contents of floor into screen
   Sleep 1000   'This place needs a screen buffer, page flip or something
Loop Until multikey(&h01)
Title: Re: Bload?
Post by: Clyde on March 21, 2007
I've tried your code, and it works with no errors.

What version of Freebasic are you using, and what IDE are you using including version?

Quote from: Clyde From Earlier
Also a tip if you are using some versions of FBIDE, you can use the command Chdir Exepath to make sure the IDE looks in the 'program your creating's directory', and not that of the IDE.
Title: Re: Bload?
Post by: rdc on March 21, 2007
Try adding ExePath to your bitmap location:

Code: [Select]
Bload ExePath & "\floor01.bmp", @floor(0)

If you have the bitmap in a subfolder then add that to ExePath:

Code: [Select]
Bload ExePath & "\images\floor01.bmp", @floor(0)
Title: Re: Bload?
Post by: CoDeMaN on March 21, 2007
Also the above code crashes for me...
I changed picture and it didnt crash but it didnt display the pic just blank screen
Title: Re: Bload?
Post by: Clyde on March 21, 2007
For different images you'll need to change it's size in here:
Dim floor(32*32*4) As Byte

Or simplified:
Dim floor(ImageW*ImageH*4) As Byte

Replace ImageW and ImageH with the correct sizes.

Floor can be changed to anything you like. If you do, then make sure elsewhere that has floor is also changed to that of the new name.
Title: Re: Bload?
Post by: rdc on March 21, 2007
Use the ImageCreate function rather than making your own array. It is a lot easier:

You declare an any pointer:

Dim image_buffer As Any Ptr

Create the image:

image_buffer = ImageCreate( 320, 200)

This create an image with width of 320 and height of 200.

This use bload on the created image buffer:

bload "filename", image_buffer

You must then destroy the image when you are done with it:

ImageDestroy image_buffer
Title: Re: Bload?
Post by: rdc on March 21, 2007
The problem may be that you are not using the correct color depth. You need to select a screen color depth that matches your bitmap.

Here is a little example:

Code: [Select]
Dim myImage As Any Ptr

'You mus set the screen to the same color depth as bitmap
Screen 18, 32

'Create image buffer
myImage = Imagecreate(128, 128)
'Load the image
Bload Exepath & "\test.bmp", myImage
'Put the image
Put (200, 200), myImage

Sleep
'Destroy the image
Imagedestroy myImage
End

Put the attached bitmap in the same folder as the compiled program.
Title: Re: Bload?
Post by: Hotshot on March 21, 2007
ahhhh right....Now I get it.....thank u so much rdc
I will be able to create sprites in freebasic.....Brilliant!  :updance:
Title: Re: Bload?
Post by: rdc on March 21, 2007
Glad to help.