Slick Forums

Discuss the Slick 2D Library
It is currently Tue May 21, 2013 12:24 pm

All times are UTC




Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: Fri Jun 18, 2010 9:17 am 
Offline

Joined: Sat Feb 06, 2010 4:29 pm
Posts: 40
Vince wrote:
Fnord wrote:
Vince wrote:
The code is not really beautiful :? (I didn't have time to change it)

doesn't care,

how was fog of war done?


A simple solution but it's works fine, so why not ? :D


thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 18, 2010 9:51 am 
Offline
Regular
User avatar

Joined: Thu May 21, 2009 10:25 am
Posts: 161
Location: France
appel wrote:
You can only play on "local" network?

How does the game handle with many players?

It would be nice if you could give us details how you implemented the networking part in the game, what stuff you send over, etc.


Yes only local network, I didn't have the capacity to make it work on the internet which means things like interpolation/extrapolation or others. Normally old RTS used a peer-to-peer network architecture but here I used a classic server-client architecture.

About network, I do something simple and not secure, I just want this to work, so here we trust clients.

I used TCP to send messages like creation/destruction of entities and player tchat message. Those packets are send only when necessary.

I send all players entities informations over network with UDP at a regular time (positions, life, countdown, etc.). Only entities which implements a special interface can send informations over network:

public interface INetworkEntity {

public int getNetworkID();

public EntityState getState();

public void setState(EntityState state);
}

Where EntityState is a really simple class with some attributes that will be send over network with Kryo.

As you know UDP packet can be lost or come in the wrong order. So I simply drop wrong packet. To finish I synchronized messages transfer between the game main loop and the network using a "Network pool". The idea is that only main loop can decide when update the game with network new packets.

Network <------------------------>Synchronized Network Pool <------------------------> Game

The network pool class contain synchronized Arraylist which stock and drop packets to send/receive.

If you want more precision or you have others questions, don't hesitate :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 18, 2010 9:56 am 
Offline
Regular
User avatar

Joined: Thu May 21, 2009 10:25 am
Posts: 161
Location: France
Gornova81 wrote:
I've tried it :D
It's cool to see things moving, fighting with enemies and so on: maybe moving maps using keys could be helpful :D


You can move quickly by pressing the mouse right click when moving. I didn't talk about game functionalities. You can take screenshots with F1. When you click on some constructor buildings, you can set a rallying point (small flag), etc. You have to discover the others by yourself :D.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 18, 2010 10:21 am 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
Vince wrote:
appel wrote:
You can only play on "local" network?

How does the game handle with many players?

It would be nice if you could give us details how you implemented the networking part in the game, what stuff you send over, etc.


Yes only local network, I didn't have the capacity to make it work on the internet which means things like interpolation/extrapolation or others. Normally old RTS used a peer-to-peer network architecture but here I used a classic server-client architecture.

About network, I do something simple and not secure, I just want this to work, so here we trust clients.

I used TCP to send messages like creation/destruction of entities and player tchat message. Those packets are send only when necessary.

I send all players entities informations over network with UDP at a regular time (positions, life, countdown, etc.). Only entities which implements a special interface can send informations over network:

public interface INetworkEntity {

public int getNetworkID();

public EntityState getState();

public void setState(EntityState state);
}

Where EntityState is a really simple class with some attributes that will be send over network with Kryo.

As you know UDP packet can be lost or come in the wrong order. So I simply drop wrong packet. To finish I synchronized messages transfer between the game main loop and the network using a "Network pool". The idea is that only main loop can decide when update the game with network new packets.

Network <------------------------>Synchronized Network Pool <------------------------> Game

The network pool class contain synchronized Arraylist which stock and drop packets to send/receive.

If you want more precision or you have others questions, don't hesitate :)


Does it really work well on local network, with no extrapolation? I would have thought you'd need it even though it's on LAN.

What if there's some lag on the LAN? Let's say the ping is 100 ms. Would that mean that game could only run at 10 fps? Or do you ensure maximum or constant framerate despite of network speed? Do things move in a choppy fashion?

Oh well, I'm just wondering because I am considering networking for my own RTS game... intended to work on the internets.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 18, 2010 11:02 am 
Offline
Regular
User avatar

Joined: Thu May 21, 2009 10:25 am
Posts: 161
Location: France
appel wrote:
Does it really work well on local network, with no extrapolation? I would have thought you'd need it even though it's on LAN.

What if there's some lag on the LAN? Let's say the ping is 100 ms. Would that mean that game could only run at 10 fps? Or do you ensure maximum or constant framerate despite of network speed? Do things move in a choppy fashion?

Oh well, I'm just wondering because I am considering networking for my own RTS game... intended to work on the internets.


About FPS, the game must not be FPS dependant (update should be call at the same speed no mater if you have 50 or 300 FPS), I used setMinimumLogicUpdateInterval and setMaximumLogicUpdateInterval from GameContainer.

Now if you want to make it works on the net, yeah you right you should consider latency and position extrapolation for UDP exchange. So the real problem is only entities movements, all other things can support a "lag" and I thing you should keep TCP for create/destruction/tchat messages.

There are others solutions:

Maybe you can try to render everything with a small delay and update packet at the real time. Or you can try to go back in time when you get packets.

You can also try to use a prediction system. If your units moved with a pathfinding algorithm, you can predict the next position on client side. In this case you will send player commands and not entities positions.

I'm not good enough to help you with that, I'm sure there are people who can answer better to this question :?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 18, 2010 11:39 am 
Offline
Game Developer
User avatar

Joined: Tue Nov 21, 2006 4:46 am
Posts: 619
Location: Iceland
Ok, thanks. I'm not going to start a multiplayer architecture discussion here and hijack your thread :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 18, 2010 12:08 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1313
Location: Italy
Have you ever thought about adding AI to it ?

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 18, 2010 12:18 pm 
Offline
Regular
User avatar

Joined: Thu May 21, 2009 10:25 am
Posts: 161
Location: France
Gornova81 wrote:
Have you ever thought about adding AI to it ?


In the beginning yes, there is a class to do that but she is empty, not enough time to implement it :? . Now that I return the project to school I can find time to make an AI but not know. I do a "Pause" with this game. Actually I want to make a platform game (but I have to find sprites before and it's always difficult). In the same time I try to learn JMonkeyEngine API and I still have work to do for school so it's hard to find time for everything :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 18, 2010 1:05 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1313
Location: Italy
Vince wrote:
Gornova81 wrote:
Have you ever thought about adding AI to it ?


In the beginning yes, there is a class to do that but she is empty, not enough time to implement it :? . Now that I return the project to school I can find time to make an AI but not know. I do a "Pause" with this game. Actually I want to make a platform game (but I have to find sprites before and it's always difficult). In the same time I try to learn JMonkeyEngine API and I still have work to do for school so it's hard to find time for everything :)


Cool :D
Do you plan to opensource this game? I'd like to play with IA little bit, and this game could be a good starting point :D

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 20, 2010 4:08 am 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
looks nice!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 23, 2010 6:30 pm 
Offline
Regular

Joined: Sun Oct 11, 2009 8:53 pm
Posts: 219
omg its a great game!

can you please realse the soruce so i can learn how you did every thing?

also, where did you load the imgs of every thing from?
i didn't see any img in the game.jar.


GREAT GAME!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 23, 2010 8:56 pm 
Offline
Regular
User avatar

Joined: Thu May 21, 2009 10:25 am
Posts: 161
Location: France
waltobc6 wrote:
omg its a great game!

can you please realse the soruce so i can learn how you did every thing?

also, where did you load the imgs of every thing from?
i didn't see any img in the game.jar.


GREAT GAME!


Sorry, but I don't thing I will open the source.

But for all resources, there is a "resources.jar" (a big jar) in the libs repository, you can find all resources in it (sounds, musics, sprites, etc.). In all my game there are resources.jar with all resources (VAlien Shoot, Beer Pac-man, etc.).

You can reuse them as you want :wink: . Just be careful with law, I'm not the owner of all sprites.

An other things my sprites images name look like:

spritesWidth_spritesHeight_name.png. ( 20_20_car.png )

It's because I have a special class that load automatically all resources from the resources.jar and I need to know sprites width/height in spritesheet :). This is useful when I want to add quickly new resources, I just have to put the new resource in the good repository, call a script which create/update the resources.jar and then call the resource in my game like this:

SpriteSheet ss = ResourceManager.getSpriteSheet("mySpriteSheet");
Music music = ResourceManager.getMusic("myMusic");
TiledMap map = ResourceManager.getMap("myMap");
etc.

I also used this class to load all resources as deferred (to use progress bar). Using this, resources using with my game when I develop are always in a jar, so when I want to make a WebStart version of the game, I already have resources in the jar :D.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 24, 2010 12:28 pm 
Offline
Regular

Joined: Sun Oct 11, 2009 8:53 pm
Posts: 219
Vince wrote:
waltobc6 wrote:
omg its a great game!

can you please realse the soruce so i can learn how you did every thing?

also, where did you load the imgs of every thing from?
i didn't see any img in the game.jar.


GREAT GAME!


Sorry, but I don't thing I will open the source.

But for all resources, there is a "resources.jar" (a big jar) in the libs repository, you can find all resources in it (sounds, musics, sprites, etc.). In all my game there are resources.jar with all resources (VAlien Shoot, Beer Pac-man, etc.).

You can reuse them as you want :wink: . Just be careful with law, I'm not the owner of all sprites.

An other things my sprites images name look like:

spritesWidth_spritesHeight_name.png. ( 20_20_car.png )

It's because I have a special class that load automatically all resources from the resources.jar and I need to know sprites width/height in spritesheet :). This is useful when I want to add quickly new resources, I just have to put the new resource in the good repository, call a script which create/update the resources.jar and then call the resource in my game like this:

SpriteSheet ss = ResourceManager.getSpriteSheet("mySpriteSheet");
Music music = ResourceManager.getMusic("myMusic");
TiledMap map = ResourceManager.getMap("myMap");
etc.

I also used this class to load all resources as deferred (to use progress bar). Using this, resources using with my game when I develop are always in a jar, so when I want to make a WebStart version of the game, I already have resources in the jar :D.


ur project can help me and alot other

in alot of subjects,
pls re consider it again, i my self can promise you only to learn from ur soruce and not abouse it or use it to build any thing.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 26, 2010 7:21 am 
Offline
Regular
User avatar

Joined: Thu May 21, 2009 10:25 am
Posts: 161
Location: France
waltobc6 wrote:

ur project can help me and alot other

in alot of subjects,
pls re consider it again, i my self can promise you only to learn from ur soruce and not abouse it or use it to build any thing.


That's not the problem. The sources are not refactoring and there is no Javadoc inside so it will be hard to read it. It's not a good start point to learn how to program a RTS (there are paper about that on web).

Anyway, it's ok :). Here a link to the complete Eclipse project (you could open it with New Java Project then Create project from existing source and by selecting the directory)

STKRTS Eclipse Project (~53 mo)

But I warn you again, it will be not easy to read :o. If you want something specific from sources, don't hesitate to tell me what. I'm in holiday so I have time to answer questions :D


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 26, 2010 8:49 pm 
Offline
Regular

Joined: Sun Oct 11, 2009 8:53 pm
Posts: 219
Vince wrote:
waltobc6 wrote:

ur project can help me and alot other

in alot of subjects,
pls re consider it again, i my self can promise you only to learn from ur soruce and not abouse it or use it to build any thing.


That's not the problem. The sources are not refactoring and there is no Javadoc inside so it will be hard to read it. It's not a good start point to learn how to program a RTS (there are paper about that on web).

Anyway, it's ok :). Here a link to the complete Eclipse project (you could open it with New Java Project then Create project from existing source and by selecting the directory)

STKRTS Eclipse Project (~53 mo)

But I warn you again, it will be not easy to read :o. If you want something specific from sources, don't hesitate to tell me what. I'm in holiday so I have time to answer questions :D


wow i got alot of questions!!

first, TY TY TY, you dont know how much you helped me.

so this is what i learned so far,
you us for interface the twl.jar which is the "GUI gui", "LWJGLRenderer lwjglRenderer", "ThemeManager theme" and "TWLInputAdapter twlWrapper".

and i got alot of questions about them,
first, i saw the load class for the imgs and every thing.
i didn't really understand how to use GUI and how its work,
how the lwjglRender help it and etc etc,
if you can pls explane more what they do and how they work.

also i saw that all the interface you load from guiTheme.xml
how did you build the xml , all the x,y i mean, how did you built the xml
because i cant figer out how to read the x,y of the Eforen.png and dividing it and all the stuff.

also, how you set the imgs for all the buttons for exmple in the mainmenu
because i saw you only did the key the create them, put them where you want, the contant they will show, and what happen if you press them.
but i didn't see how you set them imgs, clicking, mouse over etc etc.
where did you confirm them?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group