Tuesday, May 10, 2016

Using Access Pointers

Oh, Ada.

So, after a longer time that expected, I finished the program that would utilize specific access pointers! To clarify, access pointers are the "arrows" that point at the object being referenced.

To demonstrate access pointers, I created a game called "Pyramid Loot".

Explanation of the game:

Pyramid Loot is a text-based game where your goal is to get the treasure in the pyramid. To get there, you must battle 4 different monsters of increasing difficulty.

You start off being asked what kind of blessing you want. There are 3 options: health, attack, and dexterity.

You are given 2 heals.

Each battle scene is simulated in text.

At the end of each battle, the monster you killed will drop an item if it was carrying one. You will have the option to pick it up or leave it, and if you already have 2 items (because you only have 2 hands), you must decide which item you want to replace OR just leave it.

Each room has an item that simulates the same decision making as picking up a monster's item.

Swords give you attack, shields give you damage reduction.

Using heals at the right time and strategically building your character is how you beat the game and get the treasure.


How the game uses access pointers:

Anytime an object is created in Ada, an access pointer must be made for it.
Player, Monsters, Items, and Rooms are all objects that require access pointers to allow for instances of these objects!



Here is the code if you want to try it yourself. At the bottom is a sample run through of the game.






































Sample of the Game:








































If I would have lost a battle, I would have been prompted to play again or not.

Example of this:



So, this is a program that utilizes access pointers.

Even though Ada was developed for very serious purposes, it can still be used to create fun games.

Good luck everyone.







Friday, May 6, 2016

Interesting features of Ada

Interesting features of Ada


Ada has a couple of interesting features that make it stand out. They tie back to why it was created. It is no surprise that its special features are directly related to ensuring proper functionality of the programs created, for Ada was originally created for military purposes where a malfunction in the program could cause accidental injury or death. Things in Ada must be very specific to avoid error, and this is done through high-level typing.

Specifically, Ada uses explicitly declared access types.

It also supports run-time checks to protect against access to unallocated memory, buffer overflow errors, range violations, off-by-one errors, array access errors, and other detectable bugs.

These make Ada relevant in the coding of avionics, ATC, railways, banking, and military and space technology.

In my next posts, I will present some programs that will demonstrate these things!