Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: jamin1@psu.edu (Jamin Frederick) Newsgroups: scea.yaroze.programming.2d_graphics Subject: Re: autofire Date: Sat, 14 Jun 1997 03:31:40 GMT Organization: SCEA Net Yaroze News Lines: 49 Message-ID: <33a20de4.264333588@news.scea.sony.com> References: <33A08AD0.6C8F@concentric.net> NNTP-Posting-Host: ivyland206.voicenet.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Newsreader: Forte Agent .99g/32.339 Here's the way I do it: I have an extra variable that keeps track of the last buttons being pushed, call it LastPadRead; This is an unsigned long, just like the regular pad-reading type. But make sure you use STATIC, so that the variable remains unchanged: static u_long LastPadRead = 0; //the previous read (initially zero) u_long PadRead; //the current read PadRead = PadReadFunction(); //returns u_long (the pushed buttons) if(PadRead & PAD1_UP) if(!(LastPadRead & PAD1_UP)) do your UP thing -- only if both UP is currently being pushed and it wasn't pushed last time if(PadRead & PAD1_DOWN) if(!(LastPadRead & PAD1_DOWN)) do your DOWN thing -- only if both UP is currently being pushed and it wasn't pushed last time ...other directions and buttons... LastPadRead = PadRead; //set the LastPadRead so that next time, // the logic won't be done unless the user has let go // end of pad read function don't take the code verbatim... Jamin Frederick On Thu, 12 Jun 1997 19:48:32 -0400, djinn666 wrote: >hi, > > i'm writing a game but everytime the user holds the fire button it >keeps on shooting. i was wondering if anyone knows how i could make it >so when the user holds down the fire button the ship will only fire >once, making it so they must continuelly press the button to fire. >in the code the bullets are actually from "gsline" and go to the end of >the screen. > >-Djinn