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.

Newcomers DBPro Corner / (2D,DBP) Multiple bullets? (Arrays?)

Author
Message
Zyronagon
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location: USA
Posted: 2nd Nov 2009 23:24
I'm making a 2d vertical scrolling shooter, but I don't know how to make multiple bullets onscreen without making entirely new sprites. I've read somewhere that I need to use "arrays", but I have no idea what those are or how they work. Could someone explain this to me and tell me how they work?
Mulderman
20
Years of Service
User Offline
Joined: 8th Jan 2004
Location: C:\\
Posted: 3rd Nov 2009 00:00 Edited at: 3rd Nov 2009 00:01
Read TDK tutorial about variables and arrays here
http://forum.thegamecreators.com/?m=forum_view&t=96069&b=7&p=0

Also video tutorials here
http://www.youtube.com/watch?v=It4p9V6eKe0
http://www.youtube.com/watch?v=q1S9ImeOxwQ

Forum search will return even more.

New GTA2 Map Editor :: http://www.gta2madness.co.cc
Zyronagon
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location: USA
Posted: 3rd Nov 2009 03:28
Look, I don't even know how using arrays will help me. I'm asking how to create multiple sprites that move the same and act the same without having to actually make a new sprite for each one, specifically bullets. If I DO have to use arrays, then my question is "How would I use arrays to do this?"
Mulderman
20
Years of Service
User Offline
Joined: 8th Jan 2004
Location: C:\\
Posted: 3rd Nov 2009 12:57
You can go without arrays but all people use arrays for such tasks.


That's why you need to read the tutorials.
You don't know if arrays will help you. And i say they help you alot.

Bullets and things are created with types and arrays.

New GTA2 Map Editor :: http://www.gta2madness.co.cc
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 3rd Nov 2009 15:13
Quote: "You can go without arrays but all people use arrays for such tasks."


Only if you want only a handful of bullets. You really do need arrays.

Check out tutorial 11 here which covers exactly what you are asking about:

Tutorials For Beginners

But, it assumes you understand arrays and if you don't it will just point you to the tutorial Mulderman pointed you to, so I suggest you read that one first.

TDK

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Nov 2009 17:45
Weather or not you use arrays you basically set some limits like:

Sprites 100 to 200 are good guy bullets
Sprites 201 to 300 are bad guy bullets

If you want to check for collision with bad guy ships check sprites 100 to 200. If you want to check for collision with the player check sprites 201 to 300. If a sprite collides with a ship or goes off the screen you can move it to a specific coordinate (-1000, -1000). When you want to create a new bullet for either side you check for sprites at -1000,-1000 because that's an unused bullet.

Arrays make it easier since you don't have to use commands like SPRITE X() and SPRITE Y() to always get the sprite coordinates since the coordinates are usually stored in the array.

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 3rd Nov 2009 19:11
But if you use types, you don't have to have such limits.

Consider this:


"everyone forgets a semi-colon sometimes." - Phaelax
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 4th Nov 2009 19:28
True, but it's still better to put in limits so you know the ranges not to use. If you want to add other things like menu sprites that won't be using the bullet UDT you may have problems if you accidentally use the wrong sprite number.

Sprites

1 - 30 = Menu Sprites
31 - 40 = Good guy ships
41 - 60 = Bad guy ships
61 - 99 = Misc ground graphics
100 - 200 = Good guy bullets
201 - 300 = Bad guy bullets

Login to post a reply

Server time is: 2024-09-28 12:16:59
Your offset time is: 2024-09-28 12:16:59