The Artima Developer Community
Sponsored Link

Java Answers Forum
Pong

3 replies on 1 page. Most recent reply: Nov 17, 2006 12:03 PM by Lane Johnson

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Lane Johnson

Posts: 3
Nickname: tebadi11
Registered: Sep, 2006

Pong Posted: Nov 16, 2006 12:17 PM
Reply to this message Reply
Advertisement
Heres the code I have for the paddle class of Pong. I really have no idea what to do here. Any help?


public class paddle
{
private int X;
private int Y;
private int appWidth;
private int appHeight;

public class paddle(int nXpos, int nYpos, int appletHeight, int appletWidth)
{

X = nXpos;
Y = nYpos;
appWidth = appWidth;
appHeight = appHeight;

}
public void moveUp()
{

}
public void moveDown()
{

}
public void draw (Graphics g)
{
g.setColor(Color.red);
g.fillRect(x,y,5,15);
}
public int yPos()
{

}
public int xPos()
{

}



}


Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Pong Posted: Nov 16, 2006 11:01 PM
Reply to this message Reply
moveUp ... increment y
moveDown ... decrement y
yPos ... return y position
xpos ... return x position

y can't be lower than 0 (or 1, depending how the program works) or higher then appHeight

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Pong Posted: Nov 16, 2006 11:08 PM
Reply to this message Reply
I made two mistakes (should have taken a look at the draw method).

1. since the paddle has a hight of 15

y < appHeight - 15

2. your startpoint is in the upper left corner
=>
moveUp ... decrement y
moeDown ... increment y

Lane Johnson

Posts: 3
Nickname: tebadi11
Registered: Sep, 2006

Re: Pong Posted: Nov 17, 2006 12:03 PM
Reply to this message Reply
Ohh I see. Thanks dude.

Flat View: This topic has 3 replies on 1 page
Topic: Pong Previous Topic   Next Topic Topic: Help Needed

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use