Jump to content

  • Log In with Google      Sign In   
  • Create Account

Vincent_M

Member Since 16 Jan 2007
Offline Last Active Mar 03 2016 09:41 PM

Topics I've Started

Real-Time WebSockets and REST

03 October 2015 - 03:22 PM

I want to make a real-time light MMO-like Asteroids game using Unity and WebSockets for the client, and NodeJS, SocketIO and Box2D on the server side. I'll handle scaling by having each instance of my server be a separate "universe" the player can explore.

 

Players only have a single login for their account, and can jump between available servers, which are considered separate "galaxies". Since the player's account isn't directly tied to any specific server instance, the login mechanism needs to be separate from that, so I've thought about going the REST API route. Once successfully authenticated, my REST API would generate a authentication token to represent their login credentials for their session. Once the player is logged in, they can select a galaxy (server) to visit, provided it hasn't met its player capacity. When the player attempts to connect to that server, the client will pass the player's token, and the server will check if that token is a valid session with the database (this might breach RESTfulness).

 

If the server finds that the token is valid, a socket connect between the client and server is attempted. Upon success, a player object is created on the server, added to the list of current players. The server will use Box2D, or some type of physics engine to process movement, collision, etc, and report the observable portion of galaxy that the player can see as a message to the client ever few milliseconds (the goal is 30 frames per second). The Unity client will render the observable objects within view to the user. The client will periodically send input signals to the server (again, the goal is 30 fps). Those input signals are interpreted by the server to perform actions, such as steering the ship, shooting projectiles, interacting with the environment, etc. Whenever the client sends a message to the server, it also sends its token that the server uses to ensure that the client connection is coming from something that it originally considered legitimate.

 

WebSockets is primarily meant to send real-time data in the form of binary data instead of JSON to reduce overhead and serialization/deserialization between the client and server. Unity's .NET implementation appears to support binary serialization/deserialization that could be faster than JsonFX, but I have yet to benchmark it. Packing the database into binary datatypes will be a pain on the NodeJS side, but I plan on going back to a C server once I get things figured out. The server also has access to the database to submit queries such as kills, resources mined, health picked up, score, currency, in-game shop transactions, inventory pick-ups, etc.

 

The player can also update their player info in-game, send money to users, and other actions that the REST API would handle. As far as database queries go, I'd probably use AWS SQS for a larger-scale design, and have some sort of in-memory database to help with queries happening between what's actually in the database, and what's yet to be in it.

 

I'd use AWS, and have a server for the REST API, one for the database, and one for each galaxy configuration per instance required. How does this sound as far as architecture?


Career Advice

20 August 2015 - 12:28 PM

I've been programming as a hobby for well over a decade now, but I've only been programming professionally for 2 years. Due to this, I have access to mentors who know their stuff, but I also have access to some pretty gnarly code bases. I've only worked for small companies during this time. My only work-experience skills are in Unity/C# (some C# development outside of Unity), Python, ActionScript3, and a few libraries within all those.

 

I have a lot of personal experience in C++, but not in the workplace yet. I also have personal experience with PHP, SQL (I've only used MySQL for the implementation), Java, and Objective-C. I've also got experience with Qt, the Android and iOS SDKs, and a bunch of libraries. I have a degree in Management Information Systems, but I'm at most, junior-level in everything. I'm in my mid-20s, and ambitious like most people my age. Unfortunately, I lack the skills of a seasoned professional. I want to get those skills.

 

I really want to get a lead developer role in something involving backend or tools development. I really enjoy programming, and try to put in 20 hours into it a week after work and gym. I think I'm decent in C++ and C#, but far from mastery. I've been told I have potential by a potential employer, but results are what they want. I really want to have a sense of mastery when it comes to software design in general.

 

There are plenty of software development jobs in Las Vegas where I live, but I've become picky on what to apply for. Part of my pickiness comes from lack of experience. Most of my experience is in C++, but everyone wants juniors. Would it be wise to seek out a junior-level job in a field I'm not really comfortable in? I really want to run a small-time video game studio, and make fun games for mobile, and Steam. Again, who wouldn't want that here on these forums? haha


Matching Parameter Names to Class Fields

19 August 2015 - 12:33 PM

One issue I frequently run into is trying to come up with decent names for parameter names. This is especially a problem in constructors and setter methods. For example, take the following class:

class Car
{
private:
	unsigned int gas;
	unsigned int tankCapacity;
	float headlightRange;

public:
	Car(const int& gas, const int& tankCapacity, const float& headlightRange = 15.0f) :
		gas(gas), tankCapacity(tankCapacity), headlightRange(headlightRange) { }

	void SetGas(const unsigned int& amount)
	{
		gas = amount;
		if(gas > tankCapacity)
			gas = tankCapacity;
	}

	void SetCapacity(const unsigned int& amount)
	{
		tankCapacity = amount;
		if(gas > tankCapacity)
			gas = tankCapacity;
	}

	void SetHeadlightRange(const float& range)
	{
		if(range > 0.0f)
			headlightRange = 0.0f;
	}
};

Ok, so I couldn't come up with any setters where I could only think of a parameter name that matches the field that'd I'd be modifying right now, but it's been an issue for me from time to time. Still, the constructor's a concern.


Code Review

17 August 2015 - 01:19 PM

I recently interviewed with a CAD-based studio where I live for a C++/Renderer position. The role was to work on their internal 3D rendering code that's written in DX/OpenGL. They asked for a code sample of one of my personal projects. I sent them one of my projects. It's a basic, open source, texture packer application using Qt to provide the UI. It's not much, but at least it's pretty complete. The CEO got back to me about 10 days later, and said I was too junior for their company at this time. They're looking to fill a senior position first, then they'd consider bringing me on to get mentored.

 

I was only a little disappointed at first, but more curious than anything. I've been programming since middle school, but I'm only 2 years into programming professionally full-time. I've worked in 2 smaller/startup companies in this time. None of my work has been C++ or lower-level rendering-oriented, so it didn't surprise me when they turned me down. I know I'm not the best C++ programmer out there. I'd like to have some one with better knowledge of C++ to point me in the right directly as far as decent C++ practices go. I don't know if there are any good resources for this online, so I wanted to ask for one in this thread, if that's allowed. I'd really appreciate it if anyone could give me feedback. It can be downloaded here. If anything, you'd get a texture packer with source out of it.


New APIs and Beginning DirectX 12

10 August 2015 - 03:27 PM

I've done a lot of OpenGL development in the past few years, but with the release of DirectX 12 with Windows 10, I'd really like to start learning how the new APIs will work. I wanted to wait until Vulkan became available, but I'm not sure how long that'll take. From what I could find online regarding Metal, Vulkan and DX12, it sounds like these APIs are all very similar. Does this seem to be the case? For example: if I wanted to convert my game from DirectX 12 to Metal or Vulkan, the process would be "easier" than porting between OpenGL to any of the new APIs, correct?

 

If I wanted to start learning about DirectX 12, are there any decent learning resources out there to begin, or would I have to dive into MSDN docs to figure out what goes where. I did find this DirectX 12 Programming Guide on MSDN though. I read in this post that these newer APIs are more difficult to work with as they provide more explicit control over the GPU, and that game developers must now deal with the less pretty side of GPUs that older API drivers used to hide.


PARTNERS