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 / Need Help... Shooting Bullet Problem

Author
Message
Skeletor
20
Years of Service
User Offline
Joined: 21st Jun 2004
Location: florida
Posted: 22nd Jun 2004 21:05
Okay I am in the process of making a game... My game is similar to like let say space invaders but its with people. My main char that you play as has dual pistols and Im trying to program the bullets to be fired when the player hits the spacebar. Now my problem is that when I program the bullets to be fired when spacebar()=1 if the player lets go of the space bar the bullets stop in mid air and when the player hits the space bar again the bullets continue from wherethey left off. If anyone has any sugestions I would really appreciate it.
eat much pie
20
Years of Service
User Offline
Joined: 9th Apr 2004
Location: Within the mind of a lowly mortal...
Posted: 22nd Jun 2004 22:13
ooooooooooooooooooooooh, this is painfully easy. I'm guessing you do something like: "if spacekey() then move object 1,10". If you do, then you're silly. Use something like:



If ou give some code/more specifics, then I'll be able to better help you.

Checkpoint Router: my very own AI routing program: http://www.angelfire.com/theforce/eatmuchpie
Skeletor
20
Years of Service
User Offline
Joined: 21st Jun 2004
Location: florida
Posted: 22nd Jun 2004 22:25
Alright tyvm I would give some code but atm it is painfully sloppy
roswell
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location: United States
Posted: 23rd Jun 2004 00:56 Edited at: 23rd Jun 2004 01:18
eat much pie is right. The "if spacekey()=1" line should just be a trigger to start the process of moving the bullet to the target. However, in your code, the only thing the computer has to do when the spacekey is depressed is to move the bullet 10 units. If the player continues to hold the spacekey down, the bullet will continue to progress forward 10 units at a time for every iteration of the loop.

You may want to make the bullet moving/creating processes entirely separate functions. Something like this:



/* You are not expected to understand this. */

Dual Athlon 2.0/1GB RAM/GeForce Ti4200-128/Win2000 Pro
Hop a long
20
Years of Service
User Offline
Joined: 12th May 2004
Location: The Code Dump
Posted: 24th Jun 2004 03:30 Edited at: 24th Jun 2004 03:34
Skeletor
You can also choose a "bullet life" value. Once your program gets the space bar signal decrease the bullet life and move the bullet each time you go through the loop.

Here is a simple example using this idea:
http://www.geocities.com/hifin2003/shootin-gallery.html
Skeletor
20
Years of Service
User Offline
Joined: 21st Jun 2004
Location: florida
Posted: 24th Jun 2004 04:00
cool thx guys!
O and my game is complete its under codebase for 2d games (Saddam's Army)... but atm whenever I try to upload my media and screen shot Im getting an error stating cannot contact sql server or something.
But as soon as the I get the media uploaded check it out and leave me some feedback. Thanks again

Login to post a reply

Server time is: 2024-09-22 14:30:30
Your offset time is: 2024-09-22 14:30:30