Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


dEgle

Member Since 26 Feb 2012
Offline Last Active Dec 17 2012 11:07 AM

Posts I've Made

In Topic: Network programming strategies. Any tutorial?

05 November 2012 - 01:41 PM

I meant if it is a right thing to implement:)


The main challenge I can see with that is detecting whether a packet was dropped. If I send a packet to you, and there's no guaranteed stream of packets back, then I don't know whether you got it or not if I don't hear back from you.

For example if i send datagram with map data of file parts i will definitely number these packets, so if there is a non stable connection client can ask to resend right packet.
In case of lost packets with events...players might be teleporting;-)

In Topic: Network programming strategies. Any tutorial?

04 November 2012 - 01:37 PM

In that case, you want to fit all events from the queue in the single UDP datagram each time you send a datagram.

I guess it's best idea to reduce traffic when sending events from server to each clients and vice versa:)

Set a send rate -- 5 times a second, 20 times a second, whatever suits your game -- and stuff all the events into a single datagram for each packet you send. If there are no events, still send a packet, so you can detect connected vs disconnected users, do time management, detect dropped packets for re-tries, etc.

Will it work if i send events from client to server each frame (if there are any events) and server will send events to clients each frame, so there will be no exact rate?
That way I will have to have ping-pong requests to measure latency, disconnected palyers, etc.

In Topic: 2D Tile Based Lighting

04 November 2012 - 10:35 AM

You can also make multiple "light" blocks inside one tile. Light block can have 3 bytes for color and a byte for light level.
To make it faster recalculate only if there are moving lights (like torch in hand).

If you use GPU to render fancy lights then you don't need much light blocks. Only for spawning mobs for example...

Be creative and you can make your own lighting engine, even more fancy than terraria has!

In Topic: Network programming strategies. Any tutorial?

04 November 2012 - 04:40 AM

There are as many networking systems as there are game genres, because each kind of game needs different compromises in data model richness, accuracy, throughput management, and latency compensation.

Yes, it's totally fine to keep a queue of events to send on one end, send them all as one packet every so often, and then put them in a queue of events to dispatch/deal with on the receiving side. Many games work like that. If you're using TCP, beware that you have to put a length field before each "packet" that you send, because the TCP connection may/will split your send() calls into multiple recv() calls and/or combine multiple send() calls into a single recv() call.


Actually I'm using UDP, so event can fit in one packet. Thanks anyway:)

In Topic: Collision Detection HELP!

15 August 2012 - 11:56 AM

Hello! Here is my function that i use in my projects. It's just a little more compact and 100% working :) Hope it will help you.
int check_collision(SDL_Rect *a , SDL_Rect *b)
{
if(b->x + b->w < a->x) return 0; //just checking if their
if(b->x > a->x + a->w) return 0; //bounding boxes even touch
if(b->y + b->h < a->y) return 0;
if(b->y > a->y + a->h) return 0;
return 1;    //bounding boxes intersect
}

PARTNERS