Working on Doboomler…

Working on Doboomler…

Finally…

Something decent enough to publish on the market.

BAC Studios is working on a new game called Doboomler.

It falls under the endless runner game genre (Don’t worry! It’s not another clone of Temple Run). Instead of running, there will be falling. It will be a ball with a face (see that image above). Then, DOBOOM, DOBOOM AND DOBOOM. (Explosions are very common in the game)

I am currently developing it on Unity and using Inkscape to draw its assets. The journey is pretty much smooth. I am still struggling to fix so many bugs. I found drawing and redrawing assets quite tiring.

And still… it is just a small game.

But I ensure you that it will be addictive and fun to play.

I don’t wanna show much of the game until it is well polished and it has enough elements. Never mind that because I do have a deadline in my mind.

I hope that a lot of people will enjoy the game and all. I am very inexperienced in terms of marketing and advertising but I am trying my best to ensure that someone, somewhere would play my game. 🙂

 

Advertisements

My Vectors: Purpluria Range 2

My Vectors: Purpluria Range 2

Yet another Purpluria Range.

Somehow, it feels satisfying to me and looks pretty pleasant. I may try it again but this is it for now. The clouds could have been better.

This time I didn’t bothered with multiple versions.

To me, it is better than the previous version. Please, PLEASE DO COMMENT and tell me which one looks better to you. Is it good enough to be your wallpaper? Do the mountains seems flatter? Are there too less details? Do you want more of a realistic look? Should I go beyond just landscapes? Am I asking too many questions? -_-

Purpluria Range 2
Purpluria Range 2

 

My Pixels: Monochromatic – Red Dungeon

My Pixels: Monochromatic – Red Dungeon

Monochromatic… must be boring.

It is similar to the Four Shades category but… with more shades.

I hope that makes sense. This time it is a Red Dungeon… more like bloody dungeon. I started off by thinking of a horror/creepy scene and it ended up like that.

2 versions, one with more contrast. This time, I used Pyxel Edit free version which you can download here.

The only feature I used it for, is Tiling feature. It not only allow us to use a group of pixels in a repetitive tiling fashion but it does so in kinda, live mode. Other than that, you don’t get much from the free version.

Each tile is 32*32 pixels. Grid size of the whole image doesn’t matter when using tiling. So, I didn’t bothered with it.

redDungeon0Cropped
Red Dungeon
redDungeonContrast
Red Dungeon (Contrast)

 

My Vectors: Purpluria Range 1

My Vectors: Purpluria Range 1

A new series: My Vectors. Vector drawing is calculation based drawing where computer kinda do a lot of things behind the screen. I prefer vector editing over raster editing for someone who don’t own a graphic tablet like me.

My Pixels. These series seem to be pretty polar. One is pixellated and the other is smooth and curvy.

Anyhow, I did told you about Inkscape before. I used it and I liked it. It is an awesome vector editing software. And the best part is… its FREE.

I did some tries before so, I can’t call it my first. And I am not quite satisfied with the look so, I wanted to give it another try. (Note the ‘1’ in the end of the post title)

Below are the 3 versions of the same vector art. 🙂

C++ Programming Series: What’s next?

You wanted to get into game programming.

You found out that C++ is the real deal.

You came here and started reading the first post of the series.

You practiced and moved on till the end.

Now, you are confused what to do next?

(By the way, it applies to all the enthusiastic people who learned programming for the sake of making games.)

What you need to do now, is to google some simple C++ 2D Game Development Libraries.

Back in the days, SDL2 was my choice (I still use it a lot). SDL2 is pretty neat and it just clicked with me. But it does have drawbacks (for example, no easy-peasy shaders). If SDL2 is your choice, Lazy Foo’s SDL2 Tutorial Series is probably the best place for learning it. I also learned SDL2 from there.

People recommend SFML a lot. Even though I don’t use it, it won’t hurt you to try different libraries in the start and just go with what feels right.

Less features won’t hurt. But less personal compatibility will…

That is why I use SDL2. Even if there is not that something you need, you can craft your own hack to go through it.

Why not OpenGL library or just any library to make 3D games (like Call Of Duty and GTA)?

DON’T!

It’s impractical unless you got a thousand experienced people of all kinds working on it.

-_-

Why not a game engine like Unity for making 2D games?

Yeah, you can. In fact, it is awesome go and do it.

But you may consider this. They have a GUI, an editor and all fancy stuff that eases game development. And that makes your brain lazy and kinda limits your creativity.

I am not saying to built a game development career upon some C++ 2D Game Development Library (which honestly, won’t hurt). I am trying to imply the fact that doing code by hand and visualizing the game in the head will give you a much deeper understanding of what a video game is and how video game actually works.

And when you are satisfied with that experience, you can go with Unity like me.

How this deeper understanding thing works on a higher level?

It works. But you may not be able to see it working. Unconscious, maybe.

To see it in effect, just compare yourself with the one who went directly into Unity and you will realize yourself. You will be able to pick things faster than he would.

And please, take my words with a grain of salt.

So, that means I, as an individual, am stuck with 2D forever?

Hell no!

I recently started learning Blender (free, open-source 3D modelling and rigging software) and it seems like 3D is a viable option for any solo developer.

But yeah, as a solo game developer, no Call Of Duty or GTA forever. But awesome games like Gone Home and Inside are always a good option for any experienced artist and game developer.

In the end, I would like to say to make as many complete games as possible. With every completed game, your experience gets higher exponentially as compare to half-baked games.

Here is the summary:

Programming -> 2D in Game Library -> 2D in Game Engine -> 3D in Game Engine

What if I learned C++ for some other purpose?

Well, I don’t know the specifics but you can go for that purpose as hard as you can.

Sorry, I don’t have much advise on that, other than the fact that you shouldn’t go big on what ever the purpose is. Always try small and then, step towards bigger things.

Box Blur with SDL2

Box Blur with SDL2

Originally, this post is intended to be on cplusplus.com as an article of mine but they never accepted it. So, I thought why not just put it on my own website. If you know what the heck SDL2 and C++ is, you can understand the technique.


What is Box Blur?

Box Blur is a very easy technique of blurring an image. It is based on the fact that there is replacing of the color of a pixel with the average of all the colors of its adjacent pixels. With that said, the number of adjacent pixels can be increased or decreased, giving us the option to increase or decrease the extent of blurring effect as well.

The Implementation

First thing, you should know basics of C++ as well as a bit of SDL2. You should know bit shifting, some commonly used color formats and image formats.
We are going to use SDL2 along with SDL2_image. SDL2_image allows us to work with many image formats. We are only going to use PNG image format.

It is going to be a single file project and there will be no exception handling.

We are not going to make UI for managing things like input image name or blur extent. But we do have a settings file acting as input which will provide necessary data to work properly. Therefore, we will include fstream header.

We will also have some safety to know our errors and for this, we need to include iostream. All other headers are as expected.

#include <iostream>
#include <string>
#include <fstream>
#include <SDL.h>
#include <SDL_image.h>

Now that, we talked about input, there are variables to keep them too.

//Input data
int window_width = 800;
int window_height = 600;
std::string input_image_name = "inputImage.png";
std::string output_image_name = "NULL";
int blur_extent = 1;

There will be no SDL_Texture. It is almost useless to have textures because we have to do pixel manipulation with it, all onto the CPU in one way or the other. SDL_Surface is ideal for direct pixel manipulation onto the CPU.

//SDL structures
SDL_Window* window = NULL;
SDL_Event input;
SDL_Surface* windowSurface = NULL;
SDL_Surface* imageSurface = NULL;

bool quit = false;

A simple function to get input from a file in a proper way.

void getInput(std::string inputFileName)
{
	std::ifstream inputFile;
	inputFile.open(inputFileName);

	if (inputFile.fail())
	{
		std::cerr << "ERROR: Failed to open " << inputFileName << "." << std::endl; 	} 	else 	{ 		while (inputFile.good()) 		{ 			std::string tag; 			inputFile >> tag;

			if (tag == "[window_width]") inputFile >> window_width;
			else if (tag == "[window_height]") inputFile >> window_height;
			else if (tag == "[input_image_name]") inputFile >> input_image_name;
			else if (tag == "[output_image_name]") inputFile >> output_image_name;
			else if (tag == "[blur_extent]") inputFile >> blur_extent;
		}
	}

	inputFile.close();
}

After getting input, it is time for initializing the systems.

void init()
{
	SDL_Init(SDL_INIT_EVERYTHING);
	window = SDL_CreateWindow("BoxBlurrer",
		SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
		window_width, window_height, SDL_WINDOW_SHOWN);
	windowSurface = SDL_GetWindowSurface(window);
	imageSurface = IMG_Load(input_image_name.c_str());
}

After initializing the systems, we have to blur the image that we loaded in.

Box blur is just averaging the color values of adjacent pixels and then, using it as the color values of that pixel. It is called box blur because of the fact that it is always done in a square.

void blur() //This manipulates with SDL_Surface and gives it box blur effect
{
	for (int y = 0; y < imageSurface->h; y++)
	{
		for (int x = 0; x < (imageSurface->pitch / 4); x++)
		{
			Uint32 color = ((Uint32*)imageSurface->pixels)[(y * (imageSurface->pitch / 4)) + x];

			//SDL_GetRGBA() is a method for getting color
			//components from a 32 bit color
			Uint8 r = 0, g = 0, b = 0, a = 0;
			SDL_GetRGBA(color, imageSurface->format, &r, &g, &b, &a);

			Uint32 rb = 0, gb = 0, bb = 0, ab = 0;

			//Within the two for-loops below, colors of adjacent pixels are added up

			for (int yo = -blur_extent; yo <= blur_extent; yo++)
			{
				for (int xo = -blur_extent; xo <= blur_extent; xo++) 				{ 					if (y + yo >= 0 && x + xo >= 0
						&& y + yo < imageSurface->h && x + xo < (imageSurface->pitch / 4)
						)
					{
						Uint32 colOth = ((Uint32*)imageSurface->pixels)[((y + yo)
                                                * (imageSurface->pitch / 4)) + (x + xo)];

						Uint8 ro = 0, go = 0, bo = 0, ao = 0;
						SDL_GetRGBA(colOth, imageSurface->format, &ro, &go, &bo, &ao);

						rb += ro;
						gb += go;
						bb += bo;
						ab += ao;
					}
				}
			}

			//The sum is then, divided by the total number of
			//pixels present in a block of blur radius

			//For blur_extent 1, it will be 9
			//For blur_extent 2, it will be 25
			//and so on...

			//In this way, we are getting the average of
			//all the pixels in a block of blur radius

			//(((blur_extent * 2) + 1) * ((blur_extent * 2) + 1)) calculates
			//the total number of pixels present in a block of blur radius

			r = (Uint8)(rb / (((blur_extent * 2) + 1) * ((blur_extent * 2) + 1)));
			g = (Uint8)(gb / (((blur_extent * 2) + 1) * ((blur_extent * 2) + 1)));
			b = (Uint8)(bb / (((blur_extent * 2) + 1) * ((blur_extent * 2) + 1)));
			a = (Uint8)(ab / (((blur_extent * 2) + 1) * ((blur_extent * 2) + 1)));

			//Bit shifting color bits to form a 32 bit proper colour
			color = (r) | (g << 8) | (b << 16) | (a << 24); 			((Uint32*)imageSurface->pixels)[(y * (imageSurface->pitch / 4)) + x] = color;
		}
	}
}

After blurring, we want to make sure that we can see the blurred image on the screen.

void update()
{
	//Putting surface onto the screen
	SDL_BlitSurface(imageSurface, NULL, windowSurface, NULL);
	SDL_UpdateWindowSurface(window);
}

At the end, when we are quitting the program, we want to make sure that the blurred image is saved as a PNG image file. If we don’t want to have any saved output, we use “NULL” as the output image name.

void setOutput() //For saving image as PNG
{
	if (output_image_name != "NULL")
		IMG_SavePNG(imageSurface, output_image_name.c_str());
}

Now, just need to clear the resources.

void clear()
{
	SDL_FreeSurface(imageSurface);
	SDL_DestroyWindow(window);
	IMG_Quit();
	SDL_Quit();
}

Getting everything in one piece, all in our main function!

int main()
{
	getInput("settings.ini");
	init();
	blur();
	while (!quit)
	{
		while (SDL_PollEvent(&input) > 0)
			if (input.type == SDL_QUIT) quit = true;
		update();
	}
	setOutput();
	clear();
	return 0;
}

It’s pretty much straight forward and I hope that you understand that…

To those who loves to criticize, I know it could be way more better than that if we could change the blur extent by pressing some key and having its result instantly on the screen, or if we make another input tag for image format. But I think that we should keep things simple…

The Results

Unfortunately, I couldn’t post the images. But you can try and see it for yourself.

If you want to show some better pixel manipulation, I will appreciate it!

C++ Programming Series: Dynamic Arrays (Part 2, Last)

Dynamic arrays can be used with functions in exactly the same way as I have told in this post. Just keep in mind that we have to pass the size of array into the function.

void printIntegerArray(int* pArr, int totalElements)
{
  for(int i = 0; i < totalElements; i++)
  {
    cout << pArr[i] << endl;
  }
}

int main()
{
  int* array = new int[5] { 3, 4, 7, 8, 12 };

  printIntegerArray(array, 5);

  return 0;
}

Note how I allocated the memory and also, set the value of all the elements in the dynamic array in the highlighted line.

That initialization of dynamic array is what the real purpose of this small post is. Why? Because dah! I learned that very late. Very very late.

At least, I am able to save others from this.

array[0] = 3;
array[1] = 4;
//...till the end :p

Also, there is another purpose of this post.

Tell me my mistake in the code.

If you already knew it before reaching this part, you must be a keen observer. There is no delete[] array; at the end of the code.

Damn those memory bees. (By the way, it is a genuine mistake)

This ends my C++ Programming Series. Now, to ease your path, there will be another post in this series. Keep coming back and you will always find bunch of useful stuff here.