Jump to content

  • Log In with Google      Sign In   
  • Create Account


simpler

Member Since 15 Jul 2010
Offline Last Active Jul 30 2014 03:06 PM

Topics I've Started

Online arena game, inspired by WC3 mod Warlock

27 March 2013 - 06:22 PM

Hey there! I recently finished my latest game project and I want to share it with you. It's an competitive online game where you face your friends or random people in an arena surrounded by lava. You buy different items and skills to survive and eliminate the others, the lava floods the arena as time passes and it gets harder and harder to survive. Those of you that have played the Warcraft3 mod called "Warlock" probably recognize the concept. It has support for both LAN and online play.

 

I made a video on youtube showing what it looks like and here's a screenshot:

 

MbCfwfD.jpg

 

It's written in C++, uses my graphics library based on DirectX 11 and has a client/server architecture. I have implemented the networking with RakNet. I have been working on it since November and I'm really glad to finally have a version I am happy enough with to call it finished. There were several times with lack of motivation and I was near quitting the project several times. I could continue develop this a lot more but I just want "be done with it" and start with something new, just fixing the most important bugs.

 

I've learnt a lot of things with this project and the most frustrating thing has probably been the long compilation times and it doesn't get better when you have both a client and server project. Before the the next game I will take a deeper look into Lua, I really see the need of it now.

 

The game can be downloaded from my homepage and the source code can be found on my github.

 

I think that was it, if you want to try the game and need an opponent let me know! smile.png


Network game design question

21 November 2012 - 10:09 AM

I just recently started working on my next project which will be multiplayer exclusively with support for up to 8 players. It's really important that the clients are synced since avoiding projectiles and having good micro will be a key part in the game.

I got some questions regarding the networking architecture on a game like this. I'm going to use RakNet and I'm pretty sure I will use a client-server approach. I got two different methods I'm considiring

Method 1
  • The only task the server has is to inform all clients when a client does something. The server don't have any World class, it just forwards the events to the client and let them update their own World.
  • A client right clicks on the map to add a target to move to. The client then sends a package to the server containing the event id, client id and the target position. The server then only sends the package to all connected clients and let them handle it.
The bandwidth usage will be very low since packages only gets sent on user input. I do however think that the clients very easily will get out of sync, and there's nothing that will make them synced again.

Method 2
  • The server contains a World class that gets updated when clients perform actions. This World then gets broadcasted to all clients frequently (how often?) and the clients then set the objects positions so they are the same as the servers.
  • A client right clicks on the map to add a target to move to. It sends the event to the server who then updates it's World. The server does nothing more in this stage, the changes will get broadcasted to all clients in X ms.
I'm not sure how often this broadcast will happen but it will definitly be more bandwidth heavy than method 1. This method does however make sure that the clients are synced.

This is just what I came up with after 1 day of researching and I would love if you could share things I should think about and general suggestion. How would you do something like this?

Graphics library demo

16 November 2012 - 03:38 AM

I just finished a demo for my graphics library that is under development. It lets you create objects, lights and play around with some terrain tools to show the current features. I plan to continue improving the library, adding more features and use it in my next game projects. Some of the current features:
  • Multiple lights
  • Hardware skinning
  • Model importer (Assimp)
  • Normal mapping
  • Shadow mapping
  • Heightmap terrain
  • Basic collision detection
It's written in C++ and uses DirectX 11 for rendering, Gwen for the UI and Assimp to import models. If you are interested in the source code then take a look at my github profile.
The demo application can be downloaded from my homepage.

I made a short video showing what it looks like:
http://www.youtube.com/watch?v=OtyiMWQpZtg&feature=plcp

And here's a screenshot:
Posted Image

Thanks for reading!

Mapping ID3D11Texture2D problem

29 October 2012 - 06:21 PM

I've managed to bump into another problem with using the ID3D11DeviceContext::Map() function, this time mapping an ID3D11Texture2D. I have an std::vector<XMFLOAT3> contating RGB colors that I want to use as a texture. When I attempt to map the ID3D11Texture2D of the shader resource view that the shader uses nothing changes in the texture, it's still black.

This is the code that is suppose to fill the texture with the content in the XMFLOAT3 vector:

[source lang="cpp"]void Terrain::BuildBlendMapSRV(ID3D11Device* device){ // Fill out the texture description. D3D11_TEXTURE2D_DESC texDesc; texDesc.Width = mInfo.HeightmapWidth; texDesc.Height = mInfo.HeightmapHeight; texDesc.MipLevels = 1; texDesc.ArraySize = 1; texDesc.Format = DXGI_FORMAT_R32G32B32_FLOAT; // == XMFLOAT3 right? texDesc.SampleDesc.Count = 1; texDesc.SampleDesc.Quality = 0; texDesc.Usage = D3D11_USAGE_DYNAMIC; texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; texDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; texDesc.MiscFlags = 0; // Create the texture. ID3D11Texture2D* bmapTex = 0; HR(device->CreateTexture2D(&texDesc, 0, &bmapTex)); // Create the SRV to the texture. D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; srvDesc.Format = texDesc.Format; srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; srvDesc.Texture2D.MostDetailedMip = 0; srvDesc.Texture2D.MipLevels = -1; HR(device->CreateShaderResourceView(bmapTex, &srvDesc, &mBlendMapSRV)); // Get the texture. ID3D11Resource* resource = nullptr; mBlendMapSRV->GetResource(&resource); ID3D11Texture2D* texture = nullptr; resource->QueryInterface(__uuidof(ID3D11Texture2D), (void**)&texture); // Map the texture. D3D11_MAPPED_SUBRESOURCE data; GetD3DContext()->Map(texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &data); data.pData = &mBlendMap[0]; // The std::vector<XMFLOAT3> GetD3DContext()->Unmap(texture, 0);}[/source]

The mapping doesn't affect the texture at all and I got no clue why it doesn't. I believe the format is correct, DXGI_FORMAT_R32G32B32_FLOAT corresponds to XMFLOAT3 right? Hopefully it's just a detail in my code, or maybe I'm doing it all wrong. I really appreciate any help, thanks.

Problem with ID3D11DeviceContext::Map()

24 October 2012 - 07:57 AM

I want to update the content in my vertex buffer, but the call to ID3D11DeviceContext::Map() fails and returns E_INVALIDARG. This is how I create the vertex buffer:

template <class VertexType>
void Primitive::SetVertices(ID3D11Device* device, vector<VertexType> vertices, int size)
{
// Fill out the D3D11_BUFFER_DESC struct.
D3D11_BUFFER_DESC vbd;
vbd.Usage = D3D11_USAGE_DYNAMIC;
vbd.ByteWidth = sizeof(VertexType) * size;
vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vbd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
vbd.MiscFlags = 0;
// Set the init data.
D3D11_SUBRESOURCE_DATA initData;
initData.pSysMem = &vertices[0];
// Create the vertex buffer.
HR(device->CreateBuffer(&vbd, &initData, &mVertexBuffer));
mNumVertices = size;
}


And this is the attempt to update the vertex buffer:

void Terrain::UpdateVertices()
{
ID3D11DeviceContext* context = GetD3DContext();
D3D11_MAPPED_SUBRESOURCE resource;
HRESULT hr = context->Map(mPrimitive->GetVertices(), 0, D3D11_MAP_WRITE, 0, &resource);

Vertex* vertices = (Vertex*)resource.pData;
for(int i = 0; i < mPrimitive->NumVertices(); i++)
{
vertices[i].Pos.y = GetHeight(vertices->Pos.x, vertices->Pos.z); // Change the vertex Y pos.
}
context->Unmap(mPrimitive->GetVertices(), 0);
}


I get no error if I use D3D11_MAP_WRITE_DISCARD instead. I'm not even sure if my approach to update the vertex buffer is correct in this situation. It's a terrain editor where the user will be able to use tools to change the terrain. It feels unneccessary to update every vertex in the terrain when the tools only will effect a certain radius. Is UpdateSubresource() better in this case?

Anyways, I want to get it working with Map() so I then can compare the performance. Thanks for helping Posted Image

EDIT: The code tags are messing with me...

PARTNERS