Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: Howard Chen Newsgroups: scea.yaroze.programming.2d_graphics Subject: Re: autofire Date: Sun, 15 Jun 1997 12:10:22 -0500 Organization: SCEA Net Yaroze News Lines: 42 Message-ID: <33A421FE.5EA2FDBA@interaccess.com> References: <33A08AD0.6C8F@concentric.net> NNTP-Posting-Host: d250.cloud.interaccess.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.0 [en] (Win95; I) X-Priority: 3 (Normal) An simple way to force people to press down buttons is to xor the current input with the last input (which tells you which buttons just changed). "and"ing this result with the current input will tell you which buttons have just been pressed. ----Modified code from posting by jamin1@psu.edu (Jamin Frederick)---- static u_long LastPadRead = 0; //the previous read (initially zero) u_long PadRead; //the current read u_long ToggledRead; // Place xored result into this PadRead = PadReadFunction(); //returns u_long (the pushed buttons) ToggledRead=PadRead^LastPadRead; if((ToggledRead&PadRead)==PAD1_DOWN) { FireRoutine(); // The player just read a pressed down the button } LastPadRead=PadRead; ----end code example---- -Howard Chen chenhh@interaccess.com 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