Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22
  1. #21
    hamChan is offline Member
    Join Date
    Jun 2013
    Posts
    18
    Rep Power
    0

    Default Re: How to move all bullets when a key is pressed only once?

    Quote Originally Posted by Norm View Post
    To see what the code is doing, you need to add some println() statements that print out the values of variables as the code executes so that you can see what the computer sees when the program executes.

    A hint for debugging: Assign every instance of the Shot class an id number. Add code to the draw() method that draws that number on the bullet so you can see which bullet is moving. Also include that bullet id number in all the println() statements so you know what the values of the variables are for each bullet. Add this to the Shot class:
    Java Code:
       static int cntr = 0;
       int id = cntr++;         //assign next id number to this Shot
    The number of bullets which can be moved seem totally depend on the time of space button being pressed. so this is a thread problem as jim829 mentioned above?

  2. #22
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: How to move all bullets when a key is pressed only once?

    Add println()s to show when space bar is pressed and released and when events happen because of it.
    If you don't understand my response, don't ignore it, ask a question.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. How to set button to be pressed more than once
    By ajs1351 in forum New To Java
    Replies: 20
    Last Post: 12-04-2011, 07:53 AM
  2. Kep Pressed
    By mustachMan in forum New To Java
    Replies: 3
    Last Post: 03-01-2011, 09:07 PM
  3. get key pressed
    By prashant in forum Networking
    Replies: 1
    Last Post: 03-26-2009, 10:10 PM
  4. key pressed event
    By kavithas in forum New To Java
    Replies: 7
    Last Post: 12-10-2007, 03:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •