SMLabyrinth
This program is a complete version of a labyrinth game.
The goal of the game is to reach the nearest door from the start point in all the different levels, in order to gain an higher score. Every schema, in which the difficult increase compared to the increasing of the number of the level, contain an unique start point and more doors. The player, to gain the highest score, has to reach with the minimum possible number of steps and in the minimum time, the nearest door. Once a schema is finished, it will be shown the gained score and then another schema will be reach until the completion of the all (10) levels. At the end of the game it will be possible to save the achieved record, in order to keep a record chart, displayable using the Options menu. The player can starts a new game using the entry "New game" from the File menu, or open a single schema using the entry "Open game".
The best route is estimate using the function bestroute, which uses a recursive algorithm to locate the nearest door to the start point.
In all the schemas, the cost of every step in the route has an unitary value and the final score for each schema is calculated in following way: The percentage of correctness of a route made by a player is calculated with this formula:
perc = (num_step_best_routes) / (num_step_player) * 100
If the rusultant percentage is longer or equals then a set value (see default), a bonus (see default) is added to the final score. Otherwise, it's possible to score a penality (see default). For the current level (current_level), the gained score is calculated with this formula:
points = ceil( current_level * ( bonus + perc ) / ( elapsed_time / ( 1 + SEC_PER_LEVEL * current_level ) + 1 ) )
where elapsed_time correspons to the elapsed time to finisch the level and SEC_PER_LEVEL (see default) to the maximum number of seconds allowed to finish the schema.
The program is composed by the following modules:
- guihandler.c, which contains all the code that create and manage the Graphic User Interface of the project, using the functionality offerd by the other modules; list of functions that this module contains: gui, delete_event, new_tournament, drawschema, configure_event, expose_event, draw_brush, keypressed, checkKeyPressed, updateSchemaCell, win, show_records, get_player_name, checkResponseNameError, drawingAndSetSchemaInfo, open_game, generate_game, request_generate_parameters, checkResponseErrorGenerateParameters, set_gtk_entry_text_from_num, show_help, show_about;
- define.h, which includes all the data program definitions;
- schemaGameUtility.c, containing the game utility functions; list of functions that this module contains: newgame, checkRowColValues, setSchemaDataStructures, checkDoorStartPoint, loadCheckGame, getdoors, isDirectory, get_schema_name, isallowedchar, countDigits, check_if_text_is_number, calcSchemaResults.
- schemaGameGenerator.c used to generate a schema with certains features inserted by users from GUI; list of functions that this module contains: generateSchema, check_generateSchema, gameMap_alloc_and_set, create_routes, get_denyArea, getRouteNumber, set_number_of_available_cells, get_MaxRouteLen, point_in_random_direction, get_direction_from_point, increase_schema_difficult, save_schema_to_file.
- object.c, which includes all the functionality for manage the schema objects. List of own functions: weight that return the weight of the request object; isaccessible that check if the request object is accessible; color that returns a string's pointer that contains the request object's color (used to schema objects); colorVisited that returns a string's pointer that contains the request object's color (used to mark cell along a route); visitCell used to mark (with colors) the route made in the game.
- gameIOManager.c, which includes the functions that works with Input/Output. It contains the following functions: readfile used to read data from files, especially dedicated to schemas, allocResetVariable, skipCharacters, readCharacters, checkDifferentColLen, setGameRecordStructValue, readSetGameRecord, save_record used to save the users record in it's file, printschema that works only in debug mode; used to print the schemas on standard output.
The dependences between the different modules are shown in the following graph:
The compiling process and the generation of the documentation of the project are managed using the command make.
- Author:
- private, MrC