Jump to content

  • Log In with Google      Sign In   
  • Create Account


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

Topics I've Started

Network programming strategies. Any tutorial?

03 November 2012 - 02:14 PM

Hello guys. I was wondering is there any tutorial describing how to make network support in games? Like what should server send and receive and in what order? Clients?
I guess best way is to make net_events like in SDL: server should translate incoming packets into events, then handle them, generate events for clients and send them back.
Server and clients should have queue of events (like in SDL)...but i'm not sure if it's the best solution.

Problem with creating SDL surfaces

01 August 2012 - 07:42 AM

Hello guys.
I'm developing a small game and I've bumped into problem with SDL surfaces.
I've written function for creating surfaces:
[source lang="cpp"]SDL_Surface *create_surface(int width, int height){ /* Create a 32-bit surface with the bytes of each pixel in R,G,B,A order, as expected by OpenGL for textures */ SDL_Surface *surface; Uint32 rmask, gmask, bmask, amask; /* SDL interprets each pixel as a 32-bit number, so our masks must depend on the endianness (byte order) of the machine */ if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { rmask = 0xff000000; gmask = 0x00ff0000; bmask = 0x0000ff00; amask = 0x000000ff; } else { rmask = 0x000000ff; gmask = 0x0000ff00; bmask = 0x00ff0000; amask = 0xff000000; } surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, rmask, gmask, bmask, amask); return surface;}[/source]
But when i try to do something with it nothing happens:
[source lang="cpp"]Uint32 p_color;p_color = SDL_MapRGB(screen->format,255,255,255);SDL_Surface *srf = NULL;srf = create_surface(16,16);SDL_Rect temp;temp.x = 0;temp.y = 0;temp.w = 16;temp.h = 16; SDL_FillRect(srf,&temp,p_color);apply_surface(0,0, srf, screen, NULL); //simple function for blitting one surface to another.[/source]

I definitely know that srf and screen are 32bits and function for creating surfaces was copied from SDL docs.
apply_surface function works perfectly for any loaded image.
Please, help me out with this simple problem Posted Image

Distance to ray intersection

15 April 2012 - 05:54 AM

Hello guys!
I'm having such a problem: i can't figure easiest way to find distance between point and block (as shown on picture)
Posted Image
Everything that i tried is not properly working Posted Image
Could you help me please and tell way to find that distance.