Comments on: Shooting Mechanism Demo http://www.scriptedfun.com/shooting-mechanism-demo/ Game Programming for Beginners: Video Tutorials, Source Code, and Articles Mon, 18 May 2009 14:34:51 +0000 hourly 1 http://wordpress.org/?v=3.3.1 By: Chuck http://www.scriptedfun.com/shooting-mechanism-demo/comment-page-1/#comment-1091 Chuck Wed, 31 Jan 2007 02:12:18 +0000 http://www.scriptedfun.com/shooting-mechanism-demo/#comment-1091 Hi Nick. I think that making a game is a great way to learn C++, or programming in general. I hope you succeed in this! Regarding your question, I think that I could help you better if you would send me or post a snippet of the code which deals with firing. In the meantime, my guess is that you coded your game to fire bullets when the spacebar is held down. However, this check is done around 20 to 60 times per second (depending on the way you constructed your game loop). When you press the spacebar, it's not actually held down for just 1/60th of a second; it could be half a second for instance, and in such a case your plane would fire 30 shots in a half a second, which is probably what you're experiencing. To remedy this, I suggest that you keep a copy of the previous state of your spacebar. And instead of checking whether the spacebar is held down or not, do a check on whether the state of the spacebar changed - just compare the previous state and the current state. If the state has changed, that's when you check whether or not the spacebar is held down. If both conditions are fulfilled, then make a bullet fire. I hope this all made sense - I will try to elaborate further in another post, hopefully with source code. Good luck with your game! Hi Nick. I think that making a game is a great way to learn C++, or programming in general. I hope you succeed in this!

Regarding your question, I think that I could help you better if you would send me or post a snippet of the code which deals with firing.

In the meantime, my guess is that you coded your game to fire bullets when the spacebar is held down. However, this check is done around 20 to 60 times per second (depending on the way you constructed your game loop). When you press the spacebar, it’s not actually held down for just 1/60th of a second; it could be half a second for instance, and in such a case your plane would fire 30 shots in a half a second, which is probably what you’re experiencing.

To remedy this, I suggest that you keep a copy of the previous state of your spacebar. And instead of checking whether the spacebar is held down or not, do a check on whether the state of the spacebar changed – just compare the previous state and the current state. If the state has changed, that’s when you check whether or not the spacebar is held down. If both conditions are fulfilled, then make a bullet fire.

I hope this all made sense – I will try to elaborate further in another post, hopefully with source code.

Good luck with your game!

]]>
By: Nick http://www.scriptedfun.com/shooting-mechanism-demo/comment-page-1/#comment-1081 Nick Wed, 24 Jan 2007 05:57:22 +0000 http://www.scriptedfun.com/shooting-mechanism-demo/#comment-1081 hello, it's real funny because i went searching for some help on a solution to my "rate of fire" problem and it came up with this blog. the funny part is im making a similar game with the same sprite sheet (unknowingly of course). anyway, i was looking for some help on making a standard rate of fire. i am having the problem that when the space bar (the key that activates the bullets), all the bullets fire at one time. im new to game creation and i am using it as a way to learn how to program with c++. i was wondering if you had any ideas for me or could help. thanks, nick hello,

it’s real funny because i went searching for some help on a solution to my “rate of fire” problem and it came up with this blog. the funny part is im making a similar game with the same sprite sheet (unknowingly of course).

anyway, i was looking for some help on making a standard rate of fire. i am having the problem that when the space bar (the key that activates the bullets), all the bullets fire at one time.

im new to game creation and i am using it as a way to learn how to program with c++.

i was wondering if you had any ideas for me or could help.

thanks,
nick

]]>
1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214| no prescription antibiotics online online pharmacy no prescription astelin purchase lipitor medication eurax kaufen ohne rezept cheapest premarin without prescription purchase cheap maxalt cheap citalopram no prescription bactrim without prescription how to buy bupropion online no prescription buying actos with no prescriptionAccutane Online Doxycycline online Buy Cheap Lexapro Online No Prescription Prednisone Online Buy Accutane No Prescription