Show Posts
|
|
Pages: [1] 2
|
|
8
|
Games Center / 4K Game Competition - 2013 / Re: Sorcerer4K
|
on: 2013-02-27 21:34:54
|
Hey, I love the graphics  The game has a nice ambience to it. The most confusing thing for me playing the game was the projectile collision detection with the ghosts - I wasn't sure whether most of them go through them cos they're ghosts, cos I'm not exactly the same height as them or some other reason?
|
|
|
|
|
10
|
Games Center / 4K Game Competition - 2013 / Re: [WIP] 4King & Country!
|
on: 2013-02-27 13:12:28
|
Hi everyone, Thanks for the replies. So after a very long struggle with the filesize, I can happily announce it's now 4,091 bytes  But I had to sacrifice the antialiasing and font rendering.. so it's leaning more toward the "programmer" visual aesthetic now  Changes: - Game length: Now set to 20 mins instead of 10
- Controls: Now simplified (I hope) - everything can be controlled with mouse + space/w/s/d
- Town upgrades: Towns can only grow above size 2 with wood, or size 3 with iron. You still have the option of transferring extra settlers from the ship to the town (to get around this) - let me know how it plays because maybe that should be prevented too.
I would like to reincarnate the font and antialiasing if possible. Time is very short now but I'll post the code and if you have any suggestions on how to reduce the size I would really appreciate it. I have been working on it pretty manically so the code is like a bomb-site, you might have a heart attack but bear with it! 
|
|
|
|
|
11
|
Games Center / 4K Game Competition - 2013 / Re: [WIP] 4King & Country!
|
on: 2013-02-25 19:24:28
|
Nice game. But too much command for me. What is the interest of carrying iron in the ship? I guess I saw a diamond on a mountain, but nothing append... I like the exploring part, but we don't have enough time to explore (in my opinion). Anyway, I'm very curious about the code of this game  Thanks for your comments. Yes as I said the controls are pretty clunky in places... your suggestions are welcome. I was planning to replace most of the keyboard stuff with mouse controls - so anchor is right button, settle maybe left or right drag, load/unload could be done by clicking on the town resources. Regarding the time for the game, actually I didn't get much chance to play-test it yet  The iron was originally needed for building towns, but it's a bit hard to get so I reduced it to only need wood. But I think I will change the town growth requirements so the town needs wood & iron to grow bigger than a population of 2. So that would make distributing resources from one town to another important. Cool, is it possible to get the source? I mean i was able to decompile it (i'm curious about the perlin noise algorithm, because mine is lousy slow) and to understand it in general, but with the proper variable names it is easier to read.
I am going to try to tidy up the code this evening and hopefully reduce the bytesize a bit. So I should be able to post it sometime soon. There is nothing particularly clever about the Perlin noise algorithm (I wrote it to be readable as this is the first time I have implemented one), but it runs fast because it only redraws what it has to each frame. There is a double buffer the size of the screen that holds the calculated "height" from the Perlin noise for each pixel, which is only ever drawn completely for the first frame of the game. For all other frames, e.g. if the player moves 5 pixels right it just draws those columns. So that is a roughly 50-fold reduction in rendering time (5x512px vs. 512x512px).
|
|
|
|
|
13
|
Games Center / 4K Game Competition - 2013 / [WIP] 4King & Country!
|
on: 2013-02-25 01:28:17
|
Hey everyone, When I saw this competition I thought, hmm wouldn't it be cool to fit an infinite world in just 4k? So my aim was to write a naval exploration/warfare/conquest game using a Perlin noise generated "infinite" landscape. The game has gone through many manifestations - I started out with the idea of a ship-battling, sea monster-fighting action game but that never really got off the ground. Then I started to think along the lines of Colonisation and The Wager ( http://www.surprisedman.co.uk/the-wager/) to make an explore, expand, exploit game (but no exterminate!  ). Update! Now under size - 4,091 bytes  But not without some grievous cramming, as you should be able to see from the horrendous font and aliasing. Latest news: Font rendering has thankfully been restored, but not antialiasing yet  Also the flashing red screen is back... hooray! Size is 4,093 bytes. All comments and suggestions very welcome! I'm particularly interested to hear your thoughts on the gameplay as that's all pretty rough... but I feel like at long last this is a game that actually might work or even be fun  Warning! Untrusted content: sixtyten submitted an applet to JGO. If the applet asks for permissions, it will have full access to your system. ( read more) - If you allow to launch the applet, it will run in sandbox mode by default.
- Signed applets will popup a security-dialog, which asks for permission to full access to your system.
- The applets are launched from a seperate sub-domain, to protect you from eavesdroppers.
- Only run applets of people you trust, regardless of whether the applet asks for permissions or not.
JGO cannot be held responsible for the contents and/or behavior of the hosted applets. Aim:The year is 1496. The King has sent you forth to distant lands on a voyage of discovery, conquest and exploitation. Explore uncharted waters to find the finest locations to settle, and begin transporting precious resources back to sell to the motherland. You have 100 years to prove yourself - do not let the King down or you will live out the rest of your days as a serf! Serve the King well and he will make you a Lord of the realm. Interface:- Top-Left (top to bottom): Current year (game ends in 1596), Rations remaining on board (red bar), Cargo hold (to carry wood & iron), Settlers on-board (white dots)
- Top-Middle: Gold earned
- Top-Right: Mini-map showing charted & uncharted territory
Tips:- Food (red bar at town): Will help to grow the town quickly, so you can get new settlers. Also the higher the town population, the faster the resource generation rate and the more gold you make.
- Wood (green bar at town): Required for building new towns, so make sure some of your towns are near woods! (dark green areas on the islands)
- Iron (blue bar at town): The most valuable resource, generated if mountains are within the town radius.
- Resource Bonuses: Diamonds on the map are resource bonuses, the colour indicates which resource they apply to (light green: food, dark green: wood, grey: iron). If a bonus is within the radius of one of your towns, that town's production rate for the resource is doubled (or quadrupled for 2 bonuses, etc.)
- Transporting Settlers: Carrying multiple settlers can help you to expand quickly, but beware you don't end up out at sea with no rations! The more settlers you are carrying on the ship, the faster the rations deplete. If you run out of rations you will sleep with the fishes (the screen will start flashing red once the level of rations is below 25%). Your rations will automatically be replenished if you dock at a town.
- Town Growth: To grow above a population of 2 requires wood, and above 3 requires iron. So to maximise production you will need to transfer resources between towns.
Controls:- Left mouse-click: Set direction of ship or Settle new town at mouse location (in settling mode) or Load resources from town (when docked at a town, click mouse with S = settler, W = wood, D = iron)
- Right mouse-click: Unload resources from ship to town (when docked at a town, click mouse with S = settler, W = wood, D = iron)
- Space: Anchor & activate settling mode (when no town is in range) or Anchor & dock at town in range
Known Bugs:- Ship can get stuck in crevasses in the terrain. Pressing space (anchor) can sometimes help.
|
|
|
|
|
16
|
Games Center / 4K Game Competition - 2013 / Re: [WIP] 4096 B.C.
|
on: 2013-02-12 13:15:38
|
Good job getting this up and running. My suggestions: - Option to control view with mouse - I found it very difficult to aim/move with the keyboard controls. Then maybe have W/S as forwards/backwards, A/D as strafe left/right and mouse button 1 to fire.
- Increase collision distance on player/walls to stop view going "inside" walls
- Display messages on level end/beginning, even if it's just "LVL: 2!" in the middle of the screen. There is no sense of accomplishment at the moment.
- Might also be good to have a simple points system where you score for completing a level and killing enemies.
|
|
|
|
|
17
|
Game Development / Newbie & Debugging Questions / Re: Mysterious Graphics2D-related slow-down
|
on: 2013-01-28 22:44:28
|
OK, fast version: Warning! Untrusted content: sixtyten submitted an applet to JGO. If the applet asks for permissions, it will have full access to your system. ( read more) - If you allow to launch the applet, it will run in sandbox mode by default.
- Signed applets will popup a security-dialog, which asks for permission to full access to your system.
- The applets are launched from a seperate sub-domain, to protect you from eavesdroppers.
- Only run applets of people you trust, regardless of whether the applet asks for permissions or not.
JGO cannot be held responsible for the contents and/or behavior of the hosted applets. Yes, I know there are different amounts of text drawn/graphic objects. But I would be interested to hear if there's a big difference in speed between the two versions for everyone else, as there is for me. The simplest solution will probably be for me to trim down the code (which is pretty bloated as I've been trying out lots of different ideas) and reduce the number of drawX calls if possible. But it's a bit troubling that I could hit some invisible performance ceiling at any time. Does this just get filed under "Java2D sucks"?
|
|
|
|
|
18
|
Game Development / Newbie & Debugging Questions / Re: Mysterious Graphics2D-related slow-down
|
on: 2013-01-28 22:13:23
|
I think it may be the problem in the execution. Just a test. submit the old and new versions of your game here so that we can run them.
Let's see if this works - slow version: Warning! Untrusted content: sixtyten submitted an applet to JGO. If the applet asks for permissions, it will have full access to your system. ( read more) - If you allow to launch the applet, it will run in sandbox mode by default.
- Signed applets will popup a security-dialog, which asks for permission to full access to your system.
- The applets are launched from a seperate sub-domain, to protect you from eavesdroppers.
- Only run applets of people you trust, regardless of whether the applet asks for permissions or not.
JGO cannot be held responsible for the contents and/or behavior of the hosted applets.
|
|
|
|
|
19
|
Game Development / Newbie & Debugging Questions / Re: Mysterious Graphics2D-related slow-down
|
on: 2013-01-28 00:46:35
|
In your new version or you setting and global flags to use opengl? They can cause all sorts of crap to happen. Also, the performance of java2D is almost directly related to the number of Graphics.drawStuff calls as long as you are not decelerating images.
I had massive changes in performance when using java2D and trying something on one computer then another or changing small things. Will recommend switching to something more reliable.
This for the 4K compo, so I'm pretty much bound to using Java2D. Okaaaayyyy, so it makes less and less sense over time. I tried commenting out the majority of the drawing code and that worked to bring the framerate back to 60 FPS. So then bit by bit I commented the code back in, to find the faulty section. But all I can conclude after that is that the length of the code is what is causing the slow-down... as ridiculous as that sounds. For example the version with this code runs at 60FPS: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| playerCanSettle = false; long drawSettleT1 = System.nanoTime();
playerSettling = false; if (playerSettling) {
} long drawSettleT2 = System.nanoTime(); |
However, including the one (completely unreachable) line in the if statement drops the framerate to 10 FPS: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| playerCanSettle = false; long drawSettleT1 = System.nanoTime();
playerSettling = false; if (playerSettling) {
px = playerCanSettle ? 0xFFFFFF : 0xFF0000;
} long drawSettleT2 = System.nanoTime(); |
This is well beyond any kind of weirdness I'm used to experiencing. Normally I can confidently rely on the bug coming from some stupidity on my part, but this..... I feel like perhaps it's some technical aspect of the way the program's being run. Like it's hitting a memory ceiling or stack limit or something else uber-technical. So if any Java gurus have any ideas...
|
|
|
|
|
20
|
Game Development / Newbie & Debugging Questions / Re: Mysterious Graphics2D-related slow-down
|
on: 2013-01-27 22:04:28
|
I'm curious, if you substitute an int[] for BufferedImage pixels, what does that do to the timing between the two versions?
Using an int array seems to run at the same speed. What versions of Java are you referring to?
It was an upgrade to my Java plug-in in Firefox (to SE 7 U11 10.11.2.21). I don't think that should affect compilation from the Java libs though. Plus it's clear the slow-down is specific to the newer version of the code and not the old, so the issue is not with any of the Java platform per se. I don't know a lot about graphics, but there are a number of different ways to place data into a BufferedImage, and the internals of this are a bit mysterious to me: sometimes areas beyond, in the graphics accelerator process(?) are engaged. There are other folks that know more about this and will be able to help. I think it is possible to build the array, then place the entire data array into the BufferedImage in one command, rather than 512^2 writes. This might be a good work-around. I did this as follows: 1 2 3 4 5
| int[] pixelData = raster.getDataElements(0, 0, width, height, pixelData);
raster.setDataElements(0, 0, width, height, pixelData); |
Maybe that will work faster for you. "raster" is the raster you get from your BufferedImage. HTH! The problem is not the screen copying itself I think, it seems to be more of a general slow-down to all processes (blegh). I thought it might be some memory paging evil slowing everything down, so I reduced the size of one large array (a 4096x4096 double array) to 512x512, but that had no effect. I'll look into how to do some more informative profiling (I'm using Eclipse). But any suggestions/ideas are very welcome. Cheers!
|
|
|
|
|
21
|
Games Center / 4K Game Competition - 2013 / Re: 4kProf [WIP]
|
on: 2013-01-27 21:48:57
|
Looking good... don't quite understand what the rules for object movement are but got the general gist of the game. Two thoughts: 1. Could you turn on antialiasing to make the look less jagged? (altho maybe you want something deliberately retro) 2. The player animation is well, jumpy  I was thinking it's even possible you could get animation for cheap by blending between polygon vertex positions. Assuming the player graphic is made of n polygons and the polygons preserve their identity and approximate relationship (e.g. 1 for face, 1 for body, 1 for arm, etc.), then you could create a smooth animation quite straightforwardly.
|
|
|
|
|
22
|
Games Center / 4K Game Competition - 2013 / Re: Rainbow Road
|
on: 2013-01-27 21:39:46
|
Very cool! I consider the bar officially raised...  Impressive indeed that you fit this all in 4K and thanks for providing the source code. The game mechanics are pretty involved (AI, multiple actors, collisions, sprite loading, rendering) so it's good to know it is possible to squeeze it all in somehow. The only thing that seemed unusual to me was using X as the accelerator instead of the up arrow, but after playing it for a bit I think I see why you chose it like that. Anyway great job!
|
|
|
|
|
23
|
Game Development / Newbie & Debugging Questions / Re: Mysterious Graphics2D-related slow-down
|
on: 2013-01-26 00:39:31
|
This is the code snippet I was talking about: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| long plotT1 = System.nanoTime();
for (py=0; py < worldSize; py++) { for (px=0; px < worldSize; px++) {
i = (py << worldSizePow) + px; pixels[i] = 0; } }
long plotT2 = System.nanoTime(); |
Old version takes 0.6ms, new version takes 8ms - same code.
|
|
|
|
|
24
|
Game Development / Newbie & Debugging Questions / Re: Mysterious Graphics2D-related slow-down
|
on: 2013-01-26 00:24:15
|
|
Hmmm... so I went back and compiled an old version. Ran smoothly no problems.
Timing a section of code in the old version that does "plotting" gives 3-6 ms. In the newer version, it gives 60-120 ms. OK, fine.
So then I copied the exact code (from the first System.nanoTime to the second) from the old to the new version. And the timings are still exactly as before. So the conclusion is that doing exactly the same thing is 20x times slower in one version than the other...
The code that I copied is a loop that transfers data from a world-map array to the screen array (a 512x512 int array). There are various things done in the loop (which take 60-120ms in the new version). If I remove all that and just set all screen values to 0, the time taken is now 8ms - which is still slower than the old version which is doing everything else in the loop as well.
Any ideas?
|
|
|
|
|
25
|
Game Development / Newbie & Debugging Questions / Re: Mysterious Graphics2D-related slow-down
|
on: 2013-01-25 23:57:34
|
Edit: Now it is slowing down even with no drawString calls, so that alone is not the culprit. But adding or removing other Graphics2D calls still seems to massively affect the framerate. Some further background info: Most of the other graphics are done by drawing directly into a BufferedImage (as a DataBufferInt), which is then drawn to the screen using appletGraphics.drawImage.
You really need to get your shi t together and find out what it is exactly, using a profiler or sysouts of system.nanotime Well I System.nanoTime'd the hell out of everything, and all the numbers add up to 100ms+ which of course means god-awful framerate. But this is all stuff that has been running smoothly up until recently. I just installed a Java update, I wonder if that affected it. I have older versions of the code backed up so I will try compiling them again to see how they run.
|
|
|
|
|
27
|
Game Development / Newbie & Debugging Questions / Mysterious Graphics2D-related slow-down
|
on: 2013-01-25 20:59:11
|
Hey, A puzzling bug (at least to me)  - previously my game was running at 60 FPS no problem, but one day when I ran it again, the framerate was down to 3-4 FPS. I found that I could restore the full framerate by removing some graphics2D.drawString() calls. But then the next day, it seemed to be back down to 3-4 FPS (I had made some minor code changes in the interim). When I removed all but 1 of the drawString calls, the framerate went back to 60FPS again. But the amount of text I'm now able to draw without a very drastic slowdown is far less that what I could draw originally... Perhaps the drawStrings are not the issue and there is some other drawing operation that I am compensating for by removing them. I'm clutching at straws here... Has anyone experienced anything similar who could give me some suggestions what might be going on? Is there some limit to Graphics2D calls that might be causing the slow-down? Thanks.  Edit: Latest news - as far as I can tell it's a fairly generalised slow-down from the old to the new version. Profiling identical code in the 2 versions gives a performance drop of 10-20x. This is not some big complicated game, just a single class that I'm coding for the 4K compo. My latest guess is that it's something memory-related, but I am trying some more advanced profiling to see what might be going on...
|
|
|
|
|
30
|
Game Development / Newbie & Debugging Questions / Re: Rotate Towards Point
|
on: 2013-01-23 22:00:54
|
Ok, so currently I am at this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| playerAngle = (float) Math.toDegrees(Math.atan2(player.x-x, player.y - y)); turnSpeed = 2; if(Math.abs(playerAngle) < turnSpeed) { rotation = playerAngle; } else if(playerAngle > 0) { rotation -= turnSpeed; } else { rotation += turnSpeed; } |
At the moment it seems I am only accounting for the angle between two co-ordinates, and not the current rotation of the entity. It's integrating that part that I'm finding most difficult. The simplest solution (in terms of being easy to understand mathematically) is probably this - just a small modification to your previous code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| playerAngle = (float) Math.toDegrees(Math.atan2(player.y - y, player.x - x)); turnAngle = playerAngle - rotation;
if (turnAngle < -180) turnAngle += 360; if (turnAngle > 180) turnAngle -= 360;
turnSpeed = 2; if(Math.abs(turnAngle) < turnSpeed) { rotation = playerAngle; } else if(turnAngle > 0) { rotation += turnSpeed; } else { rotation -= turnSpeed; } |
Make sure you check your code carefully. There were some bugs there (y/x being swapped in atan2, decreasing rotation when the angle was > 0) which you can spot yourself if you take the time to look through.
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|