Example #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)
Example #2
0
 def DisplayVideoInfo():
     vi = pygame.display.Info()
     Log.Message("Hardware Acceleration: " +
                 ("yes" if vi.hw else "no (TODO)"))
     Log.Message((
         "Video Memory: " +
         (str(vi.wm) + "Mb" if vi.wm else "unknown")) if vi.hw else "")
     Log.Message("Width: " + str(vi.current_w) + " Height: " +
                 str(vi.current_h))
Example #3
0
 def AddMaterial(filepath):
     Log.Message("Loading material " + filepath)
     try:
         try:
             blahblahblah = MatSys.materials[filepath]
         except KeyError:
             MatSys.materials[filepath] = pygame.image.load(
                 os.path.join(os.path.dirname(__file__), filepath))
     except pygame.error:
         Log.Error("Material " + filepath + " not found!!")
         MatSys.materials[filepath] = pygame.image.load(
             os.path.join(os.path.dirname(__file__), "data/error.tga"))
Example #4
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)
Example #5
0
	def CollisionCheck(me, hp = 50, selfdestroy = False, countplayer = False):
		me_rect = MatSys.GetMaterial(me.texture).get_rect()
		me_x = me.position.x
		me_y = me.position.y
		me_w = me_rect.right
		me_h = me_rect.bottom
		for ent in EntitySystem.entities:
			if not ent == me.name:
				if ent == "background" or (ent == "player" and (not countplayer)) or "PhotonTorpedo" in ent:
					pass
				else:
					entity = EntitySystem.entities[ent]
					if entity.texture:
						mat = MatSys.GetMaterial(entity.texture)
						mat_w = mat.get_width()
						mat_h = mat.get_height()
						if not ((me_y + me_h <= entity.position.y) or (me_y >= entity.position.y + mat_h) or (me_x >= entity.position.x + mat_w) or (me_x + me_w <= entity.position.x)): 
							Log.Message("Collision between " + str(me.name) + " and " + str(ent))
							if countplayer: me.hurt(hp) 
							else: entity.hurt(hp)
							if selfdestroy: EntitySystem.RemoveEntity(me.name)
Example #6
0
def PyGame_Event_Stub_Verbose(event, engine):
    Log.Message("Stub event: " + str(pygame.event.event_name(event.type)))
Example #7
0
 def Init():
     Log.Message("Material system started")