Buscar este blog

sábado, 12 de noviembre de 2016

Falling Blocks


Hello world!

It's me updating again. This time I'm uploading a similar concept of game, again using QT libraries. I know I wasn't original with the name, but here it comes: Falling Blocks!

The game now is easier in some way: you just have to match falling blocks of the same color and when done, those two blocks disappear and the score adds up! The falling block can easily be moved using the left/right direction keys. If debug option is selected, there are some hidden features (the power of "Stopping the time", amongst others) that can be enabled with the keyboard.
As the other game I uploaded in the previous post, there are some flags that can modify the behavior of the game (just run the -h flag to find out about them).
HINT: if you select the -u flag, when your score is a multiple of 10 it will increase the falling block rate ;-)

Here is a link to the repo: https://github.com/eiger824/FallingBlocks
And here comes some screenshots:
The first screen prompts a password that must be written to get access to the game. Again, take a look at the -h flag to find out how to bypass it :P If you are too lazy to do that, it is "FallingBlocks2016".

Once logged in, blocks of random colors start falling. When you align the falling and the "fixed" one they look like this, and when you merge them, well you can see the next image.




Then the blocks will disappear and the score will add up (the screenshot I took was when the score has already been added up, just some ms before blocks disappear). Then, another block of another color starts to fall. Oh! It is also blue! That's the thing about randomness, right?

Blocks - The Game!

Hej Folks!

Long time no update. I know. Life makes me not have time to post, which usually means that either I have much to do or I'm doing well (in my case, both applies :D).

Today's project is about a game I developed recently. The game itself is similar to the classic "Connect Four", but instead of having a 7x6 board, it simply is 4x4, thus being harder to win! You can either play against another user or to the machine. Among other options/input parameters to the game that you can easily see by running the -h flag when launching the game from the terminal, there are two "graphic", runtime options that can be enabled/disabled: debug logging and timer enabled. If the first is enabled, prints info in the terminal, and if the timer is enabled, each player, either human or machine, will have 10 seconds to make a move. If time expires, then it's the oponent's turn. To navigate through the board use the direction arrows and to select a position, simply press ESC.

The project was made using Qt, a powerful set of libraries which implement a high-level API in C++. Itś just some kind of "Legoland" to programmers, the number of things you can do with these libraries is countless! Here is a link to QT's main site, worth a read if you like programming.

From now on I won't be posting the codes directly to my blog since I have ported all my projects to my Github account, so instead I will be posting a link to the Git Repo and some screenshots.

Here is the link to the repo: https://github.com/eiger824/Blocks_The_Game
And here are the screenshots:

If man vs. machine option is not selected, both users write their names and press Start (or press ENTER) to start the game.
If one of the users selects a position that is already taken, a popup appears indicating that another position shall be chosen.


This is a normal screenshot of the game. If the block has a white frame on the border, it means that the user is moving the block and has not decided the position.

Hope you enjoy!

jueves, 18 de febrero de 2016

C++ example with input arguments using flags

Hey!

I know it's been a long while since I last posted something in the blog. I just came across it some days ago and decided that I wanted to start writing again on it. So I will try to keep updating the blog from now on :)

Today's post is about a very simple, yet extremely common tool in programming: input arguments to programs. Whenever one launches a program from the terminal in Ubuntu (or command prompt in Windows), it is very normal to pass on arguments that are usually predefined by flags. In bash shell scripting language, one cannot actually think of programs that don't require input arguments. The example above is a really simple example of how this flags can be implemented to collect input arguments from the terminal (whenever the appropriate executable file has been created -using the g++ compiler, for example). This is a very simple implementation of a telephone list, where a new user is added via the flags as input arguments to the program, and the inputted user is then saved on to a file using the appropriate C++ classes (if- and ofstream).

So, as it used to be before, here are some examples of what the user may input:
  • Example 1: no input arguments. Since a user can only be added to the file through the command line, the program exits.


  •  Example 2: Adding a user in the command line using flags:


Now the user gets a message saying that "1 contact(s) ready to be saved. Select option 2". This option will write the saved user to a file, that is, it will append the new user to the end of the file contents. Once having done this, it will display a message like this:


Another option hat has been implemented is if the user just wants to see the address list. For that matter, if the --show flag is passed, it will read the file and show the contacts in the list:


This was just a really easy example on how to deal with input arguments with C++. Here is the code of the program, I hope you enjoy it!