Sebastian Calvo & Camille Girard

Implementation Information
The Map vs The Screen:
An important distinction in the code is the window versus the terrain. In the code we created a system by which to make the map by itself by placing tiles in a system divided by the size of those tiles. Then the map is saved in a system which can be read to recreate the map in the game.
Once inside the game the pre-made map is loaded. What is unique about this is that the map is loaded as a terrain behind the window, therefore always there. The window that the player sees follows the character around as they walk around the map. Therefore, the window, where the player is, is not the same as the terrain, which is displayed behind it. This is an important concept to grasp to understand how the code works, as well as how the interactions are done. This is better for the code since the map only needs to be loaded once, minimizing the computing power needed for this piece of the game.
Terrain
Window
How The Pieces Fit:
With that idea in mind, now we will explore how the game actually interacts within itself. Let's begin with the map. The map editor draws upon textures in order to load, edit and save maps. The textures file contains all the images for the tiles in the game already loaded and in a dictionary in order to reference them easily. It also contains a list of tiles that the player cannot walk on in order to check if tiles are blocked. The mapeditor file uses this textures file and makes commands to remove, place, load and format the position and tile type into a file which can be reloaded later on.

After making the map with the mapeditor the resource for the game comes from main. The first part of the game is loading the map. The mapengine function opens the files saved and created from the mapeditor then reads and displays them. The mapengine opens the file given to it and analyzes the position as well as key for each tile and then goes into the textures and reads the dictionary in order to display the tile corresponding with the key.

The tiles created by the player clicking the tile with the correct texture (brush) in hand which has been selected with
the number key in the Textures dictionary. This tile will only be placed if anything in that place has been removed - brush 'r'.
The code which reads the map files with the formatting we designed. It will read the position
and which tile key is in that space and then find the texture in the Textures file
The main file is also linked to a glob file which contains global variables for the game, this does not contain any other functions. The main file is also linked to a file which contains the information of the player. This helps control the motion of the window and also the main character. The file contains all of the attributes which are important to the player which are then used in the motions defined in the main loop. The player file then references an Non-Player Character (NPC) class which contains the difference images for the character. Using the main loop as a label and then through the player render and then through the NPC file the correct image is placed based on the direction faced and the item held in hand at the time.
The main file also references collectibles in order to place bag tiles on the map. This file contains the bag and its definition as well as all the bag tiles which have been placed by the designers of the game. The main file reads this file and then placed the bags along the terrain. The main then uses the position of the bag and the player in order to do collision detection and read the bag to update the attributes of the player. The main file also references an inventory file in order to update the attributes of the player and show them on the screen. This file contains objects with the specific attributes and then can update them as the player picks up bags.

Based on the item in hand and then direction that the player is facing the image is saved under this name to render onto the window.


The main file also references the NPC file in order to create characters which are enemies in the game. The class contains the enemies and their functions. The enemies are placed in a certain location and within them they change their direction and their movement to get closer to the player x and y. This is only once the player is close enough, the enemy will otherwise just wander around. The enemy has health and damage which will be reduced when the player is close enough and hits them with the hoe and will damage the player if they get too close.
The collision detection between the bags and the player followed by the update of the player inventory and covering
the bag up on the terrain

The movement function for the enemy. This checks if the player is close enough to the enemy and then moves the enemy in the
direction of the player and change its image.