Posts

The Public Force and Private Army

 Ah, the everlasting war between public and private. Unlike in real life, where private army wouldn't really be beneficial to everyone involved, privates are very useful in the realm of coding.  Well actually, privates don't really exist in the realm of coding too. Yes, the complier won't allow it, but if you somehow force the computer to, say, call a private function(such as using reflection), it will happily do that because computer doesn't actually care about that. Objects are just sequence of bits that computer just cuts up to show you. Your Vector2 with x and y variable is just 8-byte(if you are using 4-byte floats) object that has some sequence of bits that could be cut in half and be interpreted as 2 4-byte floats. You could just cut it to 8 1-byte numbers but that would just be garbage data with no meaning so you just say "give me x" and the computer would carefully read the first 4 bytes and interprete it as a 4-byte float. Even if the x is private, y...

Escape Velocity

Image
 My first project is finished after 3 months. I've learned a lot from making it and I'll write about few of them. 1. De-spaghettifying(if this is even a word) is even harder than I thought.  EV has a lot(and I mean a lot) of spaghetti code in it even though it's relatively small game. It's partially because Unity refuses to let me have an UnityEvent with more than 1 argument but it's mostly because I didn't know better in the beginning. Util class had a lot of feature creep and most player classes in each game basically call other classes' methods. So many classes have AudioSource or AudioPool(my class that pools several persistent AudioSources so sounds can be played rapidly over each other) field and AudioClip field(s) just to make a sound. I realized that I should have made ScriptableObject singletons for audios so I don't have to search or drag in sound effects every time I need them. 2. Making music is easier than I thought.  EV has 10 OSTs. 2 are s...

Uncomfortable Truth about Coding Tutorial Videos

I use google a lot to find information about my problems. And google seems to pick up onthat and started recommending coding tutorial videos titled something like "Learn [popular language] in [number] hours complete course", with additional keywords like "for beginners". In this kind of videos, you will learn the most basic concepts about the language and that's about it. Great, you learned if statement and for statement. Now how do I actually use them in practice? Very few would be able to write something like this after watching that video if given the appropriate problem. (And this is not a good code either. You should use Linq if it's possible.) public class Main{     public void CheckAndPrintArray<T>(T[] array, Func<T, bool> checkError){         for(int i = 0; i < array.Length; i++){             if(checkError( array[i] )) Console.WriteLine($"Array element# {i} has error."); ...

Abstraction and Encapsulation

 There are 2 main paradigms for programming languages now: imperative and object oriented. While these are vastly different paradigms, they do the exact same thing: changing and moving around some numbers. Your "Player" object doesn't really exists. Its numeric representation is just somewhere in the RAM and you just can only access it if you have to reference(pointer) to that object. But humans don't think this way. Real world doesn't work this way. So we use abstraction to make somewhat believable object that represents real world things. And this is the core concept of object oriented languages(imperative languages also have abstraction, but it's not their core concept). Abstraction is reducing real things down to concepts. Real things are complex. They are made of atoms(and even more small particles if you go further) and even the small things you can see in daily life consist of billions and trillions of atoms. But computers can't represent that. They...

The Humble Beginning

 The project I've been waiting so long finally has begun. It's Escape Velocity, my first independant game. I've been doing a lot of coding stuff but they always fell short. Most of them didn't even make to the final version that I was satisfied of. My first coding experience was a Minecraft mod that I called Biotecraft. It involved using biotech in Minecraft that apparently nobody tried before. It's been a long time since so I don't have any piece of it left but I remember making semi-realistic selective breeding feature complete with gaussian distribution. I also made a energy system made of blood vessel and machines made from mob materials that uses sugar as energy source. There were a lot of complications about this one. The Minecraft Forge that I used to make the mod was moving from using interfaces to using dependency injection which is not very easy to understand for beginners. But I chugged along, frantically searching what does this even do. Eventually I...