Skip to main content

Posts

Showing posts from March, 2017

Optimization Pattern for Unity Game Programming

Design Patterns summarize the common solutions for particular problems. Book "Gang Of Four Design Pattern" is classic. Book "Game programming pattern" shows solutions to a variety of game related problems. Here, I will summarize the optimization patterns I used often,  mainly in the game of ArmaGallant and a recent mobile game. Both work is carried on in Unity C#. Optimize Pattern 1-----Cache the result, compute once, retrieve later string operation often generate gc, for example, int.tostring(). to avoid gc, can cache the result in a dictionary. Cache result for int.tostring Cache result for string.split(':') Double key-cache result of str1 + "." + str2 or str1+str2 Dictionary<string, Dictionary<string, string>> Notice, do not cache too many things to explode the memory. Optimization Pattern 2---Temporary parameter for an object 2.1 find common set of two sets. Given problem: when you have two sets of same type objects, ...

Brief on visual

My career is mainly visual related.  In the early stage, I have done some image processing related work and then switch to game. This article is an attempt to brief the visual related area in a simple way. 1. What is a pixel? 2. How to see? 3. How to draw? 4. How does the computer think? 5. How does the computer draw? 1. What is a pixel? There are a lot of answers depends on the context. We could general refer a pixel as the a. Picture element. The name pixel is short form of pix element. Pix is the short form of picture. So pixel means picture element. An image is divided into a rectangular grid of discrete dots known as pixels. One common interpretation could be a pixel is the minimal element square block in an image. For example, an image with resolution 200x100 means there are 20000 pixel with 200 horizontally and 100 vertically. b. A light blob. From hardware point of view, it is quite true. The traffic light for pedestrians normally consist of small light blobs. ...

Tech note: Java Virtual Machine(JVM) vs Erlang Runtime System(ERTS)

Java is my first language. From third year of undergraduate, I switched to C++ because of image processing/computer graphics related course work. After graduation, I never use Java as Java is not used frequently in the game industry. Elixir is my most recently language.  It is derived from Erlang. I know Elixir follow the path of Unity->Ulink->Riak(Ulink's default database option, which is written in Erlang)->Erlang->Elixir(derivation of Erlang). Follow this path comes with Phoenix(one of most recently web-framework). Now, I have many programming language friends, Java/C++/C#/Python/Elixir and some niche languages. To know a programming language, I only have to know the machine and how the machine speaks the language . Particularly for Java and Elixir, the core is how their underlying virtual machine works.  In Erlang/Erlang virtual machine case, I was forced to think the relationship among OS processes, OS threads and CPU cores.  To make it simple, 1. ...