本文整理汇总了Python中Game.Game.start方法的典型用法代码示例。如果您正苦于以下问题:Python Game.start方法的具体用法?Python Game.start怎么用?Python Game.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game.Game
的用法示例。
在下文中一共展示了Game.start方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Main
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import start [as 别名]
def Main(stdscr):
args = Arguments(sys.argv)
mineFieldWidth, mineFieldHeight, numMines, mode = args.parse()
game = Game(stdscr, mineFieldWidth, mineFieldHeight, numMines)
game.start()
while True:
event = stdscr.getch()
my, mx = 0, 0
if event == curses.KEY_MOUSE:
_, mx, my, _, bstate = curses.getmouse()
if bstate & curses.BUTTON1_PRESSED :
if game.poke(my, mx) == "dead":
game.gameLose()
elif bstate & curses.BUTTON3_PRESSED:
game.flag(my, mx)
maxy, maxx = stdscr.getmaxyx()
if game.checkWin():
game.gameWin()
if event == ord("q") or (mx >= maxx - 9 and mx <= maxx - 4 and my == maxy - 2):
game.exit()
if event == ord("R") or (mx >= 39 and mx <= 47 and my == maxy - 2):
game.displayRecord()
if event == ord("c") or (mx >= 14 and mx <= 21 and my == maxy - 2):
game.resume()
if event == ord("p") or (mx >= 3 and mx <= 9 and my == maxy - 2):
game.pause()
if event == ord("r") or (mx >= 26 and mx <= 34 and my == maxy - 2):
game.restart()
示例2: start
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import start [as 别名]
def start():
os.system('clear');
print 'dope wars py'
name = raw_input('what\'s your name?\n')
game = Game(name, locationNames, cash, products, days)
game.start()
示例3: main
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import start [as 别名]
def main():
game = Game()
game.start()
示例4: tsaap
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import start [as 别名]
################################################################################
#
# tsaap (two ships and a planet)
#
# Authors: Vesa Nieminen, Miika Vihersaari
#
################################################################################
from Game import Game
if __name__ == "__main__":
game = Game()
game.start()
game.run()
示例5: beast_arena
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import start [as 别名]
class beast_arena(threading.Thread):
"""
main module where everything happens
"""
def __init__(self):
"""
basic constructor
"""
threading.Thread.__init__(self)
self.urwid = None
self.gamecount = 1
self.game = None
self.running = False
self.server = None
self.winners = GameWinners()
self.useUrwid = Config.__getUseUrwidVisualisation__()
self.useNetworking = Config.__getUseNetworking__()
self.log = logging.getLogger("beast-arena-logging")
def runUrwid(self):
"""
runs all urwid loops.
should be called after run() is started as program will stay in urwid main loop
till finished
"""
while not self.game:
time.sleep(0.05)
self.urwid = UrwidVisualisation(self.game)
# update content Loop:
self.urwid.start()
# main urwid loop:
self.urwid.runLoop()
def stop(self):
"""
stops run() method by setting running=False
"""
self.running = False
def setupLogging(self):
"""
initial setup of python built-in logging module
"""
self.log.setLevel(logging.INFO)
# adding streamHandler with console as target if no gui is enabled
if not self.useUrwid:
streamHandler = logging.StreamHandler(sys.stdout)
streamHandler.setLevel(logging.INFO)
self.log.addHandler(streamHandler)
if not os.path.exists("log"):
os.makedirs("log")
fileHandler = logging.FileHandler("log/beast-arena.log")
fileHandler.setLevel(logging.WARNING)
self.log.addHandler(fileHandler)
def run(self):
"""
main-method of Game.py
if networking is enabled the first part will be proceeded
"""
self.running = True
self.setupLogging()
while self.running:
self.game = Game()
if self.useUrwid:
while not self.urwid:
time.sleep(0.1)
self.urwid.changeGame(self.game)
# loop for enabled networking
if self.useNetworking:
# first time server initialisation
if self.server == None:
self.server = Server(self.game)
self.game.server = self.server
self.game.server.start()
# for all games following first one
self.game.server = self.server
self.server.game = self.game
self.log.info("Game start will be: " + str(self.game.startTime))
while self.running:
if time.time() >= self.game.startTimeMillis and not (self.game.gameStarted):
if len(self.game.beastObjectMap) > 0:
self.log.info(
"Starting Game No. %s (" + str(self.game.startTime) + ")...", str(self.gamecount)
)
self.game.start()
self.gamecount += 1
else:
self.log.info(
"Canceled start of scheduled Game ("
+ str(self.game.startTime)
#.........这里部分代码省略.........
示例6: TestGame
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import start [as 别名]
class TestGame(TestCase):
def setUp(self):
self.game = Game()
def tearDown(self):
ships = self.game.getShips()
if ships != None:
for ship in ships:
# TODO: Find out why removeNode does not work here
#ship.visualNode.removeNode()
ship.visualNode.detachNode()
ship = None
def testInit(self):
self.failUnless(self.game)
self.failUnlessEqual(self.game.state, Game.STATE_INITIALIZING)
self.failUnless( self.game.windowExists() )
self.failIf( self.game.getShips() )
self.failUnless(self.game.physWorld)
self.failUnless(self.game.physSpace)
def testStart(self):
self.game.start()
self.failUnlessEqual(self.game.state, Game.STATE_RUNNING)
ships = self.game.getShips()
shipOne = ships[0]
shipTwo = ships[1]
self.failUnless( isinstance(ships, list) )
self.failUnlessEqual( shipOne.name, Game.NAME_SHIP_ONE )
self.failUnlessEqual( shipTwo.name, Game.NAME_SHIP_TWO )
self.failUnless(shipOne.getVisualNode)
self.failUnless(shipTwo.getVisualNode)
self.failUnless( shipOne.isVisible() )
self.failUnless( shipTwo.isVisible() )
players = self.game.getPlayers()
self.failUnless( isinstance(players, list) )
playerOne = players[0]
playerTwo = players[1]
self.failUnlessEqual( playerOne.name, Game.NAME_PLAYER_ONE )
self.failUnlessEqual( playerTwo.name, Game.NAME_PLAYER_TWO )
# Test that the player can move the ship forward
pos1 = shipOne.getPos()
vel1 = shipOne.getVel()
acc1 = shipOne.getAcc()
playerOne.moveForwardOn()
# Step Panda3D's task manager one tick forward
taskMgr.step()
pos2 = shipOne.getPos()
vel2 = shipOne.getVel()
acc2 = shipOne.getAcc()
self.failIf(pos1 == pos2)
self.failIf(vel1 == vel2)
self.failIf(acc1 == acc2)
# Make sure the game is listening to events
self.failUnless(self.game.isListening)
def testResetCamera(self):
self.game.resetCamera()
# Check that the camera has been moved to the correct position
cameraPos = self.game.getCameraPos()
defaultCameraPos = Game.CAMERA_POS_DEFAULT
self.failUnless(cameraPos == defaultCameraPos)
def testSetCameraPos(self):
pos = (0, 0, 50)
self.game.setCameraPos( pos )
self.failUnless( self.game.getCameraPos() == pos )
def testGetCameraPos(self):
pos = self.game.getCameraPos()
self.failUnless(pos)
self.failUnless( isinstance(pos, tuple) )
def testSetCameraHpr(self):
self.game.setCameraHpr(Game.CAMERA_HPR_DEFAULT)
hpr = self.game.getCameraHpr()
self.failUnless(hpr == Game.CAMERA_HPR_DEFAULT)
def testGetCameraHpr(self):
hpr = self.game.getCameraHpr()
self.failUnless(hpr)
self.failUnless( isinstance(hpr, tuple) )
def testRegisterListeners(self):
self.game.start()
players = self.game.getPlayers()
playerOne = players[0]
self.game.registerListeners()
playerOneMoveForwardOnEvent = createNamedEvent(
playerOne.name, Event.PLAYER_MOVE_FORWARD_ON
)
ships = self.game.getShips()
shipOne = ships[0]
shipTwo = ships[1]
# Test that the player can move the ship forward
pos1 = shipOne.getPos()
#.........这里部分代码省略.........
示例7: Game
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import start [as 别名]
'''
Created on Oct 1, 2015
# jared is white
@author: Jared, Ethan
'''
from Game import Game
import time
if __name__ == '__main__':
my_game = Game()
my_game.start()
while my_game.in_play == True:
my_game.travel()
if my_game.map.current_space.lower() == 'c':
my_game.city()
if my_game.map.current_space.lower() == 'd':
my_game.dungeon()
if my_game.map.current_space.lower() =='m':
my_game.fight(False)
my_game.map.monsterdeath()
if my_game.map.current_space.lower() =="b":
my_game.fight(True)
my_game.map.monsterdeath()
if my_game.map.current_space.lower() == 'x':
my_game.exit_dungeon()
if my_game.map.current_space.lower() == 't':
my_game.found_treasure()
示例8: Room
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import start [as 别名]
Restroom.exits["west"] = "cellar"
Outside = Room("the Outside")
OutsideDefault = Object("default",[Action("look","You enjoy the sunlight and fresh wind. There is a path to the [west]. There's also an old butler named [Geoffrey] standing here. Ask him about the [weather].")])
Outside.addObject(OutsideDefault)
Outside.exits["north"] = "cellar"
Geoffrey = Person("Geoffrey")
Geoffrey.addTopic(Topic("path","Yeah, that old path leads to the village."))
Geoffrey.addTopic(Topic("toothpaste","Oh? You used the toothpaste to melt the window bars? How ingenious! Where are you going now?"))
Geoffrey.addTopic(Topic("weather","Well, it's a splendid day I'd say! How did you get out of the cellar?"))
Outside.addPerson(Geoffrey)
Game = Game()
Game.inventory = Inventory()
Game.addRoom(Cellar,"cellar");
Game.addRoom(Restroom,"restroom");
Game.addRoom(Outside,"outside");
## Starting Room
StartRoom = "cellar"
if len(sys.argv) > 1 and sys.argv[1] in Game.rooms:
StartRoom = sys.argv[1]
else:
exit("Fatal: Not a valid room.")
Game.start(StartRoom)
示例9: main
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import start [as 别名]
def main():
reader = MapReader()
gamemap, pacman = reader.read('gamemap.txt')
g = Game(gamemap, pacman)
g.start()