×

Discussion Board

Results 1 to 2 of 2

Thread: BAll owner

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    5

    BAll owner

    How to determine which player is currently holding the ball or which player currently has the possession to it? And also painting/drawing it?
    Please please help!

  2. #2
    Registered User
    Join Date
    Jan 2007
    Posts
    5

    Re: BAll owner

    I really need to solve this one, how should the ball's coordinates dependent on my players coordinates?

    ball class:
    Code:
    public class Ball {
        
        int xball, yball;
        int vY,vX;
        int xb,yb; //ball's position/coordinates
        
        private int w,h;
        
        private PlayerSprite player = null;
        
        private Image bball;
      
    public Ball() throws Exception{
        
         xb = 15;
         yb = 15;
        
         xball = 0;
         yball =15;
         
         vY = 5;
         vX = 2;   
    
      bball =Image.createImage("/ball.png");
    
    }
    
    public void moveBall()
    {
            try 
            {  
                  if(yball >= 15)
                      vY = vY * -1;
                  
                  else if(yball <= 0)
                      vY = vY * -1;
    
                  xball+=vX;
                  yball+=vY;
                  
            }
            catch(Exception e)
    	{
                
    		e.printStackTrace();
                    
    	}
    
    }
    
    
    public void paintBall(Graphics g){
    
           g.drawImage(bball,xb,yball+yb,0);
       }
    
     }
    player sprite

    Code:
     int meX;
           int meY;
           
           int fWidth;
           int fHeight;
           
            int ballx;
           int bally;
    .
    .
    .
    public void move()
        {
            this.move(meX,meY);
        }
    gamecanvas

    Code:
     switch(keyStatus) {
               
               case GameCanvas.KEY_NUM2:
                  //up
                   player[0].move(0,-1);  
                   player[0].setFrame(3);
                
                   break;
               case GameCanvas.KEY_NUM8:
                //down
        
                  player[0].move(0,1);
                  player[0].setFrame(2); 
                
                   break;
               case GameCanvas.KEY_NUM4:
                //left  
            
                    player[0].move(-1,0);
                     player[0].setFrame(7);
                  
                   break;
               case GameCanvas.KEY_NUM6:
                //right
           
                 player[0].move(1,0);
                 player[0].setFrame(8);
                   break;
    please help!

Similar Threads

  1. Owner draw, variable height, listbox
    By dub_sth in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-02-19, 13:36
  2. Floating Progress Ball Control Problem...
    By CodePupil in forum Symbian
    Replies: 4
    Last Post: 2008-06-08, 16:55
  3. Ball is behind the map.
    By th3martian in forum Mobile Java Games
    Replies: 2
    Last Post: 2007-02-21, 12:23
  4. bitmap-bouncing ball
    By zhenLeow in forum Symbian
    Replies: 0
    Last Post: 2003-08-27, 05:15
  5. Another Unimpressed 6310i owner
    By rustyvw in forum Bluetooth Technology
    Replies: 3
    Last Post: 1970-01-01, 02:00

Posting Permissions

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