Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
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  Games Center / Archived Projects / Re: My first multiplayer internet fighting game(GTGE) applet and jar on: 2009-05-13 13:52:48
I've created an account but it doesn't seem to let me login with it?

Tried it twice, accounts "paulo" and "paul".
2  Game Development / Newbie & Debugging Questions / Re: Parameter Passing of a Float on: 2008-09-22 23:12:17
@mulvey: Something funky is happening with your timer - I'm guessing it's that in the first time through the loop your base time (m_iLastLoopTime) is set at zero, right?  System.currentTimeMillis() gives me 1.22209855E12 at the moment, which tells me that's where that bizarre timing value came from (see the log you posted).  Make sure to initialize m_iLastLoopTime to System.currentTimeMillis() when you start out, then you should get more reasonable deltas and hopefully the rest of your code will work right.

That was the problem all along - well spotted, I can't believe I missed that!

 Smiley
3  Game Development / Newbie & Debugging Questions / Re: Parameter Passing of a Float on: 2008-09-22 11:24:16
The triangle rotates just fine when I increment it with a local value, but the problem was that I couldn't seem to pass in an external value without rotation error. I've been working on my timer, and I want to be able to use it!

Thanks to Jackal's excellent suggestion, I've watched the value of m_fAngle before and after it is modified and I now suspect my problem is a threading issue.

What I was hoping for:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
Applet init.
Applet start.
OpenGL init.
INIT GL IS: com.sun.opengl.impl.GLImpl
OpenGL reshape.
=== Main Game Count 0 ===
Game loop elapsed time value = 0.0
=== Renderer Count 0 ===
Renderer elapsed time value = 0.0
Angle before = 0.0
Angle after = 0.0
=== Main Game Count 1 ===
Game loop elapsed time value = 33.0
=== Renderer Count 1 ===
Renderer elapsed time value = 33.0
Angle before = 0.0
Angle after = 6.6
..etc...


All nice and in sequential order.

But here's what I get!

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
Applet init.
=== Main Game Count 0 ===
Game loop elapsed time value = 0.0
Applet start.
OpenGL init.
INIT GL IS: com.sun.opengl.impl.GLImpl
OpenGL reshape.
OpenGL reshape.
=== Renderer Count 0 ===
Renderer elapsed time value = 0.0
Angle before = 0.0
Angle after = 0.0
=== Renderer Count 1 ===
Renderer elapsed time value = 0.0
Angle before = 0.0
Angle after = 0.0
=== Main Game Count 1 ===
Game loop elapsed time value = 1.22207535E12
=== Renderer Count 2 ===
Renderer elapsed time value = 1.22207535E12
Angle before = 0.0
Angle after = 2.4441507E11
=== Main Game Count 2 ===
Game loop elapsed time value = 5.0
=== Renderer Count 3 ===
Renderer elapsed time value = 5.0
Angle before = 2.4441507E11
Angle after = 2.4441507E11
=== Main Game Count 3 ===
Game loop elapsed time value = 34.0
=== Renderer Count 4 ===
Renderer elapsed time value = 34.0
Angle before = 2.4441507E11
Angle after = 2.4441507E11
=== Main Game Count 4 ===
Game loop elapsed time value = 32.0


I think I need to read more JOGL and applet info, particularly with regards to implementing your own render loop properly...
4  Game Development / Newbie & Debugging Questions / Re: Parameter Passing of a Float on: 2008-09-21 21:15:14
Apologies, it's the same angle variable in the code.

The value of m_fAngle is initialised to 0.0f at the Renderer creation.

Edited my post!
5  Game Development / Newbie & Debugging Questions / Parameter Passing of a Float on: 2008-09-21 20:59:20
Hi there!  Smiley

I'm a bit new to Java so please forgive me for what is probably a very straightforward problem!

I've posted code below so you can see what I'm getting at, but quite simply I'm trying to rotate a single triangle with time-based movement.

I can't seem to convert the elapsed time from long to float and pass this into the required object without error. I feel like an idiot!

I've made a Timer class which gives me the elapsed time in millis as a long and casts to a float:

1  
m_fElapsedTime = (float)( System.currentTimeMillis() - m_iLastLoopTime );


My game loop takes this float from my Timer object and passes it into my Renderer object. The game loop:

1  
2  
3  
4  
5  
6  
7  
8  
while ( bRunning )
{
float fElapsedTime = Timer.GetElapsedTime();
m_Timer.Begin();
m_Renderer.SetElapsedTime( fElapsedTime );
m_Canvas.display();
m_Timer.End();
}


The problem is, my float never seems to pass correctly from the Timer object to the Renderer object. The code to pass the elapsed time into Renderer is simple:

1  
2  
3  
4  
5  
6  
7  
8  
9  
public class Renderer implements GLEventListener
{
// cut...

private float m_fElapsedTime;
public void SetElapsedTime( float f ) { m_fElapsedTime = f; }

//...cut
}


Is there a problem passing this value? If I were to do a System.out.println( m_fElapsedTime ) right there, it would show me the correct value 33 milliseconds.

Yet if I now go to use m_fElapsedTime in my triangle rotation code like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public class Renderer implements GLEventListener
{
// cut...

public void display( GLAutoDrawable drawable )
{
// cut...
m_fRotSpeed = 0.2f * m_fElapsedTime;
m_fAngle += m_fRotSpeed;
gl.glRotatef( m_fAngle, 0.0f, 1.0f, 0.0f );
// ...cut
}


it goes wonky. Printing out these values shows strange results:

1  
2  
m_fRotSpeed = 6.6 Correct!
m_fAngle = 2.44404437E11 Wrong!


Can anybody shed some light on what's going on with m_fElapsedTime?

One last thing - how do you indent code on a forum post?

Many thanks,
Mulvey
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.

Riven (7 views)
2014-07-29 12:53:52

Dwinin (7 views)
2014-07-29 10:59:34

E.R. Fleming (23 views)
2014-07-29 03:07:13

E.R. Fleming (9 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (51 views)
2014-07-17 23:47:54
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!