Moving a ball around

I have a really annoying problem that I can't figure out.. I think it's a problem with my casting.
      float delta = System.currentTimeMillis() - timeAtLastTick;
      timeAtLastTick = System.currentTimeMillis();
      float ychange = (float)(ball.getYVol()*(delta/1000));
      float xchange = (float)(ball.getXVol()*(delta/1000));
      float newx = xchange + ball.getXPos();
      float newy = ychange + ball.getYPos();
      System.out.println("xchange: " + xchange + " newx: " + newx + " oldx: " + ball.getXPos());
      ball.setYPos(newy);
      ball.setXPos(newx);I call that code every time I go through my game loop. xchange and ychange are always possitive, but newx and newy are always equal to oldx and oldy! Any thoughts?

Nope, I copied and pasted that code. The only difference is that it was wrapped up in a method. Here's my tick() method:
public void tick()
      float delta = System.currentTimeMillis() - timeAtLastTick;
      timeAtLastTick = System.currentTimeMillis();
      float ychange = (float)(ball.getYVol()*(delta/1000));
      float xchange = (float)(ball.getXVol()*(delta/1000));
      float newx = (xchange + ball.getXPos());
      float newy = (ychange + ball.getYPos());
      ball.setYPos(newy);
      ball.setXPos(newx);
      System.out.println("xchange: " + xchange + " newx: " + newx + " oldx: " + ball.getXPos());
}What's being printed looks something like this:
xchange: 7.5 newx: 5.48133175E11 oldx: 5.48133175E11
xchange: 16.0 newx: 5.48133175E11 oldx: 5.48133175E11
xchange: 7.5 newx: 5.48133175E11 oldx: 5.48133175E11
xchange: 8.0 newx: 5.48133175E11 oldx: 5.48133175E11
...Every time I go through my gameLoop, I call tick, and then I call repaint on the panel that's drawing my ball. Here's the drawing code:
      g2.fillOval(Math.round(ball.getXPos()), Math.round(ball.getYPos()), BALL_WIDTH, BALL_HEIGHT);It definately wasn't a problem with using the wrong class files, but I deleted them all and recompiled anyway. That didn't work....
Here's my Ball.java code if anybody wants to look at it:
package com.cyntaks.gaming.arcade.pong;
public class Ball
  private float xPos;
  private float yPos;
  private double xVol;
  private double yVol;
  public Ball(float xPos, float yPos, float xVol, float yVol)
    this.xPos = xPos;
    this.yPos = yPos;
    this.xVol = xVol;
    this.yVol = yVol;
  public float getXPos()
    return xPos;
  public void setXPos(float newXPos)
    xPos = newXPos;
  public float getYPos()
    return yPos;
  public void setYPos(float newYPos)
    yPos = newYPos;
  public double getXVol()
    return xVol;
  public void setXVol(double newXVol)
    xVol = newXVol;
  public double getYVol()
    return yVol;
  public void setYVol(double newYVol)
    yVol = newYVol;
}Well I'm stumped. I'm going to rewrite all of my ball moving/handling/drawing code tomorrow if I don't think of something in my sleep :P
The game is a multiplayer pong game. I had everything working, but then I realized that because the game speed was locked to the refresh rate, the two players' games would become out of sync if their frame rates weren't synced. That's why I implemented this "delta tick" idea. Here's a screenshot of the game in action before I started this delta thing:
http://gaming.cyntaks.com/projects/projects/tempscreens/RLKPong.gif

Similar Messages

  • Moving plugin windows around causes spinning beach ball.. 8.0.2 near???

    last q. for now...how come when moving plugin windows around in logic it can sometimes cause the dreaded spinning beach ball?? you think logic is going to crash but it doesn't, it recovers and then runs real sluggish... logic or leopard bug??? i can't wait for 10.5.2 to see what it magically fixes in logic!! any hope that we might have 8.0.2 in the near future...there are all these other updates floating down from cupertino but yet logic seems neglected...

    Thanks Pancenter... appreciate your input. Really useful information. When I bought my Mac Pro, there was an issue with the video cards; if you wanted to run 2 x 30" ACD's, then you had to up the spec to a more powerful card. The guy in the mac shop assured me the GeForce 7300 GT that came with the machine would be sweet enough for 2 x 23's... and it was. But that was with Tiger. (?)
    Is Leopard &/or LP8 graphically more demanding than Tiger &/or LP7... I wouldn't have a clue? Does anyone have an opinion on this? (I'd be REALLY interested!) Are the cards shipping with these machines really up to the job of running the OS AND something as complicated as LP8? My opinion is; They SHOULD be.
    Thanks Zuelito... I had noticed this thread & was surprised/dismayed that even 8 CORE machines were having this problem too! But then, if it's a problem with underpowered graphics cards, I don't suppose it matters how many cores you've got... does it??? Thanks for your post... again, really USEFUL information. I appreciate it! (GREAT thread.)
    I only get this problem when I open anything UAD; it runs happily in the background but out comes "the ball" whenever I open & move more than 1 instance of a UAD plug. Haven't once had it happen with Logic or 3rd party AU's.
    Thanks again for your input... keep it comin'!
    Cheers...

  • I moved the mobilesync path where my backups should be stored. However, since then I moved some folders around which I think is the source of my error. I can no longer backup my iphone. How do I fix this?

    A while ago, I moved the mobilesync path so that it would stop trying to backup onto my C drive. However, since then I moved some folders around which I think is the source of my error. I can no longer backup my iphone It just tells me that the backup is corrupted. When i go to preferences, devices, and look under backups it is empty. How do I fix this?

    Howdy there mjspace1994,
    It sounds like you are unable to backup your phone after moving the mobile sync folder from its default location. If moving it back manually does not resolve the issue, I would next use either of the following articles to remove iTunes from your computer and then re install it. The articles outline the proper order to remove them in, and step by step instructions:
    Remove and Reinstall iTunes and other software components from Windows XP
    Remove and reinstall iTunes and related software components for Windows Vista, Windows 7, or Windows 8
    Thank you for using Apple Support Communities.
    Take care,
    Sterling

  • I have recently purchased an IPad Air. This comes with "IPhoto" as well as it's usual photo App. I do not have a Mac, instead I am syncing it to my windows PC. Is there any way of actually moving a picture around, (arranging photos in a single album)

    I have recently purchased an IPad Air. This comes with "IPhoto" as well as it's usual photo App. I do not have a Mac, instead I am syncing it to my windows PC. Is there any way of actually moving a picture around, (arranging photos in a single album), in either of these apps???? They claim to be able to "Organize"  or "arrange" Photos, but for the life of me I can't figure out how......could you recommend any apps that actually allow someone to move individual photos around on an IOS Device.

    No, reordering within folders and albums is not supported. the yare arranged automatically by date. I found this, but I have not used any of the apps besides iPhone. You might check the descriptions to see if they do what you need.

  • My mouse keeps moving the screen around.  How do I reanchor it

    My Mouse keeps moving my screen around.  How do I re-anchor it?

    Goto trackpad in sys pref and try reducing your tracking speed or goto universal access in sys pref and check the mouse and trackpad settings...try altering them to solve your problem

  • Moving instances/clips around on timeline

    I am finding that moving clips/instances around is quite jerky and slow. Is this normal?
    Have all the latest updates etc on a MacPro heaps of ram and have Adobe Cert cuda card.
    I have just migrated from FCP and moving clips around on a timeline is smooth and fast in FCP.
    This is my only gripe with PP at the moment everything else fat and stable. Obviously I can use the overlay functions etc. but
    I like to move things around on the timeline manually... I hope that I'm doing something wrong.
    Anyone?
    Cheers

    Did you figure out your issue?
    I'm trying to remove clips and save them, and haven't figured out how to do that yet.

  • Adobe Photoshop CC lags on Macbook Pro when moving layer content around

    Hi,
    We just bought new Macbook Pro laptops last Friday and also got Adobe Photoshop CC and Adobe Illustrator CC. Everything works pretty fine, except moving layer content eg. images or fonts around is a bit behind, slow/laggy, without any apparent reason.
    This happens despite external screen connected or not. It also happens with or without power adapter connected. We have brand new Mac OS Mavericks and 16GB RAM so performance should not be a problem.
    I hope you can help out, we are a digital agency and do a lot of graphical work. Thanks in advance.
    Some information (translated from Finnish system info):
    Model name:          MacBook Pro
    Model:          MacBookPro11,1
    Processor:          Intel Core i5
    Processor speed:          2,4 GHz
    Processor amount:          1
    Core amount:          2
    L2-memory per core:          256 kt
    L3-memory:          3 Mt
    RAM:          16 GB
    Graphics/Screens:
    Intel Iris:
      Chip model: Intel Iris
      Type:          GPU
      Internal
      VRAM (total):          1024 Mt
      Intel (0x8086)
      0x0a2e
      0x0009
    Color-LCD:
      Retina-LCD
      2560 x 1600
      Retina:          Yes
      32-bit color (ARGB8888)
      Mirroring: Off
      Online:          Yes
      Internal:          Yes
    Acer V243PWL:
      1920 x 1200 @ 59 Hz
      32-bit color (ARGB8888)
      DisplayPort

    i cant believe this problem is still happening. same exact issue here. photoshop cs6 and CC run like **** on my macbook but run smooth on windows 7 on the same exact hardware, macbook pro 2.5ghz core i5, 16gb ram and intel hd 4000. ive talked with applecare about this, adobe support (who hasn't called me back twice now) and no response on how to fix this. its absolutely ridiculous that we are having to go through this much trouble to get this problem fixed. ive brought it up over 5 times now and no solution except for the usual suggestions (turn off hardware acceleration, delete your preferences, yada yada). same hardware, mac osx photoshop cc lags, windows photoshop runs fine.. something is wrong with the mac version of photoshop cs6 and CC adobe please fix this as soon as possible.

  • Moving audio files around that are not in the iTunes library

    Hi,
    Can someone please confirm some behaviour for me. This is regarding iTunes (on OS X naturally) and moving files around that aren't located within the iTunes library.
    Most of the files I use are located within the iTunes library, they are fine. However i do maintain a number of files outside of the iTunes library which i primarily use as a DJ. I would like to keep these files seperate, however I do move them occasionally, especially as I classify new music into categories and such.
    On my previous powerbook, I noticed that I could move these files and iTunes would still be able to find them, without my manually notifying iTunes where to find them. I did notice a hiccup though, and once when I was recovering from a backup, a bunch of files that i moved weren't found by iTunes.
    on my lovely new macbook pro I'm experimenting with the same thing, but it hasn't seemed to been working so far.
    my question: Does OS X track where files get moved to? Does iTunes for Mac automatically fix it's library after some period of time through the OS?
    I'd really like to confirm this behaviour and see what I can / can't count on.
    thanks,
    conrad

    I dont think you can rely on itunes to keep track of your files consistently if you move them around all the time. One solution would be to make a "smart folder" in finder/file/new smart folder. You could call this smart folder "chicago hard house set" and set it to find the tag "chicago hard house set" Then in itunes when you find a track or loop you want to use in that set just add the tag "chicago hard house set" to the composer line under "get info". the smart folder will find the tag in itunes and put a the file in the smart folder, if you keep the smart folder on your desktop (or wherever) Ableton will see the folder and let you access all the files in it. So you can preview all your sound files in itunes and tag them to a specific set and they will show up in that sets smart folder. I use the smart folders to keep track of multiple tracks when recording with Digital Performer onto multiple hard drives at one time.

  • Illustrator CC stopped working after I moved some fonts around

    Hi all. I had some font issues with Microsoft Excel on my mac earlier today and had messed around with the fonts, basically moving them from one folder to another, deleting duplicates etc.
    I must admit at this point that I'm no Mac expert and I do like to do things the trial-and-error way. and I may have done something that I shouldn't have as my AI CC won't launch now.
    I can't undo what I've done as I can't remember what I did, and Time Machine isn't any help.
    I can't reinstall the CC as I don't have the installer and now Adobe won't let me download it again as apparently my OS is supposedly out of date, even though it still meets the minimum requirement (OSX10.6.8) stated.
    What should I do?

    IluvAI,
    You may have moved the members of the Verdana/Tahoma font family/families out of the crucial folder or disabled them.
    You may try to move them back/enable them.
    If you have uninstalled CC (as it seems), you may try Customer Care (tick I Still Need Help and hope for an agent available for a chat),
    http://helpx.adobe.com/contact.html?product=illustrator&topic=downloading-installing-and-s etting-up
    or this specialized forum (where you may be able find the answer from previous threads),
    http://forums.adobe.com/community/download_install_setup
    There seems to be some uncertainty about your OS and CC: according to this Adobe page,
    http://www.adobe.com/products/illustrator/tech-specs.html
    you cannot use it, but reports in this forums say that it is possible (at least in some cases).

  • Moving the ball

    public class Ball extends JFrame implements Runnable
         int x = 10;          
         int y = 100;     
         int radius = 20;     
         public Ballbewegung1()
              super("Ball Moving");
              setBackground (Color.blue);
              start();
              setSize(400,400);
              setVisible(true);
         public static void main(String[]args)
              Ballbewegung1 test = new Ballbewegung1();
              test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public void start ()
              Thread th = new Thread (this);
              th.start ();
              System.out.println("Start");
         public void run ()
              Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
              while (x<=300)
                   x ++;
                   repaint();
                   try
                        Thread.sleep (20);
                   catch (InterruptedException ex)
                   Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
         public void paint (Graphics g)
              g.setColor  (Color.red);
              g.fillOval (x - radius, y - radius, 2 * radius, 2 * radius);
    }i not sure what wrong with my coding because it keep coming up the wrong out put.Any help will greatly appreciated. Thank you

    Maybe this code is your desired affect. This uses active render rather than depending the OS and java to repaint the screen. I prefer active rendering when possible. You can't use it if you have menu's or some other component that comes down into the painted area (or at least I haven't figured out how to solve the problem that when your component is painted it covers the menu...something java takes care of when using repaint()).
    Also, I went ahead a drew on your JFrame but as mentioned above it would be better to put a JPanel in the JFrame and draw on the JPanel. So basically create a class that extends JPanel and put this functionality in it and then add the JPanel to your top level JFrame. The flicker would go away if you drew on an off screen image and then moved it to the screen (at the end of the render method).
    The Timer method is the preferred method (rather than Thread.sleep) as the action it executes is executed form the Event Dispatcher Thread.
    Enjoy:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    public class Ball extends JFrame {
         private int x = 10;
         private int y = 100;
        private int radius = 20;
        private Timer animationTimer;
         public Ball() {
              super("Ball Moving");
              this.setSize(400,400);
              this.setVisible(true);
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.startAnimation();
         private void startAnimation() {
            Action animate = new AbstractAction() {
                public void actionPerformed(ActionEvent e) {
                    render();
            this.animationTimer = new Timer(4, animate);
            this.animationTimer.start();
         private void render() {
            Graphics g = getGraphics();
            g.setColor(Color.blue);
            g.fillRect(0, 0, this.getSize().width, this.getSize().height);
              g.setColor(Color.red);
              g.fillOval(x - radius, y - radius, 2 * radius, 2 * radius);
            x = x + 1;
            if (x > 300) {
                this.animationTimer.stop();
        public static void main(String[]args) {
            new Ball();
    }

  • Why has Thunderbird been arbitrarily moving my folders around; what was a primary folder becomes a subfolder in another category?

    Often when I first start Thunderbird I find that my folders & subfolders have been moved around. Honest, I'm not using my computer while I sleepwalk! Mack OS 7.5

    using a phone and IMAP perhaps?

  • Moved picture folders around now won't sync with iPhone

    I recently moved around some pictures and now most of my pictures will not sync to my iPhone.
    I have tried deleting the photo cache, moving pictures into a single folder and resetting the sync history, uninstalled iTunes, restored phone, copied all my photos to another location, and each time I get an error that that my iPhone can't be read or written to or the device times out.
    The strangest thing is most of the folders or pictures it doesn't seem to like were pictures that were on the phone previously or were not touched when I moved stuff around.
    I am running Vista and have even tried single folders and that works for some but most error out.
    Any help would be appreciated.

    Hoosierbuff wrote:
    I bought a concert bootleg direct from the artist
    Then it is not a bootleg!
    I dowloaded the songs, and now it won't sync with my iphone.  I use icloud for my songs, and I also have imatch.  WHy can't I get these songs on there?
    It is possibly an incompatibility with audio format or sample rate. 
    First, make sure that the songs play in iTunes on your computer.  If so, right-click and choose "create AAC version."  Use the new AAC version with your iPhone.

  • I am moving POP3 emails (around 100,000) to an IMAP address. Should it take so long to copy/move all my emails over? Is there a better way?

    I work for a company who want all their POP3 accounts switched to IMAP. There are around 5 accounts with over 20,000 emails with HUGE attachments (CAD and SolidWorks 3D Designs) and a lot more with only 100-500 emails. It seems I will have to manually copy all the emails into the new inbox/sentbox/archives but, as you can imagine, it takes longer than the office opening hours to complete. It's roughly moving 4,000 emails per day. Are there any plugins I could use or should I soldier on with my current method?
    Many thanks,
    Josh

    Trying to move all those emails into an IMAP mail account means uploading them back to the server, this may have the effect of changing all the dates to the date you uploaded them.
    I can think of a couple of options.
    '''1. Move emails into 'Local folders' and delete the pop mail account.'''
    These emails will not be on the server, they will be on your computer, but you can still access them via the same Profile under Local Folders. You can create a new IMAP mail account in the same Profile. So both old Pop emails and new IMAP emails can be seen in the same Profile.
    If you download the addon 'ImportExporttool', you can move all whole folder and create a backup at the same time.
    importExporttool addon:
    * https://freeshell.de//~kaosmos/mboximport-en.html
    * right click on folder
    * select 'ImportExporttools' > Export Folder
    * select where to save but not in Thunderbird.
    then rename the saved file if it is a default folder name; eg: if it was Inbox to OldInbox. This will also mean you have a backup of that file.
    In Thunderbird select the folder where you want the file to be imported.
    * right click on folder
    * select 'ImportExporttools' >Import mbox file
    * select 'Import directly one or more mbox files and click on OK (As your files may be large, I would do this one file at a time)
    * then select the saved file and click on Open
    When all folders and emails have been successfully moved and you can see them in Local Folders, you can remove the Pop mail account.
    * Tools > Account Settings
    * select the pop mail account
    * click on 'Account actions'
    * select 'Remove Account'
    * click on OK
    '''2. Keep the Pop mail account, but stop it from checking for new mail, downloading etc.'''
    This means all folder and emails stay in the same place, but the mail account is not actively connecting to the server. You can create a new IMAP mail account in the same Profile. So both old Pop emails and new IMAP emails can be seen in the same Profile.
    The downside of this is that if you later click on 'GetMail' whilst looking at those emails in that account, it will attempt to connect to server, discover no password and may prompt for one. Or if you click on 'Get all new messages', it will include the account.
    When you want to Write a new message and at the time you were viewing those folders, the email address using that server will also still be available, now if the email address is the same as the IMAP account, this could be confusing especially if one appears to prompt for a password.
    This may be irritating if you keep doing it, hence why moving emails to Local Folders may be preferable.
    Tools > Account Settings > Server Settings for the mail account
    under 'server settings'
    * uncheck all of the following.
    * 'check for new messages at startup'
    * 'check for new messages every xx minutes'
    * 'Automatically download new messages'
    * 'Leave messages on the server'
    under 'Message storage'
    * uncheck 'empty Deleted folder on exit'
    click on OK
    Then remove the saved/stored password - if you instructed TB to do this.
    * Tools > Options > Security > Passwords tab
    * click on 'Saved Passwords'
    * click on 'Show Passwords'
    * highlight both mailbox and smtp passwords for that pop mail account
    * click on 'Remove' and then click on 'Close'
    * click on OK to save changes to options.
    '''3. Create a new Profile for the IMAP emails.'''
    Disable the Pop mail account as described in (2) above, but this time you create a new Profile and then create the new IMAP mail account in the new Profile.
    This means that you can still see the old emails but you have to swap Profile to see them and remember to never create a new Write message in the Profile containing the old Pop messages.
    Creating another Profile:
    * https://support.mozilla.org/en-US/kb/using-multiple-profiles
    From the desktop:
    Move your mouse pointer to the lower-left corner of the Desktop screen, right-clicking, and selecting Run in the Quick Access menu.
    Enter the following in the Windows 'Run' box (you should substitute the actual path if you installed it in another place):
    enter all of what is written below, include the "" and the space-P
    '''"C:\Program Files\Mozilla Thunderbird\thunderbird.exe" -P'''
    This will open Profile Manager.
    You can now create a new Profile.
    If you want Profile Manager to ask you each time, which Profile to open on start up, do not select 'Don't ask at startup'.
    If you select 'Don't ask at startup' it will open on the last used Profile by default.
    '''Make a shortcut icon to the Profile Manager.'''
    If you have multiple Profiles, then you may find it much easier to create a shortcut to Profile Manager on your desktop.
    First close Thunderbird.
    * From the desktop, open 'Computer'
    * Select the OS(C:) drive as this is the usual place where Thunderbird is installed.
    * then open 'program files' folder.
    * then open 'Mozilla Thunderbird' folder
    * look for thunderbird.exe application
    * right click and select 'create shortcut'
    it will say cannot create short here do you want it placed on the desktop, say yes.
    then located the new 'Thunderbird shortcut on your desktop.
    * right click and select rename and type 'Thunderbird Profile Manager' or similar.
    * Then right click on the shortcut and choose 'Properties'
    * look at the 'Target'.
    * It will say: eg: "C:\Program Files\Mozilla Thunderbird\thunderbird.exe" (enclosed in double quoation marks)
    * you need to add a space followed by -P (dash and capital P)
    * so that it now says:
    ''' "C:\Program Files\Mozilla Thunderbird\thunderbird.exe" -P'''
    * click on apply and then OK
    You should be able to now use the shortcut as quick access to Profile Manager.

  • Moving video tracks around?

    Is there a way to click and drag a video track so it becomes a different track #? Like if I wanted track 2 to be track 7.. How would I do that?
    Thank you.
    -patrick

    Experimentation is different. I use special or isolated sequences.
    Look in the manul for moving clips from one track to another. It's needlessly confusing, FCP wants to do an insert by default. You need a tricky key combo to move stuff around without duplicating it or inserting it and making everything shift downstream.
    Shift-dragging will constrain a clip to vertical movement to upper or lower tracks.
    bogiesan

  • Whenever I truy to load a picture or video file, it will stall until I start moving the mouse around. When I stop moving the mouse, it stalls again. I am running Firefox 4.0.1 and Vista

    Any picture or video file I try to load just stalls (with the exception of sound which works OK). I move the mouse and it plays or loads. I stop moving the mouse it stalls again.

    I have had a similar problem with my system. I just recently (within a week of this post) built a brand new desktop. I installed Windows 7 64-bit Home and had a clean install, no problems. Using IE downloaded an anti-virus program, and then, because it was the latest version, downloaded and installed Firefox 4.0. As I began to search the internet for other programs to install after about maybe 10-15 minutes my computer crashes. Blank screen (yet monitor was still receiving a signal from computer) and completely frozen (couldn't even change the caps and num lock on keyboard). I thought I perhaps forgot to reboot after an update so I did a manual reboot and it started up fine.
    When ever I got on the internet (still using firefox) it would crash after anywhere between 5-15 minutes. Since I've had good experience with FF in the past I thought it must be either the drivers or a hardware problem. So in-between crashes I updated all the drivers. Still had the same problem. Took the computer to a friend who knows more about computers than I do, made sure all the drivers were updated, same problem. We thought that it might be a hardware problem (bad video card, chipset, overheating issues, etc.), but after my friend played around with my computer for a day he found that when he didn't start FF at all it worked fine, even after watching a movie, or going through a playlist on Youtube.
    At the time of this posting I'm going to try to uninstall FF 4.0 and download and install FF 3.6.16 which is currently on my laptop and works like a dream. Hopefully that will do the trick, because I love using FF and would hate to have to switch to another browser. Hopefully Mozilla will work out the kinks with FF 4 so I can continue to use it.
    I apologize for the lengthy post. Any feedback would be appreciated, but is not necessary. I will try and post back after I try FF 3.16.6.

Maybe you are looking for