Serious Game for Programming Students (C/C++)

This is a small Serious Game where the student must finish/write some functions 

to have all behaviors working on the scenery.



App Screenshot

Before Run

Packages for Ubuntu: sudo apt-get -y install build-essential xserver-xorg-dev x11proto-xf86vidmode-dev libxxf86vm-dev mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev libxext-dev libxcursor-dev

Makefile Options

clean stuff:

$ make clean

build library, this will generate lib/libseiousgame.so, that contains the base framework to students develop their tasks:

$ make lib

build documentation (requires doxygen, dot and graphviz):

$ make doc

build distribution to students (does not contains solutions and source code):

$ make dist

build application (this command can be used by teacher or students):

$ make

C++ Features Used

  • Object Oriented Code:

    • All code follows Object Oriented pratices.
  • Smart Pointers:

    • TaskObject4.cpp (evalStudentWork)
  • Lambda Expressions:

    • TaskObject4.cpp (evalStudentWork)
    • TaskObject5.cpp (evalStudentWork)
    • GameCFG.cpp (convert params from string to enum..)
  • Friend classes/methods:

    • GamePlayer/App
    • GameScene/App
  • Virtual Functions:

    • TaskObject.hpp (and subclasses)
    • GameEventReceiver (implementing keyboard actions)
  • FStream:

    • GameScene::loadSceneFromFile (Reading game scene from TXT)
  • Containers:

    • std::vector -> GameScene.hpp
    • std::map<std::string,ITexture*> -> TextureManager.hpp
  • Iterator:

    • App::run -> iterate over tasks
    • App::setupCollitions -> iterate over static and task objects
  • Rule of Three:

    • Shadow
      • Enable log in config
      • Wall -> Copy Ctor
      • Plant -> Copy Assignment Operator
  • Exceptions/Custom Exceptions:

    • GameScene -> SceneryReadException:
      • Case 1: file open error
      • Case 2: invalid character
      • throws inside reading methods, catch inside constructor
    • GameCFG -> ConfigReadException
      • Case 1: file open error
      • Case 2: param not found/incorrect

Extra Features (not proposed)

  • Chrono Library:

    • App.cpp, App::run(), used to lock FPS
  • Design Patterns:

    • Singleton: TextureManager
    • Factory: Static Objects, Task Objects
  • Inheritance/Polymorphism:

    • StaticObject and subclasses
      • some methods are done on superclass (e.g. setPosition, getPosition)
    • Tasks
      • all exends base task
  • Default Argument:

    • Shadow size
    • Logger -> log type
  • Range-based for:

    • TaskObject4.cpp (evalStudentWork)
  • Regex:

    • Used to parse configuration file (GameCFG.cpp)
  • Features not Used:

    Templates, Generic Algorithms, default_random_engine, Operator Overload

Student Tasks

Programming Content: - conditionals (if-else) - loops (for, while, do-while) - vectors (c-array) - matrices (c-matrix)

1. Door with Password

Definition: the door only can be opened by inserting the correct password;

Header: bool verify_password(int password);

Expected result: must return true if password is 1234, false otherwise

2. Enter the Lab

Definition: Each user has his own username and password, the door opens only for allowed users; The lab can handle with 5 users/passwords.

Header: bool verify_password_lab(string user, string password);

Expected result: user enters username and password, the function must return true if data match with the stored passwords, false otherwise.

The stored passwords are:
    user1: volvo
    user2: chevrolet
    user3: audi
    user4: bmw
    user5: lada

3. Encrypt Password

Definition: Some users are not happy with their passwords, for some reason they want to encrypt it. Write a code to help this task following this encrypt rule:

  • Each character must be replaced with his sucessor, e.g. a -> b, f -> g, z -> a, etc.
  • Make sure to deal with 'z' character, it must be replaced by 'a'.
  • Consider only lowercase a-z characters are inserted (no need to check this!).

Header: string encrypt(string old_password);

Sample:

old_password = "abcl"
expected return: "bcdm"

4. Generate Access Sequence

Definition: The laboratory X is a very restrict area. Researchers have free access by using fingerprint, but sometimes is needed to allow some other people to enter. This people cannot have lifetime access, instead their have a short time way to get in. This short time access is controlled by a number sequence that is generated by the computer.

Your task here is to generate valid number sequences, follow the rules:

  • the sequence is based on a single parameter: a number 'n'.
  • the sequence has fixed size: 4 numbers.
  • 'n' must be positive non-zero (return [-1,-1,-1,-1] sequence if n is zero or less).
  • the sequence contains the 4 next multiples of 'n' after 'n' (return an int array of size 4).
  • tip: use dynamic allocation to create the array (malloc).

Header: int* generateSequence(int n);

Samples:

n=3
    [6,9,12,15]
n=17
    [34,51,68,85]

5. Validate Card (Count Characters)

Definition: The last laboratory is the most restrict are in the scene, so it requires a very hard code to allow access. This code is hidden inside a character matrix of size 8x8. The matrix is composed by non-empty characters, there's only one 'x' in there. You need to locate this special character ('x'), after that, you need to count and return how many 'w' are around it (in a max distance of 1 unit). You just need to count the characters and return, Your mechanishm will be used to validate the cards.

Samples:

########
#adfwhj#
#jshuaw#
#jawhhl#
#oxihal#
#uhwgta#
#qrakkw#
########
  • 'x' is at cell matrix[4][2]
  • neighborhood (distance 1) of 'x' is:
jaw
oxi
uhw
  • there's 2 'w' in neighborhood of 'x'
  • pay attention that all matrices have the character '#' in the borders.

Header: int countCharacters(char matrix[8][8]);

Comments