Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (511)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  4k General  (Read 14081 times)
0 Members and 1 Guest are viewing this topic.
Offline pelle
« Posted 2012-01-05 19:25:17 »

OK, I'm starting to feel confident this will be complete in time for the deadline. Otherwise I guess I can save it for java4k 2013...? Started working on december 19th, based on some template posted here last year. Currently at slightly over 4k, but I have lots of things that can be removed, and made no real attempt to keep things very small. Just need to make the AI a bit more clever and have some better scenarios (probably fewer scenarios though; there are 14 now, but that is probably a waste compared to having maybe 5 good ones instead?).

Oh, I should probably come up with a name for it before submitting. At first I was planning to do something more like a Panzer General clone, so I thought of something like Panzers 4k or 4k General, but now it has diverged quite far from that anyway.

AI and scenario data/generator is using up way too much space to have nice graphics (at least at my 4k beginner skill level), but in a way that is just staying true to the genre. Smiley Maybe I can make the map look slightly better if I have a few bytes to spare.
Offline pelle
« Reply #1 - Posted 2012-01-05 19:38:29 »


- 4 unit types (infantry, tanks, artillery, engineers)
- limited field of vision (there are more enemies in game seen above, but most are too far away)
- 4 types of terrain (clear, woods, city, water)
- engineers can enter a water hex and act as a bridge for other units, for "river crossing"
- engineers are also good for attacking cities, that other units are not so good at
- a unit that is attacked is weakened (marked with a gray border) and much easier to attack later in the same turn, so you want to concentrate several units on the same enemy in the same turn (and preferably strike with artillery first)
- a campaign of several scenarios; complete a scenario by taking all cities before a certain number of turns to advance to the next scenario (fail and you get to replay the scenario)
- different units have different movement rates and combat power in different terrain
- some sort of AI... it's not very clever of course
- combat results in possible loss of attacking and/or attacked unit

Essentially what I think you expect from a turn-based wargame?

Currently all units except for artillery can move then attack, like in Panzer General, but I will probably have to remove that to save a few bytes (especially by making the game easier for the AI).
Offline pelle
« Reply #2 - Posted 2012-01-05 19:42:28 »

I would be interested to hear if you think this is a too easy project? It's my first attempt at a 4k game. I know there are some obvious features (eg supply, air-support) that I would like to add if I could, but that there will be no room for me to make a proper GUI for. Supply would be very confusing for the player if there is no good way to display what units are "in supply" and why.

Also, what other similar games have there been? Couldn't find any on the current java4k site.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline pjt33
« Reply #3 - Posted 2012-01-05 19:57:53 »

I would be interested to hear if you think this is a too easy project?
It's an achievement to create a working 4k game which is more sophisticated than Pong. This sounds more advanced than some games I've seen in previous years' competitions, so don't worry.
Offline StephR

Senior Duke

Medals: 9

« Reply #4 - Posted 2012-01-05 20:31:58 »

Your game is very promising, and will certainly make an original 4K entry. And good for every wargamer, with all these announced features. I don't remember any such turn-based wargame in previous 4K contests, although some turn-based strategy games have already been submitted.

To answer some of your questions :
- it doesn't seem at all an easy project ;
- about the scenarios, favor better and fewer ones ;
- about the name, 4K General is a cool one. Some other suggestions : 4K Storm Rising, Memoir '4K, T4ktical Assault...

Receive my encouragement to complete your game.
Offline pelle
« Reply #5 - Posted 2012-01-07 11:41:20 »

Thank to both of you!

I'm leaning towards 4k General at the moment, even if it might create some wrong expectations.
Offline ReBirth
« Reply #6 - Posted 2012-01-07 12:10:34 »

If you ask me, I'll say that your problem maybe fit it on 4K. The AI and graphics seem take lot space. I'm new to 4K too so let's rock! Grin

Offline pelle
« Reply #7 - Posted 2012-01-11 21:51:55 »

Added AI, removed some minor things (like the ability to move+attack), for a total size of 4156 bytes.

Trying to add some terrain textures, but it seems like it uses too much space (total of 4262 now) AND is too slow (I could easily fix one problem, but not both). Annoying.
Offline pelle
« Reply #8 - Posted 2012-01-11 21:59:50 »

Removed some debug code (kept the number of enemy units down to make AI debugging easier). Now I'm at 4112 bytes. Close. Smiley
Offline pelle
« Reply #9 - Posted 2012-01-11 23:03:38 »

4092 bytes. Smiley Now I only need to work a bit on the scenarios. The graphics will have to remain awful.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline pelle
« Reply #10 - Posted 2012-02-05 20:58:23 »

So... finally I sat down to do some more coding on this game. I thought an easy way to save some bytes, to leave room for improvements, would be to throw out my silly wasteful way of saving bitmap images as a long string with one character ("x" or "o") per pixel, and instead use a byte array. That didn't work out so well. JAR size increased to 4197 bytes. I know some FAQ already warned that this wouldn't work, but I guess I couldn't believe it until I saw it. Sad

Guess I'll have to git stash this implementation and forget it for now.

OK, so I have to figure out some other trick to make room for a little more content. I want the move-attack-rule back, and I know how to make the AI handle it too, but I need a few more bytes. Some other day. At least now I tried this thing (only 30 minutes lost anyway).
Offline pelle
« Reply #11 - Posted 2012-02-05 21:16:51 »

A small victory: I changed the way the woods terrain is generated, making it look better and also saved 12 bytes. Smiley
Offline pelle
« Reply #12 - Posted 2012-02-05 21:31:51 »

Added a twist (not that great) to level 4. Now at 4095 bytes.

Will try to stay away from making more changes now, only focus on scenario design.
Offline dr-snipe

Senior Newbie

Projects: 1

« Reply #13 - Posted 2012-02-08 05:26:25 »

I played a little war game before similar to what this one looks like and it was quite fun. Keep it up!

Offline pelle
« Reply #14 - Posted 2012-02-11 23:11:35 »

Ooops. I had some debug code in my jar (it was supposed to only be in the debug build). After fixing my jar is only 3776 bytes. Wow.

Suddenly I must think about adding features again.
Offline pelle
« Reply #15 - Posted 2012-02-23 23:17:35 »

3994 bytes. I would have uploaded it tonight if I had 1 found the upload button and 2 had the time to fix some balance problems.

EDIT: Oh, ok, I noticed the upload button. Still want to do some minor tweaks, and I'm too tired to write a readable description of the game now anyway.

Offline pelle
« Reply #16 - Posted 2012-02-25 23:54:27 »

Game submitted!  Grin  Cool (Of course not accepted by admins yet, but soon I hope.)

Campaign ended up being 10 scenarios. There is room for more, but I think 10 is enough. If anything there would be more interesting things to use the last 57 bytes for.

The AI is extremely defensive and rarely counterattack. One thing it definitely should do is attack with artillery more often (no risk of losses to the attacker), but if I fix that all scenarios will be much more difficult and you will need many more units to win (which will slow the game down and be boring). We'll have to pretend that the enemy is running very low on ammunition or something.  Roll Eyes
Offline pelle
« Reply #17 - Posted 2012-02-25 23:55:11 »


Click unit to select, then click a hex to attack or move to.  Repeat
for as many units as you want to move or attack with.  Proceed to the
next turn by clicking the button in the upper right corner.

An unit that has already been attacked in the current turn is easier
to attack (less risk for your unit, greater chance of eliminating it).

Artillery can attack enemy units up to 3 hexes away. Other units can
only attack adjacent hexes.

Units in woods or cities are more difficult to attack (except for
artillery attacking woods).

Terrain also affects movement speed.

Enemy units far away are not seen.

Engineers can move into river hexes to let other units cross (the only
way to cross rivers). They are also better than other units at
attacking cities.

You win by occupying all cities on the map. This means you need to
leave a unit behind to guard each city you take, it is not enough
to simply pass through them to win, you must have a unit there.

After 15 turns a scenario ends in failure and is restarted.

There are 10 scenarios. Good luck!
Offline pelle
« Reply #18 - Posted 2012-02-26 00:00:44 »

Yes, the tiles/squares are called hexes in the instructions, for historical reasons, although I didn't have enough space to add the code to actually render them as hexagons. Smiley
Offline Mike

JGO Wizard

Medals: 86
Projects: 1
Exp: 6 years

Java guru wanabee

« Reply #19 - Posted 2012-02-26 09:19:27 »

Tested all ten levels and never failed so I guess they are too easy.

Some notes:
1. Every time I click on the map the whole screen blinks so I guess you missed double buffering.
2. When engineers stand next to the water there is no indication that they can move to it.
3. The enemy never, ever attacked, making it extremely easy to win.
4. Add an indication as to whether a unit moved or not, this will also help with the visualization around the next point:
5. Sometimes when I clicked next turn it didn't register.
6. Maybe make it possible to move and attack if you have at least one spare square as that will make it more tactical where to move your units
7. When winning it isn't saying anything until you hit next turn (and that might make it 16/15 turns with just a small text showing you that you won).

Oh, and here is a link for the lazy among us Smiley


My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
Offline StephR

Senior Duke

Medals: 9

« Reply #20 - Posted 2012-02-26 10:28:31 »

pelle, I experimented the same problems than Mickelukas, although I didn't go as far as him in your game.

I recommand you to try to fix the screen blinking problem first. If you need some help to do so, don't hesitate to ask us.
Offline pelle
« Reply #21 - Posted 2012-02-26 16:51:52 »


1. It works nice without double buffering on my machine, so I was hoping to not have to spend bytes on that. Sad OK, I have a few more to use, I hope there is enough room.

2. I see indication that engineers can move to water, but it is not easy to see blue on blue. I'll think about what to do.

3. The enemy do attack. I can see that when including my debug output. But, yes, they are rare, and even when they happen do not always succeed, so you will not even notice them. Combined with the fact that it seems to easy I'll tune the AI parameters slightly to make attacks more likely. (The problem of course is that if attacks are too common the game will be easier because you can just move close to the enemy and let them kill themselves counterattacking.)

4. Grey border means a unit has moved (or been attack... reusing the same code paths).

5. OK. I never saw that. Maybe the clickable region is smaller than what the button looks like? Could add some margins. Or there is a problem with the state machine.

6. I used to have move+attack, see above, but I couldn't fit it inside of the 4096 bytes. Sad

7. Actually you can click anywhere to get the WIN to show, no need to click the turn button. I agree it should be seen earlier. I can see if it is possible to move things around without having to rewrite the huge mess of game logic.

Thanks for the link (and for StephR to comment as well; no, I do not need to ask about double buffering, but including a few more classes/methods will be tricky).
Offline pelle
« Reply #22 - Posted 2012-02-26 20:20:24 »

Trying to fix the flickering. I wasn't overriding update, since I wasn't seeing any flickering anyway.

Annoyingly when I override update (the standard trick calling paint(g)), and make sure to only clean the screen at the start of a new level (all other painting is being done inside of hexes or the status bar, so no need to redraw everything) it works well in my test Application, and in an applet running in Opera, and in Firefox, but when the applet runs in Safari it for somereason insists on filling the background with default gray and it looks horrible (and probably flickers too on some machines).

I don't want to doublebuffer, since that adds too much code (I have 16 free bytes now). What I might be able to do is to add dirty bits and only redraw hexes that actually changed, but I think by removing the clearing of the screen it will be very difficult to see any flickering anyway. Of course every individual hex/square is cleared to be redrawn, but they are so small I doubt too much flickering will be seen even on a very slow computer?
Offline pelle
« Reply #23 - Posted 2012-02-26 20:37:22 »

Trying to free some bytes and add doublebuffring, to fix the Safari problem.
Offline pelle
« Reply #24 - Posted 2012-02-26 20:45:26 »

It doublebuffers. Now it looks right in Safari. Ironically though, NOW I can see flickering now and then. But not often. First time I click in the applet it flickers, and then I can get it to flicker by clicking randomly along the edges of the applet. I guess it is the browser that decides to do a redraw of the plugin area for some reason or something. But overall I guess it should remove flickering.

Problem is the jar is now 4171 bytes. Have some thinking to do.
Offline pelle
« Reply #25 - Posted 2012-02-26 20:50:42 »

Weird. I figured there is no need to keep the doublebuffer around as an instance variable, so I moved it into the paint method, but that only saved 1 lousy byte.
Offline StephR

Senior Duke

Medals: 9

« Reply #26 - Posted 2012-02-26 22:04:20 »

On Internet Explorer and Chrome, under Windows 7, I still got some flickering on each mouse click, which I find very annoying. pelle, you should consider implementing simplier graphics in order to save some bytes.

And did you use Proguard, Pack200 and Kzip to compress your jar ? Riven's compressor tool chain is not easy to use manually, yet it could save you a lot of memory if you still don't use it.
Offline pelle
« Reply #27 - Posted 2012-02-26 22:20:28 »

I have not uploaded any new version yet, so you should still have as much flickering as there used to be.

Have no Windows 7 to test with, so I'm just adding the doublebuffering and hoping it will work for everyone. Will try to add artificial flickering by adding a delay in my paint method just to confirm that buffering removes it (ie that I implemented it correctly...) before uploading.

Got rid of some bytes by simplifying some mechanics that are not easily visible to players anyway. It is below 4096 now even with buffering, but I want to test to make sure I didn't mess up something that used to work (hm, maybe I should have written some unit tests for this game after all...).
Offline pelle
« Reply #28 - Posted 2012-02-26 22:41:14 »

Mickelukas was correct. There was a bug resulting in enemy attacks having no effect. Now they have. Not sure if it makes the game easier or more difficult. At least enemy artillery should be somewhat dangerous, so there is a good reason to try to overrun them.

Slightly tweaked the combat system so that units can only fire back once. So in addition to being easier to kill when attacked multiple times, there is no risk at all to the attacker when attacking a unit that has already been attacked.

Uploaded new version to the competition site. It's getting late here and no time for the double buffer test. Just hoping that it works for everyone. Good thing there are many days remaining before deadline.
Offline pelle
« Reply #29 - Posted 2012-02-26 22:42:29 »

Also made the move targets much easier to see. Hopefully that fixes the problem with the engineer next to the river not seeing it can move there.

Markers are not pretty, but I think being easy to see is more important.
Pages: [1] 2
  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.

Longarmx (50 views)
2014-10-17 03:59:02

Norakomi (39 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (36 views)
2014-10-15 16:18:58

TehJavaDev (66 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (56 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (44 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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 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!