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.

2D All the way! / Updating Sprites for weapons fire

Author
Message
CrayZemon
20
Years of Service
User Offline
Joined: 16th Jun 2003
Location: United States
Posted: 22nd Jun 2003 04:12
Well, after one entire week of feverish attemps to solve a problem in a tile-based verticle shooter engine I'm finally on my knees.

Could any of you provide any source code to sort of demonstrate an effecient, and somewhat robust weapon firing function that doesn't make sprite updating virtually impossible like I've made it. I want a player sprite to fire a weapon (say a plasma burst). I know how to make the sprite travel, but I can't seem to update multiple plasma bursts on the screen without running into some problems. Making it so that the sprite deletes and recycles itself after the plasma burst flies off the screen is cheating, cuz that's not what I want...

I've been pulling my hair out for about a week now, and would really appreciate your advice or code snippets. Mucho Gracias.
"I need gopher-chucks!!"
CrayZemon
20
Years of Service
User Offline
Joined: 16th Jun 2003
Location: United States
Posted: 23rd Jun 2003 08:16
Ok. I fixed it!!! I looked at the source code for a game called L-Type and utilized the same principle of hiding and re-displaying objects (sprites in this case) to achieve the effect I desire. It keeps the variable processing to a minimum and is easier to test. Sorry for the trouble

"I need gopher-chucks!!"
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 23rd Jun 2003 17:01
Yeah, it's great when you get your weapons working well .

I suggest using a delay too - so you can only fire ever 5 loops for example, then the bullets have time to exit the screen, and you don't fire silly little bursts when there's no bullets visible.

For example, if your variable was called PLYR_FIREDELAY, you would have a little bit of code like:

If controlkey()=1 and PLYR_FIREDELAY<0
PLYR_FIREDELAY=4
`fire handling
Endif
Dec PLYR_FIREDELAY,1


Van-B

My cats breath smells of cat food.
MIsfit410
20
Years of Service
User Offline
Joined: 14th Jun 2003
Location:
Posted: 23rd Jun 2003 17:26
we should have a sticky post, and collect all the pieces and parts involved in making various types of games...

I would LOVE to have the code to a game like Contra or Super Mario Brothers.

Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 23rd Jun 2003 19:10
Over at RGT - there is a Design, Thoery, and Ideas forum - although it's not hugely used. Maybe Rich will add one over here along with the makeover. With all the talent we have here, we still end up trawling the net and sites like 'Gamedev' for more advanced stuff. If we could just get the top DB'ers brains in a jar, we could charge admission to see them, ask them questions etc.

Or just pour salt on them, that'd be fun too .


Van-B

My cats breath smells of cat food.
CrayZemon
20
Years of Service
User Offline
Joined: 16th Jun 2003
Location: United States
Posted: 23rd Jun 2003 19:28
Yeah, I do use a delay. I have the weapon fire only one burst every half a second (or whatever I desire) when you're holding that fire-key down. The number of sprites I have available for the weapon changes according to the speed of the blast and the rapidity of 'em. I can see spread-fire weapons being a pain-in-the-butt to handle with this method, but possible. Any thoughts?
Thanks for the replies guys.

"I need gopher-chucks!!"
Porl
20
Years of Service
User Offline
Joined: 28th May 2003
Location: United Kingdom
Posted: 25th Jun 2003 13:05
Where did you get the L-Type Source code from? ..I would be really interested in having a look as Im having trouble getting my head around the weapons fire thing in one of my test programs..

Porl''
CrayZemon
20
Years of Service
User Offline
Joined: 16th Jun 2003
Location: United States
Posted: 25th Jun 2003 17:13
That's easy. From this forum page, go to the downloads section. There you will see multiple applications made in DBpro. Amond them is L-Type. Click on the image and it will take you to three options:
download code, download game, view code. Good stuff.

"I need gopher-chucks!!"
Porl
20
Years of Service
User Offline
Joined: 28th May 2003
Location: United Kingdom
Posted: 26th Jun 2003 14:48
thanks dude!!

Porl''
ftrules
20
Years of Service
User Offline
Joined: 1st Jul 2003
Location:
Posted: 1st Jul 2003 19:06
I'm really new to the whole programming thing.I'm working on a simple 2D scroller shooter to teach myself the basics. I can't figure out how to let there be more than one bullet on the screen at one time.It sounds like you're already past this so please help me!!!!

CrayZemon
20
Years of Service
User Offline
Joined: 16th Jun 2003
Location: United States
Posted: 3rd Jul 2003 05:14 Edited at: 3rd Jul 2003 05:18
The best way to do that is to make the sprites before-hand. Try this outside of the main loop:



Then you test for the fire-key press using a code similar to this:



Then you handle the blasts like this:



hope that helps. I know that only handles 5 blasts at a time, but that can be changed easily as well as the speed and gun-cool rate.

"I need gopher-chucks!!"

Login to post a reply

Server time is: 2024-03-29 09:13:04
Your offset time is: 2024-03-29 09:13:04