-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from Ben-Ryder/develop
v1.1 - Changing data save format to JSON.
- Loading branch information
Showing
31 changed files
with
392 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
# Ben-Ryder 2019 | ||
|
||
import pygame | ||
import random | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
# Ben-Ryder 2019 | ||
|
||
from project.control.controller import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
# Ben-Ryder 2019 | ||
|
||
import constants | ||
import paths | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,40 @@ | ||
# Ben-Ryder 2019 | ||
# Currently using PICKLE as method of file save | ||
# Currently using JSON as method of file save | ||
|
||
import pickle | ||
import json | ||
import os | ||
|
||
import constants | ||
|
||
def save(game, filename): | ||
with open(filename, "wb") as file: | ||
pickle.dump(game, file) | ||
|
||
def save(data, filename): | ||
with open(filename + ".json", "w") as file: | ||
json.dump(data, file, indent=2) | ||
|
||
|
||
def load(filename): | ||
with open(filename, "rb") as file: | ||
game = pickle.load(file) | ||
return game | ||
with open(filename + ".json", "r") as file: | ||
data = json.load(file) | ||
return data | ||
|
||
|
||
def delete(filename): | ||
os.remove(filename) | ||
os.remove(filename + ".json") | ||
|
||
|
||
def check_exists(filename): | ||
return os.path.isfile(filename) | ||
|
||
|
||
def load_map_format(map_file): | ||
with open(map_file, "r") as file: | ||
grid = file.read().split("\n") | ||
grid = [i.replace(",", "") for i in grid] | ||
|
||
# Converting for referencing as [row][col] as split by "/n" gives [col][row] | ||
new_grid = [] | ||
for row in range(constants.MAP_SIZE[0]): | ||
new_grid.append([]) | ||
for col in grid: | ||
new_grid[len(new_grid) - 1].append(col[row]) | ||
|
||
return new_grid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
# Ben-Ryder 2019 | ||
|
||
import constants | ||
|
||
|
||
|
Oops, something went wrong.