• Welcome to Dark Bit Factory & Gravity.
 

Bload?

Started by Hotshot, March 17, 2007

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hotshot

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

rdc

You need to set a graphics screen before you use bload.

Shockwave

Also you should post the code too.
Shockwave ^ Codigos
Challenge Trophies Won:

Clyde

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.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

Hotshot

this is what I have got on here

rdc

You will need to post the code. There is no way to tell what is going on from the screenie.

Hotshot


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)

Clyde

#7
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.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

rdc

Try adding ExePath to your bitmap location:


Bload ExePath & "\floor01.bmp", @floor(0)


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


Bload ExePath & "\images\floor01.bmp", @floor(0)


CoDeMaN

Also the above code crashes for me...
I changed picture and it didnt crash but it didnt display the pic just blank screen

Clyde

#10
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.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

rdc

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

rdc

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:


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.

Hotshot

ahhhh right....Now I get it.....thank u so much rdc
I will be able to create sprites in freebasic.....Brilliant!  :updance:

rdc

Glad to help.