Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 19 Aug 2002
Offline Last Active Today, 02:30 PM

#5302978 Separate 32 Bit And 64 Bit Versions

Posted by on 28 July 2016 - 01:43 PM

I found this discussion on compiling for "Any CPU" vs. 64/32 bit:
It seems I can get away with offering 1 version. I just have to detect the system ingame so I can restrict the large maps to 64 bit systems and thereby prevent out of memory crashes.

As long as all of your DLLs are also 'Any CPU' it will work. If any of your DLLs are 32-bit, you'll crash if your EXE launches in 64-bit mode (and vice versa). You'll get a BadImageFormatException when the process discovers that it can't load the DLL.

There might be a way to provide alternate DLLs per architecture using the manifest, but I haven't tried that.

#5302954 Separate 32 Bit And 64 Bit Versions

Posted by on 28 July 2016 - 11:01 AM

I've seen some programs install both: program.exe and program_64.exe. Program.exe is 32-bit, does a quick start-up check to detect if the OS is 64-bit, and then launches the 64-bit EXE if it is. If it's not, program.exe continues with the normal program startup.

#5302237 Help Deciding On New Language

Posted by on 23 July 2016 - 04:50 PM

You might like C#, DarkBASIC, or maybe GameMaker.

Anyway, your best bet is to try each language-of-interest out for a while (a couple weeks or less). Create simple programs to test out each one of your requirements that you listed, and if the language doesn't fit, try the next one. After you've tried them all you'll be able to choose which one you think fits your style the best.

#5301866 Ndk-Build Stops All Next Commands In Batch File

Posted by on 21 July 2016 - 09:17 PM

Try prefixing the line where it stops (i.e. the last one which actually executes) with "call" and see if that helps.

#5301588 Do My Swordsmen Look Like Cyborgs?

Posted by on 20 July 2016 - 10:50 AM

They look like football players that have snapped and are going on a stabbing spree.

#5300933 Parsing Xml Data

Posted by on 15 July 2016 - 05:51 PM

ReadToDescendant: You could use the return value to stop when no more descendants with that name are found.

GetAttribute: Make sure the return value isn't null.

int.TryParse: Use the return value to find out if the parse succeeded.

Alternatively you could use reflection-based serialization, which I personally like better:


#5300319 Should I leave Unity?

Posted by on 12 July 2016 - 01:30 AM

In your case the GC is likely triggering due to small, accumulated allocations pushing the heap to its capacity. You won't have performance problems if you allocate a bajillion things first, but then keep reusing them instead of allocating anything new. You will have performance problems if:

- Your heap is almost always full.
- You have lots of allocations occurring all the time.
- You have an immense number of reachable objects (slows down mark phase) with lots of cross-references between them (slows down compaction phase).

Here's what I suggest:

Watch the allocations across several frames. Most games do the same things over and over every frame. The ones that constantly allocate add up and are what trigger the GC.

Turn on deep profiling. Use the CPU Usage section of the profiler. Sort using the GC Alloc column, largest allocations first. Look at several frames to see if there are any common patterns in what's being allocated. Once you find something interesting, click on the Overview column again to get an approximate callstack for the allocation. See if there's an obvious allocation problem, or if there's something you could optimize.

As far as minimizing allocations go:

Keep collections around and Clear them instead of recreating them from scratch. Initialize them with their expected capacity (you are doing this already in the code you posted). If a collection already has the capacity, adding another element will not reallocate the internal array(s).

C#'s structs can be your friend, if you use them properly. structs which are local variables or parameters to functions live on the stack, and don't contribute to GC issues. If you have any cases where you allocate a temporary object which is only used as a parameter to a function or a return value, any immediately discarded after that, you might think about using a struct instead. The GC does not need to traverse anything which is not a reference, so if used carefully, structs can speed up the GC's mark phase.

Structs which are members of a class are allocated as part of that class's objects, instead of as a second object on the heap. This also simplifies the GC's mark phase. If you have cases where a member variable doesn't need to be passed by reference separately from its owning object, you may want to think about whether a struct makes sense for that member.

If you extensively use delegates, you should know that conversion from a lambda expression or a method group to a delegate will allocate a small object+method pair. If you reuse the same delegate construction pattern over and over, and it is not a variable-capturing delegate that needs to capture something different every time, you can construct the delegate once and store it for all your other cases to avoid that allocation.

If you extensively use the EventArgs pattern, consider making a delegate which takes a struct instead, and pass the struct by ref. In almost all cases, the EventArgs object will be discarded immediately after the handlers finish, which makes it a perfect candidate for struct stack allocation.

#5299663 What Language Is Best For Game Programming?

Posted by on 07 July 2016 - 01:16 PM

I am looking for a programming language(s) that:

  • Easily have a GUI ( pop-out window ) with code, not anything external
  • Can be executed by being clicked on ( Feel stupid for asking this, but I think I need to for some reason )

I have no idea what you're actually talking about here.

A pop-out window with code? What does it pop out from? Not external to what?

Programming languages are an abstract concept; you can't click on abstract concepts.

Step 1: You need to get better at clearly describing what you want. Because that's the very first skill you must have as a programmer.

#5299632 Interpolating a direction that reverses.

Posted by on 07 July 2016 - 11:00 AM

Is it correct to say that it's about having the physics-update generate a list of positions and times during specific events, such as collision?  Then having the interpolation traverse through it based on alpha.  After finding a position between two points that the alpha falls between in measure of time, interpolate between these points using a recalculated alpha.

Yeah, that's the idea. Maintaining such a list will add some overhead to your physics and rendering code, so you'll have to see whether it works for you and whether it's worth the cost or not.

#5299413 Interpolating a direction that reverses.

Posted by on 06 July 2016 - 06:22 PM

At time 0, the ball is headed towards the wall.
At time 0.5 it hits it.
At time 1, it's moved a bit away from the wall.

You calculate physics positions for time 0 and 1, and tell the renderer to interpolate all positions between time 0 and 1.

If you reset your interpolation start/end like suggested above, you will be unable to properly represent times before 0.5.

If you want an interpolation function that works for pre and post collision times, it would have to look something like:
if (t < 0.5)
    interpolatedPosition = initialPosition + initialVelocity * t;
else // t >= 0.5
    interpolatedPosition = impactPosition + postImpactVelocity * (t - 0.5);
But then... what if there is more than one impact per physics frame? (Ex: it hits both walls at the very corner of a room)

Generalized, your information would look be an array of "rays" that indicate the movement change at a specific time:
float time;
Vector origin;
Vector velocity;
With a function that works something like this:
entry = binary search to find the last entry with entry.time < interpolationTime
position = entry.origin + entry.velocity * (interpolationTime - entry.time);
Your physics code would update the entries each time a collision or some other velocity-altering event occurs. You could also add acceleration to the entries if you have a constant acceleration to take into account.

#5298911 Making an object move back and forth.

Posted by on 03 July 2016 - 12:30 PM

Your syntax looks like Unity C#, so I'm going to respond using that.

It seems the simplest approach would be to have a list of waypoints and use the game's time to determine which two waypoints you need to be moving between. Then use https://en.wikipedia.org/wiki/Linear_interpolation to blend between them.

List<Vector3> waypoints; // initialize these somewhere

void Update()
    // Determine where you are in the sequence based on time. floor the value to the nearest index by casting to int.
    const float kSecondsBetweenWaypoints = 5.0f;
    int sequence = (int)(Time.deltaTime / kSecondsBetweenWaypoints);
    float remainder = Time.deltaTime % kSecondsBetweenWaypoints;

    int next = sequence+1;
    // make sure the indices always lie between 0 and waypoints.Count-1
    sequence %= waypoints.Count;
    next %= waypoints.Count;

    Vector3 a = waypoints[sequence];
    Vector3 b = waypoints[next];

    // Linear interpolation
    float blend = remainder / kSecondsBetweenWaypoints;

    transform.position = Vector3.Lerp(a, b, blend); // same as: a * (1.0f - blend) + b * blend;

#5298546 What are the basic types of code used in video game programming (not languages)

Posted by on 29 June 2016 - 12:22 PM

Game programming uses everything that all programming uses, so the rest of my response is about all programming.

In most programming languages, there are:

Variables which hold values.

Expressions that combine variables, values, and operators to calculate new values.

Assignment statements (=, ++, --) that assign values to variables.

Control flow statements (if, else, do, while, for, switch, etc) that let you control what happens like a flowchart.

Functions which let you group multiple statements that you want to use from many other places in your program.

Types (things like ints, floats, Booleans, arrays, pointers, references, classes, structs, unions) which define how data is stored in values/variables of that type, and a set of operations that apply to that type. For example an int can be added, multiplied, divided, etc. A bool can be &&'d, ||'d, etc. Strings can be concatenated, uppercased, lowercased, etc.

Some languages have lots of more complicated features, but they usually work by combining the concepts listed above.

Programming is a multi-step translation process:

1. The game ideas in your head.
2. The concepts of the actions that need to be performed and what information you need to store.
3. The generic programming concepts (the ones listed above) that you can use to achieve that.
4. The language-specific code that represents those concepts.

Only step 4 is language specific. Steps 1-3 are the same when you're using Java, Javascript, C#, or any other programming language. Most of the hard stuff you need to learn are the process of getting through steps 1-3. Step 4 is a matter of memorizing what different languages and libraries use to represent each type of programming concept.

#5298471 Dear people who actually work at videogame industry:

Posted by on 28 June 2016 - 05:34 PM

I started teaching myself game programming (and programming in general) from grade school (age 6) through high school (age 18). Then I went to college for a 4-year Software Engineering degree. After graduating I worked at a couple of non-game programming jobs as well as a couple of non-programming-at-all jobs. After a couple years of looking, I finally got a game development job. I've been working for my current employer for a bit over a decade.

I've helped interview a few potential employees as well. Degree and Experience are both good, but we'll try to determine your skill and team fit regardless. Resumes are used as early filters to decide who to actually interview.

You get bonus points if:

- On resume or during an interview, you're already familiar with some of the technology (engines, languages, etc) that we use.
- During an interview, you're friendly and seem like you can get along with other people on a team.
- During an interview, you can discuss problems "gracefully": considerations you made, why you prefer a particular solution, what possible pros/cons there are to alternatives, etc.
- On resume or during and interview, you demonstrate your dedication; your motivation to work on tasks, even if they are boring.

Dropping out of high school would be a warning sign to me that you don't have the motivation to work on things that don't interest you. Programming professionally is pretty boring for most of the time. When other people are paying you, it's almost always because you're doing things THEY want, instead of things YOU want.

#5298314 Is using one the switch statement better then using multiple if statements?

Posted by on 27 June 2016 - 06:38 PM

First, you misslead the readers on what switch is. Since switch is named so improper, switch is not a switch, unless there is break keyword instruction in every sub-block of condition .
What switch does is that it evaluates all conditions in their order and executes their subblock if they are true. Logicily switch is equal to this

Switch works differently in some languages (what you said is true of ActionScript), but we're talking about C++ here.

In C and C++, and probably a bunch of other languages, a switch statement that uses constant integer cases (or integer-like at the assembly level) which are fairly close together (i.e. case 1, case 2, case 3, etc...) are converted into something like this (MSVC, x86):
cmp (int case), (constant N)  // where N is the size of the lookup table
jae breakLabel // if case >= N, skip the switch statement
jmp [lookupTable + 4*case] // single x86 instruction which jumps directly to the case block's code.
// code for each case of the switch statement goes here.
// breakLabel - represents where all of the cases go when they break.
// code for the rest of the function
// end of the function's code, start of the function's jump tables
// 0-3 byte padding to optionally align the lookupTable
// lookupTable of N * 4 bytes representing a pointer array, with each element pointing to the address of each case's code to execute.
// (more jump tables, if the function has multiple switch statements)
// optional padding to 16 byte align the next function
// start of the next function
When two cases have the same code:
case 1:
case 2:
   // some code
The compiler puts the same pointer in the table for cases 1 and 2.

When the range of integers is not near zero, the compiler will add/subtract a suitable offset when creating its table. It does the optional 'add/sub' instruction before the out-of-range 'cmp'.

When there's a gap in cases, say you have "case 1, case 2, case 4", the compiler puts a 'break' address in the lookup table for every gap.

If the cases are too far apart (case 1, case 900, case 1570, case 1571, case 1572 etc), the compiler doesn't waste space making a lookup table that large. Instead it can split the switch up into a combination of a binary if/else tree and switch statements, depending on the distribution of your cases.

I have also encountered one additional helper array for switch statements - it's a byte array which maps case numbers (0-255) to jump table indices. It's used in cases where there are a lot of case values but only a small handful of shared code. The byte array is used to reduce the overall size of the jump table. There might be a short variant of this, but I haven't seen a case statement with more than 256 separate blocks of code yet.

#5297767 Is there any reason to prefer procedural programming over OOP

Posted by on 23 June 2016 - 07:23 PM

You cannot do procedural programming in Java

You can't do it in C# either yet you use it as an example.

As far as I was aware, the only requirement to be 'procedural' were procedures (functions, methods, etc). I'm not sure what kind of silly semantic games you guys are playing here...

Are you saying that because you have to define functions inside organizational units called classes, it's no longer a procedure?

To me, procedural/object oriented is a *mentality*:
// procedural mentality
foreach (thing in collection)
    DoOperation(thing, additionalParameters);
// object oriented mentality
var visitor = new DoOperationVisitor(additionalParameters);
// functional mentality
collection.ForEach(x => DoOperation(x, additionalParameters)); // But seriously, don't use ForEach
I don't see much dogma in .Net. Dogma in programming means "lack of flexibility". .Net is anything but inflexible...
File.WriteAllBytes, File.WriteAllText // Procedural convenience functions

Stream, FileStream, StreamWriters, BinaryWriters // Object oriented composition

collection.Select(x => x.Name).OrderBy(x => x).ToList(); // Functional pipelining

UIElement // Type hierarchies in WPF with decent polymorphism and data binding; Object oriented and declarative

IAsyncResult // Capable of being used via polling, callbacks, WaitHandles, mixed with async/await, etc.
C# doesn't force you to solve your problem in one way. I think that's what Ravyne meant.