Textics

Hi guys!

I want to show you a little videogame I wrote, named Textics. It’s a textual game, played directly on the console, without any graphics.

The aim of the game is to reach the exit of each room without being captured by the enemies. Some of them will not move, and you just have to avoid walking in front of them. Instead, other ones will move following pre-determined patterns, so it will be very useful to observe where they go before to move!

The game area is divided in rows and columns, like a chessboard: every cell is univoquely identified by two coordinates, like (A;g).

Following, a screen of the game:

Textics screenshot

Legend:

  • P: player’s position
  • E: enemy’s position
  • +: enemy’s view: if you walk on it, you will be caught!
  • X: exit
  • | or _: these represents an horizontal or vertical wall, which the player cannot walk on and enemies look through (of course!).

Controls

You can use the following commands:

  • goto Xy: go to the (X; y) cell. Attention: the player can only move on a straight line!
  • wait: wait one turn, so you can observe how the enemies move;
  • exit: go through the exit e continue with the next level. It can be used only if the player is on a cell adjacent to the exit.
  • menu: go back to the main menu.
  • quit: close the game.

Levels

Levels are saved in the levels.dat file. It is an XML file, that is read from the executable and used to create levels’ map. The user can freely modify it in order to create new levels or modify existing ones.

Here’s how. First of all, you need to create a <level id=”xx”>…</level> node at the end of the file (inside <levels> root), and update the counter <levels count=”xx”> at the beginning of the file.

Here’s the list of the possible elements you can add into the level. Please note: x and y coordinates of each node must be numeric value between 0 and 19.

Mandatory nodes are:

  • <player x=”xx” y=”yy” />, that represents player’s position;
  • <exit x=”xx” y=”yy” />, that represents exit’s position.

The other, optional nodes are:

  • <hwall x=”xx” y=”yy” />, that represents an horizontal wall, that is identified on the map by ‘_’ character;
  • <vwall x=”xx” y=”yy” />,  that represents an horizontal wall, that is identified on the map by ‘|’ character;
  • <enemy x=”xx” y=”yy” view=”u/r/l/d” />, that represents one enemy. The view parameter, that can be equal to u, r, l, d, tells where he is looking: in order, up, right, left, down.
    • Enemies can move along pre-determined paths. You need to add into the enemy node, a node called <movement>; in it, you need to add as many <point> nodes as the points the enemy will reach (excluding the starting point). The syntax is: <point x=”xx” y=”yy” view=”u/r/l/d” />.
  • <dialogue>, that can be inserted at the beginning of the <level> node: you can insert the text you want to be viewed to the right of the map in it, enclosed by the tag <![CDATA[ … ]]>. It must be no longer than 20 rows, and each of them must contain no more than 30 characters.

Conclusions

Nowadays, the game counts only 10 levels, so it will take no more than a few minutes to be completed. Any progress is saved when you complete a level, and the game can be resumed at any time.

Probably, I will add an inventory system, giving the player the ability to get different items, like keys to open level’s exit, or other gadgets.

You can find the source code in the repository, and the archive with the executable can be download here.

Stay tuned!

English/italian blog

Hi everyone!

Until now, every post was made of two parts, one in Italian, one in English: in this way, they could be confusing.

Now, there are two different blogs: this one, completely in English, and the other one, completely in Italian!

On the menu at the top of the page, you can find a button to switch between the two.

Stay tuned!

General physics I: projectiles motion with Arduino and servo

 

For General physics I final, we were asked to prepare a simple physical experiment: in particular, we dealt with the study of projectiles’s motion. I developed a simple circuit that makes you able to handle the firing angle with high precision, using a servomotor connected to a little cannon. In this way, it’s simple to study how the projectile’s motion changes varying the firing angle.

In order to realize the circuit, you just need a servomotor, a LCD display (optional) and, obviously, Arduino. Read this post to know how to wire up the display; then, connect the servomotor to one Arduino digital pin (I used pin number 7)

The source code (you can find it here), takes the angle value in input from serial, updates the display and make the servomotor move.

IMG_20141219_122123 IMG_20141215_105034

IMG_20141218_145533Stay tuned!