MuscleTalk Bodybuilding Forum
Forums  Register  Login  My Profile  My Subscription  My Forums  Member List  Search  FAQ  Ticket List  Help MT  Log Out
Sponsor Message
MuscleTalk T-Shirts
MuscleTalk Publications
NEW!
Muscle Menus 2 ...


Muscle Menus 2
Bodybuilding supplements at MuscleTalk Shop
RE: Any Java programmers?
View related threads: (in this forum | in all forums)
Logged in as: Guest (JOIN FREE)
Users viewing this topic: none
  Printable Version
All Forums >> [General] >> General >> RE: Any Java programmers? Page: <<   < prev  1 [2]
Sponsored by: Muscular Supplements - UK Suppliers of Sports, Bodybuilding & Nutritional Supplements All leading Brands at discounted Prices!! - Exclusive MMA Clothing by TapouT
Bookmark this thread:
Login
Message << Older Topic   Newer Topic >>
RE: Any Java programmers? - Apr. 14 2008 22:24:58   
ZEn101


Posts: 579
Joined: Jun. 6 2006
Status: online
public Ball(int x, int y)
{
posx = x;
posy = y;
System.out.println("posx= " + posx + "posy= " + posy);
speed();
}


public void draw(Graphics g, Main main)
{
// Testing
//System.out.println("here!!2");
if(moving)
{
//speed(main);
processWallCollision();
processBatCollision(main);
processBlockCollision(main);
processOffScreen(main);

// Testing
//System.out.println(xdistance);
//System.out.println(ydistance);

posx += (xdistance);
posy += (ydistance);
}
// Testing
// System.out.println(posy);

// Draw ball
g.setColor(Color.RED);
g.fillOval(posx, posy, WIDTH, HEIGHT);
}


public void resetBall(Main main)
{
// Testing
System.out.println("RESETTING BALL!");
ball = new Ball(355, 635);
ball.draw(g, main);
main.bat.resetBat();
}

ERRORS


Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Ball.draw(Ball.java:359)
at Ball.resetBall(Ball.java:452)
at Ball.processOffScreen(Ball.java:197)
at Ball.draw(Ball.java:346)
at Main$PlayPanel.paintComponent(Main.java:244)
at javax.swing.JComponent.paint(JComponent.java:1027)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paint(JComponent.java:1036)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paint(JComponent.java:1036)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:564)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5129)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:285)
at javax.swing.RepaintManager.paint(RepaintManager.java:1128)
at javax.swing.JComponent.paint(JComponent.java:1013)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)


_____________________________

My journal

Email me food

(in reply to Paracelsus)
Post #: 21
RE: Any Java programmers? - Apr. 14 2008 22:26:33   
ZEn101


Posts: 579
Joined: Jun. 6 2006
Status: online
The ball posx/y are reset properly, but the ball isn't redrawn as g seemingly is empty!?

_____________________________

My journal

Email me food

(in reply to ZEn101)
Post #: 22
RE: Any Java programmers? - Apr. 15 2008 9:42:58   
Dan Nukem


Posts: 8889
Joined: Sep. 21 2002
From: Ireland
Status: offline
What change did you make to the original code in order to get it to work? (to satisfy my curiosity please)

Going by memory here, but I think the items in your array aren't defined, therefore giving the null pointer exception.

The compiler is aware there is an array, but its not aware thats its an array of balls.

BTW, I always hated repaint, always found it a ballache

(in reply to ZEn101)
Post #: 23
RE: Any Java programmers? - Apr. 15 2008 15:21:12   
ZEn101


Posts: 579
Joined: Jun. 6 2006
Status: online
I used the count instead of counting the OBJECTS which were blocks ... fking stupid really i had been programmnig for hours was getting dopy!!

Fixed ball re-initialisation aswell all working just need to add a new level!

_____________________________

My journal

Email me food

(in reply to Dan Nukem)
Post #: 24
Page:   <<   < prev  1 [2]
All Forums >> [General] >> General >> RE: Any Java programmers? Page: <<   < prev  1 [2]
Jump to:

Google
 
Webwww.MuscleTalk.co.uk


New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages

Diet Supplements Revealed
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition