Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

180 Neutral

About thk123

  • Rank
  1. I am implementing a Keyboard class to extend the XNA keyboard class to work using events. I have got the basics working fine but I thought I would try and integrate it with the GameWindow code (Code here) which currently uses a simple input class to manage current and previous keyboard states. The way their input with GameScreens work is they call HandleInput on the screen that has focus. Clearly this won't work in an event based system. As far as I can see, I have two options. Either in the GameScreen class, when you register an event, the method called must first check if it is active before responding to the input. However, this potentially means many calls to empty functions and the user must remember to do this check with every event method. The other option is the Window registers to a list of specified events on receiving focus and de-registers events when it looses focus. I think this solution is nicer, but I wasn't sure if there was a large performance cost to registering/deregistering. Thanks,
  2. Yeah it is only feature level 10, thanks again for your help
  3. Thank you so much for you help. The problem was the version number, apparently has to be 4 not 5? Thanks for the heads up about safety, will now make sure pointers point to null and I am actually handling error messages Thanks,
  4. Ok so I put in HRESULT results in front of all the methods that return HRESULT and the problem appear to be with the shader creation which returns "E_INVALIDARG". If I'm honest, the shader part was something the tutorial glossed over. What I did to incorporate the shader was add a file called "Shaders.hlsl" in to the source folder of the solution containing: struct VOut { float4 position : SV_POSITION; float4 color : COLOR; }; VOut VShader(float4 position : POSITION, float4 color : COLOR) { VOut output; output.position = position; output.color = color; return output; } float4 PShader(float4 position : SV_POSITION, float4 color : COLOR) : SV_TARGET { return color; } The shader loading code is: ID3D10Blob *vertexShader, *pixelShader; D3DX11CompileFromFile("Shaders.hlsl",0,0,"VShader","vs_5_0",0,0,0,&vertexShader,0,0); D3DX11CompileFromFile("Shaders.hlsl",0,0,"PShader","ps_5_0",0,0,0,&pixelShader,0,0); LPVOID vertexBufferPointer = vertexShader->GetBufferPointer(); SIZE_T vertexBufferSize = vertexShader->GetBufferSize(); //HRESULT result = device->CreateVertexShader(vertexShader->GetBufferPointer(),vertexShader->GetBufferSize(),NULL,&mVertexShader); HRESULT result = device->CreateVertexShader(vertexBufferPointer, vertexBufferSize,NULL,&mVertexShader); result = device->CreatePixelShader(pixelShader->GetBufferPointer(),pixelShader->GetBufferSize(),NULL,&mPixelShader); Is this where I am going wrong? Also, on a more general note, At each of the HRESULT points, should I be checking that they're ok before continuing? Would hate to be picking up bad practices when I have hardly begun!
  5. Hello, I am just starting out with Direct X 11. I have been following these tutorials but I am stuck at the first lesson with actual rendering (drawing a triangle). Specifically, my program crashes when I reach the present line. Actually, it doesn't crash but my computer freezes up, then the screen goes blank, then comes back on with a message saying my display driver has crashed and my program doesn't do anything more. I have updated my drivers and my graphics card is running Direct X 11. Heres the code #include <Windows.h> #include <WindowsX.h> #include <d3d11.h> #include <d3dx11.h> #include <d3dx10.h> #pragma comment (lib, "d3d11.lib") #pragma comment (lib, "d3dx11.lib") #pragma comment (lib, "d3dx10.lib") #define ScreenWidth 800 #define ScreenHeight 600 IDXGISwapChain *swapChain; ID3D11Device *device; ID3D11DeviceContext *devcon; ID3D11RenderTargetView *backBuffer; ID3D11VertexShader *mVertexShader; ID3D11PixelShader *mPixelShader; ID3D11Buffer *mVideoBuffer; ID3D11InputLayout *mInputLayout; struct Vertex { float x, y, z; D3DXCOLOR Color; }; void Init3D(HWND windowHandle); void RenderFrame(); void Clean3D(); void InitGraphics(); void InitPipeline(); LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { //MessageBox(NULL, "Hello world","My Window", MB_OK); HWND windowHandle; WNDCLASSEX windowClass; ZeroMemory(&windowClass, sizeof(WNDCLASSEX)); windowClass.cbSize = sizeof(WNDCLASSEX); = CS_HREDRAW | CS_VREDRAW; windowClass.lpfnWndProc = WindowProc; windowClass.hInstance = hInstance; windowClass.hCursor = LoadCursor(NULL,IDC_ARROW); //windowClass.hbrBackground = (HBRUSH)COLOR_WINDOW; windowClass.lpszClassName = "WindowClass1"; RegisterClassEx(&windowClass); RECT desiredSize = {0,0,500,400}; AdjustWindowRect(&desiredSize,WS_OVERLAPPEDWINDOW, FALSE); windowHandle = CreateWindowEx(NULL,"WindowClass1","TK Program", WS_OVERLAPPEDWINDOW,0,0,ScreenWidth,ScreenHeight,NULL, NULL, hInstance, NULL); ShowWindow(windowHandle, nCmdShow); Init3D(windowHandle); MSG msg = {0}; while(true) { if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); if(msg.message == WM_QUIT) { break; } //do some game related stuff } RenderFrame(); } Clean3D(); return msg.wParam; } LRESULT CALLBACK WindowProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_DESTROY: { PostQuitMessage(0); return 0; }break; } return DefWindowProc (hWnd, message,wParam,lParam); } void Init3D(HWND windowHandle) { DXGI_SWAP_CHAIN_DESC swapChainDescription; ZeroMemory(&swapChainDescription, sizeof(DXGI_SWAP_CHAIN_DESC)); swapChainDescription.BufferCount = 1; swapChainDescription.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; swapChainDescription.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChainDescription.BufferDesc.Width = ScreenWidth; swapChainDescription.BufferDesc.Height = ScreenHeight; swapChainDescription.OutputWindow = windowHandle; swapChainDescription.SampleDesc.Count = 4; swapChainDescription.Windowed = true; swapChainDescription.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; D3D11CreateDeviceAndSwapChain(NULL,D3D_DRIVER_TYPE_HARDWARE,NULL,NULL,NULL,NULL, D3D11_SDK_VERSION,&swapChainDescription, &swapChain,&device,NULL,&devcon); ID3D11Texture2D *pBackBuffer = NULL; swapChain->GetBuffer(0,__uuidof(ID3D11Texture2D),(LPVOID*)&pBackBuffer); device->CreateRenderTargetView(pBackBuffer, NULL, &backBuffer); pBackBuffer->Release(); devcon->OMSetRenderTargets(1, &backBuffer,NULL); D3D11_VIEWPORT viewport; ZeroMemory(&viewport, sizeof(D3D11_VIEWPORT)); viewport.TopLeftX = 0; viewport.TopLeftY = 0; viewport.Width = ScreenWidth; viewport.Height = ScreenHeight; devcon->RSSetViewports(1,&viewport); InitGraphics(); InitPipeline(); } void InitPipeline() { ID3D10Blob *vertexShader, *pixelShader; D3DX11CompileFromFile("Shaders.hlsl",0,0,"VShader","vs_5_0",0,0,0,&vertexShader,0,0); D3DX11CompileFromFile("Shaders.hlsl",0,0,"PShader","ps_5_0",0,0,0,&pixelShader,0,0); device->CreateVertexShader(vertexShader->GetBufferPointer(),vertexShader->GetBufferSize(),NULL,&mVertexShader); device->CreatePixelShader(pixelShader->GetBufferPointer(),pixelShader->GetBufferSize(),NULL,&mPixelShader); devcon->VSSetShader(mVertexShader,0,0); devcon->PSSetShader(mPixelShader,0,0); D3D11_INPUT_ELEMENT_DESC inputElementDesc[] = { {"POSITION",0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA,0}, {"COLOR",0,DXGI_FORMAT_R32G32B32_FLOAT, 0,12,D3D11_INPUT_PER_VERTEX_DATA,0}, }; device->CreateInputLayout(inputElementDesc,2,vertexShader->GetBufferPointer(),vertexShader->GetBufferSize(),&mInputLayout); devcon->IASetInputLayout(mInputLayout); } void InitGraphics() { Vertex OurVertices[] = {{0.0f, 0.5f, 0.0f, D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f)}, {0.45f, -0.5, 0.0f, D3DXCOLOR(0.0f, 1.0f, 0.0f, 1.0f)}, {-0.45f, -0.5f, 0.0f, D3DXCOLOR(0.0f, 0.0f, 1.0f, 1.0f)}, {0.7f,0.6f,0.3f,D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f)} }; D3D11_BUFFER_DESC bufferDescription; ZeroMemory(&bufferDescription,sizeof(D3D11_BUFFER_DESC)); bufferDescription.Usage = D3D11_USAGE_DYNAMIC; bufferDescription.ByteWidth = 3 * sizeof(Vertex); bufferDescription.BindFlags = D3D11_BIND_VERTEX_BUFFER; bufferDescription.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; device->CreateBuffer(&bufferDescription,NULL,&mVideoBuffer); D3D11_MAPPED_SUBRESOURCE mappedSubResource; devcon->Map(mVideoBuffer,NULL,D3D11_MAP_WRITE_DISCARD,NULL, &mappedSubResource); memcpy(mappedSubResource.pData,OurVertices,sizeof(OurVertices)); devcon->Unmap(mVideoBuffer,NULL); } void RenderFrame() { devcon->ClearRenderTargetView(backBuffer, D3DXCOLOR(0.0f,0.2f,0.4f,1.0f)); UINT stride = sizeof(Vertex); UINT offset = 0; devcon->IASetVertexBuffers(0,1,&mVideoBuffer,&stride,&offset); devcon->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST); devcon->Draw(3,0); swapChain->Present(0,0); } void Clean3D() { swapChain->SetFullscreenState(false,NULL); mPixelShader->Release(); mVertexShader->Release(); swapChain->Release(); backBuffer->Release(); device->Release(); devcon->Release(); }
  6. In the game I am working, on a movie clip is duplicated repeatedly to create new platforms for the player. When the platforms reach the bottom of the screen, they are removed. The game has two variables to point to the first platform on the screen (the one created earliest) and another to supply the name for the next number, one above the previous one just created. When the player resets the game I want to delete all of the MC's. However, when doing this, the last one does not disappear. I went stepped through the code using the debugger and it deletes the platforms one by one. If then gets to the final platform number and just does nothing. I have literally no idea why this can possibly be. I create the platforms like this: //at the start: var nextPlatform:Number = [1]; var oldestPlatform:Number = [1]; //At platform generation: plat_mc.duplicateMovieClip("platform"+nextPlatform,nextPlatform+[[1]]); nextPlatform++; (The oldestPlatform number is updated when the platforms pass of the edge of the screen) When I come to remove them all at the end I do this: for(var i:Number = oldestPlatform; i< nextPlatform; i++) { this["platform"+i].removeMovieClip(); } I have tried changing the less than sign to a less than or equal to sign although this was just clutching at straws as 'i' reaches the number for the last platform, it just doesn't remove it. I really am stuck here and any help would be much appreciated. [Edited by - thk123 on April 7, 2010 2:47:49 PM]
  7. Soluim Infernum, an indie turn based strategy game, used simultaneous turns as a key mechanic. The way it worked was each turn one person would be elected to be the Leader on a turn by turn basis (I think it just goes round each of the players one at a time). Anyway, so you would choose all your moves, specifying the order that you want them executed. All players send in their orders. Then, starting with the leader and working its way around it would choose each players first order on at a time then their second order and so on. You can check it out here
  8. thk123

    RTS - Two Resources or One Resource?

    As you pointed out, if all units require both resources and they are both collected in the same way, then I agree with you and the game would play just as well with one. However, one thing I am trying in an RTS I am making is by [trying] to make the resources meaningfully different. For example, all units require both Oil and People. Oil is collected much like a traditional resource, but people accumulate which you can only effect indirectly. Also, these people supply you with the third resource, money. So although you can use them to build troops, you reduce your income in the third resource (which effects things like research). So then you have units that are low population cost and high oil cost: the player must decided which units to build. If you go for high oil, you will have to battle for the oil and the opponent will be able to choke you, but you will be able to keep a high income by not using your population.
  9. thk123

    Fog of War?

    Obviously fog of war isn't required, the best strategy game ever, Chess, doesn't have it. However, it is a tool that opens up lots of strategic options such as the surprise attack and an intelligence war. Obviously, if you are not interested in these, then yeah, it is just a pain, but there are plenty of games that don't have it, like Dawn of War 2. But if you take something like Civilization, that would loose a lot with out the fog of war because defence would be come too easy.
  10. thk123

    Need advice on my new idea for a game

    My [very] limited experience tells me that if you don't plan to finish for 4 or 5 years, you will never finish. That is a really long time, do a project that will take, at most 6 months so you can actually get to the end. As for engines, you should try either Unity or Unreal as they give you a lot of power out of the box. Unreal is more top notch graphics, but I found Unity easier to get in to. They are both free.
  11. thk123

    Game Design Organization?

    Wave is interesting, but only useful if you are designing the game with other people. Word is fine, however, like you, I tend to ramble and then the document isn't very useful as it is too difficult to find out what I need to find out. Something I have found to be useful when planning is Freemind, a mind mapping piece of software. It fits really well in to my work flow. I would then use a document to put paragraphs when ideas need more explanation.
  12. As a word of encouragement, I wrote (gaming) blog for 2 years posting about once a week without getting a single hit or comment except from my friends. However, I now have an advert, I get sent games to review and I know there are some readers who actually read it. It isn't a big reader base, but it means the world to me that some people care enough to take the time to read what I have written. The fact that no one read my blog never bothered me, but if it matters to you, what I found increased my initial hits was reading and commenting on other well read blogs. Make your comments interesting and relevant, not just "great post, check out my blog". If people think you have an interesting opinion they will click on your name and read your blog. The second step therefore is to make sure there is an interesting post when they arrive there.
  13. Hello, if this should be in the .NET forum I apologise, I wasn't sure. I am using Silverlight with C# to create an application. One of the elements is an output window, TextBox sudoOutputWindow; . Throughout the running of the application, lines are added on to the text box: sudoOutputWindow.Text += "example line /n" Anyhow, what I want to be able to do is get the text box to scroll down once the lines reach the bottom of the box so the user can always see the latest line. I couldn't find any function in the TextBox class, so is there some other way?
  14. I think, as people have already said, you would need to focus on the strategic side of battle. Obviously you would have the small laser guns firing constantly, but if you have a massive turret that as 1min cool down, choosing when to fire and at what could be important. If you could come up with enough strategic decisions throughout a fight, then it could be just as interesting. Maybe having your shields up is a major drain on all your resources so you have to choose when to have it up. (Or even in the context of the larger game, do you focus on protecting key areas with it) I suppose the easy answer is you go in to a smaller fighter ship and control that as per normal except you occasionally have to make decisions for the bigger ship. However, this some what defeats the point...
  15. I really like your idea. For people who don't want the stress of permadeath, they can take the first option. However, the second option can provide an excellent challenge for those who want it. The danger I see comes at two times. Firstly, when you first become vulnerable you will be no (or not much) stronger than other players, but can die. I think for this period there needs to be some kind of defence. Maybe, when you join the ranks of the vulnerable, you get some special equipment for a limited period of time. However, the other problem I see is, as they reach the hero end of the spectrum are they going to become virtually invincible? I suppose what you could do, is have a bounty appear on their head for killing them, which increases as they become more powerful. However, this may be a little unfair...
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!