Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (547)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Drawing many images / Getting started with Muliplayer  (Read 741 times)
0 Members and 1 Guest are viewing this topic.
Offline Gjallar

JGO Coder


Medals: 13
Projects: 1


Follower of Nurgle


« Posted 2012-08-08 07:13:54 »

Hello lovely community, I have two questions.

1:
I'm planning to write a simple 2D, top-down game wich rather small tiles. If I have many objects and want to deal with collisions I could use a quadtree for example, but how do I go about drawing those many objects? Till now I just iterated through all the objects with two for-loops and img.draw(), but that eats more performance than necessary doesn't it?

I will be using Slick2D and remember that I read somewhere on here that I should use img.start() and img.stop() or something like that but I can't find it for the life of me..

2:
I'd like to have multiplayer in this game. I looked through the "Networking & Multiplayer" section on the forum but couldn't really find anything that would help me to get started. I read the UDP vs. TCP article that raeking posted but obviously that didn't really help me getting started, all I know now is that I should use UDP  Grin

Now I have following in mind because I really enjoy it's simplicity. In Terraria one player simply opens a server by pressing "Host multiplayer game" and other players can join by pressing "Join multiplayer game" in their client and entering the hosts IP and a port. Nice and easy. Now I guess that's more of a LAN thing since we had to use Hamachi to get it to work, but I dont really mind that.

Please keep in mind that I know virtually nothing about networking yet, I was always a little afraid of it because it seems rather difficult. I think Slick2D doesn't have any networking features so will I need to use any additional libraries, or can I work with basic Java?


As always I really appreciate your help. JGO's community is simply amazing... especially compared to a community like DotA 2's or HoN's (Play it and you'll know what I mean  Tongue)
Thank you Riven for making this possible  Smiley
Offline davedes
« Reply #1 - Posted 2012-08-08 11:19:25 »

1. Read this:
http://slick.cokeandcode.com/wiki/doku.php?id=performance_memory_tips

2. Networking is a pretty complex beast. I'd suggest looking at some open source games (like BrowserQuest or some of Kev's open source network games). For libraries, Kyro-Net or JGN (Java Game Networking) may be of interest.

Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #2 - Posted 2012-08-08 13:44:13 »

If you have actual entities that needs collisions, you can use a quadtree. However, I'd suggest that you just use cells instead like described in this thread.

For tiles, it's relatively simple to check wether or not they're actually on the screen. If not, just don't draw them!

When using Slick2D it's also important that you don't bind (as in the OpenGL function with textures) too many times. Image.startUse() binds a texture, and then Image.drawEmbedded() becomes almost free, until you call Image.endUse(). You can only draw the texture you currently have bound. Image.draw() will just bind and draw. It doesn't take into account what is currently bound, so drawing many sprites this way becomes really expensive.

Just something to take into account. If you don't remember it, you'll run into serious FPS problems. When binding, you're loading an entire texture into the GPU. Therefore you should avoid making each texture too small. If you have a lot of different terrain put it all on a larger image (a spritesheet), so you can draw all the terrain before binding the next texture.

I realize I might not have explained myself very well, and that you might already be aware of what I'm telling you.

Good luck, nonetheless!

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Gjallar

JGO Coder


Medals: 13
Projects: 1


Follower of Nurgle


« Reply #3 - Posted 2012-08-08 15:05:05 »

@davedes: Thank you very much  Smiley

I realize I might not have explained myself very well, and that you might already be aware of what I'm telling you.

You pretty much explained what davedes' link did, and no I did not know that, so thank you aswell!  Wink
Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #4 - Posted 2012-08-08 15:16:00 »

thank you!  Wink

You bet! Cheesy

I didn't comment on networking at all, so I'll offer my 2 cents.

I would go with KryoNet just because it's so easy to use, and it's powerful. For instance, you can just use ints and be fine, even though you have low values - Kryonet will make those bytes/shorts if possible. That single feature I enjoy a lot! I don't have to worry!
You can send any objects over the network, and that makes development a lot easier. You just don't have to worry about the tedious things that often comes with sending data over a network.
Kryonet will just serialize your objects and send them over. It's pretty cool.

Pages: [1]
  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.

atombrot (25 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (13 views)
2014-08-16 06:20:21

Tekkerue (20 views)
2014-08-16 06:12:11

Rayexar (58 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!