Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (636)
Games in Android Showcase (178)
games submitted by our members
Games in WIP (688)
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] 2 3
1  Games Center / 4K Game Competition - 2012 / Re: 4k Code Optimization Tips list on: 2011-12-09 08:33:01
Might be the wrong place, but this is what I used in Burning Man to fit so many levels into a small space -

Assuming your game has tiles, and there are several different sorts of tiles, the naive way to store them is a big array that goes left to right, with a byte or part of a byte for each tile type in order.  You can improve this by adding things like back references (something like: tile type 15 doesn't exist, it means the next byte says how many bytes backwards to look, and the byte after that says how long to keep copying old bytes).  However, this comes out to much larger file sizes than necessary as well.

The way to really pack those down is what the ROM hacking scene calls an object format (or they did when I was a part, it's been ten years).  The idea here is that your level files consist of a series of records like Type, X, Y, Width, Height - bit-packed however works for your specific case, of course (do not bit pack across byte lines, the space savings in the file will almost always get canceled out by the extra code).  Write a pair of for loops that take those stats and fill in that tile type in your array, and do that for each entry in order.

So, if your game has a 16x16 grid, and you have 4 types of objects, your format could look something like this:

XXXXYYYY WWWHHHTT - one nibble of X, one nibble of Y, three bits each of width and height, and two bits for type

You also need a terminator that says when a level is done.  Pick a value you'll never use for the first byte and quit when you get there.  I normally use 0xFF because that's what everything ever uses in ROM hacking, but you don't have to do that.  In the above format, that would mean no objects can start in the lower right corner.

An example level with the above looks something like this:

00001000 11111101 //x=0, y=8, width=8, height=8, type = 1.  A rectangle of stone blocks in the lower left quadrant
10001010 11110101 //x=8, y=10, width=8, height=6, type = 1.  A lower rectangle of stone blocks in the lower right quadrant
11001010 01101111 //x=12, y=10, width=3, height=3, type = 3.  A small pool of water in the lower right quadrant
11111111 // FF terminator

Which is to say, roughly the first level of Burning Man.  That's 9 bytes.  (The real thing uses 13 bytes)

Writing this out by hand is AWFUL so don't.  I wrote a level editor for Burning Man.  Your editor doesn't need to be 4k at all so go nuts and do it the normal way.  Your editor doesn't need to be used by anyone else either, so go nuts and make it super unfriendly.  The Burning Man editor was write-only (I remade levels from scratch every time I wanted to modify one, this helped keep size down) and would only do one level.  I used cat to put the level set together.
2  Games Center / 4K Game Competition - 2012 / Re: Griefer 4k on: 2011-12-09 08:01:50
I enjoyed this game!

Like the others, I think shoving some effects in there (sound and particles) would be the best way to add to the game.

You said the griefer is blocked by 2-tall blocks, does that mean he can climb 1-tall ones?  If so, you should see if you can find a way to put staircases and hills in to take advantage of that.  Hopefully there's some clever gameplay trick that can be added using that, as well.
3  Games Center / 4K Game Competition - 2012 / Re: Interest for a source code analyser/processor on: 2011-12-09 07:58:31
More tools are ALWAYS better.  I think Riven's tool is one of the best things that has happened to this competition.

I would suggest trying to lower the barrier to entry to using your tool, once it's completed.  If you can get a website up that allows users to paste in their source code, as in Riven's tool, that will help a lot of users who could be scared off by installing files.

I would certainly use such a tool, but I don't think it would be compatible with the black magic I'm using this year.
4  Games Center / 4K Game Competition - 2012 / Re: 4K 2012 contest preliminaries on: 2011-12-09 07:53:57
I missed all of the 2011 season so I don't have feedback specific to then.

I like the competition format, I don't think there need to be changes like categories or anything.  I think the site could use a minor change, in having the actual game applet hidden by default (for instance the game starts as a screenshot and becomes an applet when clicked) - this is because many of the games use a very CPU-heavy timing loop, and it would be nice to be able to keep a tab open for a specific game without eating your computer.

Originality is a problem, but not one that should be approached in the rules.  We should attempt to tackle it as a community, by doing our best to rise above the easy concepts and encouraging others to do the same.  I, for one, will always do an original IP with my games.  It makes our competition look better, so our games get more players and our community gets more competitors.  Or, for a more utilitarian argument - different IPs are better suited to different budgets, platforms, and constraints.  No existing IP has been optimized to be put in four kilobytes of java, but your own IP can be.

I'm looking forward to this year's competition!
5  Games Center / 4K Game Competition - 2011 / Re: CraftCraft on: 2010-12-12 03:31:43
Heh, I made a complete RTS with basebuilding and ten different units in 4k last year by skipping pathfinding, scrolling, and fog of war.  So I think you're fine with just the ones I missed, it makes us even  Wink.
6  Games Center / 4K Game Competition - 2011 / Re: CraftCraft on: 2010-12-12 01:54:06
Yeah, fog is the least necessary of the features you listed.

The game is very impressive.  The graphics are great.

How exactly do you get your guys to attack? Is there a way to specifically target an enemy soldier? I have trouble getting my men to engage unless they've been sitting still and the enemy has be firing at them for some time.  If there isn't a way to target a specific enemy, I would put that on top of any potential feature wishlist.  Without it my mad actual-starcraft skills are useless.
7  Games Center / 4K Game Competition - 2011 / Re: soszip2 - brute-force comression utility on: 2010-12-09 01:42:10
I tried it out on Oh My Glob! but after an hour the resulting file didn't get any smaller than 6234 bytes, whereas it's compressing to 3662 bytes using KZip under Riven's tool.

Don't let this discourage you; I'm sure you'll get there if you keep working on it.
8  Games Center / 4K Game Competition - 2011 / Re: Rule Check - Highscore Tables on: 2010-12-07 22:12:00
Will the table be displayed on the game page as HTML, or will we be getting the current table back from the API and expected to render it using game logic?

Also, a suggestion: could the jar have several methods that could do the same thing with different names?  So even though the actual method is something like sendToHighScoreTable(String, int), there are aliases like drawString(String, int, int) that just call the real thing, but allow people to pick whichever one will compress best for their game.
9  Games Center / 4K Game Competition - 2011 / Re: 4Kanabalt on: 2010-12-07 12:20:01
Very nicely done!

I love the level of polish on the game's graphics, especially the running animation.  I see you opted to load that from an image file; I think that was a good choice, it makes the generated objects much less obvious.  Do you have room to make the birds more detailed?
10  Games Center / 4K Game Competition - 2011 / Re: Rule Check - Highscore Tables on: 2010-12-07 11:55:46
As I understand the rules, you are only allowed to do client/server stuff if both sides are Java programs that fit inside the same 4k.  So you would have to give your program multiple entrances or multiple class files, and somehow fit the overhead from that, the overhead from network calls and your actual highscore logic into the 4k.  At which point it seems wasteful to spend so much room and not be making a game that's primarily about some client/server interaction.

All of which is a shame.  I would completely support Java4k having an API for this sort of thing, if everyone (especially the people in charge!) was in favour of it.
11  Games Center / 4K Game Competition - 2011 / Re: Applet templates on: 2010-12-07 00:02:09
Does anyone have a good method for passing mouse input to the main function?

For key input there's the giant array of booleans that we al know and love, but passing mouse events over is hard.

What I've been doing is maintaining a LinkedList of Events and using it as a queue.  HandleEvent adds them, your input loop does while(!events.isEmpty()) {Event e = events.removeFirst(); [Input Code]}

That requires you to wrap your entire event handler in an exception handler though, or you'll get concurrent modification issues that don't make any sense.  On the bright side, wrapping something in an exception handler is free if you're doing anything else that requires exception handling, such as the Thread.sleep() in my version of the template.

But requiring a LinkedList is kinda crappy.  You could also do it with an array and an index, which might be smaller, but I haven't checked.
12  Games Center / 4K Game Competition - 2010 / Re: Burning Man on: 2010-12-04 01:32:26
CyanPrime - Nope, never even heard of it.  The actual process behind the game's concept goes something like this:

Me: Hey, I have this really sweet fire effect, and I bet it would be easy to port to a 4k environment.  Hey Ben, what's good excuse for a game to have tons and tons of fire?
Ben: What if you are on fire?
Me: Oh man, you could like... burn through wooden platforms.  It'd be great.

Appel - Sorry I took half a year to respond; I made that "Game of the Year Edition" version but that was actually 4k again.  I might go make a full version.  A friend and I are starting up a business, so there might be a full version for Android sometime in the next few months.
13  Games Center / 4K Game Competition - 2011 / Re: Demon Attack 4K [Atari 2600] [Work In Progress] on: 2010-12-03 00:24:46
Ah, if you're trying to mimic a game's gameplay faithfully then you shouldn't take my suggestions on how to change the gameplay, heh.

And Thread.sleep() is only noticeably less consistent if you don't change the amount of time you pass to it based on the output of something like nanoTime.  I'd recommend trying both and seeing which packs better, at least.
14  Games Center / 4K Game Competition - 2011 / Oh My Glob! on: 2010-12-03 00:20:44

So I'm pretty happy with this one.  Click to launch a ball, try to hit ones of the same colour.

I'm currently at 2676 bytes, so if you think it needs anything I probably have room.
15  Games Center / 4K Game Competition - 2011 / Re: Gradius 4K [Work In Progress] on: 2010-12-02 21:04:01
Just how many retro games are you planning on porting this year? Cheesy

That was quite fun, and very well done.  I agree with teletubo that more variety in levels would be nice.  I also think you could make the game a little better looking for cheap by putting a black outline on the border of the walls.
16  Games Center / 4K Game Competition - 2011 / Re: Demon Attack 4K [Atari 2600] [Work In Progress] on: 2010-12-02 20:52:50
I got 3615 on my first time.

I really like all the different graphics, especially of enemy shots.  That's the sort of touch you don't see very often.  The gameplay is pretty solid too, though it seems like the player's craft sometimes coasts a little bit if you attempt to fire and quickly change direction.  Is that intentional?

Do enemies start to fall to the ground to attack before splitting is introduced?  I first noticed it on the splitting level, but I can't be sure.  If they do both start at once, I'd recommend moving that apart, since different concepts should be introduced in different levels.  And if there's anything new after splitting, I recommend moving that earlier so people actually see it, unless I just suck at this game Wink.

Finally, are you using a while/yield loop for timing?  If so, try using Thread.sleep(desired frame delay) instead.  Even with the code to ignore an Exception I've found that it takes less room (your mileage may vary) and, more importantly, it prevents the game from taking up 50% of CPU and needlessly spinning up the user's fan.
17  Games Center / 4K Game Competition - 2011 / Re: Preparations.. on: 2010-11-13 04:55:22
So apparently the notes I read on improvements in 1.6 completely missed the incredibly useful Path2D.  That's more than enough to make me want to switch to 1.6, by itself.  So consider my vote switched.  Though I think the consensus was already leaning towards 1.6 ;-).
18  Games Center / 4K Game Competition - 2011 / Re: Preparations.. on: 2010-11-11 00:12:51
I looked through the changes for 1.6.  Library wise, they added more support for scripting languages, some XML stuff, an interface for referencing Java compilers, an updated database framework, annotations, and some helpers for working with Swing.  I don't think anyone has room to include a scripting language, XML is huge, referencing a compiler midway through a game sounds downright bizarre, accessing a database is probably a rules violation, annotations increase your class file size in a way your compressor won't get along with, and Swing is too bloaty for Java4k.  I don't think we need any of the new libraries.  The new VM has some significant performance improvements, especially on low-level stuff so it's likely especially improved for our purposes.  However, I'm pretty sure anybody running 1.6 gets those performance improvements regardless of the version of Java the application was compiled for, so this is no different than our users having differently capable computers.

So I'd vote for sticking with 1.5, because I don't think there are any advantages to the upgrade.

If, however, anybody thinks of a use for any of the new library features, I'm willing to change my vote.  Of the above, I think the new scripting language features are the most promising, since their API seems surprisingly J4k-friendly.  Before I head off and run experiments, I have to ask: would using a scripting language be allowed in Java 4k?  If parts of your game are written in Perl or whatever, does that violate the idea that the program should be compiled in Java?
19  Games Center / 4K Game Competition - 2011 / Re: Preparations.. on: 2010-10-29 08:52:40
I'm looking forward to the next round.  Not much more than a month away!

I really liked the voting system last time, though of course it can always be improved.  I think the instructions could be more prominent on the page.  Maybe it they're a couple sizes extra large there will be less people thinking they're supposed to rank every game 1 to 5.

For main website suggestions, there are a few things I would like to see.  Describing exactly what Java4k is about should be right front and center, of course.  I also think the link to the discussion forum should always be prominent, instead of hiding in the FAQ and news posts.  News could be moved lower down to make room, as well: the people who want news are people who already care about the website, we'll all scroll down for it.  The top should be the explanation of what we do and everybody's shiny games.  As for the shiny games themselves, I think the system for picking which games are shown on the front page needs to be rethought.  It would be nice to primarily show the games that have had the least views, for fairness sake.  Though that might run contrary to trying to promote the contest, since you want something really flashy to draw people in, so I'm unsure.  There are a lot of ways you could do it, and a lot to be said about each of those ways; all I ask is that you give it some extra thought Smiley.

Oh, and I think that requiring that every game get hosted on the Java4k website was an absolutely fabulous idea, and really helps the contest as a whole to have everything in one spot that we all trust.  To that end, is there any chance that, if our games require something to be run server-side, we can run it on Java4k provided it fits under some cpu/memory/bandwidth requirement?

Also, I have a pair of monstrously epic games in mind for next year, everybody best be ready Wink.
20  Games Center / 4K Game Competition - 2010 / Re: RESULTS!!! on: 2010-03-25 02:51:20
I just found a pretty nasty bug in that GameOfTheYear version; please ignore it until I get a chance to fix it.

21  Games Center / 4K Game Competition - 2010 / Re: RESULTS!!! on: 2010-03-24 16:04:33
You can add a link in the game description, or add it to the URL field.

Put up an applet on games4j, I'd like to keep free of any non-4k games Smiley
That's still 4k.
22  Games Center / 4K Game Competition - 2010 / Re: RESULTS!!! on: 2010-03-24 03:50:29
So I promised a "Game of the year edition" version of Burning Man.  Here it is.

This includes both the packed version and the regular jar.  If it can get published on the site somehow, that'd be absolutely amazing.  Otherwise (well, either way, really), I hope you all enjoy it.
23  Games Center / 4K Game Competition - 2010 / Re: Burning Man on: 2010-03-19 15:48:32
Thank you, everyone.
24  Games Center / 4K Game Competition - 2010 / Re: RESULTS!!! on: 2010-03-19 15:46:32
Thanks everyone!

Would it be possible or desirable for me to put up a "game of the year edition" of Burning Man?  I managed to make the game run a lot better and I'd like to go back and redo some of the levels.
25  Games Center / 4K Game Competition - 2010 / Re: Applets in retrospect... on: 2010-03-19 15:37:54
Using applets was a great improvement.  We should stick with that.

I didn't like that opening a game's page automatically loads the applet.  You can't read the description, instructions, or comments without the game starting.  Since most of the games (mine included) immediately jump up to 100% CPU usage, this is painful.  This could be fixed if the applet was initially hidden, so you needed to click to show it - some video websites do this with their embedded player, where there's an image until you click, then the flash is inserted.

It would also help if the initial template didn't have the CPU use problem, which can be fixed by starting with the one I posted.  But I'd still like to see the applets initially hidden.
26  Games Center / 4K Game Competition - 2010 / Re: Burning Man on: 2010-03-11 21:28:52
DzzD, Gudradain: Congrats.  Don't get too cocky though, I might release a pack of levels I rejected because they were too damn hard  Wink.  Or I can at least release the level editor.

Markus Persson: I was wondering why my number of downloads doubled overnight, then I saw that it was on your blog.  Thanks!

kapta: Yeah, a friend insisted that I post it.  I didn't realize quite how many downloads it'd get me though, I might have to go post BugWar too so it doesn't get jealous.

27  Games Center / 4K Game Competition - 2010 / Re: Burning Man on: 2010-03-03 04:56:24
Thanks everyone!

Answering questions...

The second bomb level (most common place people get stuck on) is really simple.  I recommend just wasting a few lives poking around and figuring out what does what.  You're probably making your job more complicated than it really is.  Actually, that applies to most of the hard levels.  Only a handful really require precision, if you figure out the tricks.

The fire is a simple particle system; particles cycle through an array of images I've generated ahead of time.  Each image is a color fading to transparent in a circle pattern.  The fire particles have a random direction and velocity, with the velocity skewed to be faster if their direction is up.  The particles all slow down by just multiplying their speed by some constant.

The floor tiles:
Stone is a bunch of randomly sized circles in a clever color palette.
Wood is a brown, then two passes of stripes are drawn with y varying pixel-by-pixel to get the grain texture.
Acid and water are just solid transparent colors.
The bombs are... complicated.  It's a lot of math and per-pixel stuff.

The background is drawn using a giant heap of math.  I started out with a spiral, which is (cosine of arctan of angle to center)+(distance to center) with constants added.  Then my girlfriend played with it a bit and I have no clue what she did to the spiral.  Then I took every pixel and multiplied it by some value based on how close to a diamond pattern it is, so there'd be a consistent texture to make the heat distortion more obvious.  In retrospect I would've preferred if that diamond pattern was a bit more pronounced; one of my older (uglier) ones did a better job of showing off the heat distortion.

How the heat distortion effect works will have to wait until after judging.  I want to leave a little bit of mystery until then Wink.
28  Games Center / 4K Game Competition - 2010 / Re: Community Voting on: 2010-03-03 01:45:49
I love that everyone gets to vote, and that the voting mechanism you chose requires that people have played at least a reasonable sample of the year's games.  Looks great.

Do you think that, when the final results are posted, you could do a separate subscore that only shows the votes made by people who have submitted games to Java4k?  A "devloper's choice" award if you will.  I think it would be interesting to see that as a separate measure.
29  Games Center / 4K Game Competition - 2011 / Re: Applet templates on: 2010-03-02 18:45:41
I didn't use this on either of my entries because I didn't realize that it's smaller than the method I was using until too late, but here's a template that maintains a relatively steady frame rate and goes easier on your CPU.

import java.applet.Applet;
import java.awt.Event;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;

public class G extends Applet implements Runnable {

   public void start() {
      new Thread(this).start();

   public void run() {
      setSize(800, 600); // For AppletViewer, remove later.

      // Set up the graphics stuff, double-buffering.
      BufferedImage screen = new BufferedImage(800, 600, BufferedImage.TYPE_INT_RGB);
      Graphics g = screen.getGraphics();
      Graphics appletGraphics = getGraphics();

      // Game loop.
      while (true) {
         long lastTime = System.nanoTime();

         // Update
         // TODO add some update logic here.

         // Render
         g.fillRect(0, 0, 800, 600);
         g.drawString("FPS " + String.valueOf(fps), 20, 30);

         // Draw the entire results on the screen.
         appletGraphics.drawImage(screen, 0, 0, null);

         //Lock the frame rate
         long delta = System.nanoTime() - lastTime;
         if(delta < 20000000L)
               Thread.sleep((20000000L - delta) / 1000000L);
            catch(Exception e)
               //It's an interrupted exception, and nobody cares

         if (!isActive()) {

        public boolean handleEvent(Event e) {
            switch ( {
                  case Event.KEY_PRESS:
                  case Event.KEY_ACTION:
                      // key pressed
                  case Event.KEY_RELEASE:
                      // key released
                  case Event.MOUSE_DOWN:
                      // mouse button pressed
                  case Event.MOUSE_UP:
                      // mouse button released
                  case Event.MOUSE_MOVE:
                  case Event.MOUSE_DRAG:
             return false;

Replace the 20000000L with your desired frame delay.
30  Games Center / 4K Game Competition - 2010 / Re: Thank you - submission period ended on: 2010-03-01 04:55:44
I re-uploaded mine (after the deadline) because some users were complaining about an applet not found error.  This was identical to the before-deadline one, please don't kill me.
Pages: [1] 2 3
Dwinin (73 views)
2015-11-07 13:29:08

Rems19 (81 views)
2015-10-31 01:36:56

Rems19 (79 views)
2015-10-31 01:32:37

williamwoles (107 views)
2015-10-23 10:42:59

williamwoles (93 views)
2015-10-23 10:42:45

Jervac_ (111 views)
2015-10-18 23:29:12

DarkCart (137 views)
2015-10-16 00:58:11

KaiHH (118 views)
2015-10-11 14:10:14

KaiHH (158 views)
2015-10-11 13:26:18

BurntPizza (173 views)
2015-10-08 03:11:46
Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48

Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11 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‑
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!