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 / New shooting arcade game help.

Author
Message
Gingerkid Jack
19
Years of Service
User Offline
Joined: 15th May 2005
Location: UK
Posted: 16th Nov 2009 21:20 Edited at: 16th Nov 2009 21:22
Hello, I decided to try and make a simple working arcade game which is where you try and survive against kamikaze UFO's and stuff, however I've written about a million different ways of making the UFO's spawn and float down towards the bunker but none work so I was wandering if anyone could spin me round and point me in the right direction thanks.

So in short, how can I instance lots of different sprites which i can then check bullet collision with and remove when hit.

Here is a screenshot of the game so far:



PS: The big blue shop will only appear at the end of each "round".

TheCleverGuyz

Attachments

Login to view attachments
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Nov 2009 00:25
Quote: "So in short, how can I instance lots of different sprites which i can then check bullet collision with and remove when hit."


Translation: How do I write my game?...

There's no way to tell you 'in short' how to do what you ask because essentially, that is your game.

All games - even simple ones like yours - consist of lots of smaller sub-topics. In the sentence I quoted above, you are talking about game logic, sprites and collision - each one time consuming to learn.

You are asking us to tell you something most of us have spent months and years learning to do.

You are trying to lump all of them together in your program without learning how they all work first. If you had learnt the 'building blocks' of programming already, you wouldn't be asking the question you asked.

So, what you need to do is split your game up into different parts which require different programming skills, then put your game to one side for a little while.

Take sprites for example:

You need to write some very basic sprite programs and build up to examples which use arrays for their screen positions. (If you don't understand arrays, then check out my tutorials).

Then do the same with collision and so on until you have an understanding of what everything does. Then you can think about joining it all together to write a game.

Seriously, no-one is going to be able to answer your question without writing a novel, or writing your program for you.

Good luck..

TDK

Gingerkid Jack
19
Years of Service
User Offline
Joined: 15th May 2005
Location: UK
Posted: 17th Nov 2009 08:47
I know about sprites and collision with them as I made a breakout game using them anyway I think I have figured out how to do it.

Thanks anyway.

TheCleverGuyz
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 17th Nov 2009 09:29
Collision would be the same as your breakout games ball (bullet) vs brick (UFO). The SPRITE COLLISION command can return the sprite number it's hitting so you can detect exactly which sprite to remove when a bullet hits it.

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Nov 2009 13:00
Quote: "I know about sprites and collision"


So it's only the creation, movement and removal of multiple sprites that you aren't sure about then?

Keeping your questions as specific as possible give them a lot better chance of being answered. More 'general' questions on different topics may not.

Controlling Multiple Sprites:

One method is to use arrays to store the X and Y position of each sprite and whether it exists or not. When a sprite exists the 'exist array' element for that sprite is set to 1 and when it is hit and removed, is set to 0.

When a new sprite is spawned, the exist array is scanned until an empty slot is found (contains 0). The slot is used, the exists array set to 1 and the position array initialised at that sprite's starting position.

Moving the sprites is done in a loop counting from 1 to MaxSprites, only updating and repositioning a sprite if it exists (the exists array element of the sprite in question is set to 1).

TDK

Gingerkid Jack
19
Years of Service
User Offline
Joined: 15th May 2005
Location: UK
Posted: 17th Nov 2009 17:04
Thanks alot TDK thats what I was looking for, I was scanning through your 2D shooting tutorial which helped me alot as well thanks again.

TheCleverGuyz
Gingerkid Jack
19
Years of Service
User Offline
Joined: 15th May 2005
Location: UK
Posted: 17th Nov 2009 18:45 Edited at: 17th Nov 2009 18:47
Sorry for double post but im stuck, here is the code I used to spawn the enemies:




However when I try and check collision with the sprites it comes up with an error. Especially when I do this? What does the error mean and can anybody give me any clues to fix it?



I don't have a clue on earth what to do. Are those arrays local or something? But it's driving me nuts.

TheCleverGuyz
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 18th Nov 2009 04:46
Quote: "it comes up with an error"


Telling us what error would be useful...

Quote: "Are those arrays local or something?"


An array is only local to a function if the array is dimensioned inside that function. (All covered in the tutorials).

Use the help files to look up:

Sprite Collision (N,0)

TDK

Login to post a reply

Server time is: 2024-11-23 22:33:32
Your offset time is: 2024-11-23 22:33:32