## Game Math: More on Numeric Springing

This post is part of my Game Math Series.

Source files are on GitHub

Previously, I talked about numeric springing and provided some examples.

I have been saving up miscellaneous topics I would like to discuss about numeric springing, and now I have enough to write another post. Here are the topics:

• Using The Semi-Implicit Euler Method
• Numeric Springing vs. Tweening
• Half-Life Parameterization

## Apparently, Game Devs Are Considered Non-Threatening to US National Security at All

I would like to share an interesting story about my past two visits to American Institute in Taiwan (AIT).

For people in Taiwan to study or work in the US, they need a student visa or a work visa. Visas are acquired by interviewing with an official at one of the two AIT offices. Luckily, one of them is very close to where I lived in Taipei.

I went to AIT to get my student visa for DigiPen in 2011, as well as my work visa stamp for Naughty Dog in 2015. My experience with both visits told me that, apparently, game devs are considered non-threatening to US national security at all.

## Subway’s Free Cookie Code Pattern

As a result of going to Subway too many times and taking lots of online feedback surveys in a short burst, I accidentally noticed the pattern of Subway’s validation code you put down on a receipt after taking an online survey, which allows you to redeem a free cookie the next time you visit Subway.

The pattern is actually quite simple:

(Average Survey Score)-(Store Number)-(Date)-(Time)

For example, given the following information on the receipt:

The store number is 38023-0.
The date is 04/17.
The time is 12:47.

If I choose 10 for all items on the survey form, the average score will be 10.
Then, the corresponding validation code would be 10-38023-0-0417-1247.

## Game Math: Numeric Springing Examples

This post is part of my Game Math Series.

Source files are on GitHub

So, you have seen how to precisely control numeric springing in my previous post.

I showed this animation as an example.

Manually fine-tuning the animation with animation curves can possibly give better results, if it’s a fixed animation, that is.

One big advantage of numeric springing over animation curves is that it can be dynamic and interactive. For instance, when the springing simulation has not completely come to a stop, and you poke the system (modify the target value or velocity) based on user input, the system can handle it gracefully with numeric springing and everything looks natural. On the other hand, it’s usually hard to interrupt an animation using animation curves and have it animate to a new target value without making it look visually jarring.

I will show you several examples of numeric springing in this post.

Before that, let’s quickly review the spring function presented in my previous post.

```/*
x     - value             (input/output)
v     - velocity          (input/output)
xt    - target value      (input)
zeta  - damping ratio     (input)
omega - angular frequency (input)
h     - time step         (input)
*/
void Spring
(
float &x, float &v, float xt,
float zeta, float omega, float h
)
{
const float f = 1.0f + 2.0f * h * zeta * omega;
const float oo = omega * omega;
const float hoo = h * oo;
const float hhoo = h * hoo;
const float detInv = 1.0f / (f + hhoo);
const float detX = f * x + h * v + hhoo * xt;
const float detV = v + hoo * (xt - x);
x = detX * detInv;
v = detV * detInv;
}
```
Posted in Gamedev, Math, Physics | 7 Comments

## Game Math: Precise Control over Numeric Springing

This post is part of my Game Math Series.

Source files are on GitHub

Check out this post if you want to see more visual examples of numeric springing.

Numeric springing is a very powerful tool for procedural animation. You specify the initial value, initial velocity, target value, and some spring-related parameters; the result is a smooth springing effect. You can apply this technique to all sorts of numeric properties, some common ones being position, rotation, and scale of an object.

Posted in C/C++, Gamedev, Math | 9 Comments

## GDC Social Tips

This post is part of My Career Series.

I wrote some tips on meeting people at GDC a while ago. It was the GDC that lead me to my current job at Naughty Dog (more on this here). Recently, I got some friends asking me for advice on breaking into the game industry, how to present yourself, and how to meet people at GDC. So I decided to write another post about it. This will be a collection of what I learned from the Career Service Center and the career workshops at DigiPen, plus my own experience.

These tips worked for me, but they might not suit everyone. Feel free to disregard any of them at your discretion.

Before doing anything else, you should have a professional-looking email address. Don’t use random internet names like AwesomeDude7345; that makes your address look unprofessional. Make sure the only thing present in the name part of the address is your name. The email address I share with people is MingLun.Chou[at]gmail.com.

Applying the same rule to your Twitter handle and domain name can help them appear more professional as well. My Twitter handle is TheAllenChou, and my domain name is AllenChou.net. Of course, you can always throw in some variation if that helps express more about yourself, such as JasonGameDev.net or AmysArt.net.

Get a LinkedIn account, period. LinkedIn is a professional social network where you can build online professional connections. You can join groups and follow companies on LinkedIn. Your profile page is the place to show people your professional side; maintain it well. Many recruiters actively look for potential hires on LinkedIn by going through his/her 1st, 2st, and 3rd degree connections. It is important that you build connections with people in the industry on LinkedIn. I constantly receive messages on LinkedIn from recruiters in the game industry and software engineering industry.

Posted in Gamedev | 2 Comments

## Safe Scope-Based Instrumented Profiler

Let’s say we have an interface for an instrumented profiling library that looks like this:

```namespace Profiler
{
void BeginBlock(const char *name);
void EndBlock(void);
};
```

The argument you pass to `BeginBlock` is a custom block name for you to identify the block in the profiler output.

You call `BeginBlock` at the beginning of a block of code and call `EndBlock` when the program exits the block.

```void GameLoop(void)
{
Profile::BeginBlock("GameLoop");
UpdateInput();
UpdatePhysics();
UpdateLogic();
Render();
Profile::EndBlock();
}
```

Let’s say you also inserted the proper calls to the profiling functions inside the functions you wish to profile, then the profiler might give you an output like this:

```GameLoop - 16.0ms // 60fps, woo~
|--UpdateInput - 1.0ms
|--UpdatePhysics - 10.0ms
|    |--InitRigidBodies - 0.1ms
|    |--SolveConstraints - 0.6ms
|    |--IntegrateRigidBodies - 0.3ms
|--UpdateLogic - 5.0ms
```

This all depends on the fact that you properly call the `EndBlock` function before the program exits a block of code. What if, say, someone decides to throw in an early-out inside one of your functions and forgets to call `EndBlock`?

Posted in C/C++, Gamedev | 2 Comments

## My Life at Naughty Dog So Far

This post is part of My Career Series.

Here is the Chinese translation of this post.

Disclaimer: Opinions expressed in this post are my own and does not represent Naughty Dog in any way.

Edit: Thank you for all your concern. I already ran this post through the PR people at Naughty Dog before posting. Rest assured. My NDA is not violated.

I started working at Naughty Dog a few months ago, and I decided to share about my life so far at Naughty Dog and some interesting tidbits about the company. It is a brain dump, so I will just present it as a list, in no particular order of importance:

### Scooters

People at Naughty Dog use scooters a lot as a means of travel within the office. From my standpoint, designers and animators visit the programmer section on scooters to communicate with us quite frequently.

When you see a scooter parked outside the restroom, you know someone is in there.

### The Signing Counter

The kitchen counter at the office is used as a signing counter. People put things on the counter to be signed, such as game cases, posters, art books, etc. Usually, these things are products of Naughty Dog, which makes sense. However, people sometimes put things on the counter to give them away, usually followed by a company-wide email informing everyone.

If a giveaway stays on the counter for too long, someone eventually will mistakenly sign on it, and more people will follow. There was an old DVD player left on the counter for a week, and people just started signing on it until it was covered by signatures. Then one day it just disappeared. Perhaps someone took it home because of the signatures, not because he or she needed a DVD player.

Basically, if you leave stuff on the kitchen counter for too long, no matter what it is, people will start signing on it.

Posted in Gamedev | 1 Comment

## Scope-Based Resource Management (RAII)

This post is part of my Game Programming Series.

It has been 4 months since I graduated from DigiPen and started working at Naughty Dog as a Game Programmer. Since then, I have been too lazy to write anything big and technical on my blog, mostly because I just want to relax and play games after work. From now on, instead of dealing with topics that are wide and deep like game physics and game math, I’ll probably just write about quick and tiny tips, most likely related to game development.

I’m going to begin with the programming idiom RAII (Resource Acquisition Is Initilization). I like how some people on StackExchange refer to RAII as a more friendly name, Scope-Based Resource Management, so I will stick with this name.

Scope-Based Resource Management is a very common and important resource management technique where the resource is tied to an object’s lifetime. This is done by allocating the resource in a helper object’s constructor and releasing the resource in the helper object’s destructor.

The usefulness and importance of this technique can be best illustrated by an example.