Jump to content

  • Log In with Google      Sign In   
  • Create Account

alnite

Member Since 07 Nov 2002
Offline Last Active Sep 24 2016 01:48 PM

#5244352 High Speed Collision Detection

Posted by on 03 August 2015 - 01:22 PM


During the collision detection phase I would do a line intersection test with the hitbox of my other collidable objects.

 

If other objects are also moving, you need to raycast all of them.




#5243470 C++ Loading config files, with extend/inheritance and full error handling

Posted by on 29 July 2015 - 07:37 PM

If I understand you correctly, you need a schema for your config file, another file that defines a list of all the expected fields and their types, and if necessary the structure.  XML has its official schema definition file, while for JSON you may need to create one your own.  Your config loader will read the schema first, and store the expected fields and types in a separate map.

 

When you load your config files, then comes the error handling.  I would recommend raising the errors as early as possible, rather than populating it with default values that may not even work.  Before it even reaches the `loadVehicleType`, KeyValues should only contain valid values, structures, and types.  If you want to enforce some min-max range, I would put that check in the object's constructor, as it pertains to application logic.

 

So your step looks like this:

1. Load schema

2. Load config files

3. Check config files against the schema (field's existence, type checking, and structure)

4. Pass values to object constructors

5. Object validates for acceptable values.

 

 

Alternatively, you can also put range validation in the schema (step 3), if the schema supports it.  Although, I wouldn't do that personally.  For example, if I have a field "gravity = -2.8" in my config file, I would just accept that as is.  Shit are going to be all over the place, but I am not going to dictate whether that is a good or bad thing.  The solution to that problem is simply "well, don't put -2.8 for gravity".




#5243230 What skills is more important for a Junior programmer to master

Posted by on 28 July 2015 - 12:50 PM


Should I learn Unity or Unreal to the point that I can create a Pong Game and a Retro Game and then learn one of them more in depth? Or, should I learn Unity to the point where I can create any type of game such as a Shooting Game, and a Multiplayer Game and after I have mastered these, then learn the Unreal engine?

 

Either one of these would work.  The employer will assume that you do everything wrong in your games.  The reason why is that the employer has its own development process and methodologies that there is no way a junior programmer would immediately fit in or understand their process.  Even if you have created a FPS, you won't create the same FPS in the company.

 

It's a good resume to show that you created multiple simple games.  If you create one complex game, it's also a good thing.  It shows that you have passion and that's a good thing to have.  Don't sweat over what games to show off.  Pong, pacman, tetris, failed attempts at MMORPG work just as effective.




#5242789 Who wants to see a C replacement?

Posted by on 26 July 2015 - 11:52 AM

The Golang is kind of like what you are asking for.

If you use it, it feels a lot like C. IMO, these are the improvements that Golang has over C:

  1. No header files, but you still need to include.  This is obvious for obvious reasons.
  2. Pointers are simplified, but they are still there.
  3. GC.
  4. Simplified threading, thanks to go routines and channels.
  5. Simplified distribution, since all your code is compiled into one big binary.  So you don't need lib this and that to run Go programs.

I'm sure there are a few more.

 

Some people are super ecstatic about it.  I think this is partly a fad.  It's still a good language.

If what you are making have anything related to multithreading, Golang should be one of your options.




#5242537 Finding a string in a file given x tags

Posted by on 24 July 2015 - 08:23 PM


The function GetWord() takes the tags as an argument and returns the word.

Shouldn't GetWord() return multiple words?  What if there are multiple words with the same tags?

 

Hello: Tags: Greeting, Polite

Hi: Tags: Greeting

GetWord("Greeting")

 

 

The 'best' way to implement this varies depending on the scope of this problem.  There's already several solutions out there that can perform a map/reduce query, and that is perfect for situations like this.  However, you do make this sound like a homework/exercise problem, in which using a 3rd party library/database probably wouldn't make sense, or beyond of what was being asked.




#5235979 Do you comment Above or Below your code?

Posted by on 21 June 2015 - 12:21 AM

Obviously above.

 

But, one can also perhaps write comments using the footnote system.  Using Hodgman's example:

// [1]
void FooBar()
{
  string fourtyTwo = "2A";// [2]
...


// [1] Beware: for legacy reasons, this function uses numbers that are encoded in strings as hexadecimal
// [2] 42 = 0x2a

biggrin.png




#5234402 4 unsigned chars to float?

Posted by on 12 June 2015 - 12:46 AM

I don't quite understand the original question, but if you just need the float in 4-unsigned-chars format, why not use union?

#include <stdio.h>

int main() {
  union {
    float v;
    unsigned char c[4];
  };

  v = -9000.50f;
  printf("Float value: %f\n", v);
  printf("Byte values: ");
  for (int i = 0; i < 4; ++i) {
    printf("%02x ", c[i]);
  }
  printf("\n");
}

Output:

Float value: -9000.500000
Byte values: 00 a2 0c c6 

Although, big/little endian will bite you hard in the ass. Make sure you know the endianess of your system, and anything else it sends this data to.




#5233215 What should I do now that I implemented a game mechanic that is not popular a...

Posted by on 06 June 2015 - 02:18 PM

Yeah the bottom line is are you making this for yourself or other people to play.

 

Adding too much realism in games aren't as fun as people think.  Video games are meant to be fun.  So anything that prevents people from having fun, e.g. seeing their own entities get destroyed by their own projectiles, should be taken into consideration.

 

You could just brush that off and say that this is how you want your game.  That's your choice, that's your game.




#5232101 Code design/architecture

Posted by on 31 May 2015 - 11:48 PM

My share; also review code of others, who didn't get that feedback.
Could be a win/ win: both better synchronized overall code and learn from the other code "ways"

 

+1 for code review.

 

Code design is a personal preference.  However, you are working on a team here.  You are not the only one working on that code base.  So, brainstorm the design/architectural choices.

 

Some guidelines:

  1. Consistency, even if it's bad.  It's easier to digest a consistently bad code, rather than reading a mix of good and bad practices thrown in together.  For example, it is more frustrating to see code that uses snake_case_for_its_method_names with other methods in camelCase and even lptrHungarianCase mixed in together.  If the code is already in Hungarian notation, even if you don't agree with it, keep it in Hungarian.
  2. Modularity.  Proper separation of controls between your classes and objects.  If you are following the MVC pattern, don't put controllers stuff into your views and models.  Views for rendering only, and models for that specific model-related logic only.  Even though this makes your code more verbose, it will be easier to maintain.

 

The team lead is also partly responsible here.  He or she should have established some common best practices when you start working there.  I would go through this for every new team member we hire.  The team lead needs to establish some process that works for the team.  For example, recently we hired an engineer who likes to commit to the master branch directly, even when his commits are partially working.  When you have automated build and testing going, this will flag a lot of errors for every commit.  The remedy to this is to NOT remain silent and unload your frustration on the yearly review.  The remedy is proper communication immediately.  Establish a code review process before every commit, and make sure team members are fluent on the git protocols (resolving conflicts, branching, merging, rebasing, etc), or whatever code versioning tools you use.

 

Failure to establish this communication is the fault of the team lead.




#5229883 Communication between objects and systems in Game engines.

Posted by on 19 May 2015 - 12:41 PM

If you haven't gotten too far in your engine development, you really should have a generic entity that respects the physics system.  This includes all movable and collidable objects in your game.  If your player can fall and stand on the ground, bump into other objects or walls, then I presume there are other objects too that share this same functionality.  These objects should inherit from a common parent.  This is where you put your collision code.




#5228798 (Best Practice) Multithreading instantiation

Posted by on 13 May 2015 - 09:44 AM

If you think about the sequence of steps, we can say that in order to fully instantiate this object, thread 1 needs to inform thread 2 that it has completed its part, and thread 2 needs to inform thread 3, and so on until thread N.  So the chain of process is sequential that the threads must wait until the previous thread completes its job.  To me, this sounds like something that you should do inside a single thread, rather than split the work into multiple threads and create unnecessary complexity.

 

So, I would go with the factory object idea.  If you are concerned with the performance, you actually want to initialize all objects at the loading screen.  Creating and destroying objects as your game/simulation is running and rendering is typically a bad idea, especially loading textures and accessing the hard drives.  If you have to remove objects from the scene, you want to have a flag in your object that you can toggle on and off, rather than invoking the constructor/destructor, and have an object pool to manage inactive objects.

 

This way, all your objects are already fully initialized and ready to use before you enter your multi-threaded environment.




#5225702 Why Does Everyone Tell Newbies To Make Games?

Posted by on 26 April 2015 - 02:31 PM

So what do you recommend to newbies then?  Not make games?




#5223256 Write ToLower As Efficient, Portable As Possible

Posted by on 14 April 2015 - 05:14 PM

"Portable" and "Efficient" is almost a polar opposite of each other.

 

Efficiency makes certain assumptions and/or optimizations based on current architecture/environment/encoding (e.g. ASCII only).

Portable means that it must be usable in as many architectures and environments as possible.




#5221739 are non sql databases better than sql databases?

Posted by on 06 April 2015 - 06:44 PM

A few corrections to your misunderstanding here:

 

The reason why Redis is fast is not because it's a NoSQL Database, it's because it's an in-memory database.  If someone implemented an in-memory, scalable SQL database, it will be fast too.

 

NoSQL does not have to be a KV-driven, or document-based database as people have started to commonly refer this as.  There's also a graph database (e.g Neo4j).  It's a bucket term for any kind of database that are not using relational tables to store its data.

 

 

What is the difference between redis and C# dictionary?  Redis is a cluster of computers all dedicated to store your data in-memory, while C# dictionary only persist your data locally in one node.  If you are running your code in multiple server nodes, you can start seeing a problem where some data might exist in one node, but a request tried to retrieve it from another node.  That's what Redis is solving that it makes sure your data is available across the network.

 

You can put XML on redis since it isn't trying to format your data in anyway.  Set the key to your document to any string, and the value to be your XML.




#5221718 Two Questions - Willing to Trade experience on Tools and Business Side, for M...

Posted by on 06 April 2015 - 04:57 PM

The best way to learn is just do it.  It seems you have done your own research in what language and platform you want to use.  Most beginners are still confused in that state.

 

People here can talk in length of best practices, for loops, OOP designs, etc, but without the context and experience, you won't understand why best practices are best practices.  So my advice is just get your feet wet and build something.






PARTNERS