Example #1
0
        public World(Level level)
        {
            m_level = level;
            m_camera = new Camera();
            m_player = new Player();
            m_background = new Background(m_camera);

            m_camera.Bounds = new Box2(0, 0, m_level.Map.Size.X, Math.Max(1000, m_level.Map.Size.Y));
            m_camera.Target = m_player;

            Player.SetPosition(new Vector2(0, 350));

            var random = new Random();

            for (var i = 0; i < 50; i++)
            {
                var slime = new Slime();
                slime.SetPosition(new Vector2((float)random.Next(0, (int)m_level.Map.Size.X),
                    (float)random.Next(0, (int)m_level.Map.Size.Y)));
                slime.SetTarget(Player);
                EnnemyManager.Instance.AddEnnemy(slime);
            }

            s_instance = this;
        }
Example #2
0
        public Background(Camera camera)
        {
            m_camera = camera;

            m_backgroundTexture_01 = Texture2D.Load(typeof(Background).Assembly.GetManifestResourceStream("Test.Game_01.Textures.Background_01.png"));
            m_backgroundSheet_01 = new SpriteSheet(m_backgroundTexture_01);
            m_backgroundSprite_01 = m_backgroundSheet_01.AddSprite("", new Box2i(Vector2i.Zero, m_backgroundTexture_01.Size));
            m_backgroundRenderer_01 = new SpriteRenderer(m_backgroundSheet_01);
            m_backgroundInstance_01 = m_backgroundRenderer_01.AddSprite(m_backgroundSprite_01);

            m_backgroundTexture_02 = Texture2D.Load(typeof(Background).Assembly.GetManifestResourceStream("Test.Game_01.Textures.Background_02.png"));
            m_backgroundSheet_02 = new SpriteSheet(m_backgroundTexture_02);
            m_backgroundSprite_02 = m_backgroundSheet_02.AddSprite("", new Box2i(Vector2i.Zero, m_backgroundTexture_02.Size));
            m_backgroundRenderer_02 = new SpriteRenderer(m_backgroundSheet_02);
            m_backgroundInstance_02_First = m_backgroundRenderer_02.AddSprite(m_backgroundSprite_02);
            m_backgroundInstance_02_Second = m_backgroundRenderer_02.AddSprite(m_backgroundSprite_02);
        }