Example #1
0
        internal static void Initialize()
        {
            Keyboard = new KeyboardInput();
            Gamepad  = new GamepadInput(PlayerIndex.One);

            FeLog.FerretInfo("FerretInput initialized!");
        }
Example #2
0
        public void SetVirtualResolution(int vWidth, int vHeight)
        {
            FeLog.FerretWarning($"Setting virtual resolution: {vWidth}x{vHeight}");

            _VWidth  = vWidth;
            _VHeight = vHeight;

            _dirtyMatrix = true;
        }
Example #3
0
        private void ApplyResolutionToGraphicsDevice()
        {
            FeLog.FerretInfo($"Applying resolution settings. Preferred Back Buffer Size: {_width}x{_height}. Fullscreen: {_fullscreen}.");

            _graphicsDevice.PreferredBackBufferWidth  = _width;
            _graphicsDevice.PreferredBackBufferHeight = _height;
            _graphicsDevice.IsFullScreen        = _fullscreen;
            _graphicsDevice.PreferMultiSampling = true;
            _graphicsDevice.ApplyChanges();
        }
Example #4
0
        public PlayerEntity()
        {
            Sprite[] sprites = FeContent.LoadSpriteSheet("character/charAtlas.feAsset");

            Animation           anim  = new Animation(sprites, "walk", .1f);
            AnimationController contr = new AnimationController(anim);

            Renderer          = new SpriteRenderer(sprites[0]);
            Renderer.Material = new Material(SandboxGame.TestEffect);

            AnimationComponent animComponent = new AnimationComponent(Renderer, contr);

            Bind(Renderer);
            Bind(animComponent);



            BoxCollider col = new BoxCollider(sprites[0].Width, sprites[0].Height, Vector2.Zero);

            Bind(col);

            col.OnCollisionEnter += o => FeLog.Debug($"PLAYER ENTER: {this}");
            col.OnCollisionExit  += o => FeLog.Debug($"PLAYER EXIT: {this}");


            ParticleType partType = new ParticleType(FeContent.LoadSprite("box.png"))
            {
                Lifetime       = ParticleLifetime.RandomRange(0.5f, 1f),
                StartAngle     = ParticleAngle.RandomRange(0, 360),
                StartSpeed     = ParticleSpeed.RandomRange(-2f, 2f),
                StartDirection = ParticleDirection.RandomRange(0, 360)
            };

            ParticleEmitter emitter = new ParticleEmitter(partType)
            {
                AutoEmit       = true,
                BurstCunt      = 5,
                EmitDelay      = 3,
                BurstSteps     = 8,
                BurstStepDelay = .1f
            };

            Bind(emitter);



            Bind(new PlayerComponent());
            //Bind(new PlayerComponentGamepad());
        }
Example #5
0
        public static Effect LoadEffect(string path)
        {
            try
            {
                path = CheckFilename(path, ".fxb");
            }
            catch (Exception e)
            {
                FeLog.FerretError($"Loading effect '{path}' resulted on an exception:\n{e}");
                path = CheckFilename("Ferret/Effects/error.fxb", ".fxb");
            }

            byte[] bytes = GetFileResourceBytes(path);
            return(new Effect(FeGame.Instance.GraphicsDevice, bytes));
        }
Example #6
0
        internal static void LoadContent()
        {
            _graphicsDevice = _game.GraphicsDevice;

            _spriteBatch = new SpriteBatch(_game.GraphicsDevice);

            FeLog.FerretDebug($"Creating Render Target. Size = {Resolution.WindowWidth}x{Resolution.WindowHeight}");
            _renderTarget = new RenderTarget2D(GraphicsDevice, Resolution.WindowWidth, Resolution.WindowHeight);

            _currentMaterial = Material.Default;
            Materials        = new MaterialLibrary();

            Pixel       = Sprite.PlainColor(1, 1, Color.White);
            DefaultFont = FeContent.LoadFont("Ferret/Fonts/MatchupPro.ttf", 12);

            FeDraw.Font  = DefaultFont;
            FeDraw.Color = Color.White;
        }
Example #7
0
        public ResolutionManager(GraphicsDeviceManager graphicsDevice, int vWidth, int vHeight, int windowWidth, int windowHeight, bool fullscreen)
        {
            FeLog.FerretInfo("Initializing Resolution Manager.");

            StringBuilder str = new StringBuilder();

            str.Append("Available resolutions: ");
            foreach (DisplayMode dm in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
            {
                str.Append($"{dm.Width}x{dm.Height} ");
            }

            FeLog.FerretInfo(str.ToString());

            _graphicsDevice = graphicsDevice;
            SetVirtualResolution(vWidth, vHeight);
            SetResolution(windowWidth, windowHeight, fullscreen);
        }
Example #8
0
        public SpriteSheet(Texture2D texture, int spriteWidth, int spriteHeight,
                           int offsetX, int offsetY, int beginX, int beginY)
        {
            Texture      = texture;
            SpriteWidth  = spriteWidth;
            SpriteHeight = spriteHeight;
            OffsetX      = offsetX;
            OffsetY      = offsetY;
            BeginX       = beginX;
            BeginY       = beginY;

            _textureWidth  = texture.Width;
            _textureHeight = texture.Height;

            _spritesWide = (_textureWidth - beginX) / (spriteWidth + offsetX) + 1;
            _spritesHigh = (_textureHeight - beginY) / (spriteHeight + offsetY) + 1;

            FeLog.FerretWarning($"SpriteSheet created [{_spritesWide}x{_spritesHigh}]");
        }
Example #9
0
        public BoxEntity(Material mat = null)
        {
            if (mat == null)
            {
                mat = Material.Default;
            }

            Sprite sprite = FeContent.LoadSprite("box.png");

            Bind(new SpriteRenderer(sprite)
            {
                Material = mat
            });


            for (int i = 0; i < 8; i++)
            {
                Texture2D tex = new Texture2D(FeGraphics.GraphicsDevice, 24, 24);

                Color[] colors = new Color[24 * 24];
                for (int j = 0; j < 24 * 24; j++)
                {
                    colors[j] = new Color(255, 255, 255, i * 32);
                }
                tex.SetData(colors);

                Bind(new SpriteRenderer(new Sprite(tex))
                {
                    LocalPosition = new Vector2((i + 1) * 32, 0)
                });
            }



            BoxCollider col = new BoxCollider(sprite.Width, sprite.Height, Vector2.Zero);

            Bind(col);

            col.OnCollisionEnter += o => FeLog.Debug($"BOX ENTER: {this}");
            col.OnCollisionExit  += o => FeLog.Debug($"BOX EXIT: {this}");
        }
Example #10
0
 public override void Begin()
 {
     base.Begin();
     FeLog.Info("Test scene entered!");
 }
Example #11
0
 public void SetResolution(int width, int height, bool fullScreen)
 {
     FeLog.FerretWarning($"Setting resolution: {width}x{height}. Fullscreen: {fullScreen}.");
     SetResolutionImpl(width, height, fullScreen);
 }