public void LoadContent(ContentManager content, int width, int height) { AssetsManager.Instance.ContentManager = content; DeviceManager.Instance.Viewport = new Rectangle(0, 0, width, height); // Load textures AssetsManager.Instance.AddTextures("sprBg0", "sprBg1", "sprBtnPlay", "sprBtnPlayDown", "sprBtnPlayHover", "sprBtnRestart", "sprBtnRestartDown", "sprBtnRestartHover", "sprPlayer", "sprLaserPlayer", "sprLaserEnemy0", "sprExplosion", "sprEnemy0", "sprEnemy1", "sprEnemy2", "Explosion10", "Explosion50", "Fireball02"); // Load sounds AssetsManager.Instance.AddSounds("sndBtnDown", "sndBtnOver", "sndLaser", "sndExplode0", "sndExplode1"); // Load sprite fonts AssetsManager.Instance.AddSpriteFonts("arialHeading", "arialSmall", "arialTiny"); _font = AssetsManager.Instance.GetSpriteFont("arialTiny"); _scrollingBackground = new ScrollingBackground(new List <string> { "sprBg0", "sprBg1" }); _gameState = new MainMenuState(); _gameState.Enter(); _fps = new FramesPerSecondCounter(); _lblTest = new Label(_font, VerticalAlignment.Top, HorizontalAlignment.Left, new Vector2(0.0f, 0.0f), "Testing, testing, testing, 1, 2, 3...", Color.Cyan, 1.0f, 0.5f); _lblFps = new Label(_font, VerticalAlignment.Bottom, HorizontalAlignment.Right, DeviceManager.Instance.ScreenDimensions, "FPS: ", Color.Cyan) { TextShadow = true }; AssetsManager.Instance.AddAnimation("sprPlayer", AnimationSpecCreator.Create(AssetsManager.Instance.GetTexture("sprPlayer"), 16, 16, 160, true)); AssetsManager.Instance.AddAnimation("sprEnemy0", AnimationSpecCreator.Create(AssetsManager.Instance.GetTexture("sprEnemy0"), 16, 16, 160, true)); AssetsManager.Instance.AddAnimation("sprEnemy1", AnimationSpecCreator.Create(AssetsManager.Instance.GetTexture("sprEnemy1"), 16, 16, 160, true)); AssetsManager.Instance.AddAnimation("sprEnemy2", AnimationSpecCreator.Create(AssetsManager.Instance.GetTexture("sprEnemy2"), 16, 16, 160, true)); AssetsManager.Instance.AddAnimation("Fireball02", AnimationSpecCreator.Create(AssetsManager.Instance.GetTexture("Fireball02"), 128, 128, 20, false)); AssetsManager.Instance.AddAnimation("Explosion10", AnimationSpecCreator.Create(AssetsManager.Instance.GetTexture("Explosion10"), 256, 256, 20, false)); }
public DeiInTerra() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; fpsCounter = new FramesPerSecondCounter(60); fpsLocation = new Vector2((float)(9 / 10f) * (ScreenManager.Instance.Dimensions.X), (float)(1 / 20f) * ScreenManager.Instance.Dimensions.Y); }
//----------------------//------------------------// public virtual void LoadContent() { Content = new ContentManager(SceneManager.Instance.Content.ServiceProvider, "Content"); _fpsCounter = new FramesPerSecondCounter(); _debugFont = Content.Load <SpriteFont>("fonts/DebugFont"); DebugValues = new Dictionary <string, string>(); }
public FpsCounter(Vector2 position, SpriteFont font, Color color) { _position = position; _color = color; _font = font; _fps = new FramesPerSecondCounter(); }
protected override void Initialize() { _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 1024, 768); _camera = new Camera2D(_viewportAdapter); _mapRenderer = new TiledMapRenderer(GraphicsDevice); Window.AllowUserResizing = true; _fpsCounter = new FramesPerSecondCounter(); base.Initialize(); }
public override void Initialize() { _viewportAdapter = new DefaultViewportAdapter(GraphicsDevice); _camera = new Camera2D(_viewportAdapter); _mapRenderer = new TiledMapRenderer(GraphicsDevice); _fpsCounter = new FramesPerSecondCounter(); base.Initialize(); _players = new List <Client.Model.Player>(); SignalR(); }
public Engine(int width, int height, float windowScale = 1.0f, bool fullScreen = false, string debugFont = "font/04b03") { INSTANCE = this; Content.RootDirectory = "Content"; this.width = width; this.height = height; this.windowScale = windowScale; this.fullScreen = fullScreen; this.debugFontName = debugFont; graphics = new GraphicsDeviceManager(this); fpsCounter = new FramesPerSecondCounter(); Log.Debug("Engine started width=" + width + " height=" + height + " fixedTimeStep=" + IsFixedTimeStep); }
public override void Start() { base.Start(); GameRef.BGColor = Color.Red; //GUI _entitiestext = new Text(this, "entitestext", GameRef.Game.Content.Load<SpriteFont>(@"font"), "none", new Vector2(5, 5)); AddEntity(_entitiestext); _fpscounter = new FramesPerSecondCounter(this, "FPSCounter", GameRef.Game.Content.Load<SpriteFont>(@"font"), new Vector2(400, 400)); _fpscounter.Body.Position = new Vector2(GameRef.Viewport.Width - _fpscounter.TextRender.DrawRect.Width, GameRef.Viewport.Height - _fpscounter.TextRender.DrawRect.Height); AddEntity(_fpscounter); }
protected override void Initialize() { _renderingContext = new RenderingContext(GraphicsDevice); _viewportAdapter = new WindowViewportAdapter(Window, GraphicsDevice); _camera = new Camera2D(_viewportAdapter); var viewingVolume = new Rectangle(0, 0, _viewportAdapter.ViewportWidth, _viewportAdapter.ViewportHeight); _projection = Matrix.CreateOrthographicOffCenter(viewingVolume, 0, 100); _fpsCounter = new FramesPerSecondCounter(); Scene.State = SceneState.Enter; Scene.Enter(); base.Initialize(); }
protected override void Initialize() { _fpsCounter = new FramesPerSecondCounter(); _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _camera = new Camera2D(_viewportAdapter) { MinimumZoom = 0.1f, MaximumZoom = 2.0f, Zoom = 0.7833337f, Origin = new Vector2(400, 240), Position = new Vector2(408, 270) }; Window.AllowUserResizing = true; base.Initialize(); }
protected override void Initialize() { _fpsCounter = new FramesPerSecondCounter(); _viewportAdapter = new BoxingViewportAdapter(GraphicsDevice, 800, 480); _camera = new Camera2D(_viewportAdapter) { MinimumZoom = 0.5f, MaximumZoom = 2.0f, Zoom = 0.5f, Origin = new Vector2(400, 240), Position = new Vector2(408, 270) }; Window.AllowUserResizing = true; Window.ClientSizeChanged += (s, e) => _viewportAdapter.OnClientSizeChanged(); base.Initialize(); }
/// <summary> /// Initializes a new instance of the <see cref="T:MB2D.MBGame"/> class and /// defines essential graphics settings. /// </summary> public MBGame(Type initSceneType) { _graphics = new GraphicsDeviceManager(this); _scenes = new SceneStack(); // main scene stack _gameObjects = new EntityMap(); _fps = new FramesPerSecondCounter(); _textHandler = new TextInputHandler(); _lastInput = string.Empty; _initScene = initSceneType; ForceQuit = false; Content.RootDirectory = "Content"; // 720p _graphics.PreferredBackBufferWidth = 1280; _graphics.PreferredBackBufferHeight = 720; _graphics.ApplyChanges(); }
public AlienGame() { _graphics = new GraphicsDeviceManager(this); Graphics = _graphics.GraphicsDevice; ScreenWidth = _graphics.PreferredBackBufferWidth; ScreenHeight = _graphics.PreferredBackBufferHeight; _frames = new FramesPerSecondCounter(); Random = new Random(); Content.RootDirectory = "Content"; IsMouseVisible = true; IsFixedTimeStep = false; KeyboardInput.Initialize(this, 500f, 20); _screenManager = new ScreenManager(); Components.Add(_screenManager); _sceneManager = new SceneManager(_screenManager, this); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { _frameCounter = new FramesPerSecondCounter(); GSM = new GameStateManager(); socket = new Sockets(); viewport = new ScalingViewportAdapter(graphics.GraphicsDevice, 800, 480); camera = new Camera2D(viewport) { MinimumZoom = 0.1f, MaximumZoom = 2.0f, Zoom = 1.0f, Origin = new Vector2(400, 240), Position = new Vector2(408, 270) }; Window.AllowUserResizing = true; GSM.PushState(new GameState(GSM, camera)); while (true) { if (socket.message == null) { continue; } else { PlayerPosition = new Vector2((int)socket.message["X"] * 32, (int)socket.message["Y"] * 32); camera.LookAt(PlayerPosition); Sockets.token = (string)socket.message["Token"]; break; } } base.Initialize(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { fps = new MonoGame.Extended.FramesPerSecondCounter(); IsMouseVisible = false; // avoids doubled mouse pointer base.Initialize(); }
public FpsRenderAble(ContentManager content) { fps_counter = new FramesPerSecondCounter(); bitmapFont = AssetLoader.LoadFont(content, "montserrat-32"); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { fps = new MonoGame.Extended.FramesPerSecondCounter(); base.Initialize(); }
public FPS(string text, Color color, Vector2 position) : base(text, color, position) { this.fpsCounter = new FramesPerSecondCounter(); this.fpsTimer = new ContinuousClock(1); this.fpsTimer.Start(); }
public void LoadContent(ContentManager content) { _fps = new FramesPerSecondCounter(); Controls.LoadContent(content, true); }
static void Main(string[] args) { StartSetupScreen(); var world = new World(); LevelOne levelOne = new LevelOne(); var fpsCounter = new FramesPerSecondCounter(world); var fpsWriter = new FpsRenderer(world); MapLevelDetails map = new MapLevelDetails(25, 11); // initialize map world.Set(map); MapRenderer mapRenderer = new MapRenderer(world); Queue <string> playerMessageQueue = new Queue <string>(2); world.Set(playerMessageQueue); MessageBoxRenderer messageBoxRenderer = new MessageBoxRenderer(world); HealthComponent health = new HealthComponent() { Health = new RegenerateAttribute() { Current = 27, Max = 40, Name = "Health", RegenRatePerSecond = 0.5 } }; ManaComponent mana = new ManaComponent() { Mana = new RegenerateAttribute() { Current = 25, Max = 30, Name = "Mana", RegenRatePerSecond = 0.2 } }; ExperienceBar xpBar = new ExperienceBar(); PlayerStats playerStats = new PlayerStats("Dave", health, mana, xpBar); world.Set(playerStats); ConsoleInputSystem playerInput = new ConsoleInputSystem(world); PlayerMovementSystem playerMovementSystem = new PlayerMovementSystem(world); PlayerRenderSystem player = new PlayerRenderSystem(world); PlayerPosition playerStartPosition = new PlayerPosition(map, world); //initialize player playerStartPosition.MoveTo(27); world.Set(playerStartPosition); MonsterMoveController[] monsters = levelOne.CreateMonsters(world, map); //initialize monsters world.Set(monsters); MonsterMovementSystem monsterMovement = new MonsterMovementSystem(world); MonsterRenderSystem monstersRenderer = new MonsterRenderSystem(world); List <string> combatMessagesQueue = new List <string>(3); world.Set(combatMessagesQueue); CombatHandler combatHandler = new CombatHandler(world); world.Set(combatHandler); CombatMessages combatMessages = new CombatMessages(world); var updateSystems = new IUpdate[] { playerInput, playerMovementSystem, combatHandler, monsterMovement, fpsCounter, health, mana }; //Order is important! var renderSystems = new IRender[] { player, monstersRenderer, mapRenderer, messageBoxRenderer, combatMessages, fpsCounter, fpsWriter, health, mana, xpBar }; GameEngine gameEngine = new GameEngine(updateSystems, renderSystems, player, monstersRenderer); mapRenderer.PrintMap(map.Map); gameEngine.Start(); }