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


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!

miércoles, 20 de febrero de 2013

Mutant Encryption Algorithm

Today's project is more about the same topic of encrypting passwords.This piece of code is aimed to encrypt passwords, but this time it won't return a single character array, but a constantly-changing matrix which contains the password. I am currently working on the decrypting algorithm, which I'm done so far with. As you may deduce from the code, what I do is 'insert' the password character by character into the matrix following this order:

  • First element will go in row 0 and a random column between 13 and 36
  • Second element will go in row 1 and a random column between 13 and 36
  • 'n' element will go in row n-1 and a random column between 13 and 36
Here I attach the file, as always:

And here I show the code, which is really simple:

jueves, 7 de febrero de 2013

Test-Type Exam Correction With Java

Hello everyone!

Today's little project is a simple way of correcting tests with Java. In this piece of code I just defined two possible models or answers, they're all random, but the only thing needed is to update them with valid answers. The length of the test? I just did it for a 10-question test, but it can naturally be extended to the number of answers the teacher may want.

Here's a snapshot:

And the code:

miércoles, 6 de febrero de 2013

A simple function that hides typed passwords in C++

In C++ console there's no way of hiding passwords at the same time we type them (I mean, our password remains visible for everyone who may sit next to us). There's a simple way to avoid this that resembles to what can be easily made in HTML or JavaScript: simply adding a cls command to clear all the console output until that moment and then popping up the same stuff but now with '*' instead.


sábado, 2 de febrero de 2013

Password-Decryption with C++

Hi there!
I just finished the second and last part of my little project called Encrypting&Decrypting Passwords with C++. What I show you today is the other part of the code: how to get the real password from a senseless and non-intuitive string, previously encrypted by the first program. As you may know, there are millions of ways of encrypting stuff like passwords, texts, phone numbers...strings in general. Here I show you what first came to my mind. The current program asks the user to type the encrypted password, and it recognizes whether it went through the simple-mode or advanced-mode encryption way. And that's it, it gives back the original password.

 Here are a couple of snapshots, where user chose simple-mode and the result was a string with just numbers:

and user chose advanced-mode ant the result was a string with weird characters:

Here is the file located on my Skydrive account:

And here is the code: