Namek Dev
a developer's log
NamekDev

Practical knowledge of git

March 15, 2015

Some time ago, for about a year I’ve been teaching myself and newcomer company programmers about proper and efficient usage of git. Since git is a distribued VCS, which is well done for time pressure work, the “distributed” part isn’t really the easiest one in such heavy context. Inbetween those teaching times I have noticed that there is much more to teach rather than only how to use some new source code management tool.

I’m not gonna explain the tool itself and tricks around it. I’d like to focus on problems around it. The following may be your checklist for practical knowledge of git. Ready for exam? Then read on.

→ Continue reading git, self-development

Common code for Singletons using PHP's traits

February 22, 2015

I hate singletons. Some say that singletons are not bad, instead “singletonism” is the evil. I would argue. Anyway, I’ve been working on some common Singleton pattern code in PHP for a particular reason - I had to create common code for two basecodes:

  1. Laravel app using Facades
  2. some other custom API

Usage

class DataUtilsInst {
    use Singleton;

    public static function getClassName() {
        return '\NS\common\utils\DataUtils';
    }
}
→ Continue reading php

gulp.js is my build system

October 31, 2014

When I’ve seen Grunt (a build system) I have imagined that it would be awesome to have such setup making my code easy to maintain and optimized production version at the same time. When I tried to create my n-th Gruntfile.js, after some more play with Grunt, I realized that this system didn’t work as well as supposed to. That was the moment I gave a chance to gulp - “the streaming build system”. I’m gonna talk about why and why so much “yes”!

→ Continue reading web, javascript

C++ inline Assembler hack back in 2008

October 17, 2014

Digging deep in my work from past years I stumbled upon interesting Assembler workaround I made then for C++. I was looking for a solution that could make possible to wrap a class method into Function class object. These days with C++11 it’s just a matter of using std::bind and std::function but I think it’s pretty interesting to see what Assembler could be behind such “simple” task as encapsulating pointer to method.

→ Continue reading c++

Working on workflow for Unity and git

August 2, 2014

Unity3D seems to be a great software for rapid prototype development. It certainly is but when properly used. You’re alone with your prototype? It’s OK but I was the other case. When it comes to collaborate there’s a belief that nothing will change during the process of development. Well, the reality is that the teamwork does change a lot. If you dare to work with team using Unity, then you may find my experience useful to you.

→ Continue reading csharp, gamedev, git

Iterative version of Ramer-Douglas-Peucker line-simplification algorithm

June 28, 2014

In one of our games we needed to beautify user mouse or touch input. Actually it isn’t simple task since there can be found many criteria due to point reduce. I have tried several solutions like discovering big angle change between segments (built of last given input points), big distance discovering, Catmul-Rom curve approximation and even joining all of those methods.

Later on I have found Ramer-Douglas-Peucker algorithm which helped to reduce unneeded points in a more visually proper way. In the end I’ve been reducing points by small distance and little angle between segments to put less points into the algorithm. Since it had to be done in realtime that wasn’t enough of optimizations. Next optimization was to make the iterative version of Douglas-Peucker algorithm.

→ Continue reading csharp, gamedev, unity3d

Why I hate Unity3D popularity

June 17, 2014

Unity3D is an often recommended game making tool for beginners, the same way, how it was with Game Maker and a few others. I have been stumbling upon Unity3D for 3 months and I do have my strong opinions about that fact.

My thesis is that Unity3D may not be suited for beginners. Some people argue and say that it is a matter of taste. I disagree. In my opinion it’s the matter of skills and facts. I would like to share some of my observations about Unity3D or actually how it can be misused. The following will not be an advanced take on the topic but rather a cover for beginning game developers who want to start with Unity.

I can see three following areas of (lacking) skills which often kill projects in later development:

  1. writing production-ready code - maintainable for a longer time than a month
  2. knowledge of differences between programming paradigms like OOP, GOC or ECS
  3. performance problems awareness - due to target hardwarde, language and architecture

Let me explain.

→ Continue reading Entity Component Systems, gamedev, unity3d

Memory leaks in Adobe AIR Mobile / AS3 project

June 10, 2014

As many Adobe Flash / AIR / AS3 projects we have been using Event Dispatcher. This concept seemed to be too uncontrollable and lacking of many wanted information. Doubts about garbage collector made us to recreate the idea to take more of control and information about event listeners.

Keywords: Garbage Collector Which Sucks, Event Dispatcher, Event Bus, Event Listener, Object Pool, Disposable Objects

→ Continue reading actionscript3, gamedev

"Just" implement tutorial into the game

June 1, 2014

Today many games need tutorial. Tutorial is a hot topic for discussion in indie games community. Anyhow, for programmer-non-designer tutorial implementation is just a job which comes with unwanted problems. Most of them appear because it tends to be made in the end of project. And worst situation is when tutorial is being done incrementally.

I will not discuss topic of tutorial design. Instead I’d like to present some notes about coding a tutorial in online game which are derived from my experience and observations. In the end I’ll give my advices for coding tutorials.

→ Continue reading gamedev

Why should you document your design?

May 18, 2014

Documenting a project vision is justified in probably all of development methods and methodologies, like Agile/SCRUM, Waterfall, PRINCE2 or even Kanban. The idea of documenting is simple - we need to know what to develop. When vision of a new concept becomes to be a project, it’s always a good idea to document it. That’s what we are taught on universities, in companies or on trainings. But what are some objective reasons for doing that? Why not just start the project straight from a concept in the head?

→ Continue reading gamedev

Quick implementation of Network for existing Game

May 15, 2014

There are 2 common choices of architecture for game network implementation:

  1. client-server
  2. peer-to-peer

What I did was some kind of hybrid of those two. I used Remote Procedure Calls (RPCs). In this post I will describe this technique giving some basic examples showing the role of server and actually giving it some tools to do it’s role as a server.

→ Continue reading csharp, gamedev, unity3d

Time update issues with Keyframe-based animation

April 21, 2014

Some time ago I joined to some project developed since 3 months before by a 3-4 person team. After next 4 months I made a refactor request to modify whole engine and game to make game frame update based on the time, rather than device power. Yeah, there was a constant constraint set - maximum 30 Frames Per Second.

Many of world-existing mobile devices couldn’t achieve those constant 30 FPS-es. On the other side some devices could show 60 without a problem but couldn’t because of constraint.  It seemed crucial to me to change that. I have seen a game in previous company where 60 FPS were desired and some devices didn’t make 30-40. Those games felt totally too slow.

I was developing a whole animation system then but I’d like to describe one element of it all - keyframe-based animation which was a huge part, actually most crucial. I tried to look for solutions, even tried to look into Spine (which is a great software, I recommend it!) libgdx ”runtime” which is open-sourced. Unfortunately, our needs were too wide.

→ Continue reading actionscript3, gamedev

Unity - is this point within a box?

April 19, 2014
I am currently using Unity for two weeks and I have started to implement logic and graphical tweaks into mechanics. It happened that I needed a little math to correct some calculation failures based on user mouse or touch input. A simple check was needed - is a given 3D point contained within a box? I was pretty disappointed that Unity does not have such functions already made. And even more disappointed I couldn’t find ready solution for Unity-specific library code. → Continue reading csharp, gamedev, unity3d

Adobe AIR trick: Faster file loading on development machine

March 31, 2014

I had pretty weak company computer in my recent job and also pretty old rubbish Windows installation. Because of that, duration of loading our Adobe AIR game was about 14 seconds. Colleagues had better times, like 11 seconds. I was curious if I could make it faster.

Every change in code made whole application recompile, restart and load again. I disliked it more and more, then a simple idea came to my mind:

if you don’t want to waste time on loading every time, then load it once!

Actually, why not. Easier said than done, right? Load whole data into RAM in another application and then send it through sockets to the application.

So I wrote simple application in C# which reads all files (graphics, sounds, etc.). I have also added new option of loading data to the game - through sockets. Result - came down from 14 seconds to 7 seconds! I could have done it earlier.

actionscript3, gamedev

WPF/Silverlight Design Data without XAML

February 19, 2014

Here’s a class for our sample data. That’s where the data should go into.

public class MainViewModelDesignData : MainViewModel {
    public MainViewModelDesignData() {
        // TODO: instantiate your sample data
    }
}

In App.xml define your namespace:

xmlns:models="clr-namespace:YourApp.ViewModels"

and then:

<Application.Resources>
    <models:MainViewModel x:Key="DesignDataContext" />
</Application.Resources>

The last step - instantiate sample data as DesignContext. You can do it in your Window, Page or whatever. I did it in MainPage.xaml in my Windows Phone 7 application:

<phone:PhoneApplicationPage.DataContext>
    <models:MainViewModelDesignData />
</phone:PhoneApplicationPage.DataContext>

Our sample data is bound to whole page. Use it like every other binding.

csharp

CoffeeScript to JavaScript compilation in Sublime Text 2/3

May 19, 2013

Ever wanted to write code in CoffeeScript? It surely is great but you wonder why is this not automated or smaller. Actually there are two options:

  1. include CoffeeScript so it will compile to JavaScript when page is loaded
  2. include pure JavaScript - generated from CoffeScript code.

First option is very easy but may vary on performance. Second is better in performance bad worse in usage. I’ll teach you how to automate that process so it will be both fast on page load and easy too.

→ Continue reading