How to Implement the Paint Fill

Emulating paint fill is easy and can be done either iteratively or thru stacks. This demonstration is done using plain text, but the same idea could be implemented using your favorite graphics framework.

First, we're given a two-dimensional array of canvass of type char with size [N][M], where N is the number of rows and M is the number of columns.

Let's suppose N = 11 and M = 15, but of course, the values of these two may vary.

How to Create the Noise Effect

Noise is another special effect to emulate an old TV without a signal. A naive approach to do this graphic effect is to create a double for-loop and randomize the color of the pixel being placed on each of the coordinates of the screen.

for (y = 0; y < MAX_SCREEN_HEIGHT; ++y)
    for (x = 0; x < MAX_SCREEN_WIDTH; ++x)
        putPixel(x, y, RBGA(rand()%256, rand()%256, rand()%256, rand()%256));

This will work but not as fast as we would like it to be due to the following reasons:

Tags:

How to Become a Better Programmer Fast

Programming is not easy. If you're just starting with it, expect a long way through before achieving mastery. But there are things you can do to improve your skills and become a better coder immediately. But I must say, this only works if you have a real passion for learning otherwise don't even bother.

Here are some of my tips to become a better programmer. Give it about six months and you'll see a difference between now and then:

How to Create Fire Effect

Today's article brings us back to the time where you have to be imaginative and creative. The fire effect is a special technique to emulate a blazing fire that you may use in your next game application. Save each frame in a sprite and include it in your tile-based RPG games.

Tags:

How to Create Melt Effect

Melt is a technique I've been using when developing 2D games to demonstrate the illusion of melting objects. This effect is something that you cannot just do in Photoshop. Some things are better done the hard way giving you more control of the parameters and function behavior. This is another Throwback Thursday's article so I've written it using QBASIC.

The Technique is simple, you can apply it to any bitmap/canvass of any modern graphic libraries that you are using. The basic idea is, given an object you need to:

Tags:

GOTO is Not Pure Evil

From garbage collection, hard to debug code, infinite loops, and other notorious bugs, there is quite a list of issues in using the GOTO statement. Due to GOTO's bad reputation, it's hardly being used and most programmers do not even know that such a control statement exists.

Let's take a look at the most common issues of GOTO statements and see if these assumptions are true. Otherwise, your idea that "GOTO is BAD" is just indoctrination!

How to Find the Sum of 1 to 100, and Its Variants

Legend has it that the German Mathematician, Carl Friedrich Gauss, who was an elementary student during the late 1700s, showed his teacher how quickly he summed up the numbers 1 to 100 by using a simple mathematical trick.

Centuries later, most programmers are still doing it the long way!

What is Brute Force Modeling?

Brute Force Modeling is a technique used to solve problems by tabulating results in hopes of finding a pattern by induction. The pattern or formula is then normally used as the basis for solving the problem thru iteration or recursion.

Let's take the Josephus Problem, where he (Josephus) and 40 other soldiers decided to choose mass suicide over capture by arranging themselves in a circle and killing the kth person in the circle. The problem of Josephus is where to sit in the circle such that he is the last to die (or escape).

Lattice Paths Part 3 (Combinations)

Starting in the top left corner of a 2 x 2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.

How many such routes are there through a 20 x 20 grid, or any N x N grid?

--

This is the last of the three-part series article about explaining how you could have arrived at the solution yourself in solving the Lattice Paths Problem. If you haven't tried it yet, do it first. I do not intend to deny you of your epiphany moment!

Note: All implementations are written in C/C++.

--

Lattice Paths Part 2 (Brute Force Modeling and Iteration)

Starting in the top left corner of a 2 x 2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.

How many such routes are there through a 20 x 20 grid, or any N x N grid?

--

This is the second of a three-part series article about explaining how you could have arrived at the solution yourself in solving the Lattice Paths Problem. If you haven't tried it yet, do it first. I do not intend to deny you of your epiphany moment!

Note: All implementations are written in C/C++.

--

Subscribe to Everett Gaius Vergara RSS