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 (534)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Gravitational Fourks  (Read 4707 times)
0 Members and 1 Guest are viewing this topic.
Offline pjt33
« Posted 2009-01-12 20:31:45 »

This is a two-player game, but the players must share a mouse - networking is not on the cards. Take it in turns to fire missiles, aiming to hit the other player. Once you fire a missile the only force to act on it will be gravity, so you must judge the initial course and speed carefully. Control is entirely with the mouse.

http://cheddarmonk.org/java4k/gravfourks/grav4k_latest.jnlp


Offline irreversible_kev

Junior Member





« Reply #1 - Posted 2009-01-12 22:09:42 »

Error Lips Sealed

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  
No applet found on web page, try as JNLP direct
java.lang.InternalError:
****************************************************************
ERROR: the javaplugin.version system property wasn't picked up
by the com.sun.deploy.Environment class. This probably happened
because of a change to the initialization order in PluginMain
where the deployment classes are being initialized too early.
This will break jar cache versioning, and possibly other things.
Please undo your recent changes and rethink them.
****************************************************************
   at sun.plugin2.applet.Applet2Environment.initialize(Unknown Source)
   at sun.plugin2.applet.viewer.JNLP2Viewer.run(Unknown Source)
   at sun.plugin2.applet.viewer.JNLP2Viewer.main(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at com.sun.javaws.Launcher.executeApplet(Unknown Source)
   at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
   at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
   at com.sun.javaws.Launcher.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
   at a.start(Unknown Source)
   at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Exception: java.lang.NullPointerException


For some reason its talking about applets...

Does your code do anything with applets? If so that might be the problem.
Offline pjt33
« Reply #2 - Posted 2009-01-13 00:01:58 »

Error Lips Sealed

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  
No applet found on web page, try as JNLP direct
java.lang.InternalError:
****************************************************************
ERROR: the javaplugin.version system property wasn't picked up
by the com.sun.deploy.Environment class. This probably happened
because of a change to the initialization order in PluginMain
where the deployment classes are being initialized too early.
This will break jar cache versioning, and possibly other things.
Please undo your recent changes and rethink them.
****************************************************************
   at sun.plugin2.applet.Applet2Environment.initialize(Unknown Source)
   at sun.plugin2.applet.viewer.JNLP2Viewer.run(Unknown Source)
   at sun.plugin2.applet.viewer.JNLP2Viewer.main(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at com.sun.javaws.Launcher.executeApplet(Unknown Source)
   at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
   at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
   at com.sun.javaws.Launcher.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
   at a.start(Unknown Source)
   at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Exception: java.lang.NullPointerException


For some reason its talking about applets...

Does your code do anything with applets? If so that might be the problem.
I've no idea what "recent changes" it thinks someone has made to something. The game is an applet launched by JNLP which works fine for me - and I just cleared my cache to make sure. It seems to find the class and then throw an NPE, which is a bit odd. Which version of Java are you using?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline SimonH
« Reply #3 - Posted 2009-01-13 02:34:37 »

Worked fine for me - bit tricky to guestimate though... (can't you zoom out to keep the missiles on the screen?  Wink)

People make games and games make people
Offline pjt33
« Reply #4 - Posted 2009-01-13 12:21:59 »

Worked fine for me - bit tricky to guestimate though... (can't you zoom out to keep the missiles on the screen?  Wink)
That's on the list of possible but improbable additions. It would mean expanding the size of the backbuffer, which would make the fading operation slow.
Offline steveyO
« Reply #5 - Posted 2009-01-13 13:34:09 »

This reminds me of a game I used to play with a sheet of paper and pencil (during University lectures many years ago.. tut)... Each player had 5 ships and could either move or shoot..  Movement/shooting was done by flicking the pencil downwards at an angle,  and following the path..  Wot fun..  Maybe something similar (ie  Move ability too and maybe 3 ships each?)  ps. Any reason you didnt use antialiasing?  This should greatly improve the graphics..

https://play.google.com/store/apps/details?id=com.bullsquared.alggame Annoying Little Gits (Android)
www.bullsquared.com   Play java (applet) games! www.chessclockpro.com Free Online Chess Clock
Offline pjt33
« Reply #6 - Posted 2009-01-13 13:42:13 »

ps. Any reason you didnt use antialiasing?  This should greatly improve the graphics..
Also on the list. It will mean reworking the collision detection. At the moment I do that by XORing the missile onto the backbuffer, scanning its bounding box for pixels of the colour which that turns planets into, and then XORing again to clean up the backbuffer. I think it should just be a case of extending the pixel test a bit.
Offline pjt33
« Reply #7 - Posted 2009-01-16 19:56:45 »

The latest release has much snazzier graphics, including anti-aliasing.
Offline irreversible_kev

Junior Member





« Reply #8 - Posted 2009-01-16 20:14:15 »

I've no idea what "recent changes" it thinks someone has made to something. The game is an applet launched by JNLP which works fine for me - and I just cleared my cache to make sure. It seems to find the class and then throw an NPE, which is a bit odd. Which version of Java are you using?

1  
2  
Java Plug-in 1.6.0_12
Using JRE version 1.6.0_12-ea Java HotSpot(TM) Client VM


The "Gravitational Fourks" JFrame/Frame comes up with a grey contents and I get that exception in the Java Console.

EDIT:

1  
D:\Program Files\Java\jre1.6.0_11\bin>javaws http://www.toothycat.net/~pjt33/java4k/grav4k_latest.jnlp

WORKS (jre1.6.0_11)

and

1  
D:\Program Files\Java\jre6\bin>javaws http://www.toothycat.net/~pjt33/java4k/grav4k_latest.jnlp

DOESN'T WORK (jre1.6.0_12)


lol it's epic when you do a full orbit and shoot yourself in the ass. It's very rewarding when you acctualy hit the opponent though!
The guides really help.
Offline ShannonSmith
« Reply #9 - Posted 2009-01-16 20:41:27 »

Nice game. I would tend to have less planets though, gravity becomes a bit hard to predict after more than about 3 bodies. Also if you want even better looking planets I wrote a tutorial a while back on just that topic see here. If you have minimal space to spare, running the input coordinates to your texture function through this will give you nice spherical looking planets:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
void distort(float x, float y, Vector2D dest) {
  float z;
  float nxangle, nyangle, theta1, theta2;
  float ri = 0.5f; // refraction index

  z = (float)Math.sqrt ((1 - x * x  - y * y ));

  nxangle = (float)Math.acos(x / Math.sqrt(x * x + z * z));
  theta1 = PI / 2 - nxangle;
  theta2 = (float)Math.asin (Math.sin (theta1) * ri);
  theta2 = PI / 2 - nxangle - theta2;
  dest.x = x - (float)Math.tan (theta2) * z;

  nyangle = (float)Math.acos (y / Math.sqrt(y * y + z * z));
  theta1 = PI / 2 - nyangle;
  theta2 = (float)Math.asin(Math.sin (theta1) * ri);
  theta2 = PI / 2 - nyangle - theta2;
  dest.y = y - (float)Math.tan (theta2) * z;
}
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #10 - Posted 2009-01-16 20:46:55 »

Cool, this is sort of like what my Spoo4k game originally started out as.

It seems sort of sparse at this point, however, and it can be very difficult. I even shot myself instead of my opponent once.

See my work:
OTC Software
Offline pjt33
« Reply #11 - Posted 2009-01-16 21:05:17 »

1  
2  
Java Plug-in 1.6.0_12
Using JRE version 1.6.0_12-ea Java HotSpot(TM) Client VM
Thanks, but I'm puzzled by jre1.6.0_12, because I can't find anything more recent than update 11 on sun.java.com. Where did you download it? Edit: oh, I see an -ea at the end. If you will beta-test stuff you've got to expect it to have problems Tongue

Thanks for the comment on the guides.

sws26, I'll check out your guide. My guess is that it's basically spherical lighting, but I haven't looked yet. The idea had occurred to me, although it will have to be either that or Perlin noise until I optimise the noise.

The gravity is supposed to be hard to predict: after a bit of practice, ones with four or five planets get too easy.
Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #12 - Posted 2009-01-16 22:44:36 »

Might be interesting to overlay a grid that displays the gravitational sheer at each vertex.
Or maybe a full gravity map, using a color gradient to display the magnitude of the gravitational force at each pixel (the direction of the force would not be needed, as it would be obvious by the color of the surrounding pixels)

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline pjt33
« Reply #13 - Posted 2009-01-16 22:56:39 »

Nice game. I would tend to have less planets though, gravity becomes a bit hard to predict after more than about 3 bodies. Also if you want even better looking planets I wrote a tutorial a while back on just that topic see here. If you have minimal space to spare, running the input coordinates to your texture function through this will give you nice spherical looking planets:
Ok, now that I've read the accompanying page I see that it's a bit more complicated than I thought. Having said that, the code is more complicated than it obviously needs to be. Are there good numerical analytic reasons for not simplifying it thus?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
void distort(float x, float y, Vector2D dest) {
  float z;
  float tmp, theta;
  float ri = 0.5f; // refraction index

  z = (float)Math.sqrt(1 - x * x  - y * y);

  tmp = x / (float)Math.sqrt(1 - y * y);
  theta = (float)Math.acos(tmp) + (float)Math.asin(tmp * ri);
  dest.x = x - z / (float)Math.tan(theta);

  tmp = y / (float)Math.sqrt(1 - x * x);
  theta = (float)Math.acos(tmp) + (float)Math.asin(tmp * ri);
  dest.y = y - z / (float)Math.tan(theta);
}


Edit: in fact if my algebra is correct the trig functions can be eliminated entirely so: (warning: untested code, as is the stuff above)
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
void distort(float x, float y, Vector2D dest) {
  float z;
  float tmp, rx, ry;
  float ri = 0.5f; // refraction index

  z = (float)Math.sqrt(1 - x * x  - y * y);

  rx = ri * x;
  tmp = (float)Math.sqrt(1 - rx * rx - y * y);
  dest.x = rx * (1 - y * y) / (z * tmp + rx * x);

  ry = ri * y;
  tmp = (float)Math.sqrt(1 - x * x - ry * ry);
  dest.y = ry * (1 - x * x) / (z * tmp + ry * y);
}

Offline ShannonSmith
« Reply #14 - Posted 2009-01-16 23:33:14 »

Entirely possible that the code is horribly inefficient, I never bothered trying to simplify it any further (wasn't for a 4k contest). I'll try your code tonight, if it works I'll update my tutorial (assuming you have no objections to me using your version).
Offline pjt33
« Reply #15 - Posted 2009-01-17 00:45:06 »

Entirely possible that the code is horribly inefficient, I never bothered trying to simplify it any further (wasn't for a 4k contest). I'll try your code tonight, if it works I'll update my tutorial (assuming you have no objections to me using your version).
None at all. I'm not going to use it as is, though, because it occurs to me that that's the forward transform and unless I plan to write a ray tracer I'd need the reverse transform. Is it the same with reciprocal index of refraction? Have to think about it some more.
Offline ShannonSmith
« Reply #16 - Posted 2009-01-17 01:29:18 »

Why would you need the reverse transform?
Offline pjt33
« Reply #17 - Posted 2009-01-17 09:02:30 »

Why would you need the reverse transform?
If I understand your page correctly (this may be the problem!) then I pass texture coords to that method and it passes back screen coords. Is it really the other way round?
smith
Guest
« Reply #18 - Posted 2009-01-17 18:49:52 »

Correct, pass in screen coords to get texture coords (probably should have made that clearer.
Offline pjt33
« Reply #19 - Posted 2009-01-17 22:52:26 »

Might be interesting to overlay a grid that displays the gravitational sheer at each vertex.
Or maybe a full gravity map, using a color gradient to display the magnitude of the gravitational force at each pixel (the direction of the force would not be needed, as it would be obvious by the color of the surrounding pixels)
I've added the latter. I think you may be overestimating the ability of the average punter to visualise a Laplacian, but I like the look.
Offline Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #20 - Posted 2009-01-17 23:41:39 »

I've added the latter. I think you may be overestimating the ability of the average punter to visualise a Laplacian, but I like the look.

I see what you mean, it does look cool! =>

and it is *slightly* helpful

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline pjt33
« Reply #21 - Posted 2009-01-20 01:10:04 »

Now updated to version 1.0, which will be the final version unless I get any bug reports.

Would someone with suitable access be able to stick a screenshot on the java4k.com entry?
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

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

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

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

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

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

Zero Volt (47 views)
2014-07-17 23:47:54

danieldean (38 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
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!