Code not working... again :P

This is my 'paddle' game. You bounce a ball around the around the screen, and it's all working. I'm on the final part, which is what happens when you miss the ball (it goes off the left side of the screen). I'd like to print out a message to the middle of my screen saying "Press R to Reset", while the ball is not anywhere to be seen on the screen (is there a way I can get it to stop moving? my method right now is just to place it far away off screen, which just doesn't seem very professional to me). I made an if statement that should control this, but it's not working (when the you miss the ball, it disappears but nothing prints to the screen, and pressing R doesn't do anything either ) .
To skip quickly to the if statement just use the find option in your browser and put in 'PROBLEM'
This is all written in an applet.
This is my code:
int width, height, x, ypaddle, xball = 1, yball = 1, xctrl = 1, yctrl = 1, speed = 5, scorekeeper = 0, startkeeper = 0, keykeeper;
    Graphics g;
    String startagain;
    char move;
    Thread run;
    private Random random = new Random ();
    int ballstart = random.nextInt (400);
     *Initializes variables
    public void init ()
        resize (700, 500);
        setBackground (Color.white);
        addKeyListener (this);
        addMouseListener (this);
        addMouseMotionListener (this);
        run = new Thread (this);
        run.start ();
        startagain = "To Reset Press R";
        xball = ballstart;
        yball = ballstart;
    public void run ()
        while (true)
            try
                run.sleep (50);
                if (xctrl == 1 && startkeeper == 0)
                    xball = xball + speed;
                if (yctrl == 1 && startkeeper == 0)
                    yball = yball + speed;
                if (xctrl == 0 && startkeeper == 0)
                    xball = xball - speed;
                if (yctrl == 0 && startkeeper == 0)
                    yball = yball - speed;
                if (xball + 50 >= 660 && startkeeper == 0)
                    xball = xball - speed;
                    xctrl = 0;
                if ((xball + 50) < 15 && yball <= ypaddle + 50 && yball >= ypaddle - 70 && startkeeper == 0)
                    xball = xball + speed;
                    xctrl = 1;
                if (yball + 50 >= 460 && startkeeper == 0)
                    yball = yball - speed;
                    yctrl = 0;
                if (yball + 50 <= 35 && startkeeper == 0)
                    yball = yball + speed;
                    yctrl = 1;
//PROBLEM BELOW
                if (xball + 50 <= 0 && startkeeper == 0)
                    if (xball + 50 <= 0)
                        yball = -100;
                        xball = -100;
                        repaint ();
                        g.drawString (startagain, 300, 300);
                    if (xball + 50 <= 0 && startkeeper == 1)
                        scorekeeper = scorekeeper + 1;
                        xball = ballstart;
                        yball = ballstart;
                        startkeeper = 0;
                repaint ();
            catch (Exception e)
    public void keyPressed (KeyEvent e)
        keykeeper = e.getKeyChar ();
        if (keykeeper == 'r')
            startkeeper = 1;
            keykeeper = 'x';
    }

For a public Usenet forum, most readers will stop reading by 20Kb, and start complaining at 30Kb.
lol, I have a long way to go before i make programs that big :P
By incompatible snippet, do you mean I should post the whole thing? Here it is:
// The "Ping" class.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
*Ping
*@author Lenny
public class Ping extends Applet
    implements KeyListener, MouseListener, MouseMotionListener, Runnable
    int width, height, x, ypaddle, xball = 1, yball = 1, xctrl = 1, yctrl = 1, speed = 5, scorekeeper = 0, startkeeper = 0, keykeeper;
    Graphics g;
    String startagain;
    char move;
    Thread run;
    private Random random = new Random ();
    int ballstart = random.nextInt (400);
     *Initializes variables
    public void init ()
        resize (700, 500);
        setBackground (Color.white);
        addKeyListener (this);
        addMouseListener (this);
        addMouseMotionListener (this);
        run = new Thread (this);
        run.start ();
        startagain = "To Reset Press R";
        xball = ballstart;
        yball = ballstart;
    public void run ()
        while (true)
            try
                run.sleep (50);
                if (xctrl == 1 && startkeeper == 0)
                    xball = xball + speed;
                if (yctrl == 1 && startkeeper == 0)
                    yball = yball + speed;
                if (xctrl == 0 && startkeeper == 0)
                    xball = xball - speed;
                if (yctrl == 0 && startkeeper == 0)
                    yball = yball - speed;
                if (xball + 50 >= 660 && startkeeper == 0)
                    xball = xball - speed;
                    xctrl = 0;
                if ((xball + 50) < 15 && yball <= ypaddle + 50 && yball >= ypaddle - 70 && startkeeper == 0)
                    xball = xball + speed;
                    xctrl = 1;
                if (yball + 50 >= 460 && startkeeper == 0)
                    yball = yball - speed;
                    yctrl = 0;
                if (yball + 50 <= 35 && startkeeper == 0)
                    yball = yball + speed;
                    yctrl = 1;
//PROBLEM HERE
                if (xball + 50 <= 0 && startkeeper == 0)
                    if (xball + 50 <= 0)
                        yball = -100;
                        xball = -100;
                        repaint ();
                        g.drawString (startagain, 300, 300);
                    if (xball + 50 <= 0 && startkeeper == 1)
                        scorekeeper = scorekeeper + 1;
                        xball = ballstart;
                        yball = ballstart;
                        startkeeper = 0;
                repaint ();
            catch (Exception e)
    public void keyPressed (KeyEvent e)
        keykeeper = e.getKeyChar ();
        if (keykeeper == 'r')
            startkeeper = 1;
            keykeeper = 'x';
    public void keyReleased (KeyEvent e)
    public void keyTyped (KeyEvent e)
    public void mouseEntered (MouseEvent e)
    public void mouseExited (MouseEvent e)
    public void mousePressed (MouseEvent e)
    public void mouseReleased (MouseEvent e)
    public void mouseClicked (MouseEvent e)
    public void mouseMoved (MouseEvent e)
        ypaddle = e.getY ();
        repaint ();
    public void mouseDragged (MouseEvent e)
    public void paint (Graphics g)
        paddle (g, ypaddle);
        walls (g);
        //enemies (g);
        ball (g);
     * Creates the paddle for hitting the ball
     *@param    y   value used to move the paddle vertically
    public void paddle (Graphics g, int y)
        g.fillRect (10, y - 25, 15, 70);
     *Creates the walls for the ball to bounce off of.
    public void walls (Graphics g)
        g.setColor (Color.yellow);
        g.fillRect (25, 10, 675, 25);
        g.setColor (Color.red);
        g.fillRect (675, 10, 25, 475);
        g.setColor (Color.cyan);
        g.fillRect (25, 475, 675, 25);
     *Creates the enemies to avoid.
    public void enemies (Graphics g)
        int place1 = random.nextInt (1000);
        int place1a = random.nextInt (1000);
        int place2 = random.nextInt (1000);
        int place2a = random.nextInt (1000);
        g.setColor (Color.black);
        g.fillOval (place1, place1a, 10, 10);
    public void ball (Graphics g)
        g.setColor (Color.black);
        g.fillRect (xball + 50, yball + 50, 20, 20);
        g.setColor (Color.white);
        g.fillRect (xball + 53, yball + 55, 5, 5);
        g.fillRect (xball + 63, yball + 55, 5, 5);
        g.fillRect (xball + 56, yball + 63, 9, 5);
} // Ping classEdited by: soundweave on Jan 16, 2010 7:54 PM

Similar Messages

  • SQL Server dragging of tables to worksheet is not working again in V3.2

    V3.2 the SQL Server drag of tables is not working again.
    It says Query Builder is not Supporte for this connection type.
    Query Builder disabled.

    A lost function my users will surely complain about.
    My auditors love SQL Developer because from one tool they can audit Oracle and SQL Server databases.

  • HT1349 The nice man Joseph Shen helped me with my google problem on my iPhone and worked for 2 days and now not working again please help me solve this problem were I can retrieve my messages on the I phone when I am not at home  on my wi Fi is the only t

    The nice man Joseph Shen helped me with my google problem on my iPhone and worked for 2 days and now not working again please help me solve this problem were I can retrieve my messages on the I phone when I am not at home  on my wi Fi is the only time it works correct. Bill. [email protected]  708 752  3667 

    http://lifehacker.com/5852948/what-to-do-if-youve-forgotten-your-iphones-passcod e

  • Why is my video cam NOT working again after it had been sent in to get fixed already

    Model Number: QE024UA
    Model Description: HP PAVILION DV6-6169US NOT
    Serial Number: 5CH1430SD9
    I had my computer sent to get the video cam working... they sent it back and it worked for about 2-3wks and is not working again also when I call someone elses computer I can hear and see them but they can no longer see or hear me. Cant see due to video not working again again on my part but they used to be able to at least hear me.. Now neither works. I have written plenty of messages to HP (at least 3 that I remember) but with no reply. Not a happy camper right now about this. When I bought this computer It had everything I thought I needed and more for my basic use. I chat on facebook Play their game and browse the web.. watch my netflix. I never really needed a video cam but now since family life has changed and I live so far away from them I specifically ordered this computer cuz of its high quality in video plus I liked the fact it played Blue-Ray. I used to have a Dell that lasted me a good 5yrs of usage. I have had this less than 3mnths and twice the cam has gone out on me.

    I'm avoiding buying anything else to use my iMac and had the same problem. I have PC headset with mic and headphones and also a Motorola bluetooth headset, neither worked how they should, no mic function:
    I can use the pc headphones that I already had (just didn't input the mic jack part), and the iMac built-in mic together as I chat.
    Just go to System Preferences and make the Sound settings for Output to built-in Headpones and Input to Internal Microphone -select "Use ambient noise reduction.
    Its a get-around, but it works.

  • Battery changed,but click wheel not working again

    i was changed the new battery for my ipod mini 4G 1 st gen, however the click wheel not working again. the ipod is chargeble, and can lock and unlock, but when the switch turn back to unlock, the ipod is restarting. does anyone who knows what problem i have, and how to fix it? thank you so much
    dell   Windows XP  

    very likely it is a hardware issue, if after restore to factory setting does not solve.
    it could be caused by poor contact or the faulty click wheel of the iPod, just like mine

  • NFL Redzone = NOT WORKING AGAIN?

    Is NFL Redzone not working again this week?? Last week it took over 2 hours to finally work, and this week it looks like the same problem. I tried to activate it through my remote, but it comes up with an error messaging saying unable to process your request. And of course when I call, I'm hold for 10 mins like usual. HELP

    MiMeQu wrote:
    I wanted to see if anyone else has had this issue.  I have set up to get an on screen alert anytime certain teams enter the Redzone and are being shown on the Redzone channel.  I did this through the Redzone Widget.  However, I did not get any on screen alerts.  My understanding was that an onscreen alert would pop up to let you know that a team that you selected was being shown on the Redzone Channel so you could switch to that channel.  My understanding was also that the onscreen alert would occur no matter what channel you were currently watching.
    I just wanted to see if anyone else had this issue and whether my understanding of the on screen alerts is correct.  Do I need to do something else?  Does it not work on any channel you are on?
    Any information would be appreciated.  Thanks.
    The widget must be active for you to receive alerts. Next week, while RedZone is broadcasting, make sure you launch the FiOS Football Widget and remain in the widget to receive alerts.
    While in the widget, press the FiOS TV button (LIVE TV on some remotes) to toggle between full-screen and widget modes, and switch to your game by inputting the channel number for your game. While in widget mode, or while an alert is on screen, pressing C will take you to the NFL RedZone channel, however to get back to your game, you must input the appropriate channel number (the LAST button will not work--Verizon PLZFIX!!!)
    You will not be able to use the Guide, Menu or Info screens without exiting the widget. If you exit the widget (either by pressing Exit or by attempting to access the Guide, Info or Menu screens) you will no longer receive alerts,

  • Dashboard widgets not working. I trash the dashboard .plist and redo all widgets then after a restart. Widget not working again.

    Dashboard widgets not working. I trash the dashboard .plist and redo all widgets then after a restart. Widget not working again.

    Yes hello,
    My widgets are not working as well, i looked on forms and it seams that the 10.5 update fix there problems. I also did an archive and install from 10.4... One of the major reasons i purchased the upgrade was to use widgets to clip parts of safari, i'am totaly bummed because all forums i find end with the question un answered. i'am a little bummed becuase there are a couple of things that worked with 10.4 that are not working in 10.5 (like some meg moives not playing.
    i do not wish to create a new account because i do not want to reinstall all my software, photoshop, final cut, dvd studio pro.. etc.
    i hope to find the fix some how.
    I have opened up the console application and when i select widgets load or delete them i see no activity in the console. I'am not familiar with the console app. or command lines.
    is there any more info on this matter? is there any support from apple?
    Thankyou

  • Looks like updates via the App. store update option is not working again. Comments?

    Looks like updates via the App. store update option is not working again. Comments?

    There are a number of other threads from people reporting a problem with a blank Updates tab in the App Store app - it looks like there is a problem at Apple's end which they need to fix.
    Some posts are suggesting that you if you go into the Purchased tab in the App Store app you might be able to update the apps from there, though you will need to scroll through the list to find those with updates and individually update them.

  • Formscentral is not working again. All the open forms become blank either in IE or Chrome.

    Formscentral is not working again. All the open forms become blank either in IE or Chrome. Please check.

    Yes, we're still working on it.  I will update the Announcement at the top of the forum as we have more of an update.
    Thanks,
    Josh

  • PS4 Game Voucher Code not working

    my PS4 Game Voucher Code not working and says: "The code you entered may not be correct or may no longer be valid" "Please check your entry (e-820000134)  

    Voucher codes are region-specific. For instance a US voucher won't work with a UK account. First thing to check is whether the voucher's region matches your account's region.

  • URGENT NEED OF HELP!! Gift code not working!

    Hi everyone, I have a flight tomorrow and I wanted to make sure I was set in terms of music. Since I am from Hong Kong, I bought a 3 Month Spotify Premium card from 7-11 and tried to redeem it the day after. Not only was the actually spotify.com site not working for me (repeatedly telling me that there was a "502 Bad Gateway" error), but when I tried to redeem it via phone, it told me multiple times that the code was not valid or that there was an error and I should try again (and I did, several times). I also found another code on the receipt that gave me the same answer.  Is there no phone number to contact Spotify at? Is this normal? How can I securely redeem this code? Please answer ASAP as I'm in a rush for tomorrow and very, very frustrated... 

    Please read this:
    https://community.spotify.com/t5/Ongoing-Issues/Gift-cards-starting-with-INC-aren-t-redeeming/idi-p/1161146#M6584

  • VBA code not working in SEM-BPS 3.2

    We are currently running on BW 3.1 and SEM-BPS 3.2 environment. I am trying to create a screen in excel with VBA code doing validation on user input. For some reason the code works perfectly fine in standalone Excel. But when it comes to BPS, the code does not work. Is there any setting to invoke the code? Any help would be greatly appreciated.
    Thanks

    Bindu,
    Thanks for your reply. I checked in the layout builder and both the VBA Macro - SAPAfterDataPut and SAPBeforeDataGet are checked. Below is the code:
    Thanks again!
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("D1:D1000")) Is Nothing Then
        If Target.Value = "183998" Or Target.Value = "192999" Or Target.Value = "0000183998" Then
        ActiveSheet.Unprotect
        On Error Resume Next
        'Application.EnableEvents = False
        MsgBox "You cannot plan on TPIs 0000183998 Or 0000192999"
        Target.ClearContents
        'Application.EnableEvents = True
        ActiveSheet.Protect
      End If
    End If
    End Sub

  • BF3 Specact code not working.. or is it?

    Hi,
    I have received two codes and saw other messages, so I understand what happens. My problem is when I redemmed and downloaded both dog tags and specact upgrade they did not show up in the game.
    My friend suggested downloading again, so I did for both, but now only dog tags are coming up. I went through every single weapon/add on and perk available and I don't seem to see any upgrades that I did not already unlock at my level3... Any idea where to look for it, or is it just not working properly?
    Solved!
    Go to Solution.

    I have not received mine, but recently unlocked the Ranger camo, to change your person's camo:
    Go to Customize My Player (or very similar, going off of memory right now) on main screen, it's where you go to customize your weapon setups. Once you are on the screen with the 4 classes shown, hit the TRIANGLE button (PS3) this will get you to the customize camo menu, it should be there.
    Hope this helps.

  • HT1918 security code not working

    Im trying to update my billing information, but it keeps saying security code is invalid?

    HOW TO FIX "INVALID SECURITY CODE" PROBLEM:
    Since apple's "customer support" consists of a whole bunch of ******** derelicts who blame you or your credit card company for this message, I had to take it upon myself to figure out a way around the problem.  All you have to do is change your billing information in iTunes from your credit card to PayPal.
    I was getting this same ridiculous "invalid security code" message when I knew I had entered it correctly!
    It's funny, because PayPal recognized it as a valid account and security code, and now all my apps finally work again.
    Open iTunes
    Go to the Store
    On the right, click on "Account"
    Next to "Payment Type", click "Edit"
    Click the PayPal logo and either enter your existing PayPal account info or create a new one (as I did)
    I'm not a fan of PayPal, therefore I never had one.  I created one really quickly and even used the same account that mysteriously stopped working.  (AND WITH NO PROBLEMS... THANKS, APPLE)
    I really hope this helps anyone with this same problem as it is really frustrating when somebody **cough cough apple** tells you that you're doing something wrong when you know you're not, and takes no liability whatsoever when the error is on their behalf.
    Happy Apping.... For now

  • End Routine Code not Working after Support Pack Upgrade

    Hi BI Community,
    We have recently upgraded to SPS17 (BW SP19) for our production system and the code deriving the values of several attributes in the end routine of the transformation for one InfoObject (as info provider) does not work anymore. We have been trying to identify the root cause but the fact is that we did not change anything to the InfoObject and its transformation and this used to work fine. The strange thing is that when we debugged the code we could see the value of the aforementioned attributes was derived correctly but the value is just not updated to the InfoObject where we still see the old values for these attributes.
    We have a similar InfoObject with the same end routine code in the transformation and it is working fine. We are out of idea what could have caused this during the SP upgrade.
    Thanks in advance for your feedback.
    Regards,
    Peter

    Cannot say what might have caused it but one check you can perform.
    Open your transformation in change mode and you can see a button next to create end routine button, titled ' Update Behavior of End Routine Change', click on that and say all fields.
    Hope it helps...
    Regards,
    Ashish

Maybe you are looking for

  • Playing real instruments with software instruments

    Hey, I've been using logic for years but have never tried playing with a real instrument until now. When i connect my guitar Logic recognizes it and changes the driver to unknown USB device, but there is no sound since built-in input isn't selected a

  • Hard drive scratching noises?

    I've had my mac book for about 7 months now and i haven't had any problems until now. about a week ago my macbook began to make strange scratching noises whenever i did anything that required a lot of processing power like editing a large photoshop f

  • Using Keynote remotely via a WebConference

    Does anyone know of a process in which one can create a Keynote that is presented live in front of an audience, along with being filmed during the presentation and allow remote users to view both the video of the presenter and the live Keynote screen

  • Photosmart 8750 banner printing on 13 x 19

    I've got 2 big landscape panorama images that I want to print on, say, 2 side by side 13 x 19 sheets to make a big 12 x 36 pano. The only banner option is 2x2 pages, which I tried with the images justified to the top in the hopes that it would print

  • Button not working on top of html

    I have a button on top of an html overlay and it's not working. I did a test and tried swapping out the html overlay for a jpg and it worked fine, but I need to have the html in there. The button is part of a simple 2 state MSO that is on top of the