コード例 #1
0
ファイル: Stage.cs プロジェクト: Jessebeau2001/FinalApproach
        public Stage() : base()
        {
            Map leveldata = MapParser.ReadMap(mapPath);

            background = new Sprite("textures/" + leveldata.ImageLayers[0].Image.FileName, false, false);
            SpawnColliders(leveldata, true);

            playerHUD = new HUDOverlay(player, _itemList);
            player    = new Player(930, 930, _itemList, playerHUD, this);

            AddChild(background);               //seperated the addChildren so we can set what renders on top of what -Jesse
            foreach (Pickup item in _itemList)
            {
                AddChild(item);
            }
            foreach (ColBox box in boundigBox)
            {
                AddChild(box);
            }
            foreach (NPC enemy in enemies)
            {
                AddChild(enemy);
            }
            AddChild(player);
            AddChild(playerHUD);
            AddChild(winMark);
        }
コード例 #2
0
        int frame = 0;         //For some reason when loading via menu player instantly collides with NPC soo hardcoded this weird bs -Jesse

        public Player(float x, float y, Pickup[] itemList, HUDOverlay playerHUD, Stage stage, bool showBounds = false) : base(100, 20)
        {
            this.itemList = itemList;

            _position.x = x;
            _position.y = y;
            x           = _position.x;
            y           = _position.y;

            playerSprite.SetOrigin(0, playerSprite.height);
            scaleFactor        = (width * 1f) / (playerSprite.width * 1f);
            playerSprite.scale = scaleFactor;              //calculating and setting a scaling so that the player width will always be 100 pixels
            playerSprite.y    += height;
            AddChild(playerSprite);
            ShapeAlign(CenterMode.Min, CenterMode.Min);
            NoFill();
            Stroke(245, 66, 66);
            if (showBounds)
            {
                Rect(0, 0, width - 1, height - 1);
            }

            this.playerHUD = playerHUD;
        }