Castles-Game Prototype(Webstart)

This is just a prototype…has the basic game mechanics.
I am planning to add lots more,change the graphics a lot and add some music.

Play Here…designinks.bravehost.com/game/castles.jnlp

http://img213.imageshack.us/img213/9838/screenshotrh6.png

I have packed the game in an executable jar.

Game Description :

You choose a kingdom and try to destroy the opposite kingdom's castle..Any units made will move towards the right..
Once made no units can be controlled...A worker unit will bring the wood from tree back to the castle (which will increase your coins).A sword unit can be destroyed only by another sword unit.A thief if sucessfully sent to the opposite camp can steal 150 coins.A speed unit can travel faster than the other units.

  COST: Worker : 5 coins
               Swordsman : 25 coins
               Thief  : 45 coins
                Speed unit : 60 coins.

This is a very basic version and has a large load time ???after u press ‘s’ key to start the game…
Anybody with ideas that can be added to the game,please give them… :slight_smile:

how about posting some screenshots? :slight_smile:

Concept sounds interesting and the graphical style shows merit… don’t suppose you’d like to Webstart it for us?

Cas :slight_smile:

Yes! Good idea! You have a jar, it would be easy to configure java webstart!

Game Over
You Win!

Cool graphics.

My main critisism would be that it took too long to complete the game.

Here is a crazy idea:
You can use a cannon/ caterpolt from the top of the castle. It charges for a while ( say 45 seconds ) and then you can click on it then click somewhere on the ground to fire a large stone and destroy enemies or anyone that is there. It would add a bit of ‘instant-interactivity’ to the game.

Perhaps you start with a basic cannon and you can buy upgrades like a flaming ball or somthing.

Thanks for ur comments irreversible_kev ,

This is just prototype,did it in 2 days…i am planning to improve the gameplay,add more units,ability to build new buildings,season changes,etc…

Will it be a good idea to make the game side-scrolling ??? More space for the gameplay…

princec & gouessej : Webstart version ready…please leave a comment

You need to set the mime-type on the server for JNLP files to application/x-java-jnlp-file by the way.

Verdict: I think you’re on to a winner here if you can manage to build on this basic game concept. Scrolling might not necessarily make it any better but varied scenery and multiple paths would. And lots and lots of different things to send forth. I can envisage a game so good I’d pay for it if you get it right.

Cas :slight_smile:

Princec is right, add this :

<?php header("Content-type: application/x-java-jnlp-file"); echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";

?>

and rename your file with the extension “.php”.
Side-scrolling is easy to implement on my view. It might be interesting but I agree with Princec, the main point is to improve the variety of interactions with the player.

I tried your game from command line. Why is the frame rate so low? Only 40 FPS here. Could you use JOGL or LWJGL inside your game? It isn’t an absolute necessity but it might improve the performance.

I like it ;D - would probably even fit into the j4k…

This is a good idea!I like it!

Great game! AI is a bit too easy, still it is nice! Would love to play it with a real player, even hot-seat mode!

40fps is fine for this game I think, though obviously 60fps would be ideal :wink: Which should be achievable using plain old Java2D easily - not sure where the bottleneck is here or why it runs at 100% CPU.

Cas :slight_smile:

40 FPS is enough but I really think there is a huge room for improvements.

I have never used webstart before…can u post a link containing some basic guide…btw i did what u wrote…didn’t work… ???

I fixed the frame rate to 40 FPS using Thread.yeild(); // I think that is making the processor run at 100 %.
Any idea on how to implement a constant frame rate loop in game…

Thank you very very much ;D for the positive comments…Juriy…gjh9413…kingaschi…i am planing to rework the game completely…switch from Java2D to JOGL…add more units,buildings…random terrain generation,different modes of game play.

I am also going to concentrate on multiplayer support…

I fixed the Framerate to 40 fps…used… Thread.yeild();

code :

float target = 1000 / 40.0f;
float frameAverage = target;
long lastFrame = System.currentTimeMillis();
float yield = 1000f;
float damping = 0.1f;

	long renderTime = 0;
	long logicTime = 0;
	
	while (gameRunning) {
		long timeNow = System.currentTimeMillis();
		frameAverage = (frameAverage * 10 + (timeNow - lastFrame)) / 11;
		lastFrame = timeNow;
		
		yield+=yield*((target/frameAverage)-1)*damping+0.05f;

		for(int i=0;i<yield;i++) {
			Thread.yield();
		}

//=========================================================================

I can’t play at all! :’( I just get this page;

[b]The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


End tag ‘information’ does not match the start tag ‘description’. Error processing resource 'http://designinks.bravehost.co

</information>

------^[/b]

Please don’t yield.


int targetFramerate = 40;
long milliesPerFrame = 1000 / targetFramerate;

long lastFrame = System.currentTimeMillis();

while(true)
{
   // do your thing here

   long nextFrame = lastFrame + millisPerFrame;
   while(System.currentTimeMillis() < nextFrame)
      Thread.sleep(1); // a sleep of 1ms, doesn't suffer from snapping to 15ms by the OS

   lastFrame = nextFrame;
}

I quite like a high priority thread unlocking a wait 60 times a second. Having said that it does not handle low resolution timers when using only standard calls.

Capping FPS using yield does seem dodgy because since when is yield meant to take a set amount of time? But I’ve seen it used by Onyx and Kev in their games. Using sleep is good since it doesn’t max out the CPU unlike yield but since sleep(time) doesn’t gaurantee a sleep of time, often it will be much longer and you will miss frame updates. For example, sometimes when you increase the sleep time by one incrementally it does not seem to make any difference until you get to say 5ms or 20ms ???.

But how do you get your high priority thread to time things properly and wake up your thread at the right time? You’ll still have to use a sleep or yield technique

The graphics for this game look great by the way :slight_smile: