Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started 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
-
You need to set a graphics screen before you use bload.
-
Also you should post the code too.
-
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.
-
this is what I have got on here
-
You will need to post the code. There is no way to tell what is going on from the screenie.
-
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)
-
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?
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.
-
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)
-
Also the above code crashes for me...
I changed picture and it didnt crash but it didnt display the pic just blank screen
-
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.
-
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
-
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.
-
ahhhh right....Now I get it.....thank u so much rdc
I will be able to create sprites in freebasic.....Brilliant! :updance:
-
Glad to help.