Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (603)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (652)
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 966 times)
0 Members and 1 Guest are viewing this topic.
Offline Gjallar

JGO Coder

Medals: 19
Projects: 1

Follower of Nurgle

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

Hello lovely community, I have two questions.

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

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:

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: 19
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.

SHC (21 views)
2015-08-01 03:58:20

Jesse (19 views)
2015-07-29 04:35:27

Riven (39 views)
2015-07-27 16:38:00

Riven (21 views)
2015-07-27 15:35:20

Riven (24 views)
2015-07-27 12:26:13

Riven (14 views)
2015-07-27 12:23:39

BurntPizza (35 views)
2015-07-25 00:14:37

BurntPizza (46 views)
2015-07-24 22:06:39

BurntPizza (28 views)
2015-07-24 06:06:53

NoxInc (36 views)
2015-07-22 22:16:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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!