How to setup auto paddle & constant speed for ball

I wanted to setup an automatic paddle so that this game will works as a one-player game. I have 3 files here. Ball.java, Play.java and pong.java.
My code below doesn't seem to get the paddle moving at all. How can I do so? What's my mistake or how should I do it correctly?
Pls help....:(
Also the ball runs faster and faster after each volley and the ball deflects at a smaller x-axis angle after hitting the rightWall & leftWall. How can I get a constant velocity as well as a more balance deflection??
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Toolkit;
import java.awt.event.ItemEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.geom.Rectangle2D;
import javax.swing.JButton;
import javax.swing.Timer;
import javax.swing.JPanel;
import java.awt.*;
import java.awt.event.*;
class Play extends JPanel implements ActionListener, MouseMotionListener, ItemListener {
     private double maxX,maxY,y; // dimensions of the surface of play
     private double heightP,widthP,semiWidthP; // dimensions of the paddle
     double thickness = 10; // thickness of the walls, ceiling and floor
     private Toolkit tk;
     private Ball ball; // graphic objects
     private Rectangle2D user_paddle,computer_paddle, leftWall, rightWall, exitA, exitB;
     private Timer timer; // objects of interaction
     private JButton button, reset;
     private int countA, countB;
     int computer ;
     int user;
     TextField userscore = new TextField(4);
     TextField compscore = new TextField(4);
     Thread t = null;
     Play(Ball ball,Timer timer,JButton button, JButton reset) {
          this.ball=ball;
          this.timer=timer;
          this.button=button;
          this.reset=reset;
          userscore.setEditable(false);
          compscore.setEditable(false);
          // dimensions of the applet
          this.maxX = getSize().width;
          this.maxY = getSize().height;
          tk = getToolkit();
          // paddle
          semiWidthP = ball.getDiametre()/2;
          widthP=semiWidthP*2;
          heightP = 50;
          user_paddle = new Rectangle2D.Double((maxX-thickness-heightP)*0.05,(maxY)/4,
          semiWidthP,heightP);
          computer_paddle = new Rectangle2D.Double((maxX-thickness-heightP)*1.03,(maxY)/4,
          semiWidthP,heightP);
          // borders
          exitA = new Rectangle2D.Double(0,0,thickness,maxY);
          exitB = new Rectangle2D.Double(maxX-thickness,0,thickness,maxY);
          rightWall = new Rectangle2D.Double(0,0,maxX,thickness);
          leftWall = new Rectangle2D.Double(0,maxY-thickness,maxX,thickness);
          // to indicate that the movements of the mouse will be listened to
          addMouseMotionListener(this);
     }//end of Play
     // to adjust the graphic objects if the play changed dimension
     public void updateWall() {
          double maxX=getSize().width, maxY=getSize().height;
          if(this.maxX!=maxX ||this.maxY!=maxY){
               this.maxX=maxX;
               this.maxY=maxY;
               user_paddle.setFrame((maxX-thickness-heightP)*0.05,(maxY)/4,semiWidthP,heightP);
               //computer_paddle.setFrame((maxX-thickness-heightP)*1.03,(maxY)/4,semiWidthP,heightP);
               exitA.setFrame(0,0,thickness,maxY);
               exitB.setFrame(maxX-thickness,0,thickness,maxY);
               rightWall.setFrame(0,0,maxX,thickness);
               leftWall.setFrame(0,maxY-thickness,maxX,thickness);
     }//end of UpdateWall
     // posting of the contents of the screen
     public void paintComponent (Graphics g) {
          super.paintComponent(g);
          Graphics2D g2D = (Graphics2D)g;
          updateWall();
          paintPad(y);
          //g2D.drawString(ball.getX()+","+ball.getY(),10,15);
          g2D.drawString("Player A: "+ countA,10,20);// drawString update scores
          g2D.drawString("Player B: "+countB,500,20);
          g2D.fill(exitA); g2D.fill(exitB);
          g2D.fill(rightWall);
          g2D.fill(leftWall);
          g2D.setColor(Color.blue);
          ball.toPost(g2D);
          g2D.setColor(Color.red);
          g2D.fill(user_paddle);
          //g2D.fill(computer_paddle);
          g2D.setColor(Color.gray);
          g2D.drawLine(300,0,300,400);
          while( t!=null) {
               try     {
                    t.sleep(10);
               catch(InterruptedException e) {}
     }//end of paintComponent
     private void bip(){
          tk.beep();
     public void itemStateChanged(ItemEvent ev) {
               Object sc = ev.getSource();
               boolean on =ev.getStateChange()== ItemEvent.SELECTED;
     //treatment of the Action Vents of Timer
     public void actionPerformed(ActionEvent e) {
          double dx = ball.getDx();
          double dy = ball.getDy();
          // to move the ball//
          ball.toGoA(ball.getX()+ball.getDx(),ball.getY()+ball.getDy());
          // checking of a change of direction (with acceleration...)
          if(ball.intersects(leftWall) || ball.intersects(rightWall)){ // striking with dimensions
               ball.setDy(dy>0 ? -(++dy) : -(--dy));
               bip();
          else if((ball.intersects(user_paddle)) || (ball.intersects(computer_paddle))){
               ball.setDx(dx>0 ? -(++dx) : -(--dx));
               bip();
          else if((ball.intersects(leftWall)||ball.intersects(user_paddle)) || (ball.intersects(leftWall)||ball.intersects(computer_paddle))){
               ball.setDx(dx>0 ? -(++dx) : -(--dx));
               bip();
          else if((ball.intersects(rightWall)||ball.intersects(user_paddle))||(ball.intersects(rightWall)||ball.intersects(computer_paddle))){
               ball.setDx(dx>0 ? -(++dx) : -(--dx));
               bip();
          else if(ball.intersects(exitA)){
               ball.toHide();
               button.setText("Start");
               timer.stop();
               ++user;
               paintC(computer, user);
               //++countB;
          else if(ball.intersects(exitB)){
               ball.toHide();
               button.setText("Start");
               timer.stop();
               ++computer;
               paintC(computer, user);
               //++countA;
          paintPad(dy);
          repaint();
     }//end of actionPerformed
     public void setTextFields(TextField c1, TextField c2) {
          compscore=c1;
          userscore=c2;
     public void paintC(int computer, int user) {
          compscore.setText( " " + computer );
          userscore.setText( " " + user );
          compscore.repaint();
          userscore.repaint();
     public void paintPad(double y){
          computer_paddle.setFrame((maxX-thickness-heightP)*1.03,y-semiWidthP,semiWidthP,heightP);
          while( t!=null) {
               try     {
               t.sleep(10);
               catch(InterruptedException e) {}
          //computer_paddle.setFrame(computer_paddle.getX(),dy-semiWidthP,semiWidthP,heightP);
          repaint();
     // draft displacements of mouse
     public void mouseDragged(MouseEvent ev){// ignore
     public void mouseMoved(MouseEvent ev){
     // replace X by making sure that one remains in the terminals of the applet
          double dy = ball.getDy();
          double px = Math.min(maxY-thickness,
          Math.max(ev.getY(),semiWidthP+thickness));
          user_paddle.setFrame(user_paddle.getX(),px-semiWidthP,semiWidthP,heightP);
          repaint();
}

Hi,
For creating the deliveries automatically you can use the T.code VL04 in the b/g or run the program RV50SBT1 in the b/g every 2 hours. This can be done using T.code SM36, this is where you set up the job. Here you can specify the details and the timing.
For creating the TO's for the delivery, either you do it through the config setting or run a similar job in the b/g and TO's should be created automatically.
For some reason if you find deliveries are not created you may use V.22 and give the Log number(which you will get from the job log) and see the reasons for delivery not being created.
hope this helps.

Similar Messages

  • How to file auto number in save for web ?

    Hi All,
    how to file auto number in save for web ?
    I have make an action script in Photoshop cs5 that
    change the image resolution and SaveForWeb...
    (but at this point user need to supply the file name)
    so, How to write the code/action such that when the
    action button is click the image will save into the file
    file2eMail_001,file2eMail_002,file2eMail_003,file2eMail_004
    or to any unused number ?
    thank for any help!

    You could also ask over in the Photoshop Scripting Forum, I’m pretty certain stuff like progressively numbered copies has been addressed there previously.

  • How do I lower the write speed for burning a DVD?  It gives me no option!

    How do I lower the write speed for burning a DVD?  It gives me no option!

    Export the dvd as an image from Encore, then use Imgburn to make the discs. I usually export a dvd folder from Encore and then use Imgburn to create the iso and do the burning
    The Official ImgBurn Website
    Be careful if you download it, it will try and install allsorts of other programs. This thread might be of some help.
    Imgburn and Bloatware Add-ons

  • How to setup the 'Client Licensing Mode' for Windows server?

    Hello,
    We will install the SBO server:
    OS: Windows Server 2003 Standard Edition
    SBO Clients: 150
    How should we setup the 'Client Licesing Mode' for the windows server?
    If we select the mode "Per server,Number of concurrent connections", how to set the connection number?
    Thanks in advance.
    Don

    Hi..
    you can set License to Particular user using License under Administration and Client will automatically fetch License using License Manager on License Server
    Regards,
    Bhavank

  • How to stop auto generation of ids for h:dataTable

    I am using <h:dataTable> tag to display more than one error messages.
    My code goes like this
    <h:dataTable id="messagetb" value="#{searchZug.searchZugParam.allMessages}" var="message">
    <h:column>
    <h:outputText style="color:red;" value="#{message}" />
    </h:column>
    </h:dataTable>
    When i run my application, console is displaying a message like
    'WARNING: Component _id79 just got an automatic id, because there was no id assigned yet. If this component was created dynamically (i.e. not by a JSP tag) you should assign it an explicit static id or assign it the id you get from the createUniqueId from the current UIViewRoot component right after creation!'
    I checked in the generated html source. It is generating id for tbody as 'messagetb:tbody_element', this is causing the problem.
    How can i stop this auto generation of ids? if not possible, then how can i explicitly specify the id for tbody?
    Thanks,
    Murthy

    Narasimha.Murthy.d wrote:
    I am using JSF version 1.3There exist no "JSF 1.3". When talking about "JSF" without mentioning the implementation name, we assume it as JSF specification. The JSF specification is only been available as 1.0, 1.1, 1.2 and 2.0. As said before, we´re more interested in the JSF implementation name. Is it Apache MyFaces? Is it Sun RI or Sun Mojarra? And then please tell the version from that.

  • Constant speed for an unbalanced load

    I have a machine that uses a Dart 253g to drive a dc motor. The arm if an offset arm that rotates.. We have tried to balance the arm the best we could but the load is still off. What happens is as the heavier part of the arm is on the upswing of the motion, the drive cranks up the torque and pushes it up and over the peak of the rotation. The problem is, on the way back down, the load takes off and "freewheels' around until the upswing starts again. Would a constant speed drive help eliminate this? This machine has no feedback on the arm 
    Thanks in advance 
    Ken 

    You will need a regen or 4-quadrant drive to provide dynamic braking.  A tachometer will always help with speed regulation(only on the upswing with your current drive, though).

  • How to choose the right processor speed for application

    Hi,
    Can any one help me to identify the right cRIO model.
    I want to choose the cRIO processor for an application. The cRIO- 9025, has processor of 800 MHz speed. Where as there is another cRIO model which comes with 400 MHz of the processor.
    How do I decide which model to choose?
    The mathematical calculations will help me to reach at a conclusion. I am not sure how to go ahead with the mathematical calculations.
    Can any one advise me on this.
    ThanX

    I don't think you will get any mathematical calculations telling you witch cRIO you have to use based on the level of information you have given.
    I don't think there are any mathematical calculations to decide witch cRIO a user can use. 
    You need to give a lot more information about what you are going to use cRIO for, before anyone can give you an advice.
    What does you setup look like ?
    Wwitch modules are going in the cRIO ?
    What are they doing ( input/output )?
    Are the cRIO interacting witch external systems?
    Are the cRIO only collecting data ? How fast ?
    What operation are the cRIO going to do ?
    Just a fewe of the questions you need to ask yourself. 

  • How to setup a New Flex environment for an existing project

    Hi,
    I am a capable embedded SW engineer but have not used Flex or Adobe developer products before.
    I replace a software engineer who left the company at the end of last year and did not generate any design/development document for a flex application that he had created (circa 2011) and that is currently in use by customers.
    The development environment was on his personal Macbook so this is gone. My task is to debug and fix problems with built in SQL queries that are not retrieving or writing data correctly. My workaround is to manually edit the dB tables but this is not practical for the customers.
    I am English and wish to work with an English language installation but as my location is in Austria and the OS (Win7, 64) is in German it is hard (maybe not possible) to manage the Adobe auto language/region detect.
    I include an image of the project directory and the .project file for reference,
    <?xml version="1.0" encoding="UTF-8"?>
    <projectDescription>
              <name>CWPConfigurator</name>
              <comment></comment>
              <projects>
              </projects>
              <buildSpec>
                        <buildCommand>
                                  <name>com.adobe.flexbuilder.project.apollobuilder</name>
                                  <arguments>
                                  </arguments>
                        </buildCommand>
                        <buildCommand>
                                  <name>com.adobe.flexbuilder.project.flexbuilder</name>
                                  <arguments>
                                  </arguments>
                        </buildCommand>
              </buildSpec>
              <natures>
                        <nature>com.adobe.flexbuilder.project.apollonature</nature>
                        <nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
                        <nature>com.adobe.flexbuilder.project.flexnature</nature>
              </natures>
              <linkedResources>
                        <link>
                                  <name>bin-release1</name>
                                  <type>2</type>
                                  <location>/Users/daniel/Desktop/CWPConfigurator</location>
                        </link>
              </linkedResources>
    </projectDescription>
    I see the <location> string above will need changing but what to, is that the target location for build/debug/development??
    So far I have on my C drive, the Apache Flex SDK, AIRSDK_Compiler, apache-ant-1.9.3 and am working through the Flex SDK readme file to download SW and set up the Path variables.
    I got stuck on the FlashPlayerDebugger.exe as I cannot find where the Debugger installation is located (ActiveX or Plugin). Now skipping this moving onto the following points.
    A real concern is that I am using 64bit OS and how that affects the resulting project when it is to be installed on a 32bit customer server.
    Regards,

    You might get better help asking on [email protected]

  • PS migration: How to stop auto-creation of PR for completed activities?

    We are migrating project master & transactional data from R/3 4.7 to ECC5. In the old system, majority of the ext. activities in our projects already carries the status REL. Purchase Requisition was auto-created > PO done > GR/IR done > actual cost for the ext. activity already posted into the project.
    In our migration effort, we are transferring the whole project structure & master data from the old 4.7 to ECC5 and subsequently updating the system & user statuses of the whole project structure.
    How can we stop the system from auto-creating a PR again when the statuses are updated for those activities that are already completed, i.e. actual cost posted, as in 4.7 system?
    We thought of using the logic if a PO exist for the activity in the 'old' system, then the field AFVGD-AUDISP (Res/Pur.req) for the activity in CJ20N should be set to 'Never'. However, my ABAPer was saying this could not be done as AFVGD is a structure and not a table.
    Have any one of you face similar predicament? Is there other method to address this issue? Appreciate your assistance.
    Edited by: Quah Ai Ling on Jun 10, 2008 5:36 AM

    Hi Varshal,
    Thanks for the suggestion.
    However, we thought of an alternate method that does involve changing the customers existing business process.
    1) Change the field AUDISP in the network profile to 1 "Never" for the conversion.
    2) Migrate the data. Program will create Networks, Activities & Components with the field AUDISP set to "Never create Reservation or Purchase Requisition".
    3) Change the field in AUDISP in the network profile back to "2 From Release".
    We will have to get the users to clean-up their data (close outstanding PRs or convert those PRs to POs) before this exercise for a clean cut-over.

  • How to use AUTO in Mapping name for EDIFACT

    Hi
    I have a source which will be posting 2 diff kinds of EDIFACT  to XI.
    I want to use just a single channel where i want to configure my .sda module.
    I've seen that we can use 'AUTO' in MappingName parameter, so that the mapping is chosen dynamically.
    However,when i tried to do so, i get an error saying that the adapter cannot find the mapping in the classpath.
    Can anyone guide me as to how to use the AUTO parameter?
    If possible, provide a link for some blog where they are using it.

    Hi Alok,
                  Reason behing not getting the EDI payload was missing of splitter configuration, you need to configure the splitter as
    you need to use AUTO mappingName instead of specific mapping name
    once you configure split parameter of bic  to true, it will generate an attacments like KEY|MAPPINGNAME|ACCEPTED|MessageNo
    then based on this configuration splitter will look for the same key in Seeburger workbench configuration and then generates a XI message (SXMB_MONI entry) ...
    If you dont want acknowledgement of EDI and sure about the version of the mapping then you can configure the mappingName
    directly instead of AUTO...in BIC paramter
    HTH
    Rajesh

  • How to setup auto dim, when light darkens

    when i went to the Mac Store, the guy working there showed me this auto dim feature, that when the light around the laptop(environment) darkens the laptop gets brighter and the keyboard lights up.
    i just bought my laptop and got it today and i would like to know how i can activate this feature  i have the 15.5 inch macbook pro with normal screen

    System Preferences/Keyboard/Keyboard - place a check mark next to "Illuminate keyboard in low light conditions."
    Or call the store where you purchased the computer and ask the sales clerk you spoke to.

  • How to ceate auto scroll mp3 lyric for 5233 music ...

    I have a song that already has embedded lyric. When I played that song in my Nokia 5233 music player the lyric scrolls automatically. But when I tried to embed lyric using the softwares MediaMonkey, MiniLyrics etc. in one of my song and played in the music player, it did not auto scroll.
    So how do that song has auto scroll lyrics. Could any one let me know if there is any software to embed auto scroll lyric in MP3 so as to play in my default Nokia 5233 music player.
    Thanks in Advance.

    When editing info if you use the right click then get info option you will not be interrupted on editing.

  • How to setup MM costing and drive for new parts before ECM release key is triggered?

    Hi,
        I am on the engineering side of SAP ERP where I create new materials, BOMs, etc.  We do this with a change master without release key today.   We are switching to a more controlled/managed process for engineering changes where we will use change masters with a release key and approval workflows for these tasks (ECM).   The problem we are seeing is that the supply chain side of the business is not able to perform their tasks of costing materials and driving for new parts until the ECM workflows are complete, release key is active, and the changes are valid for production.  There must be a way for supply chain to perform these tasks beforehand, so that when the release key becomes active, material costing is complete, new materials are already on hand (or at least been ordered), so that the process of procurement/production orders are not delayed.  Can you point me to documentation that provides an overview, or summarizes what the best practices are for our supply chain when we start working with ECM release keys?
    Thanks,
    Joseph

    the release key allows you to release the change for specific business functions. Please look at the options available in release key configuration. You will need multiple release keys to bring the changes in a more controlled manner.

  • How to setup a static IP for a wireless printer

    This problem has been ongoing for several versions of OS X and the last five printers I've had and I'm finally over messing with it.  For some reson, when using a wireless printer with OS X this is a repetetive problem, and I think if I configured the printer to a static IP address instead of using DHCP, it might work better.  At least once a week, if not more often, I'll print something and get the ubiquitous Dock error of "Printer is not connected".  The printer is still in Preferences, but if I delete it, then it doesn't show up as it should for selection.
    The only way to fix this is reboot, and then the printer shows up again in Preferences.  I select it and all is well again...until a few days pass and the same thing happens again.  Using an HP LaserJet P1102w, still a current model, but it doesn't matter which printer I use.  I also have an Epson Artisan 725 and the same thing happens with it about once a week.  Also, this happens from both my Mac and my wife's Mac, so it's not an issue with just my machine.
    I've searched for documentation on how to setup a static IP address for a wireless printer with the Airport Extreme, but all I find are tutorials on how to do it with an ethernet hard-wired printer.  Any help would be greatly appreciated.

    You could set up your router to do manual assignment of IP address instead of using DHCP, but that is a PITA, because then you'd have to manually set up IP for all your devices.
    If you have AirPOrt Extreme, you could do this:
    In your Apple TV, go to the Settings >> About and write down the MAC address of your ATV
    Start up the AiPort Admin Utility
    Go to Network tab
    click + in the DHCP reservations
    Choose an IP you want for your ATV & Enter the MAC address
    From now on, this IP address will be reserved to the MAC address and only your ATV will be able to get it, no other device will.
    It is not a static IP in a true sense, but behaves just like one.
    Works great for me...
    If you don't have a AP Extreme, I'm sure other routers will allow you do reservations too.

  • How to setup /dev/random to SSL seed no. in JDK 1.4

    In order to speed up the SSL encryption and reduce CPU resources in WebServer, pls let us how to setup/define the /dev/random for SSL seed no in JDK 1.4 on Solaris 8 (Latest Patch).
    Current Setup:
    H/W:
    + Sun V880 with 2 x 1.2GHz US-III CPU, 2GB RAM
    S/W:
    + SunOne Web Server 6.1 SP1
    + Solaris 8 (latest patch) support /dev/random
    + JDK 1.4
    Rgds,
    William

    You may get a better response posting this question to one of the security forums, specifically:
    http://forum.java.sun.com/forum.jsp?forum=2
    http://forum.java.sun.com/forum.jsp?forum=60
    You could also try the App server product forum:
    http://swforum.sun.com/jive/category.jspa?categoryID=30

Maybe you are looking for

  • Error while creating a overwrite method in class

    Hello. I'm trying to create an overwrite method in the class CL_HREIC_EECONTACT2SRCHV_IMPL but it just won't let me. Every time I try I get the message "The class has not yet been converted to the new class-local types" and I cannot create it.The thi

  • PL/SQL and Forms executable in Oracle 8i Lite ?

    I've got 2 basic and important questions: 1.) Is it possible to store procedures with PL/SQL in a Oracle 8i Lite Database(Operating System Windows 2000) 2.) Are the normal Forms 6i - Applications executable on a Oracle 8i Lite Database. (Operating Sy

  • Moving events from one calendar to another

    Is it possible to move events from one calendar to another? Here is our scenario: User abc123 has set up a calendar abc123:boardroom for other users to book slots in the board room (he didn't know about resource calendars at the time and so didn't re

  • How to get the EJB "Cached Beans Current Count" in Command-Line

    I use WebLogic console to monitor EJB's "Cached Beans Current Count" property in monitor tab, but I want to get the result in Command-Line using "weblogc.Admin". What arguments to be used? I can get the EJB property use: java -cp weblogic.jar weblogi

  • The bottom of my laptop is coming off

    The bottom of my MacBook is coming off and I'm not really sure why.  Does anyone know what I can do for this?