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 / need help in sprite

Author
Message
Ed222
18
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 18th Nov 2007 21:21 Edited at: 18th Nov 2007 21:24
I need help in using this code


When i went to school a long time ago we would use this code to make sprites first we would use print screen after excuting it than save it as a bit map than we would get a sprite sheet and save it on the bit map and then in dark basic we would type

to get the sprite this is the part i'm stuck i've forgotten how to load the sprite please help me what should I type?
[edit] also I think i'm souppose to load the bit map the sprite is on i'm i right?
e.g.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 18th Nov 2007 22:44
@Ed
Yep, you're right so far
You don't load sprites thought you just type SPRITE n,x,y,img and DB creates it; [img] specifies the image number you want to use.

"You must be someone's friend to make comments about them." - MySpace lied.
LBFN
19
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 19th Nov 2007 00:02
You can create the image for a sprite using the 2D drawing commands available in DBC (which you have done). You can also create them in a separate program, such as MS Paint, and load the bitmap in and pull images off of it or you can use LOAD IMAGE "myimage.bmp",number
to load a single image into your program.

I would create a separate bitmap to load/grab/create images in. By using bitmap 0, you are drawing directly to the screen and it can be seen while it is happening. I would also recommend using the sync commands.

Lastly, the red, green and blue values used in the RGB command each have a max of 255.

LB
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 19th Nov 2007 00:30
Quote: "Lastly, the red, green and blue values used in the RGB command each have a max of 255. "

They do, but it wont return an error as this will still produce an integer that DB needs for colour, but it might not be what you wanted . I've tested it out and the values just wrap after rgb(255,255,255), so rgb(510,510,510) is white.

To understand colour in DB, you need to understand how the rgb command works. This short program shows how the rgb values are "stacked" on each other.

As you can see here blue is the least valued colour; each "unit" of blue is worth 1 "colour unit". Let's test this out

The screen is brightest blue.
The next colour up is green, as you saw in the last snippet, each "unit" of green is worth 256 "colour units" (256*blue); green relates to blue in much the same way as tens relate to units.
Let's test this out

The screen is now brightest green.
The final colour is red: each "unit" of red is worth 65536 "colour units" (256*green). Red relates to green like hundreds relate to tens.
Let's test this out

The screen is now brightest red.

hope this helps

"You must be someone's friend to make comments about them." - MySpace lied.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 19th Nov 2007 03:20
I've made a complete mess of your code here so...


It's too late for me to work out how you positioned those boxes, pretty smart
guess you're not as nooby as I thought
I noticed you start with CLS and all your commands are in caps
are you an old school BASIC programmer?

"You must be someone's friend to make comments about them." - MySpace lied.
Ed222
18
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 20th Nov 2007 00:29 Edited at: 20th Nov 2007 00:31
actually I didn't make these boxes this was from my teacher that asked us to use this code to make sprites anyways the cap cls was an result of a bad habit that I started to get from followng the teacher anyways that code was saved on a txt doc so I nevered typed that also I think it was tyler that wrote that my teachers helper so yeah I'm kind of a noob and I guess I deserve it for never listing to the teacher talk well ok I half listened anyways the credit should go to tyler feel free to use it
[edit]
if you figuer out how to.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 20th Nov 2007 02:48
@Ed
haha don't worry about it dude, everyone starts off as a noob
The code is pretty good but I've noticed a few bad things, like this

INK is being set to the same value every loop! The INK command should be before the loop, then the cpu only has to do it once.
I think he wrote it like that because the first loop's colour changes and he just copied the whole loop.

Did my colour stuff help?

"You must be someone's friend to make comments about them." - MySpace lied.
Ed222
18
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 22nd Nov 2007 00:52
@obese87
kinda
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 22nd Nov 2007 23:06 Edited at: 23rd Nov 2007 11:03
@Ed222

Maybe this applies... There is something I originally found confusing about using DBC. It was the term Bitmap. I was used to the idea that a bitmap was just a picture that ended with the extension .bmp . In DBC language, a bitmap is actually a screen or a page on which a picture is drawn or loaded to. The actual picture (regardless of the .bmp extension or .jpg etc.) is called an Image.

When you want to load a picture, you have to think of it in terms of loading an image. When you want to load the picture onto a specific screen, you think in terms of loading the image onto a bitmap. There are 32 screens that you can load an image onto. The only one you can see is Bitmap 0 . The other screens are hidden and are used for drawing things out of view.

So here is where the command differences come into play. When you use the command Load Bitmap you are telling DBC to load a picture onto a specific screen (ex load bitmap "mypicture.bmp",1 tells DBC to load your graphic named mypicture.bmp onto screen 1).

When you use the command Load Image you are loading your picture into memory with a specific image number. This image isn't displayed until you paste it onto the main bitmap 0. You can have up to 65535 different images loaded into memory.

Back to your question about sprites. LBFN was suggesting how to handle the images and the bitmaps (remember, in DBC a bitmap is the screen an image is displayed on) and OBese87 was explaining how to create a sprite. Once you have loaded your picture by either directly loading it onto a bitmap, or by loading it into memory as an image, you have to deal with the picture using Image commands. That is where Get Image comes into play. Get Image is only useful once one of your bitmap pages has a picture on it. If you loaded your graphic as an Image, you have to first paste that image onto a bitmap screen. If you loaded your graphic using Load Bitmap, then the picture is ready for manipulation.

A sprite is created from an image. You can use an image from memory, or you can create a new image by capturing a portion of a bitmap screen. Capturing the image from the bitmap screen seems to be the method your program is using. Once you have captured the image you are going to use as the sprite and assigned it an image number, you create the sprite by assigning the image to a specific sprite number using the sprite command:
Sprite <sprite number>,x,y,<image number> where x and y are the screen position of the top left corner of the sprite.

Though this explanation is long winded and a repeat of what the others had said, I think it's important to understand the distinction between a Bitmap in DBC and an Image.

Enjoy your day.
Ed222
18
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 22nd Nov 2007 23:52
@Latch thanks that really clears things up a lot
Ed222
18
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 23rd Nov 2007 00:55
hi me again i need help now to make the sprite move here i'll upload it here i want to make it look like the one in my 2d game beta and no i didn't do all the coding and i never did the sprite code before thats why i don't know i just want to make the sprite move inorge the bullet code.
P.S. I've noticed alot of people not having winrar so i made it into a self extracting file so there shouldn't be a problem.
demons breath
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 24th Nov 2007 11:30 Edited at: 24th Nov 2007 11:32
quick example of how to make a sprite move



that should work - haven't tested it yet though...


EDIT: OK it's fine now I just missed a comma on the dot command but I've added it in, apart from that it worked.

Ed222
18
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 25th Nov 2007 16:32
thanks

Login to post a reply

Server time is: 2026-07-06 02:52:11
Your offset time is: 2026-07-06 02:52:11