Things are now identified by unique integer IDs rather than by name, allowing multiple things to go by the same name.

This commit is contained in:
Patrick Marsee 2019-05-15 01:37:35 -04:00
parent 20812b362f
commit 267f0e9123
2 changed files with 133 additions and 298 deletions

View file

@ -27,6 +27,7 @@ class GameBase(object):
self.eventQueue = []
self.gameTime = 0.0
self.skipLoop = True
self.nextThing = 0
# player info
self.playerx = -1
@ -413,9 +414,9 @@ Object can be the name of the object, or its coordinates."""
# load the new level
if len(args) == 2:
self.level = _gm.GameMap.read(args[0], int(args[1]), preLoaded)
self.level, self.nextThing = _gm.GameMap.read(args[0], int(args[1]), preLoaded, self.nextThing)
else:
self.level = _gm.GameMap.read(args[0], preLoaded)
self.level, self.nextThing = _gm.GameMap.read(args[0], None, preLoaded, self.nextThing)
# get persistent things from it
if args[0] in self.persist:
@ -451,7 +452,7 @@ Object can be the name of the object, or its coordinates."""
self.persist[self.level.name][i] = self.level.getThingByName(i)
# build data object to be saved
data = (self.playerName, self.playerx, self.playery, self.playerInv, self.level.name, self.persist, self.eventQueue, self.gameTime)
data = (self.playerName, self.playerx, self.playery, self.playerInv, self.level.name, self.persist, self.eventQueue, self.gameTime, self.nextThing)
# save it!
fileName = 'saves/' + args[0].replace(' ', '_') + '.dat'
@ -482,7 +483,7 @@ Object can be the name of the object, or its coordinates."""
fileName = args[0]
x, y, levelname = 1, 1, 'testing/test1.txt'
with open(fileName, 'rb') as f:
self.playerName, x, y, self.playerInv, levelname, self.persist, self.eventQueue, self.gameTime = _pi.load(f)
self.playerName, x, y, self.playerInv, levelname, self.persist, self.eventQueue, self.gameTime, self.nextThing = _pi.load(f)
#print(levelname, x, y, file = self.outstream)
self.loadMap((levelname, x, y))
#_hq.heappush(self.eventQueue, (self.gameTime, _ge.NoOpEvent()))