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.

Author
Message
Jaskel
18
Years of Service
User Offline
Joined: 13th Jun 2006
Location:
Posted: 9th Nov 2006 23:23
Okay, can someone explain (or link to an explanation of) sprites to me? I get that you extract the sprite by indicating a pixel range, and I've done that to grab a whole image from a bitmap. However, how do you know which pixels to use if you only need a small part, and how do you use that to make the sprite animated?

The tutorial that came with DBC didn't really explain it well enough for me.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 10th Nov 2006 05:09 Edited at: 10th Nov 2006 05:12
Most of the time I load a graphic into a drawing program (like Paint Shop Pro) and at the bottom it shows the x and y where the mouse is. Put the mouse at the top left corner of where you want to grab and write down the x and y then move the mouse to the lower right corner and write down the x and y.

Most of the time you'll use a for/next loop to grab multiple images increasing the x by the image length (that you discover in the drawing program) and when you get to the end you reset x to 0 and increase y by the height of the images.

To animate it you need to grab several images and cycle through the images by changing the image number used by the sprite. If you have Pro you can use the "create animated sprite" command. If you do let me know and I'll post code on "create animated sprite".

Jaskel
18
Years of Service
User Offline
Joined: 13th Jun 2006
Location:
Posted: 10th Nov 2006 17:11 Edited at: 10th Nov 2006 18:01
Nope, don't have Pro, but thanks! I think I'm starting to understand now.

Edit: Actually, it's having problems. I tried to reduce it to 3 images so that I could test it out, and it won't load them to the screen.

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 10th Nov 2006 19:21
Np.

When you use "load image" its a combination of "load bitmap" and "get image"... so you don't need to grab the images if you use "load image".

Jaskel
18
Years of Service
User Offline
Joined: 13th Jun 2006
Location:
Posted: 10th Nov 2006 20:23
Okay, it works! Thank you!
Jaskel
18
Years of Service
User Offline
Joined: 13th Jun 2006
Location:
Posted: 11th Nov 2006 01:47
Okay, I'd make a new post but I read something saying not to do that.

I'm really starting to get this, and I was thinking of making little project with controls sort of like Asteroids or Sinistar (you know, involving thrust and rotation, etc). I've been told this involves vectors, so... would anyone like to explain that a little? ^^

It would be much appreciated.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 11th Nov 2006 03:45
That's probably what they'd be in Mame but not in Darkbasic. You can use sprites. The only thing is it's easier in Darkbasic Pro because of "rotate sprite". You'd have to rotate the sprite in a drawing program and save each frame. Going forward from whatever sprite angle you want would involve "sin" and "cos".
Antidote
19
Years of Service
User Offline
Joined: 18th Mar 2005
Location: San Francisco, CA
Posted: 11th Nov 2006 16:44
Actually asteroids can be done with vectors. This is a great tutorial that shows exactly how to do asteroids with vectors and goes into great detail about how to use them.

http://www.kentaree-studios.com/tutorials/vectors/index.htm

Jaskel
18
Years of Service
User Offline
Joined: 13th Jun 2006
Location:
Posted: 11th Nov 2006 19:51
Looks like it's for DB Pro. I only have Classic
Jaskel
18
Years of Service
User Offline
Joined: 13th Jun 2006
Location:
Posted: 12th Nov 2006 19:06 Edited at: 12th Nov 2006 19:42
okay, let's forget the vectors for a while. I've decided to make a game akin to Space Invaders (I'll need this question answered anyway)

Okay... I want to have it so that when the player presses space, it fires the laser. I have a sprite set up for the laser, but how do I make it appear from the position of the ship?

Edit: I'd also like to know if there is a way to reuse the same image as different sprites. I have 2 colors of the "basic" alien set up for the first level, and there will preferrably be more than just 2 ^^
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 12th Nov 2006 23:10
To find the x and y of a sprite use the commands "sprite x(spritenumber)" and "sprite y(spritenumber)".




Yes you can make any sprite use the same image... if the image changes all other sprites using that same image number will change.

Jaskel
18
Years of Service
User Offline
Joined: 13th Jun 2006
Location:
Posted: 13th Nov 2006 00:11
Haven't tried putting in the enemies yet, but I have the bitmaps loaded anyhow.



I'm having problems as I have indicated in the code (inside the rem section.
Dracula
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: DBP Recreation of Castle Csejthe
Posted: 13th Nov 2006 00:37
you need to have a flag variable that is set to say "1" while the laser is on the screen or until it hits an enamy. That is something like:



Hopefully this helps some

D
Jaskel
18
Years of Service
User Offline
Joined: 13th Jun 2006
Location:
Posted: 13th Nov 2006 20:53
It seems to make sense, but when I try to run the code with those additions made, I get the same problem (I erased the old lines, too.)

regardless of what the new shipx is, laserx is always 320. the lasery-3 lines seem to do nothing, as the sprite just sits in its spot. With the addition of the new code it doesn't even go up while the spacebar is held, which, is a good thing I guess, because it should be moving upward regardless.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 14th Nov 2006 01:37
You should probably post all the code you have so far and the media so we can see what's going on easier.
Jaskel
18
Years of Service
User Offline
Joined: 13th Jun 2006
Location:
Posted: 14th Nov 2006 03:01
Okay, attached the folder with the code inside. It's a RAR file.

I've gotten the laser to actually move now, but I'd like for the ship to be able to move after firing without the laserx value changing.

Attachments

Login to view attachments
Dracula
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: DBP Recreation of Castle Csejthe
Posted: 14th Nov 2006 04:44
I didn't look at your code, but looking at what I've told you, you need to increment the laser up while laserflag=1. Here's a small updated bit for you:



This is just my off the top of my head and I see potential optimization, but it should work now. Let me know if not.

D
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 14th Nov 2006 07:50
You want to define laserx inside the spacebar check. If you leave it outside it'll always follow the ship.

Jaskel
18
Years of Service
User Offline
Joined: 13th Jun 2006
Location:
Posted: 15th Nov 2006 17:57
Okay, thanks for the help so far. I've got the ship and the laser working right now, and I've loaded the enemy sprites into my code. There are 8 of them which are created with For Next loops.



So now, I'd like to make them move. They should move right, and when they reach the edge of the screen, go down one step and begin moving left.

I tried to get this working a few times, but to no avail.
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 16th Nov 2006 02:27 Edited at: 16th Nov 2006 02:28
There is an old thread (over a year) for a space invader clone project that
I helped with. It's definately not perfect (very rough and ugly in fact), but
it might prove useful to you I think. See if any of it helps.

http://forum.thegamecreators.com/?m=forum_view&t=54896&b=4
slicer 4 ever
18
Years of Service
User Offline
Joined: 11th Jul 2006
Location: currently: planet gamma3295
Posted: 16th Nov 2006 03:08 Edited at: 16th Nov 2006 03:10
i use a ok that's very simple although i should say i like using gosub commands to seperate parts of my code so

ai code:



sorry i havent tested that but it should work just add it into your code with a gosub command for example:



my smiles love me =-)=-)=-)(-=(-=(-=

Login to post a reply

Server time is: 2024-11-14 01:21:10
Your offset time is: 2024-11-14 01:21:10