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
Farooqaaa
18
Years of Service
User Offline
Joined: 26th Jun 2006
Location: Universe
Posted: 30th Jul 2006 23:49
Hello,

I am a beginner and made a FPS (First Person Shooter). But i have a problem! see my code:-


When i click mouse then it decrease 8 or 10 from the ammo instead of decrease 1 on just a single click :S. Can some body help me fix it plz!!!!

Thanks

-----------------------
I will be a good Game Programmer soon!
Farooqaaa
18
Years of Service
User Offline
Joined: 26th Jun 2006
Location: Universe
Posted: 30th Jul 2006 23:54
[Edit]And also the sound repeats about 8 or 10 time on a single click. And when it repeats about 8 or 10 time the sound just get crash![/edit]

-----------------------
I will be a good Game Programmer soon!
Captain America
19
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Here
Posted: 31st Jul 2006 02:30
i think your problem is just that the computer does it so fast that it fires 10 bullets in the time you click the mouse once.

I've had these problems before too, but im not sure how to help you in this case because all the methods I know will freeze the game until you let go.

Sorry I cant help you, but read this thread and see if you can integrate it into your game.

http://forum.thegamecreators.com/?m=forum_view&t=84478&b=10

hope that helps.

Cap'n


Cheers,
Capt. America
Justin W
20
Years of Service
User Offline
Joined: 28th Apr 2004
Location: Vancouver, Canada
Posted: 31st Jul 2006 06:55 Edited at: 31st Jul 2006 06:59
What you need to do is add a delay timer to your shooting code.

if mouseclick()=1 and delay = 0
delay =30
do shooting stuff here
endif

if delay > 0 then dec delay

Thats how I have always done it, hope that helps.
Farooqaaa
18
Years of Service
User Offline
Joined: 26th Jun 2006
Location: Universe
Posted: 31st Jul 2006 13:20
Thanks for the help!

@Captain:- Thanks i used the help in the link that u gave me and that helped me i did it as:-


@Justin:- Also thanks for your help!

Thanks

-----------------------
I will be a good Game Programmer soon!
Farooqaaa
18
Years of Service
User Offline
Joined: 26th Jun 2006
Location: Universe
Posted: 31st Jul 2006 13:51
Another problem! see the code:-



When i holde the left click and try to move around, then it moves a bit slow. When i leave the left click it moves clear :S. Any solution for this problem?



Thanks

-----------------------
I will be a good Game Programmer soon!
Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 31st Jul 2006 13:54
that it moves slow is due the Wait 75.

it waits a while and stops the shole game for a while and then continues.it does it quick stopping so that explains the slow movements.

so never use a Wait 75 in a shooting code...use a timer and DELAY the shooting.

B-DA FIRE!
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 31st Jul 2006 14:06
About your first problem, if you want them to keep clicking in order to shoot, you could just use a FLAG value, which changes from 0 to 1. When it is at 0 you can shoot, but when it reaches 1 you can't, and it only goes back to 0 when you are not pressing the mouse.

EXAMPLE:



Just another way.

Farooqaaa
18
Years of Service
User Offline
Joined: 26th Jun 2006
Location: Universe
Posted: 31st Jul 2006 14:17
Thanks my problem solved!!

Thanks again SIXTY!

-----------------------
I will be a good Game Programmer soon!

Login to post a reply

Server time is: 2024-11-26 14:46:58
Your offset time is: 2024-11-26 14:46:58