added pebbles; moved placing stuff to placable; made start script
This commit is contained in:
parent
68b36d742e
commit
3dad905195
|
@ -4,6 +4,7 @@
|
|||
"wall": "#",
|
||||
"rock": "X",
|
||||
"stone": "o",
|
||||
"pebble": "*",
|
||||
"player": "@",
|
||||
"ground": ".",
|
||||
"grass1": ",",
|
||||
|
|
|
@ -14,7 +14,7 @@ import getpass
|
|||
import client
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description="The client to Vamok World aka Project Doggo 2017. Run this to connect to to the server.", epilog="""
|
||||
parser = argparse.ArgumentParser(description="The client to Rooms. Run this to connect to to the server.", epilog="""
|
||||
Gameplay information:
|
||||
Control your player with the arrow keys or wasd. Press escape to exit.
|
||||
You can pick up something with the 'e' key, and drop whatever you're holding with 'q'.
|
||||
|
|
|
@ -42,18 +42,31 @@ class Stone(GameObject):
|
|||
attributes = {
|
||||
"takable",
|
||||
}
|
||||
ground = None
|
||||
|
||||
def place(self, ground):
|
||||
def take(self, other):
|
||||
self.remove()
|
||||
other.inventoryAdd(self)
|
||||
|
||||
def drop(self, other):
|
||||
other.inventoryRemove(self)
|
||||
self.place(other.getGround())
|
||||
|
||||
def getInteractions(self):
|
||||
interactions = {}
|
||||
if self.ground:
|
||||
self.ground.removeObj(self)
|
||||
ground.addObj(self)
|
||||
self.ground = ground
|
||||
|
||||
def remove(self):
|
||||
self.ground.removeObj(self)
|
||||
self.ground = None
|
||||
interactions["take"] = self.take
|
||||
else:
|
||||
interactions["drop"] = self.drop
|
||||
return interactions
|
||||
|
||||
|
||||
class Pebble(GameObject):
|
||||
|
||||
char = 'pebble'
|
||||
size = 0.2
|
||||
attributes = {
|
||||
"takable",
|
||||
}
|
||||
|
||||
def take(self, other):
|
||||
self.remove()
|
||||
|
@ -123,6 +136,7 @@ objectdict = {
|
|||
"tree": Tree,
|
||||
"player": playerent.Player,
|
||||
"stone": Stone,
|
||||
"pebble": Pebble,
|
||||
"rock": Rock,
|
||||
#"rabbit": Rabbit,
|
||||
"grass": Grass,
|
||||
|
|
|
@ -6,6 +6,7 @@ class GameObject:
|
|||
char = ''
|
||||
size = 0
|
||||
attributes = {}
|
||||
ground = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
pass
|
||||
|
@ -13,11 +14,24 @@ class GameObject:
|
|||
def getChar(self):
|
||||
return self.char
|
||||
|
||||
def place(self, ground):
|
||||
ground.addObj(self)
|
||||
|
||||
def getInteractions(self):
|
||||
return {}
|
||||
|
||||
def exists(self):
|
||||
return True
|
||||
def inRoom(self):
|
||||
return self.ground != None
|
||||
|
||||
def place(self, ground):
|
||||
if self.ground:
|
||||
self.ground.removeObj(self)
|
||||
ground.addObj(self)
|
||||
self.ground = ground
|
||||
|
||||
def remove(self):
|
||||
if self.ground:
|
||||
self.ground.removeObj(self)
|
||||
self.ground = None
|
||||
|
||||
|
||||
def getGround(self):
|
||||
return self.ground
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ class Player(GameObject):
|
|||
self.controller = {}
|
||||
self.room = room
|
||||
self.name = name or str(id(self))
|
||||
self.ground = None
|
||||
self.holding = None
|
||||
self.moveCooldown = 0
|
||||
room.addUpdateListener(self.update, self)
|
||||
|
@ -23,18 +22,12 @@ class Player(GameObject):
|
|||
def setController(self, controller):
|
||||
self.controller = controller
|
||||
|
||||
def place(self, ground):
|
||||
if self.ground:
|
||||
self.ground.removeObj(self)
|
||||
ground.addObj(self)
|
||||
self.ground = ground
|
||||
|
||||
|
||||
def update(self):
|
||||
self.moveCooldown = max(self.moveCooldown-1, 0)
|
||||
|
||||
if "action" in self.controller:
|
||||
action = self.controller["action"]
|
||||
del self.controller["action"]
|
||||
|
||||
if action in self.ground.getNeighbours() and self.moveCooldown <= 0:
|
||||
newPlace = self.ground.getNeighbours()[action]
|
||||
|
@ -44,7 +37,6 @@ class Player(GameObject):
|
|||
self.moveCooldown = self.slowness
|
||||
newPlace.onEnter(self)
|
||||
|
||||
del self.controller["action"]
|
||||
|
||||
def inventoryAdd(self, obj):
|
||||
if not self.holding:
|
||||
|
@ -86,15 +78,12 @@ class Player(GameObject):
|
|||
return items
|
||||
|
||||
def remove(self):
|
||||
self.ground.removeObj(self)
|
||||
super().remove()
|
||||
self.room.removeUpdateListener(self)
|
||||
|
||||
def getEvent(self):
|
||||
return self.event
|
||||
|
||||
def getGround(self):
|
||||
return self.ground
|
||||
|
||||
def getInventory(self):
|
||||
if self.holding:
|
||||
return [self.holding]
|
||||
|
|
|
@ -31,6 +31,8 @@ def generateBeginRoom():
|
|||
g.set(x, y, "water")
|
||||
|
||||
g.set(3, 8, ["grass", "stone"])
|
||||
g.set(4, 7, ["grass", "stone"])
|
||||
g.set(6, 8, ["grass", "pebble"])
|
||||
g.set(30, 20, {"type": "roomexit", "args": ["basement", "stairup"], "kwargs": {"char": "stairdown"}})
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user