Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (753) Games in Android Showcase (228) games submitted by our members Games in WIP (842) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Show Posts Pages: [1]
 1 Game Development / Newbie & Debugging Questions / Re: proteced access on: 2009-07-31 16:13:33 PERFECT...! Just ran across the same probem.Thanks!
2  Game Development / Newbie & Debugging Questions / Re: Image Placement with Precision - Graphics2D on: 2009-01-11 17:23:43
I used the cast method as suggested by SimonH (gave me the answer in the first post, but I didn't quite grasp it)...
 1 `g2.drawImage(myBall.getBall(),(int)myBall.getX(),(int)myBall.getY(),null);`

... and everything works perfectly. Thank you very much, a wonderful first experience on this forum.

/ happily goes back to coding
 3 Game Development / Newbie & Debugging Questions / Re: Image Placement with Precision - Graphics2D on: 2009-01-10 20:38:25 Many many thanks to everyone who replied!Cheers
4  Game Development / Newbie & Debugging Questions / Re: Image Placement with Precision - Graphics2D on: 2009-01-10 18:57:57
I'm writing a simple app to simulate gravity on an object for a Physics project

The problem occurs in the Maths when the ball is at the top of the fall... because I have to cast to (int) for movement, it stalls until the value is greater than 0.5 or less than -0.5... So it just hangs there.

Here is the code for the movement of the ball...
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17 `// Variablesprivate final long DELAY = 20;                                  // Timer delay (10 ms)        private float a = 9.8f;                                         // Default acceleration 9.80 m/s/s     private float t = DELAY / 1000.0f;public void cycle(){        // Increase velocity based on rate of acceration        myBall.setY((int)(myBall.getY() + (t * (myBall.getVY() + a * t))));        myBall.setVY(myBall.getVY() + a * t);        //System.out.println(myBall.getY());        //System.out.println(myBall.getVY());                if(myBall.getY() > getHeight() - myBall.getRadius() * 2){            myBall.setVY(-myBall.getVY()*myBall.getElast());        }`

/Edit - Added the variables... note getVY returns a float (myball current velocity)
 5 Game Development / Newbie & Debugging Questions / Re: Image Placement with Precision - Graphics2D on: 2009-01-10 17:51:06 Indeed... but then I loose the precision. Sorry if this is silly question. ( Hence Newless Clubies)
 6 Game Development / Newbie & Debugging Questions / Image Placement with Precision - Graphics2D on: 2009-01-10 17:42:38 Hi,This is my first post!I would like to load an image and control the placement/movement in a JPanel with precision (float). After a gazzilion searches and paging through books it seems that I can only position an image using (int).Is there a trick I can use... Like somehow attaching the image to a rect, or another image method I can use?Cheers & Thanks
 Pages: [1]
 ivj94 (585 views) 2018-03-24 14:47:39 ivj94 (49 views) 2018-03-24 14:46:31 ivj94 (383 views) 2018-03-24 14:43:53 Solater (63 views) 2018-03-17 05:04:08 nelsongames (109 views) 2018-03-05 17:56:34 Gornova (159 views) 2018-03-02 22:15:33 buddyBro (703 views) 2018-02-28 16:59:18 buddyBro (92 views) 2018-02-28 16:45:17 xxMrPHDxx (494 views) 2017-12-31 17:17:51 xxMrPHDxx (734 views) 2017-12-31 17:15:51
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org