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 Professional Discussion / very basic problem

Author
Message
Patgarret
23
Years of Service
User Offline
Joined: 24th Jun 2003
Location:
Posted: 25th Jun 2003 01:20
here is the code
I cant figure out why in the hell all I get is a black screen. the bmp file is there in the same dir and all the pixel size are okey dokey.
Please help


SET DISPLAY MODE 640, 480, 32
HIDE MOUSE
`CLS
SYNC ON

`Load the source bitmap file
LOAD BITMAP "F15.bmp", 1

`Grab image 1 from bitmap
GET IMAGE 1,0,0,300,300

`Draw the sprite
SPRITE 1,170,90,1
SYNC

`Wait for keypress
WAIT KEY

END
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Jun 2003 01:32
After the GET IMAGE command, put the line 'SET CURRENT BITMAP 0'
Patgarret
23
Years of Service
User Offline
Joined: 24th Jun 2003
Location:
Posted: 25th Jun 2003 01:36
but I want the plane on the background. In the way u suggest the background gets delated!

the sprite command should display on the screen. Even if I dont use the zero slot. Isn't it?

spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 25th Jun 2003 01:37
Remember bitmap 0 is the screen. You are loading piccy into a new bitmap 1 but grabbing from bitmap 0.

after LOAD command, SET CURRENT BITMAP 1, get image is ok as it is, then SET CURRENT BITMAP 0

Alternativly, if bitmap is correct size, why not just LOAD IMAGE "F15.bmp",1 or LOAD IMAGE "F15.bmp",1,1 if you want pixel perfection

Don't do drugs kids. There is a time and place for everything. It's called college.
Patgarret
23
Years of Service
User Offline
Joined: 24th Jun 2003
Location:
Posted: 25th Jun 2003 01:53
this is the right code?

it doesn't work...Im getting mad

SET DISPLAY MODE 640, 480, 32
HIDE MOUSE
SYNC ON
LOAD BITMAP "F15.bmp", 1
set current bitmap 1
GET IMAGE 1,0,0,300,300
set current bitmap 0
SPRITE 1,170,90,1
SYNC
WAIT KEY
END

spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 25th Jun 2003 02:02
Sprites only appear if in a loop

DO
SYNC
LOOP

Don't do drugs kids. There is a time and place for everything. It's called college.
Patgarret
23
Years of Service
User Offline
Joined: 24th Jun 2003
Location:
Posted: 25th Jun 2003 02:17
uh...now it appears to work...
a question...what about if I want to display that image on a background? I would use this code, but it doesn't work.
That's because now I'd like to know how to display multiple images at the same time.
By the way, guys, dont buy the book "beginners guide to dark basic programming" as you can see from my posts all the coding is mess up.

SET DISPLAY MODE 640, 480, 32
HIDE MOUSE
SYNC ON

load bitmap "background.bmp",0
LOAD BITMAP "F15.bmp", 1
set current bitmap 1

GET IMAGE 1,0,0,300,300
set current bitmap 0

do
SPRITE 1,170,90,1
SYNC
loop

WAIT KEY
END

spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 25th Jun 2003 02:45
Please excuse messy code but should give you idea:

HIDE MOUSE
SYNC ON
load bitmap "background.bmp"
LOAD BITMAP "f15.bmp", 1
set current bitmap 1
GET IMAGE 1,0,0,300,300
set current bitmap 0
sync
SPRITE 1,170,90,1
set sprite 1,1,1
offset sprite 1,150,150
do
rotate sprite 1,wrapvalue(sprite angle(1)+1)
move sprite 1,1
SYNC
loop

WAIT KEY
END

Don't do drugs kids. There is a time and place for everything. It's called college.
spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 25th Jun 2003 02:47
If the f15.bmp is already 300 by 300, then bypass all that bitmap stuff and just load it straight into an image for use as a sprite.

p.s. you only do the SPRITE command once, outside the loop. Once initialised it is auto pasted at every sync command. All you do in loop is rotate, size and move it about.

Don't do drugs kids. There is a time and place for everything. It's called college.
Patgarret
23
Years of Service
User Offline
Joined: 24th Jun 2003
Location:
Posted: 25th Jun 2003 14:18
Ok, now...I have this tutorial here, downloaded from this site...and it says that by typing this code the sprite should appear:

load image "sprite.png",1,1
sprite 1,240,190,1
wait key

and there is no "set current bitmap 0"
now this clashes with what you say about displaying images on the screen? and it is also what my book says....
WHO IS RIGHT?


I guess that's you Sonic, for the simple reason that with the code you provided it works...but I want to understand...

thanks

spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 25th Jun 2003 14:27
Can't help you as I'm at work for next 7 hours or so. This is also first time I have used any sprite commands but I think I am correct.

Regarding bitmap commands.

bitmap 0 is the screen but you may load images into other bitmaps.

you are loading your plane into bitmap 1 but the get image command uses the CURRENT BITMAP which you can change at will. therefore you change to bitmap 1 to grab plane into image 1 which you later use as a sprite. You then set current bitmap back to 0 so you can see whats going on.

Now, it would be a lot easier to make sure f15.bmp was already correct size and simply use load image command to bung it straight into image 1 and then you would not need any bitmap commands at all.

Make sense?

Don't do drugs kids. There is a time and place for everything. It's called college.
Patgarret
23
Years of Service
User Offline
Joined: 24th Jun 2003
Location:
Posted: 25th Jun 2003 15:01
I'm at work too...
anyway I think that I should learn more about the "load image" command 'cause it works perfectly with no "set current bitmap" command. The sprite gets drawn on the screen perfectly

great! thank you very much

Login to post a reply

Server time is: 2026-07-17 23:12:00
Your offset time is: 2026-07-17 23:12:00