top of page

Assorted C++ Work

Where all of my current experience with other languages have been in engines and editors such as Unity and GameMaker Studio, my work with C++ has mostly been outside of engines and editors -- mostly smaller programs with simple features. With the exception of one project, my work in C++ has so far has not had the grand scale or individuality of a unique game project, so this page is dedicated towards the projects I have worked on using C++.

Stack reverse + sort + sorted merge:

With this project, I was tasked to create a way to reverse and sort a list of int values using stacks, then to take another sorted stack and merge the two in a way that the merged list would be sorted during the merge. This was way to see how well I understand the concepts of stacks as well as pointers. Basically as each value is added to the stack, it creates a link to the previous head of the stack. Reversing the stack is possible by, for each value, storing the link into a temporary variable, setting the link of the current value to a variable storing the previous value (initially set to null), then setting that previous variable to the current value, then setting the current value to be the stored link that was saved at the start of the process. It repeats until the current value is seen as null. For sorting, it first calculates the number of values in the stack itself, then performs a loop that number of times. If the current node has a value greater than the node that would come after it, then the links for the two nodes are then swapped -- basically just a bubble sort with pointers and links. 

For the merging, while I could have also just made it so the final point of list 1 points to the start of list 2 and then sort that, this instead does the sorting as part of the merge process. First it takes pointers to the heads of the two lists, and creates a merged list pointer variable that is initially set to point to which of the two heads contains the lowest value. (If it is the second one, the two list pointer variables swap places so I wouldn't have to copy and paste the next section with just changing each instance of head 1 to head 2 and visa versa) Then it performs a loop while the first head links to something, and while the second head isn't null. In this loop, it iterates linearly through the "main" list (the list that the merged pointer initially pointed at), comparing the next link's value to the current value of the other list. If the other list's value is lower than what the next link's value is, then that value is essentially pushed into the main list by setting the first list's value's link to the second list's value, and setting that value's link to what was the first list's value's link. It will iterate until the main list doesn't have anything it's pointing to, and if the other list has run out of values for it to be put into the merged list. It then returns the pointer of the merged list.

Click here to view the code for this.

Maze:

For this, I was tasked to create a maze that the user would be able to traverse. The maze itself would be made up of an array of node objects, with each node containing information on which node(s) it would be connected to, as well as a unique identifier that the user would be able to see. As the user moves into a room, it tells the player which rooms they can move to (by seeing which "edges" aren't null), if they have reached a dead end, and if they have reached the exit.

Click here to view the code for this.

Chess move checker:

In this project, I created a system that checks the moves in a chess game to see if a player has entered a set of movements that contained an illegal move. Originally just meant to test general pawn movement, I later added functionality for the other pieces in my free time. However, it does not take into account turn order, pawn promotions, or castling. The project itself was mostly a test to see how well I could use custom classes, pointers, and turning input into data the program could properly use, not to create a complete simulation of the game completely. The user first enters the number of cases they would like to test, then entering the information of each move in the form of selected X, selected Y, target X, and target Y, with that itself being in the form of letters for X, and numbers for Y. Each case would be separated by a line break, so the full input for 3 test cases would, for example, look like this: 

 

3

b2b3 b8c6 c2c4 c7c5

e2e4 g8f6 d1h5 f6h5

d2d4 e7e5 g1f3 e5d4 c2d4 d8e7

For each case, it would then return the move where it saw an illegal action and display it, with it displaying 0 if it saw no error. In the first test in the cases above, it would return 4. On turn 2, player 2 moved their knight at b8 to c6, which would prevent the pawn at c7 from moving to c5 on turn 4, as pawns cannot jump over any unit. For the above input, it would display the following results:

4 0 5

Click here to view the code for this.

Tunnel Bounce:

This project was one of my few forays into OpenGL, using that to create a simple game. I was provided starting code for this, which featured a system that allowed the importing of 3D models (as .obj files) and applying various properties to those objects, such as gravity, movement, and hitboxes. Using this system, I created my own properties to suit the game that I wished to create within the time given to work on this project. As this was a game project, it has its own page here.

bottom of page