• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

150 Neutral

About beefsteak

  • Rank
  1. snap-back synchronization?

    What you describe sounds like the client is only interpolating between packets of data received from the server. With such an approach smooth movement is hard to achieve: 1. Due to network latency, data displayed on the client side is never up-to-date. The client "lags". 2. Due to network latency, the packets don't arrive at perfectly regular intervals. Latency will cause "jumps" in your movement animations.   The better solution is to implement client-side movement prediction, as hplus0603 pointed out. With a good movement prediction algorithm, corrections will happen rarely.   Here's an article that explains the whole issue very clear and from a high level perspective: http://gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking/  
  2. The flag WS_EX_LAYERED didn't change much. For some reason, with WS_EX_LAYERED the preview is not entirely blank anymore, but rather showing an empty (white) window including borders and title bar. The function DwmSetIconicLivePreviewBitmap is part of the WDM api, which I'd rather not use due to Windows XP support. Using it would allow for some workarounds probably.
  3. In your windows message loop, you can listen for events of type "WM_ACTIVATE" and "wParam == WA_INACTIVE". See the msn documentation for details.   This will solve only part of your problem though, because it won't work for all the possible cases: For alt-tab and windows-key, you will receive a WM_ACTIVATE event. For ctrl+alt+del and lock screen (windows-key + L) you will not receive an event.   So, if you really want to catch all possible cases where your fullscreen mode is interrupted, you have to do what Medo3337 pointed out: In regular time intervals, actively check the state of your window and/or your display device. This might seem inconvenient, but I have found no better way.
  4. A also pondered about the device- and window-class configurations I am using: Maybe some special setting I am using in fullscreen mode causes incompatibility issues with the windows desktop manager?   In case it matters I have posted my configurations below:   // window style for window-mode: title bar, close box, minimize box const DWORD Window::WIN_STYLE_WINDOWED = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; // window style for fullscreen: no titlebar, popup style const DWORD Window::WIN_STYLE_FULLSCREEN = WS_POPUP | WS_VISIBLE; Window::Window(HINSTANCE hInstance, WNDPROC messageHandler, LPCTSTR title, int width, int height, bool pFullscreen): window(NULL), activeCursor(NULL), fullscreen(pFullscreen) { // start with default cursor activeCursor = DfCursor::C_DEFAULT; // define window class properties windowClass.style = NULL; windowClass.lpfnWndProc = messageHandler; windowClass.cbClsExtra = 0; windowClass.cbWndExtra = 0; windowClass.hInstance = hInstance; windowClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); windowClass.hCursor = activeCursor == NULL ? NULL : activeCursor->getWinCursor(); windowClass.hbrBackground = NULL; windowClass.lpszMenuName = NULL; windowClass.lpszClassName = title; RegisterClass(&windowClass); // calculate correct window size and position RECT clientRect; calculatePosition(width, height, fullscreen, &clientRect); window = CreateWindow(windowClass.lpszClassName, title, fullscreen ? WIN_STYLE_FULLSCREEN : WIN_STYLE_WINDOWED, clientRect.left, clientRect.top, clientRect.right - clientRect.left, clientRect.bottom - clientRect.top, GetDesktopWindow(), NULL, windowClass.hInstance, NULL); if (window == NULL) { throw (TEXT("Window Constructor: Failed to create a new window!")); } } DfGraphicsManager::DfGraphicsManager(ResourceManager *resourceManager, HWND window, int width, int height, bool fullscreen): resourceManager(resourceManager), context(NULL), device(NULL), desiredScreenResolutionX(width), desiredScreenResolutionY(height) { context = Direct3DCreate9(D3D_SDK_VERSION); if (context == NULL) throw(TEXT("D3DManager Constructor: Failed to create a Direct3D Context!")); parameters.BackBufferWidth = width; parameters.BackBufferHeight = height; parameters.BackBufferFormat = D3DFMT_X8R8G8B8; parameters.BackBufferCount = 1; parameters.MultiSampleType = D3DMULTISAMPLE_NONE; parameters.MultiSampleQuality = 0; parameters.SwapEffect = D3DSWAPEFFECT_FLIP; // flip between front and back buffer parameters.hDeviceWindow = window; parameters.Windowed = !fullscreen; parameters.EnableAutoDepthStencil = true; parameters.AutoDepthStencilFormat = D3DFMT_D16; parameters.Flags = NULL; parameters.FullScreen_RefreshRateInHz = 0; parameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // create the device. HRESULT result = context->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, D3DCREATE_MIXED_VERTEXPROCESSING, &parameters, &device); errorCheck(result, TEXT("D3DManager Constructor: Failed to create device!\r\n")); // for a 2D application: turn off z-buffer, culling and lightning device->SetRenderState(D3DRS_ZENABLE, false); device->SetRenderState(D3DRS_LIGHTING, FALSE); device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); }
  5. Hi folks, I've written a 2D game client in C++ using DirectX/D3D 9. In case you want to try, you can get it here: http://darkfire-rpg.com/download.html By default, the game runs in fullscreen mode, at a resolution of 800x600. When the user leaves the application while running, for example using the alt-tab keys, the application is reduced to the taskbar. In this state, when the user hovers with the cursor over the taskbar icon, a thumbnail and preview image of the application should be displayed. That's a feature of the "windows desktop manager", also known as "aero effect". In my case, these preview images are always blank and I couldn't find a good way to fix that. (Please note that the problem is limited entirely to the fullscreen mode - in window mode the preview images work perfectly.)   [attachment=17143:taskbar_preview_blank.jpg]   When the application is moved to the background (while in fullscreen mode), the device object I am using (IDirect3DDevice9) goes into the state of a "lost device" (D3DERR_DEVICELOST). In that state I cannot execute any drawing operation. Only after the application is activated again by the user (returning into the foreground), the application is able to "reset" the device and continue drawing. I suspect this might be the root of the problem: As the application is unable to draw while in the background, the preview images which supposedly reflect the current "screen" state, are also blank. If that was true, how to fix it? - the behaviour of the device cannot be changed in that regard. I experimented with a mechanism that would automatically switch the application to window mode while in the background. That produced lots of unwanted side effects however, leaving the impression of a bad hack. I also experimented with the windows desktop manager api. Using it allows for example to set a static bitmap for the thumbnail preview in the taskbar. Unfortunately, the windows desktop manager api is not available on windows XP, so when using and linking it, the application won't run on XP anymore.   Did anyone else run into this problem? What is the proper solution?
  6. MORPG "Darkfire Legends" is now online

    I'd love some feedback [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
  7. Hi everybody, My MORPG "Darkfire RPG" is now online and waiting for players. The graphics are 2D and retro-style - This has to do with my limited artistic skills, but also with inspirations from old games like final fantasy, secret of mana, diablo and crossfire. There are plenty of options to customize you character and create a build that is truly unique: stat point distribution system, bound to level-ups an abundance of rare magical items to collect skills to learn runes can alter and improve skills "alternative" character classes, like the mutant or robot In order to play the game, please download and run the windows installer (msi): [url="http://darkfire-rpg.com/download.html"]http://darkfire-rpg.com/download.html[/url] The client "should" run on windows xp, vista, 7 and 8. Fullscreen mode will attempt to use a resolution of 800x600 - which should be supported by most devices. So far, it is tested only with windows vista and 7 - please report back when you have troubles installing or starting the game. Any kind of feedback is most welcome! Special thanks to the gamedev community for supporting me with technical knowledge in several occasions. You will find many more infos on the website: [url="http://darkfire-rpg.com"]http://darkfire-rpg.com[/url] Screenshots:
  8. [quote name='mhagain' timestamp='1349363895' post='4986785'] ID3DXSprite::Draw has a D3DCOLOR parameter and the default texture stage states are set for modulation, so you could use a 1x1 white texture and set this color appropriately for untextured drawing. [/quote] Thank you for this hint - I didn't realize I can do that. Starting with a white texture is really a cool trick. Now I'm using a white "blueprint" texture for primitive drawing, then add color via the "sprite.Draw" method. This makes life a lot easier indeed, because I don't need to create and manage multiple textures for the purpose of primitive drawing. If anyone else has other / better ideas, I would be glad to read about it.
  9. [quote name='yewbie' timestamp='1349363151' post='4986782'] Are you strictly limiting yourself to 2d? I ended up just drawing everything 2d as primitives in my engine I did and subverted LPD3DXSPRITE all together. [/quote] The graphics of my game are 2D, which means everything is drawn flat and there is no depth. I wouldn't mind using 3D functions for programming however, if they are suitable for my needs. The problem I currenty have with 3D functions is that I couldn't find a way to render images. How did you handle that in your engine? Image I have an image of a red dragon, stored in a png file on disk - how can I print that to the screen?
  10. I would like to develop a 2D game client in c++ and windows, with DirectX 9. Most of the graphics are stored in png format, hence I found textures to be very useful (easy to load png files with "D3DXCreateTextureFromFile"). In order to be able to draw the textures on the screen in 2D, I used one sprite (LPD3DXSPRITE). This seemed like a simple solution and works perfectly fine for textures. Now I would like to additionally draw some colored rectangles in between the drawing of images. Surprisingly for me, sprites in DirectX don't support any kind of primitive drawing. There is only one "Draw" method that will render a texture to the display device. So far I've been pondering about the following solutions: 1. Create textures that contain a certain area of solid color. Then draw any kind of rectangle by aligning the small single-colored textures next to each other. I guess it will work but seems really cumbersome, as I will need to write lots of code to manage the color textures and do the drawing. 2. Find a better way to draw my images to the display device, so that i can mix the image-drawing with primitive drawing operations. So far I couldn't figure out how to do it. I suspect I will need some kind of intermediate "surface" object to draw my texture on. 3. Mix sprite drawing operations with device drawing operations. This would require to split up my drawing code to use many different sprites for different purposes. I will need to call sprite.Begin/End very often. On the whole I don't like this idea because it seems "messy". Thank you for any kind of feedback that will point me in the right direction! [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
  11. winsock: is gethostbyaddr needed?

    Thank you for your replies! I'm still unsure what to do though. Maybe switching to getaddrinfo could help, but I still don't understand what gethostbyaddr is actually supposed to do for me: I start out with a correct IP address, and a connection is possible. Then I'm supposed to drop it because gethostbyaddr failed? What's the point in that? Is there even a possible scenario where gethostbyaddr returns an IP address different from the one I passed into the function, which is helping to establish a connection that would otherwise fail? That seems hard to believe.
  12. What I want to do is create a network socket connection from a client application to a server machine, with winsock. I used the following code, which is more or less taken from manuals (see msdn, winsock examples): // on windows, initialize WSA first // 'szServerName' is a char-string, containing either host name or IPv4 address struct hostent *hp; unsigned long addr; struct sockaddr_in server; if ((addr = inet_addr(szServerName)) != INADDR_NONE) { // get host by address hp = ::gethostbyaddr((char*)&addr, sizeof(addr), AF_INET); } else { // get host by name hp = ::gethostbyname(szServerName); } if (hp == NULL) { LOG("hostname '" << szServerName << "' is unknown"); close(); // close connection return false; } // connect to server, using address in 'hp->h_addr' The problem: I am running a DSL-router with two machines attached, forming a small LAN subnet. I'm trying to connect from one machine to the other, with above code, using IP-address. The target machine is firewalled by the standard windowsXP firewall. The connection fails because gethostbyaddr returns NULL. I think the target machine's firewall might be blocking the call to gethostbyaddr. The connection does work if I use gethostbyname, in spite of passing an IP-address. It also works if I take the address returned from inet_addr, and force-feed it into the server struct ('server.sin_addr.s_addr = addr'). Now I am wondering, why the heck should I even use gethostbyaddr if it's only giving me trouble? I don't actually care about the host name, all I want is a working connection. Is it wise to do it like this?: // on windows, initialize WSA first // 'szServerName' is a char-string, containing either host name or IPv4 address struct hostent *hp; unsigned long addr; struct sockaddr_in server; if ((addr = inet_addr(szServerName)) != INADDR_NONE) { // take specified IP address without questioning server.sin_addr.s_addr = addr; } else { // get host by name hp = ::gethostbyname(szServerName); if (hp == NULL) { LOG("hostname '" << szServerName << "' is unknown"); close(); // close connection return false; } server.sin_addr.s_addr = *((unsigned long *)hp->h_addr); } // connect to server, using address in 'server.sin_addr.s_addr' Another alternative may be using gethostbyname ALL the time. The msdn site claims this wouldn't work with IP-addresses, but apparently it does. I have never seen anything like this in any socket tutorial I could find though. That makes me wonder wether I'm wrong after all, and should stick with gethostbyaddr for some reason I don't yet understand? Thank's for help! [smile]
  13. problem with SDL_DisplayFormat

    Ah, that explains it. Thank you very much for this helpful answer. I rate you up. Thanks.
  14. I'm fairly new with SDL. What I want to do is load an image and display it. For fast blitting, I convert it to the display format using SDL_DisplayFormat. Here's how I load my image: // initialize SDL first... SDL_Surface *image = IMG_Load("image.png"); // load image if (image != NULL) { // convert to display-native pixel format, for fast blitting SDL_Surface *dfImage = SDL_DisplayFormat(image); SDL_FreeSurface(image); if (dfImage != NULL) { LOG("with = " << dfImage->w << ", height = " << dfImage->h << ", pitch = " << dfImage->pitch); if (dfImage->pixels == NULL) LOG("pixels NULL!"); } } As I have indicated, I initialize SDL before executing this code. When I call SDL_SetVideoMode with flags SW_SURFACE, then everything works fine and the output appears to be correct:  with = 76, height = 67, pitch = 304 When I call it with flags SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN, then I get the following:  with = 76, height = 67, pitch = 320  pixels NULL! Why is the pixels data NULL in this case? The surface seems to be unusable that way. And why is pitch 320 instead of 304? (Note: 76 width * 4 depth = 304 pitch) Is it not possible to convert pixelformat to a hardware-surface? I thought it's just the same, converting to 4 byte color depth. I'm using WindowsXP, VisualStudio, Cpp, SDL for graphics and an NVIDIA GeForce FX 5200 graphics card, if it matters. Thanks for help! [smile]
  15. IMO ease of learning is all about accessibility. There is a relation between acessibility and fun. Games which are easy to learn tend to be more fun than other games. In so far I understand your observation. The reason for this IMO is that the part where you have to learn a game is generally not fun. Learning a game is work, often real hard work, and that's not what players are looking for. So if you manage to cut that part out, you have cut out something bad and are thus left with a better (more fun) game. I would not agree to go any further like saying ease of learning is key to fun. If the basic gameplay is just bad, then the best accessibility will not help you. Long-term fun in particular is something I believe must stem from gameplay, more than anything else.
  • Advertisement