Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (483)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (550)
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  
  Gravitator4K  (Read 10362 times)
0 Members and 1 Guest are viewing this topic.
Offline Sandor

Junior Member


Projects: 3



« Posted 2006-02-22 21:57:01 »

Here's an early version of Gravitator4K.

The game is fairly simple, and is controlled via mouse.  There's a particle fountain randomly placed on the left side of the screen, with a blinking blue target randomly placed on the right side.  You click on the screen to create gravitational masses (left click for attractors, right-click for repulsors).  You can place up to 25 masses on the screen, but not inside the target area.  You need to get 100 particles to the target in 60 seconds.  Each level up, the target decreases in size a little.

The level difficulty really doesn't change much, and I still need to work on this.

SCREENSHOT:
Click to Play


NOTES:
1. I've only tested this with Java 1.4, not 1.5.
2. I have not tested this on Mac or Linux, only on Windows so far.
3. The machine being used for testing is a 2GHz P4 running Windows XP, with 512MB of RAM.

JAR File (2836 bytes): http://www.curiouskangaroo.com/4k/gravitator4k/g.jar
JNLP File (707 bytes): http://www.curiouskangaroo.com/4k/gravitator4k/Gravitator4K.jnlp

I still have some work to do, but I welcome any comments.  For this game, I have not yet used any special compression techniques, so I do still have some room to play with.
Offline DonaldEKnuth

Junior Member





« Reply #1 - Posted 2006-02-22 22:38:17 »

Cool game, but if I run it through JWS using Java 1.5 Update 2 on Windows XP (latest SP and patches) I can't see the bottom of the window as intended: Example

Apart from that little flaw it's nice. I just poked around with exactly that sort of physics for a 2D planet simulation. Smiley

My 4k 2006 Entry: Sokoban4k
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2006-02-22 23:06:41 »

Nice idea, but in level 4 the destination-thingy gets way too small Smiley

You could make it more difficult by having more than 1 emitter

Or having more that 1 destination, with a certain amount of particles required per destination

Or both! Smiley

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Sandor

Junior Member


Projects: 3



« Reply #3 - Posted 2006-02-22 23:46:46 »

Cool game, but if I run it through JWS using Java 1.5 Update 2 on Windows XP (latest SP and patches) I can't see the bottom of the window as intended: Example

Apart from that little flaw it's nice. I just poked around with exactly that sort of physics for a 2D planet simulation. Smiley

Thanks, I'll adjust the placement in my next update.
Offline Sandor

Junior Member


Projects: 3



« Reply #4 - Posted 2006-02-22 23:49:03 »

Nice idea, but in level 4 the destination-thingy gets way too small Smiley

You could make it more difficult by having more than 1 emitter

Or having more that 1 destination, with a certain amount of particles required per destination

Or both! Smiley

Thanks!

Yes, figuring out exactly what to do with the levels is going to be my challenge for the next few days.  I'll play around with the idea of multiple destinations/emitters.  What about color-coded ones?  For example, white particles need to hit a white target and blue particles need to hit a blue target.

Also, if possible, I might play around with making the masses draggable.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #5 - Posted 2006-02-23 01:40:42 »

Making masses draggable makes it too easy, way too easy. You'd only need 1 mass then, and drag is around a bit until it's in place.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline woogley
« Reply #6 - Posted 2006-02-23 04:50:04 »

cool game

you could save yourself some bytes if you stop listening for keys (just have the game start with the click of a mouse since the keys do nothing else anyway)
Offline DonaldEKnuth

Junior Member





« Reply #7 - Posted 2006-02-23 12:19:54 »

The idea with color codes sounds nice. I think the goal circle for the particles should never be smaller than an emitter, but it's just me (it's hard to tell where it is sometimes).

My 4k 2006 Entry: Sokoban4k
Offline Sandor

Junior Member


Projects: 3



« Reply #8 - Posted 2006-02-23 19:19:46 »

Ok, modified the game to include multiple emitters/goals on higher levels.  Made the particles themselves a little bigger.  Goals don't start shrinking until level 6.  Replaced key-press with mouse-click.  No draggable masses.  Number of masses you are allowed increases with the number of goals.  Number of required "hits" in the center of each goal.  Text doesn't go as far down now.

Used proguard/jarg/kzip (originally the class was small enough just to use normal zip compression and no classfile optimizers) so the jar size is now smaller than before.

Link above still works, I just replaced the jar file.  Also replaced the screenshot.

Still plenty of room for more code, but I'm not sure how much more time I'm going to have.

Any other suggestions or comments welcome!

Strategy hint: setting up multiple successful streams at once is cool, but sometimes it is easier to concentrate on one at a time... as long as it doesn't take you too long to set it up.

Hint #2: when placing masses (or anti-masses) far away from the emitter/fountain, gravitational effects will add up significantly by the time the particles travel far enough.  Also, since all particles are affected when you place a new mass, even far away ones, expect your particle stream to change sometimes ten or fifteen seconds AFTER placing the mass (enough time for further away particles that were perhaps just emitted when you were placing the mass to travel across the field).

Hint #3: anti-masses are good for completely reversing particle flow when the emitter is facing entirely the wrong way... otherwise they can be used to "nudge" a stream, but should probably be placed further away from the stream than you think.

EDIT: I'm able to get up to level 4, score 159777.  Haven't passed level 4 yet, though.
Offline moogie

JGO Knight


Medals: 12
Projects: 6
Exp: 10 years


Java games rock!


« Reply #9 - Posted 2006-02-25 06:30:11 »

I thought id give your game a go and got to level eight before i stopped to get ready to go out.

see the screenie blow:

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Anon666

Junior Member




aka Abuse/AbU5e/TehJumpingJawa


« Reply #10 - Posted 2006-02-25 12:35:38 »

Got to level 7, before quitting 'cos my sore throat is realy hurting Undecided

360000

The new version is much better - is it my imagination, or do each of the particles also attract one-another?
Offline Sandor

Junior Member


Projects: 3



« Reply #11 - Posted 2006-03-01 17:11:39 »

Got to level 7, before quitting 'cos my sore throat is realy hurting Undecided

360000

The new version is much better - is it my imagination, or do each of the particles also attract one-another?

Thanks!  Inter-particle attraction is just your imagination.  However, it is important to note that when you place a new mass somewhere down the "chain", it affects everything on the field, even particles very far away.  What happens next is that you see your mass immediately affect nearby particles in some fairly obvious way... usually the way you intended.  However, over time, as the distant particles finally arrive near the mass, they will behave slightly differently than the nearby particles did and will take on new trajectories.  This behavior is pretty non-intuitive and can occassionally look like the particles are affecting one another.  Also, there is a granularity to the simulation - this means that even if you settle down to a steady-state situation and never add new masses you'll still see occassional variations in particle trajectories from one another, even though they are starting at the same point at the same velocity being affected by the same masses.
Offline jimmoores

Innocent Bystander





« Reply #12 - Posted 2006-03-09 17:39:56 »

This came is amazingly addictive!  I've been totally hooked for the last few days and keep going back for more.  The only problem I have is that I can't see the numbers when the targets get small on the higher levels!  Also I've found it'd be nice to be able to pause it (work calls).  Just goes to show a bit of originality can produce a really playable game.  And in only 4K!
Offline Sandor

Junior Member


Projects: 3



« Reply #13 - Posted 2006-03-09 18:07:02 »

This came is amazingly addictive!  I've been totally hooked for the last few days and keep going back for more.  The only problem I have is that I can't see the numbers when the targets get small on the higher levels!  Also I've found it'd be nice to be able to pause it (work calls).  Just goes to show a bit of originality can produce a really playable game.  And in only 4K!

I do intend to do additional work on it after the contest.  Thanks for pointing out the problem with higher levels... I actually haven't had the time to get that far myself!  Also, I'll release the source code.  Maybe I should set it up as a project on java.net?  If so, it may need to get reworked into something a little more easily maintainable.  When you're shooting for small size, good design goes out the window!  If this were developed into a full-blown game, for example, I'd want to add sound, and I'd want to upgrade from the 1.0 Event Model, among other things!

I also imagine an "Evil" level where the playfield is a solar system, with planets orbiting the sun.  Try to shoot your targets with any accuracy THEN!

Thanks for the compliments, by the way.  It means a lot to hear when people enjoy playing your game!  It's more important than winning or losing the contest itself.

And this game currently weighs in at only 2.77K
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #14 - Posted 2006-03-10 15:25:13 »

I should get a super bonus for not using a single mass to complete this level.  Grin

Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #15 - Posted 2006-03-10 15:28:23 »

It is suprisingly addictive.  I have made it to level 14 so far, but could not continue playing.  Like suggested, a pause key would be really nice.  Especially when nature calls.  Also it seems on later levels that some emmiters shoot particles at a lower rate than others.  A lot of times I am wating 2-3 seconds between particles to finish the last target while others are just spitting them out left right and centre.

Offline Sandor

Junior Member


Projects: 3



« Reply #16 - Posted 2006-03-10 17:03:16 »

It is suprisingly addictive.  I have made it to level 14 so far, but could not continue playing.  Like suggested, a pause key would be really nice.  Especially when nature calls.  Also it seems on later levels that some emmiters shoot particles at a lower rate than others.  A lot of times I am wating 2-3 seconds between particles to finish the last target while others are just spitting them out left right and centre.

Thanks!  Pause is definitely high on the list.  As far as the particles go, there is one piece of code that controls all emitters.  The emission rate is constant among ALL emitters taken as a whole.  So when you're not seeing one emitter shooting particles, that means another one is actually doing the shooting.  Even with only two emitters, if you look closely you'll see that they're never shooting particles at exactly the same time.  Basically on higher levels I was worried about the sheer number of particles.  The program doesn't only have to keep track of the particle positions and velocities, but it has to compute the gravitational effects of every mass (and there can be quite a # on higher levels) on every particle on every frame.

However, I have a few ideas:
1. Rather than perform those calculations at every frame for every particle, simply make an in-memory map of the combined gravitational field.  A particle would just need to refer to the map, depending on its current position, to see how its velocity vector should change.  The map would be updated with every mass placement.  One potential problem - added granularity to the simulation.  It might result in less predictable behavior, which would kill the game.  Of course, I can't be sure until I test it.  Also, I'm not sure how long updating the map would take when a new mass is placed.
2. Limit the # of masses.  Not sure how this would affect the balance of the game.  A well played level shouldn't need more than a handful of masses.  However, sometimes those extra ones are necessary to cancel out the effect of a badly placed mass.
3. Simply allow more particles in the system, which would limit the lower-end machine that the game could be played on.

Also, that screenshot you posted previously is hilarious!  I wonder: should the game prevent such serendipity?  Or is it okay to sometimes have that kind of thing happen?
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #17 - Posted 2006-03-10 19:24:56 »

However, I have a few ideas:
1. Rather than perform those calculations at every frame for every particle, simply make an in-memory map of the combined gravitational field.  A particle would just need to refer to the map, depending on its current position, to see how its velocity vector should change.  The map would be updated with every mass placement.  One potential problem - added granularity to the simulation.  It might result in less predictable behavior, which would kill the game.  Of course, I can't be sure until I test it.  Also, I'm not sure how long updating the map would take when a new mass is placed.
2. Limit the # of masses.  Not sure how this would affect the balance of the game.  A well played level shouldn't need more than a handful of masses.  However, sometimes those extra ones are necessary to cancel out the effect of a badly placed mass.
3. Simply allow more particles in the system, which would limit the lower-end machine that the game could be played on.
1.  This would probably work.  Since the masses are not moving, the map would only be updated infrequently.  Even if you take a few cycles to update the map, to the plyer it would just look like the particles are settling in on the new field.
2.  No, I think the current number of masses is ok.  Maybe reduce a couple, but overall it is nice to have them for emergencies.
3.  Instead of this, maybe have each emitter only emit at a certain point.  So if you have say 6 emitters, then within 1 second, each would only produce 1 particle at a certain appointed time.  The times would be 166, 333, 500, 666, 833, 1000 miliseconds.  So white would be at (166, 1166, 2166, ...), yellow at (333, 1333, 2333, ...) etc... So you guaruntee even particle flow and limit the total particles still.

Also, that screenshot you posted previously is hilarious!  I wonder: should the game prevent such serendipity?  Or is it okay to sometimes have that kind of thing happen?
No.  I don't think it is necessary.  The chance of it happening is pretty small.  And if it does, it is like a bonus.  Most of the time I don't even get 1 emitter pointing at a consumer.

Offline Sandor

Junior Member


Projects: 3



« Reply #18 - Posted 2006-05-04 21:18:25 »

Source code posted at:

http://www.curiouskangaroo.com/4k/gravitator4k/G_java.txt

under GPL.

Please let me know if you make any changes, and I'll make them available for all to enjoy.

I'll probably make mods at some point in the near future, as I get time.
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.

CopyableCougar4 (15 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (38 views)
2014-08-06 19:49:38
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!