Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  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  
// Variables
private 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]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (44 views)
2014-10-16 15:22:06

Norakomi (34 views)
2014-10-16 15:20:20

lcass (38 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (68 views)
2014-10-14 00:35:47

TehJavaDev (60 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (86 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!