Initial commit
This commit is contained in:
commit
99b2a70472
26 changed files with 2445 additions and 0 deletions
19
.direnv/bin/nix-direnv-reload
Executable file
19
.direnv/bin/nix-direnv-reload
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
if [[ ! -d "/home/ty/Dev/School/CSCI200/Sets/6/L6C" ]]; then
|
||||
echo "Cannot find source directory; Did you move it?"
|
||||
echo "(Looking for "/home/ty/Dev/School/CSCI200/Sets/6/L6C")"
|
||||
echo 'Cannot force reload with this script - use "direnv reload" manually and then try again'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# rebuild the cache forcefully
|
||||
_nix_direnv_force_reload=1 direnv exec "/home/ty/Dev/School/CSCI200/Sets/6/L6C" true
|
||||
|
||||
# Update the mtime for .envrc.
|
||||
# This will cause direnv to reload again - but without re-building.
|
||||
touch "/home/ty/Dev/School/CSCI200/Sets/6/L6C/.envrc"
|
||||
|
||||
# Also update the timestamp of whatever profile_rc we have.
|
||||
# This makes sure that we know we are up to date.
|
||||
touch -r "/home/ty/Dev/School/CSCI200/Sets/6/L6C/.envrc" "/home/ty/Dev/School/CSCI200/Sets/6/L6C/.direnv"/*.rc
|
1
.direnv/flake-inputs/01x5k4nlxcpyd85nnr0b9gm89rm8ff4x-source
Symbolic link
1
.direnv/flake-inputs/01x5k4nlxcpyd85nnr0b9gm89rm8ff4x-source
Symbolic link
|
@ -0,0 +1 @@
|
|||
/nix/store/01x5k4nlxcpyd85nnr0b9gm89rm8ff4x-source
|
1
.direnv/flake-inputs/0v05wrinzf90rdm7n9i10r261hqacr5h-source
Symbolic link
1
.direnv/flake-inputs/0v05wrinzf90rdm7n9i10r261hqacr5h-source
Symbolic link
|
@ -0,0 +1 @@
|
|||
/nix/store/0v05wrinzf90rdm7n9i10r261hqacr5h-source
|
1
.direnv/flake-inputs/vqhkmj60457j8nrw9vb94ln40rkic1p6-source
Symbolic link
1
.direnv/flake-inputs/vqhkmj60457j8nrw9vb94ln40rkic1p6-source
Symbolic link
|
@ -0,0 +1 @@
|
|||
/nix/store/vqhkmj60457j8nrw9vb94ln40rkic1p6-source
|
1
.direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source
Symbolic link
1
.direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source
Symbolic link
|
@ -0,0 +1 @@
|
|||
/nix/store/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source
|
1
.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa
Symbolic link
1
.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa
Symbolic link
|
@ -0,0 +1 @@
|
|||
/nix/store/qkf3jcwnwb09hb1rzk21fdjc4xa1amz8-nix-shell-env
|
2005
.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc
Normal file
2005
.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc
Normal file
File diff suppressed because it is too large
Load diff
1
.envrc
Normal file
1
.envrc
Normal file
|
@ -0,0 +1 @@
|
|||
use flake
|
67
Makefile
Normal file
67
Makefile
Normal file
|
@ -0,0 +1,67 @@
|
|||
# THE NAME OF YOUR EXECUTABLE
|
||||
TARGET = L6C
|
||||
# ALL CPP COMPILABLE IMPLEMENTATION FILES THAT MAKE UP THE PROJECT
|
||||
SRC_FILES = main.cpp
|
||||
|
||||
# NO EDITS NEEDED BELOW THIS LINE
|
||||
|
||||
CXX = g++
|
||||
CXXFLAGS = -O2
|
||||
CXXFLAGS_DEBUG = -g
|
||||
CXXFLAGS_WARN = -Wall -Wextra -Wunreachable-code -Wshadow -Wpedantic
|
||||
CPPVERSION = -std=c++17
|
||||
|
||||
OBJECTS = $(SRC_FILES:.cpp=.o)
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
TARGET := $(TARGET).exe
|
||||
DEL = del
|
||||
Q =
|
||||
|
||||
INC_PATH = Z:/CSCI200/include/
|
||||
LIB_PATH = Z:/CSCI200/lib/
|
||||
|
||||
RPATH =
|
||||
else
|
||||
DEL = rm -f
|
||||
Q = "
|
||||
|
||||
INC_PATH = /usr/local/include/
|
||||
LIB_PATH = /usr/local/lib/
|
||||
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
CXXFLAGS += -D LINUX
|
||||
RPATH =
|
||||
endif
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
CXXFLAGS += -D OSX
|
||||
RPATH = -Wl,-rpath,/Library/Frameworks
|
||||
endif
|
||||
|
||||
UNAME_P := $(shell uname -p)
|
||||
endif
|
||||
|
||||
LIBS = -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio -lsfml-network
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(CXX) -o $@ $^ $(RPATH) -L$(LIB_PATH) $(LIBS)
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) $(CXXFLAGS) $(CPPVERSION) $(CXXFLAGS_DEBUG) $(CXXFLAGS_WARN) -o $@ -c $< -I$(INC_PATH)
|
||||
|
||||
clean:
|
||||
$(DEL) $(TARGET) $(OBJECTS)
|
||||
|
||||
depend:
|
||||
@sed -i.bak '/^# DEPENDENCIES/,$$d' Makefile
|
||||
@$(DEL) sed*
|
||||
@echo $(Q)# DEPENDENCIES$(Q) >> Makefile
|
||||
@$(CXX) -MM $(SRC_FILES) >> Makefile
|
||||
|
||||
.PHONY: all clean depend
|
||||
|
||||
# DEPENDENCIES
|
||||
main.o: main.cpp
|
61
flake.lock
Normal file
61
flake.lock
Normal file
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1733212471,
|
||||
"narHash": "sha256-M1+uCoV5igihRfcUKrr1riygbe73/dzNnzPsmaLCmpo=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "55d15ad12a74eb7d4646254e13638ad0c4128776",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
20
flake.nix
Normal file
20
flake.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
description = "CSCI200 Lab 6C";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
outputs = { nixpkgs, flake-utils, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; in {
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
sfml
|
||||
];
|
||||
|
||||
packages = with pkgs; [
|
||||
gcc
|
||||
clang-tools
|
||||
];
|
||||
};
|
||||
});
|
||||
}
|
101
main.cpp
Normal file
101
main.cpp
Normal file
|
@ -0,0 +1,101 @@
|
|||
#include <SFML/Graphics.hpp>
|
||||
using namespace sf;
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
string filename;
|
||||
if (argc >= 2) {
|
||||
filename = argv[1];
|
||||
} else {
|
||||
cout << "Please enter a maze filename to load: ";
|
||||
cin >> filename;
|
||||
}
|
||||
cout << "Loading maze file " << filename << endl;
|
||||
|
||||
ifstream mazeFile(filename);
|
||||
if (mazeFile.fail()) {
|
||||
std::cout << "Failed to open specified file path " << filename
|
||||
<< ", does it exist?" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int rows, cols;
|
||||
mazeFile >> rows >> cols;
|
||||
mazeFile.get(); // move cursor past newline to actual grid characters
|
||||
|
||||
char** grid = new char*[rows];
|
||||
pair<int, int> start(-1, -1);
|
||||
for (int row = 0; row < rows; row++) {
|
||||
grid[row] = new char[cols];
|
||||
for (int col = 0; col < cols; col++) {
|
||||
grid[row][col] = mazeFile.get();
|
||||
if (grid[row][col] == 'S') start = make_pair(row, col);
|
||||
}
|
||||
mazeFile.get(); // advance past newline
|
||||
}
|
||||
|
||||
// create a window
|
||||
RenderWindow window( VideoMode(15*cols, 15*rows), "Maze Drawer" );
|
||||
|
||||
// create an event object once to store future events
|
||||
Event event;
|
||||
|
||||
// while the window is open
|
||||
while( window.isOpen() ) {
|
||||
// clear any existing contents
|
||||
window.clear();
|
||||
|
||||
/////////////////////////////////////
|
||||
// BEGIN DRAWING HERE
|
||||
|
||||
// place any draw commands here to display in the window
|
||||
for (int row = 0; row < rows; row++) {
|
||||
for (int col = 0; col < cols; col++) {
|
||||
sf::RectangleShape rectangle;
|
||||
rectangle.setSize(Vector2f(15, 15));
|
||||
rectangle.setPosition(col * 15, row * 15);
|
||||
switch (grid[row][col]) {
|
||||
case 'S':
|
||||
rectangle.setFillColor(Color::Green);
|
||||
break;
|
||||
case 'E':
|
||||
rectangle.setFillColor(Color::Red);
|
||||
break;
|
||||
case '#':
|
||||
rectangle.setFillColor(Color::Black);
|
||||
break;
|
||||
case '.':
|
||||
rectangle.setFillColor(Color::White);
|
||||
break;
|
||||
}
|
||||
|
||||
window.draw(rectangle);
|
||||
}
|
||||
}
|
||||
// END DRAWING HERE
|
||||
/////////////////////////////////////
|
||||
|
||||
|
||||
// display the current contents of the window
|
||||
window.display();
|
||||
|
||||
/////////////////////////////////////
|
||||
// BEGIN EVENT HANDLING HERE
|
||||
// check if any events happened since the last time checked
|
||||
while( window.pollEvent(event) ) {
|
||||
// if event type corresponds to pressing window X
|
||||
if(event.type == Event::Closed) {
|
||||
// tell the window to close
|
||||
window.close();
|
||||
}
|
||||
// check addition event types to handle additional events
|
||||
}
|
||||
// END EVENT HANDLING HERE
|
||||
/////////////////////////////////////
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
7
mazePack/1.maze
Normal file
7
mazePack/1.maze
Normal file
|
@ -0,0 +1,7 @@
|
|||
6 9
|
||||
#########
|
||||
#S#...#E#
|
||||
#.#.#.#.#
|
||||
#.#.#.#.#
|
||||
#...#...#
|
||||
#########
|
8
mazePack/2.maze
Normal file
8
mazePack/2.maze
Normal file
|
@ -0,0 +1,8 @@
|
|||
7 8
|
||||
########
|
||||
#.##..E#
|
||||
#.##.###
|
||||
#.#..###
|
||||
#.##...#
|
||||
#S...#.#
|
||||
########
|
9
mazePack/3.maze
Normal file
9
mazePack/3.maze
Normal file
|
@ -0,0 +1,9 @@
|
|||
8 26
|
||||
##########################
|
||||
#S#............#....#....#
|
||||
#.#...###....###.##.#.##E#
|
||||
#.#.###.#..#...#.##.#.##.#
|
||||
#.....#...###....#....##.#
|
||||
###.##..##.#..####.##..###
|
||||
###..##....####....#######
|
||||
##########################
|
9
mazePack/4.maze
Normal file
9
mazePack/4.maze
Normal file
|
@ -0,0 +1,9 @@
|
|||
8 26
|
||||
##########################
|
||||
#S#............#....#.##.#
|
||||
#.#...###....###.##.#.#.E#
|
||||
#.#.###.#..#...#.##.#.##.#
|
||||
#.....#...###....#....####
|
||||
###.##..##.#..####.##.####
|
||||
###..##....####....#######
|
||||
##########################
|
9
mazePack/5.maze
Normal file
9
mazePack/5.maze
Normal file
|
@ -0,0 +1,9 @@
|
|||
8 26
|
||||
##########################
|
||||
#S#............#....#.##.#
|
||||
#.#...###....###.##.#.#.E#
|
||||
#.#.###.#..#...#.##.#.##.#
|
||||
###...#...###....#....####
|
||||
###.##..##.#..####.##.####
|
||||
###..##....####....#######
|
||||
##########################
|
8
mazePack/6.maze
Normal file
8
mazePack/6.maze
Normal file
|
@ -0,0 +1,8 @@
|
|||
7 9
|
||||
.........
|
||||
.........
|
||||
.........
|
||||
..S...E..
|
||||
.........
|
||||
.........
|
||||
.........
|
9
mazePack/7.maze
Normal file
9
mazePack/7.maze
Normal file
|
@ -0,0 +1,9 @@
|
|||
8 26
|
||||
##########################
|
||||
#S#............#....#....#
|
||||
#.#...###....###.##.#.##E#
|
||||
#.#.#.#.#..#...#.##.#.##.#
|
||||
#.....#....##.........##.#
|
||||
###.##..##.#..#.##.##....#
|
||||
###..........##....#######
|
||||
##########################
|
4
mazePack/8.maze
Normal file
4
mazePack/8.maze
Normal file
|
@ -0,0 +1,4 @@
|
|||
3 60
|
||||
############################################################
|
||||
#S........................................................E#
|
||||
############################################################
|
17
mazePack/9.maze
Normal file
17
mazePack/9.maze
Normal file
|
@ -0,0 +1,17 @@
|
|||
16 41
|
||||
#########################################
|
||||
#.....................................#.#
|
||||
#.....................................#.#
|
||||
#.....................................#.#
|
||||
#.....................................#.#
|
||||
#.....................................#.#
|
||||
#....................................S#E#
|
||||
#.....................................#.#
|
||||
#.....................................#.#
|
||||
#.....................................#.#
|
||||
#.....................................#.#
|
||||
#.....................................#.#
|
||||
#.....................................#.#
|
||||
#.....................................#.#
|
||||
#.....................................#.#
|
||||
#########################################
|
17
mazePack/A.maze
Normal file
17
mazePack/A.maze
Normal file
|
@ -0,0 +1,17 @@
|
|||
16 41
|
||||
#########################################
|
||||
#.......................................#
|
||||
#.......................................#
|
||||
#.......................................#
|
||||
#.......................................#
|
||||
#.......................................#
|
||||
#.......................................#
|
||||
#.......................................#
|
||||
#.......................................#
|
||||
#.......................................#
|
||||
#.......................................#
|
||||
#..E....................................#
|
||||
#.......................................#
|
||||
#..S....................................#
|
||||
#.......................................#
|
||||
#########################################
|
9
mazePack/B.maze
Normal file
9
mazePack/B.maze
Normal file
|
@ -0,0 +1,9 @@
|
|||
8 26
|
||||
##########################
|
||||
#S#............#....#.##E#
|
||||
#.#...#.#....#.#.##.#....#
|
||||
#.#.#.#.#..#...#....#.##.#
|
||||
#.....#....##....#....##.#
|
||||
###.#...##.#..#.##.##.##.#
|
||||
###...#......##..........#
|
||||
##########################
|
8
mazePack/C.maze
Normal file
8
mazePack/C.maze
Normal file
|
@ -0,0 +1,8 @@
|
|||
7 9
|
||||
.........
|
||||
.........
|
||||
.........
|
||||
..E...S..
|
||||
.........
|
||||
.........
|
||||
.........
|
26
mazePack/D.maze
Normal file
26
mazePack/D.maze
Normal file
|
@ -0,0 +1,26 @@
|
|||
25 3
|
||||
###
|
||||
#S#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#.#
|
||||
#E#
|
||||
###
|
26
mazePack/E.maze
Normal file
26
mazePack/E.maze
Normal file
|
@ -0,0 +1,26 @@
|
|||
25 3
|
||||
...
|
||||
.S.
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
...
|
||||
.E.
|
||||
...
|
Loading…
Reference in a new issue