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 / sprites....

Author
Message
jlb1987
20
Years of Service
User Offline
Joined: 10th May 2005
Location:
Posted: 21st Aug 2005 16:06
I really am stuck with how to create a sprite. I have experiance with a lot of the 3D features in DB, but I want to make 2D games with sprites, really. Having made this decision last night, I tried to teach myself via the DB command list how to create and move sprites but with no success. So far I've managed to load a bitmap image using the load bitmap command, like this

load bitmap "x.bmp"

this worked; then I tried to add a number after it like this

load bitmap "x.bmp",1

however, after adding the number, the bitmaped image would not appear. I am assuming it is some blindingly obvious mistake, but my questions are 1)Why was there just a black screen, nothing else, after adding the number; 2)How do I make a sprite; 3)How do I move sprites?

I know I must sound like a dumb n00b or something... I guess that is because I am. But any help would be appreciated.

"We dads have a saying- You can't fix it 'til you've broken it." Brian Johnson.
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 21st Aug 2005 16:39 Edited at: 25th Mar 2011 07:11
In regards to the bitmap problem, well DB treats Bitmaps as if they were screens. There's 32 ish (from memory) bitmaps (screens) Bitmap zero being the screen. So your loading your picture to one of the (invisible) bitmaps

With bitmaps you can copy section of them and even draw to them, but their really not what you want. You want IMAGES.

If you load your picture as an IMAGE, it can then be pasted at will to the current bitmap (which is by default the screen)... but you can't draw to it !.. there's always a catch

; load the image into slot #1
load image "MyPIcture.bmp",1

; draw it x position 200 and y pos 100
paste image 1,200,100


Sprites use images, their really just management layer.. anyway that should get you started

jlb1987
20
Years of Service
User Offline
Joined: 10th May 2005
Location:
Posted: 21st Aug 2005 17:11
It shall, indeed, get me started at least, it would appear I was ignorant of any image command... You are a gentleman, thank you very much.

"We dads have a saying- You can't fix it 'til you've broken it." Brian Johnson.
greg man
21
Years of Service
User Offline
Joined: 6th May 2004
Location:
Posted: 21st Aug 2005 23:29
another way to load images is to load a bitmap then use the 'get image' command. the difference between that and load image is that you can load only a small part of a bitmap and also you can load lots of images from 1 bitmap. the downside is that you have to tell the program exactly which part of the bitmap you want.


(ps. i usually delete each bitmap after i've got the images i need cos it saves on memory)

making and moving sprites is quite easy when you have your images loaded. you use the 'sprite' command.



the first 1 after 'sprite' is the number you want the sprite to be.
the next number is the x position on the screen you want to put the sprite at and the next number is the y position. the last number is the image you want the sprite to look like.

to make the sprite move you just make the x and y positions variables and change them



I hope this helped

Login to post a reply

Server time is: 2025-05-22 14:05:33
Your offset time is: 2025-05-22 14:05:33