• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Johannes1991

Members
  • Content count

    70
  • Joined

  • Last visited

Community Reputation

441 Neutral

About Johannes1991

  • Rank
    Member

Personal Information

  • Location
    Sweden
  1. Ok, thanks for the tips. But I want to make the input code separated from the callback function. And I still have no clue why it causes my program to stall from time to time.
  2. Hi I've recently moved from directInput to using win32 for input and I've been experienced some hold ups in my program. The window stops responding for a  split second and works again, And the longer the program runs the longer the stops gets. If the program loses focus and gets it back then the program stops responding completely and has to be terminated. I'm suspecting it's the game loop and/or use of peekmessage()!  GameLoop   MSG msg; bool gameRunning = true; uint lastFrame = frameTimeStamp; while(gameRunning) { lastFrameTimeStamp = frameTimeStamp; frameTimeStamp = timeGetTime(); if(frameTimeStamp - lastFrame > 17) { elapsedTime = (float)(frameTimeStamp - lastFrame) * 0.001f; input.Update(); while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT) { gameRunning = false; break; } TranslateMessage(&msg); DispatchMessage(&msg); } game.Update(); game.Render(); lastFrame = frameTimeStamp; } } input class:   void HInput::Update() { if (!wndHandle) return; keyEventCount = 0; mouseEventCount = 0; MSG msg; // shift current keystates to last keystates memcpy(lastKeyStates, currentKeyStates, sizeof(bool) * INPUT_KEY_COUNT); // intercept input messages from the window while (PeekMessage(&msg, wndHandle, WM_KEYFIRST , WM_KEYLAST, PM_REMOVE)) { TranslateMessage(&msg); INPUT_KEY key = TranslateWin32Key(msg.wParam); INPUT_KEY button; int x = GET_X_LPARAM(msg.lParam); int y = GET_Y_LPARAM(msg.lParam); switch(msg.message) { case WM_KEYDOWN: if (key == KEY_UNSUPPORTED) break; SET_KEY(key); AddKeyEvent(key); break; case WM_KEYUP: if (key == KEY_UNSUPPORTED) break; CLEAR_KEY(key); break; case WM_CHAR: AddCharEvent(msg.wParam); break; } } POINT pos; GetCursorPos(&pos); ScreenToClient(wndHandle, &pos); deltaX = pos.x - mouseX; deltaY = pos.y - mouseY; mouseX = pos.x; mouseY = pos.y; while (PeekMessage(&msg, wndHandle, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE)) { INPUT_KEY button; int x = GET_X_LPARAM(msg.lParam); int y = GET_Y_LPARAM(msg.lParam); switch(msg.message) { case WM_LBUTTONDOWN: SET_KEY(MOUSE_LMB); AddMouseEvent(IMET_CLICK, MOUSE_LMB, x, y); break; case WM_LBUTTONUP: CLEAR_KEY(MOUSE_LMB); AddMouseEvent(IMET_RELEASE, MOUSE_LMB, x, y); break; case WM_LBUTTONDBLCLK: AddMouseEvent(IMET_DOUBLECLICK, MOUSE_LMB, x, y); break; case WM_RBUTTONDOWN: SET_KEY(MOUSE_RMB); AddMouseEvent(IMET_CLICK, MOUSE_RMB, x, y); break; case WM_RBUTTONUP: CLEAR_KEY(MOUSE_RMB); AddMouseEvent(IMET_RELEASE, MOUSE_RMB, x, y); break; case WM_RBUTTONDBLCLK: AddMouseEvent(IMET_DOUBLECLICK, MOUSE_RMB, x, y); break; case WM_MBUTTONDOWN: SET_KEY(MOUSE_MMB); AddMouseEvent(IMET_CLICK, MOUSE_MMB, x, y); break; case WM_MBUTTONUP: CLEAR_KEY(MOUSE_MMB); AddMouseEvent(IMET_RELEASE, MOUSE_MMB, x, y); break; case WM_MBUTTONDBLCLK: AddMouseEvent(IMET_DOUBLECLICK, MOUSE_MMB, x, y); break; case WM_XBUTTONDOWN: // for both x buttons if (HIWORD(msg.wParam) & XBUTTON1) button = MOUSE_M4B; else if (HIWORD(msg.wParam) & XBUTTON2) button = MOUSE_M5B; SET_KEY(button); AddMouseEvent(IMET_CLICK, button, x, y); break; case WM_XBUTTONUP: if (HIWORD(msg.wParam) & XBUTTON1) button = MOUSE_M4B; else if (HIWORD(msg.wParam) & XBUTTON2) button = MOUSE_M5B; CLEAR_KEY(button); AddMouseEvent(IMET_RELEASE, button, x, y); break; case WM_XBUTTONDBLCLK: if (HIWORD(msg.wParam) & XBUTTON1) button = MOUSE_M4B; else if (HIWORD(msg.wParam) & XBUTTON2) button = MOUSE_M5B; AddMouseEvent(IMET_DOUBLECLICK, button, x, y); break; } } }  
  3. I have started making my own shader loader and of course it's not working! When I read from the shader file i separate the hlsl code and my own code into different strings and when i try to compile the shader code with D3DX11CompileFromMemory() I get this error message: "error X3000: syntax error: unexpected end of file" I have put a null terminator in the end of the string but it doesn't work... So anyone know the reason for this problem? Code: std::fstream file(path, std::ios::in); std::string shaderCode = "", tempBuffer; if(file.is_open()) { while(!file.eof()) { //file.get(tempBuffer); file >> tempBuffer; if(tempBuffer == "ShaderInformation") { int i = 0; i += 0; } else { shaderCode += " " + tempBuffer; } } } shaderCode += '\0'; HRESULT hr; ID3D10Blob *vsBlob, *psBlob, *errorBlob; //Dummy hlsl code const char temp[] = "Texture2D colormap;" "Texture2D lightmap;" "SamplerState fullscreenQuadSampler;" "struct VertexInput" "{" "float3 position : POSITION0;" "float2 uv : TEXCOORD0;" "};" "struct PixelInput" "{" "float4 position : SV_Position;" "float2 uv : TEXCOORD0;" "};" "PixelInput VS(VertexInput input)" "{" "PixelInput output;" "output.position = float4(input.position, 1.0f);" "float2 halfPixel = float2(0.5f / 800.0f, 0.5f / 600.0f);" "output.uv = input.uv;// + halfPixel;" "return output;" "}" "float4 PS(PixelInput input) : SV_Target" "{" "float3 diffuseColor = colormap.Sample(fullscreenQuadSampler, input.uv).rgb;" "float4 lightData = lightmap.Sample(fullscreenQuadSampler, input.uv);" "float3 diffuseLight = lightData.rgb;" "float specularLight = lightData.a;" "return float4(diffuseColor * diffuseLight + specularLight, 1.0f);" "}" "\0"; hr = D3DX11CompileFromMemory(temp, sizeof(temp), "FinalComposition.hlsl", NULL, NULL, "VS", "vs_4_0", D3D10_SHADER_PACK_MATRIX_ROW_MAJOR, NULL, NULL, &vsBlob, &errorBlob, NULL); if(hr != S_OK) { if(!errorBlob) return false; char msg[20000]; strcpy_s(msg, sizeof(msg), (char*)errorBlob->GetBufferPointer()); OutputDebugStringA(msg); MessageBoxA(GetDesktopWindow(), msg, "VertexShader Compilation Failed!", MB_OK | MB_ICONERROR); errorBlob->Release(); return false; }    
  4. Maybe some pictures could help us determine? or it's may just me
  5. Here's a perfect example! [img]http://weknowmemes.com/wp-content/uploads/2011/10/hello-yes-this-is-dog.png[/img]
  6. Solved it! I was sending to many packages! per second
  7. I've been playing around with winsock now from time to time and i decided to make a test server and client. I got the server up and going and the client works aswell. But there's a delay of 1 - 2 secs, just now i'm only sending the positions back and forth. First when i used send() i set the len paramter with sizeof(package). But it made my client side unstable. But when i set a constant size it became very stable. The code is in c++, Server code,(process package is in the client too): [CODE] bool Server::Initialize_Server(UINT MaxClients) { this->MaxClients = MaxClients; ClientAddresses = new sockaddr_in[MaxClients]; ClientSockets = new SOCKET[MaxClients]; AddressSize = sizeof(sockaddr_in); NumberOfClients = 0; if(WSAStartup(MAKEWORD(2,2), &Winsock) == WSAVERNOTSUPPORTED) { cout << "\n\nCouldn't Start Winsock\n\n"; WSACleanup(); return false; } HostSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if(HostSocket == INVALID_SOCKET) { cout << "\n\nServer Socket Couldn't Be Created\n\n"; WSACleanup(); return false; } ZeroMemory(&HostAddress, sizeof(sockaddr_in)); HostAddress.sin_family = AF_INET; HostAddress.sin_port = htons(PortNumber); HostAddress.sin_addr.s_addr = INADDR_ANY; if(bind(HostSocket, (sockaddr *) &HostAddress, sizeof(sockaddr_in)) != 0) { int i = WSAGetLastError(); cout << "Couldn't Bind Socket"; WSACleanup(); return false; } if(listen(HostSocket, MaxClients) != 0) { cout << "Couldn't Listen To Socket"; WSACleanup(); return false; } u_long iMode = 1; ioctlsocket(HostSocket, FIONBIO, &iMode); MultiPlayer_1(); return true; } void Server::Process_Packages() { int PackageSize, PointerPos; char* tempPackage; for(int i = 0; i < NumberOfClients; i++) { PointerPos = PackageSize = 0; ZeroMemory(Buffer, BufferSize); PackageSize = recv(ClientSockets[i], Buffer, BufferSize, NULL); while(PointerPos < PackageSize) { char PackageID = *((char *) (Buffer + PointerPos)); switch(PackageID) { case PackageID_Player: { //tempPackage = Network_Stuff.Check_Complete_Package(sizeof(GroupUnitInfos_Package), &PackageSize, 512, &PointerPos, (char *&) *Buffer); if(!Check_Package_Whole(&ClientSockets[i], &PointerPos, sizeof(Player_Package), &PackageSize, tempPackage)) { Player_Package* temp = (Player_Package *) tempPackage; Player* tempPlayer = (Player *) GameData.ObjectList[temp->Player_ID]; tempPlayer->Set_Position(temp->Position); tempPlayer->Set_Direction(temp->Direction); delete[] tempPackage; }else { Player_Package* temp = (Player_Package *) (Buffer + PointerPos); PointerPos += sizeof(Player_Package); Player* tempPlayer = (Player *) GameData.ObjectList[temp->Player_ID]; tempPlayer->Set_Position(temp->Position); tempPlayer->Set_Direction(temp->Direction); } }break; default: { cout << "\n\nCouldn't Identify Package\nPackage Size: " << PackageSize * 0.001f << "kb\n\n"; PointerPos = PackageSize; } break; } } } } bool Server::Check_Package_Whole(SOCKET* const Socket, int* PointerPos, const int SizeOfPackage, int* RevievedPackageSize, char *& tempBuffer) { if(*RevievedPackageSize - *PointerPos < sizeof(SizeOfPackage)) { int PartSizeInBuffer = *RevievedPackageSize - *PointerPos; tempBuffer = new char[sizeof(SizeOfPackage)]; memcpy(tempBuffer, (char *)(Buffer + *PointerPos), PartSizeInBuffer); *RevievedPackageSize = recv(*Socket, Buffer, BufferSize, NULL); memcpy((char *) (tempBuffer + PartSizeInBuffer), Buffer, sizeof(SizeOfPackage) - PartSizeInBuffer); *PointerPos = sizeof(SizeOfPackage) - PartSizeInBuffer; return false; } else return true; } void Server::Update_Clients() { Player_Package Package; for(int i = 0; i < NumberOfClients; i++) { Package.Player_ID = i; Package.Position = GameData.ObjectList[i]->Get_Position(); Package.Direction = GameData.ObjectList[i]->Get_Direction(); for(int c = 0; c < NumberOfClients; c++) { if(c == i) continue; send(ClientSockets[c], (char *) &Package, BufferSize, NULL); } } } [/CODE]
  8. I've been trying to rotate a box around a certain point (for the purpose of angular velocity). I Know how to rotate the mesh around a point by changing the origo in mesh space, but the problem is that the i don't know how to rotate the Position variable too. Because if i change the rotation point(and the mesh origor) then the box "jumps" so the new origo in mesh space. Here's a pic for further explanation: [attachment=5856:Pic.png] The Plus is the Box Mesh Origo and the red circle is the Rotation Point. Thanx in advance
  9. I've been trying to rotate a box around a certain point (for the purpose of angular velocity). I Know how to rotate the mesh around a point by changing the origo in mesh space, but the problem is that the i don't know how to rotate the Position variable too. Because if i change the rotation point(and the mesh origor) then the box "jumps" so the new origo in mesh space. Here's a pic for further explanation: [attachment=5856:Pic.png] The Plus is the Box Mesh Origo and the red circle is the Rotation Point. Thanx in advance
  10. [quote name='ApochPiQ' timestamp='1316711835' post='4864765'] WSAAsyncSelect is evil. I believe the Forum FAQ has a lot of explanations of precisely why. I think you'll have a much easier time of things if you use a different technique for handling your sockets! [/quote] haha ok I'm making a small RTS game so what type of socket would you recommend?
  11. I'm using WSAAsyncSelect with TCP. Then thing about [color=#1C2837][size=2] FD_READ [/size][/color]is that i only get it if recv() have been called. i don't get FD_READ when I KNOW data has been sent to the server.
  12. I've been playing around with Winsock(non blocking) and there are some things that i don't just get 1: I only get a FD_READ message when i've called the function recv() and a package arrive later. Is it suppose to be like that? for example if i call recv() 500 times and 100 packages was recieved. Will it keep checking for those 400 other package till the end of the program? 2: When i send a package that is 16 bytes and the recv() size is 256 then the reading of the package isn't always precise and vice versa. Only if the sizes are equal. So should i have a constant size for all of the packages(even if they are less)?. for example the constant size is 256 but i still send stuff that is 128 bytes, but the first bytes identifies the package so it's used correctly 3: If i should have a constant size then what is the reasonable size?
  13. [quote name='hplus0603' timestamp='1315858363' post='4860848'] [quote name='Johannes1991' timestamp='1315848307' post='4860760'] [code] while(NumberOfClients < MaxNetworkPlayers) { ClientSockets[NumberOfClients] = accept(Socket, (sockaddr*) &ClientAddresses[NumberOfClients], &AddressSize); if(ClientSockets[NumberOfClients] != SOCKET_ERROR) { NumberOfClients++; } }[/code] [/quote] So, nobody can send or receive any packets until the maximum number of players has joined the game? That doesn't seem right to me. [/quote] I'll thead that bad boy then! ;P
  14. Fixed it! Solution! [code] while(NumberOfClients < MaxNetworkPlayers) { ClientSockets[NumberOfClients] = accept(Socket, (sockaddr*) &ClientAddresses[NumberOfClients], &AddressSize); if(ClientSockets[NumberOfClients] != SOCKET_ERROR) { NumberOfClients++; } }[/code]