Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- namespace EngineTest.MacOS
- {
- public class Game1 : Game
- {
- GraphicsDeviceManager graphics;
- SpriteBatch spriteBatch;
- private List<Entity> _entities;
- public Game1()
- {
- graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- graphics.IsFullScreen = false;
- graphics.PreferredBackBufferHeight = 720;
- graphics.PreferredBackBufferWidth = 1280;
- }
- protected override void Initialize()
- {
- base.Initialize();
- }
- protected override void LoadContent()
- {
- spriteBatch = new SpriteBatch(GraphicsDevice);
- var playerTexture = Content.Load<Texture2D>("box");
- var blockTexture = Content.Load<Texture2D>("Block");
- var font = Content.Load<SpriteFont>("font");
- _entities = new List<Entity>()
- {
- new Player(playerTexture)
- {
- Position = new Vector2(100, 200),
- },
- new Block(blockTexture)
- {
- Position = new Vector2(120, 384),
- },
- new Block(blockTexture)
- {
- Position = new Vector2(120, 368),
- },
- new Block(blockTexture)
- {
- Position = new Vector2(120, 352),
- },
- new Block(blockTexture)
- {
- Position = new Vector2(120, 336),
- },
- };
- for (var i = 0f; i < 1280/16f; i++)
- {
- _entities.Add(
- new Block(blockTexture)
- {
- Position = new Vector2(i*16, 400),
- }
- );
- }
- }
- protected override void Update(GameTime gameTime)
- {
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
- Exit();
- foreach (var entity in _entities)
- entity.Update(gameTime, _entities);
- base.Update(gameTime);
- }
- protected override void Draw(GameTime gameTime)
- {
- graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
- spriteBatch.Begin();
- foreach (var entity in _entities)
- entity.Draw(spriteBatch);
- spriteBatch.End();
- base.Draw(gameTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement