Exemplo n.º 1
0
 def Init():
     Log.Message("Engine init")
     try:
         config = json.loads(
             open(os.path.join(os.path.dirname(__file__), "game.cfg"),
                  "r").read())
         Engine.properties["screen"] = (config["resolution"][0],
                                        config["resolution"][1])
         Engine.properties["title"] = config["title"]
     except IOError:
         Engine.properties["screen"] = (1024, 768)
         Engine.properties["title"] = "7444"
     pygame.init()
     Engine.properties["lastframe"] = time.time()
     if not pygame.font: Log.Warning("Warning, font disabled")
     if not pygame.mixer: Log.Warning("Warning, sound disabled")
     Engine.properties["display"] = Engine.CreateWindow(
         Engine.properties["screen"])
     Engine.DisplayVideoInfo()
     Engine.SetCaption(Engine.properties["title"])
     MatSys.Init()
     Engine.LoadSounds()
     HUD.Init(Engine)
     #Add required entities
     EntSys.AddEntity(Player, "player", Vector2D(200, 200))
     EntSys.AddEntity(Camera, "camera")
     EntSys.AddEntity(Background, "background", Vector2D(-480, -270))
     KeysGuide.Load()
     Engine.properties["font"] = pygame.font.Font(
         "data/fonts/newscycle-regular.ttf", 18)
     Log.Message("Entering loop")
     SfxSys.Play("data/sfx/the_final_frontier.wav", True)
Exemplo n.º 2
0
 def GetMaterial(filepath):
     try:
         return MatSys.materials[filepath]
     except KeyError:
         Log.Warning("Material " + filepath + " is not loaded")
         MatSys.AddMaterial(filepath)
         return MatSys.materials[filepath]
Exemplo n.º 3
0
	def AddEntity(entity, name = None, position = Vector2D(0,0), physics = False, engine = None):
		nname = None
		if EntitySystem.draw_over:
			nname = name if name else str(entity).split('.')[1] + str(random.randint(0, 4563564575785745))
			Log.Message("Spawning entity " + str(entity) + " with name " + str(nname))
			ent = entity()
			ent.name = nname
			ent.load(engine, position)
			ent.set_pos(position)
			EntitySystem.entities[nname] = ent
			return EntitySystem.EntityByName(nname)
		else:
			Log.Warning("Think or draw is not over, adding to queue")
			EntitySystem.spawnqueue[nname] = (entity, nname, position)