public override void LoadContent() { _debug = new DebugViewXNA(_world); _debug.LoadContent(ScreenManager.GraphicsDevice, ScreenManager.Content); _debug.AppendFlags(FarseerPhysics.DebugViewFlags.Shape); _debug.AppendFlags(FarseerPhysics.DebugViewFlags.PolygonPoints); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load <SpriteFont>("font"); cursor = new SpriteSheet("cursor"); cursor.LoadTexture(Content, 1, 1); cursor.SetScale(2f); cursor.SetCurrentSprite(0, 0); movePointer = new SpriteAnimation("movepointer", Content, 8, 1); movePointer.SetScale(1f); for (int i = 0; i < 8; i++) { movePointer.AddFrame(i, 0, 50); } if (DebugView == null) { DebugView = new DebugViewXNA(Physics.World); DebugView.AppendFlags(DebugViewFlags.DebugPanel); DebugView.AppendFlags(DebugViewFlags.PerformanceGraph); DebugView.DefaultShapeColor = Color.White; DebugView.SleepingShapeColor = Color.Red; DebugView.LoadContent(GraphicsDevice, Content); } }
public override void StartFrame() { if (!m_debugView.Loaded && Engine.Renderer != null) { m_debugView.LoadContent(Engine.Renderer.Device, Engine.AssetManager.ContentManager); m_debugView.AppendFlags(FarseerPhysics.DebugViewFlags.CenterOfMass); m_debugView.AppendFlags(FarseerPhysics.DebugViewFlags.PolygonPoints); m_debugView.AppendFlags(FarseerPhysics.DebugViewFlags.ContactPoints); m_debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Shape); Engine.Renderer.RenderLayers["DebugPhysicsOverlay"].Renderables.Add(this); } float timeCoef = Engine.Debug.EditSingle("TimeCoef", 0.85f); Engine.World.UpdatePrePhysics(); m_world.Step(Engine.GameTime.ElapsedMS * 0.001f * timeCoef); //fix rigidBody foreach (var go in Engine.World.GameObjects) { if (go.RigidBodyCmp != null) { go.RigidBodyCmp.UpdateGameObjectPosition(); } } Engine.World.UpdatePostPhysics(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); if (world == null) { world = new World(new Vector2(0, 9.82f)); } else { world.Clear(); } this.IsMouseVisible = true; lvlBuilder = new LevelBuilder(Content, world); lvlBuilder.readLevel("level1.txt"); backgroundTexture = Content.Load <Texture2D>("cornflowerback"); objectList = lvlBuilder.getLevelObjects(); //FarseerPhysics.Collision font = Content.Load <SpriteFont>("font"); debugView = new DebugViewXNA(world); debugView.LoadContent(this.GraphicsDevice, this.Content); debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Shape); debugView.AppendFlags(FarseerPhysics.DebugViewFlags.PolygonPoints); //debugView.AppendFlags(FarseerPhysics.DebugViewFlags.DebugPanel); debugView.AppendFlags(FarseerPhysics.DebugViewFlags.CenterOfMass); // TODO: use this.Content to load your game content here }
//TODO: debugview in eiegene componente auslagern public WorldManager() { this.WorldStep = 30f; this.IsEnabled = true; this.EntitiesInRange = new List <Entity>(); this.World = new World(Vector2.Zero); #if DEBUG debug = new DebugViewXNA(this.World); debug.DefaultShapeColor = Color.White; debug.SleepingShapeColor = Color.LightGray; // debug.AppendFlags(DebugViewFlags.PerformanceGraph); // debug.AppendFlags(DebugViewFlags.DebugPanel); debug.AppendFlags(DebugViewFlags.ContactPoints); // debug.AppendFlags(DebugViewFlags.ContactNormals); // debug.AppendFlags(DebugViewFlags.PolygonPoints); debug.AppendFlags(DebugViewFlags.Controllers); debug.AppendFlags(DebugViewFlags.CenterOfMass); debug.AppendFlags(DebugViewFlags.AABB); debug.RemoveFlags(DebugViewFlags.Joint); #endif }
private void TryInitPhysDbg() { if (Physics.World == null) { dbgv_?.Dispose(); return; } if (dbgv_ != null) { return; } dbgv_ = new DebugViewXNA(Physics.World); dbgv_.LoadContent(Graphics.Device, Content.Manager); dbgv_.RemoveFlags((DebugViewFlags)Int32.MaxValue); // dbgv_.AppendFlags(DebugViewFlags.AABB); dbgv_.AppendFlags(DebugViewFlags.CenterOfMass); // dbgv_.AppendFlags(DebugViewFlags.ContactNormals); dbgv_.AppendFlags(DebugViewFlags.ContactPoints); // dbgv_.AppendFlags(DebugViewFlags.Controllers); // dbgv.AppendFlags(DebugViewFlags.DebugPanel); dbgv_.AppendFlags(DebugViewFlags.Joint); // dbgv.AppendFlags(DebugViewFlags.PerformanceGraph); dbgv_.AppendFlags(DebugViewFlags.PolygonPoints); dbgv_.AppendFlags(DebugViewFlags.Shape); }
public Scene(SpriteBatch sb, GraphicsDeviceManager graphicsDeviceManager, GraphicsDevice gd, GameWindow window, ContentManager content, int FOVWidth, int FOVHeight, IDrawSystem system = null) { buffer = new RenderTarget2D(gd, graphicsDeviceManager.PreferredBackBufferWidth, graphicsDeviceManager.PreferredBackBufferHeight); GraphicsDevice = gd; SpriteBatch = sb; _graphicsDeviceManager = graphicsDeviceManager; Content = content; GameWindow = window; Camera = new Camera(this, gd.Viewport) { FOV = new Vector2(FOVWidth, FOVHeight) }; Input.Instance = new Input(this); GameObjects = new GameObjectManager(this); TiledPrefabs = new Dictionary <string, Type>(); World = new World(Vector2.Zero); Settings.AllowSleep = true; Settings.VelocityIterations = 2; Settings.ContinuousPhysics = true; DebugView = new DebugViewXNA(World); DebugView.RemoveFlags(DebugViewFlags.Shape); DebugView.RemoveFlags(DebugViewFlags.Joint); DebugView.DefaultShapeColor = Color.LightPink; DebugView.SleepingShapeColor = Color.MediumPurple; DebugView.LoadContent(GraphicsDevice, content); DebugView.AppendFlags(DebugViewFlags.DebugPanel); DebugView.AppendFlags(DebugViewFlags.PerformanceGraph); Debug = true; LoadedTiledPrefabs = new List <TiledPrefab>(); Pipeline = new CludoContentPipeline(gd); Vector = Pipeline.LoadContent <Texture2D>("Vector", content, true); Line = new Texture2D(GraphicsDevice, 1, 1); Line.SetData(new[] { Color.White }); GameWindow.ClientSizeChanged += (sender, args) => { VirtualResolutionScaler = new VirtualResolutionScaler(this, graphicsDeviceManager.PreferredBackBufferWidth, graphicsDeviceManager.PreferredBackBufferHeight, gd, true); }; VirtualResolutionScaler = new VirtualResolutionScaler(this, graphicsDeviceManager.PreferredBackBufferWidth, graphicsDeviceManager.PreferredBackBufferHeight, gd, true); Pipeline.LoadContent <SpriteFont>("Font", Content, true); if (system == null) { SetDrawSystem(new NormalDrawSystem(GraphicsDevice, this, new Vector2(graphicsDeviceManager.PreferredBackBufferWidth, graphicsDeviceManager.PreferredBackBufferHeight))); } else { SetDrawSystem(system); } StartScene(); }
public WorldScreen(Game Game) : base(Game, GeneralManager.ScreenX, GeneralManager.ScreenY) { GeneralManager.LoadAnimation("TestAnim", Vector2.One * 64, 6, 80); GeneralManager.LoadAnimation("PlayerIdle", Vector2.One * 64, 1, 10000); DebugWindow.Visible = false; DebugWindow.AddGUI(FarseerDebugCheck, DebugWindow); AddGUI(DebugWindow); LE = new LightingEngine(); Color a = new Color(ambient, ambient, ambient); LE.SetAmbient(a, a); //LE.SetAmbient(Color.Gray, Color.Gray); Renderer.AddRendererEffect(LE, "LightingEngine"); LoadContent(); Map = new Map(this, tileSize, mapSize); //Renderer.AddPostProcess(new BlurEffect(), "Blur"); SE = new BlurSwitchEffect(); SE.MaxTime = 1f; SE.TurnOffAction = delegate() { Renderer.RemovePostProcess("Switch"); }; Renderer.AddPostProcess(SE, "Switch"); Camera.Init(GeneralManager.GetPartialRect(0, 0, 1, 1), new Rectangle(0, 0, tileSize * mapSize, tileSize * mapSize)); PlayerLight = new SpotLight() { IsEnabled = true, Color = new Vector4(0.9f, .7f, .7f, 1f), Power = .6f, LightDecay = 600, Position = new Vector3(500, 400, 20), SpotAngle = 1.5f, SpotDecayExponent = 3, Direction = new Vector3(0.244402379f, 0.969673932f, 0) }; LE.AddLight(PlayerLight); Debug = new FarseerPhysics.DebugViews.DebugViewXNA(Map.PhysicalWorld); Debug.AppendFlags(FarseerPhysics.DebugViewFlags.Shape); Debug.AppendFlags(FarseerPhysics.DebugViewFlags.AABB); Debug.AppendFlags(FarseerPhysics.DebugViewFlags.PerformanceGraph); Debug.AppendFlags(FarseerPhysics.DebugViewFlags.Joint); Debug.AppendFlags(FarseerPhysics.DebugViewFlags.ContactPoints); Debug.DefaultShapeColor = Color.White; Debug.SleepingShapeColor = Color.LightGray; Debug.LoadContent(Parent.GraphicsDevice, Parent.Content); //Weapon w = new Weapon("test", "Gun", 100, 10, Hands.One, 10, 600, 10, 10, 10); //Serializer.Serialize<Weapon>("weapon.xml", w); }
private void SetupDebug() { // create and configure the debug view _debugView = new DebugViewXNA(PhysicsWorld); _debugView.AppendFlags(DebugViewFlags.PerformanceGraph); _debugView.AppendFlags(DebugViewFlags.CenterOfMass); _debugView.AppendFlags(DebugViewFlags.Shape); _debugView.AppendFlags(DebugViewFlags.DebugPanel); //_debugView.AppendFlags(DebugViewFlags.AABB); _debugView.DefaultShapeColor = Color.White; _debugView.SleepingShapeColor = Color.LightGray; _debugView.LoadContent(GraphicsDevice, Content); }
public override void LoadContent() { base.LoadContent(); if (World == null) { return; } DebugView = new DebugViewXNA(World); DebugView.AppendFlags(DebugViewFlags.TexturedShape); DebugView.RemoveFlags(DebugViewFlags.Shape); DebugView.RemoveFlags(DebugViewFlags.Joint); DebugView.DefaultShapeColor = Color.White; DebugView.SleepingShapeColor = Color.LightGray; DebugView.LoadContent(ScreenManager.GraphicsDevice, ScreenManager.ContentManager); Vector2 gameWorld = Camera2D.ConvertScreenToWorld(new Vector2(ScreenManager.Camera.ScreenWidth, ScreenManager.Camera.ScreenHeight)); _border = new Border(World, gameWorld.X, gameWorld.Y, 1f); ScreenManager.Camera.ProjectionUpdated += UpdateScreen; // Loading may take a while... so prevent the game from "catching up" once we finished loading ScreenManager.Game.ResetElapsedTime(); }
public ControllerViewManager(GraphicsDevice graphicsDevice, ContentManager content) { controllers = new List <Controller>(); views = new List <IView>(); this.content = content; this.graphicsDevice = graphicsDevice; this.batch = new SpriteBatch(graphicsDevice); this.world = new World(new Vector2(0, Constants.GamePlayGravity)); this.controllerQueue = new ConcurrentQueue <Tuple <Controller, QueueState> >(); this.viewQueue = new ConcurrentQueue <Tuple <IView, QueueState> >(); if (Constants.DebugMode && debugView == null) { debugView = new DebugViewXNA(world); debugView.AppendFlags(DebugViewFlags.DebugPanel); debugView.DefaultShapeColor = Color.Red; debugView.SleepingShapeColor = Color.Green; debugView.LoadContent(graphicsDevice, content); } if (camera == null) { Viewport v = graphicsDevice.Viewport; camera = new Camera2D(graphicsDevice); camera.Position = new Vector2(v.Width / 2, v.Height / 2); } else { camera.ResetCamera(); } }
public override void LoadContent() { base.LoadContent(); if (World == null) return; DebugView = new DebugViewXNA(World); DebugView.AppendFlags(DebugViewFlags.TexturedShape); DebugView.RemoveFlags(DebugViewFlags.Shape); DebugView.RemoveFlags(DebugViewFlags.Joint); DebugView.DefaultShapeColor = Color.White; DebugView.SleepingShapeColor = Color.LightGray; DebugView.LoadContent(ScreenManager.GraphicsDevice, ScreenManager.ContentManager); Vector2 gameWorld = Camera2D.ConvertScreenToWorld(new Vector2(ScreenManager.Camera.ScreenWidth, ScreenManager.Camera.ScreenHeight)); _border = new Border(World, gameWorld.X, gameWorld.Y, 1f); ScreenManager.Camera.ProjectionUpdated += UpdateScreen; // Loading may take a while... so prevent the game from "catching up" once we finished loading ScreenManager.Game.ResetElapsedTime(); }
/// <summary> /// Initializes a new <see cref="Scene"/> instance. /// </summary> public Scene() { World = new World(Vector2.Zero); DebugView = new DebugViewXNA(World); gameObjects = new Dictionary <string, GameObject>(); addedGameObjects = new Dictionary <string, GameObject>(); destroyedGameObjects = new List <GameObject>(); Camera = new Camera(); BackgroundColor = Color.White; DebugView.AppendFlags(DebugViewFlags.DebugPanel); DebugView.AppendFlags(DebugViewFlags.ContactPoints); DebugView.AppendFlags(DebugViewFlags.ContactNormals); DebugView.LoadContent(GameManager.Instance.GraphicsDevice, GameManager.Instance.Content); DebugView.Enabled = false; }
public Map(GraphicsDevice pDevice, ContentManager content, int pTileWidth, int pTileHeight, int pWidth, int pHeight) { ConvertUnits.SetDisplayUnitToSimUnitRatio(100); entityList = new List<MapEntity>(); verticesList = new List<Vector2>(); //light = content.Load<Texture2D>("lightmask"); effect = content.Load<Effect>("File"); //effect.Parameters["lightMask"].SetValue(light); prevState = Keyboard.GetState(); hud = new Hud(new string[] { "Undertale is bad,\nand so am I." }, content); speaking = false; blocks = new List<Body>(); tileWidth = pTileWidth; tileHeight = pTileHeight; width = pWidth; height = pHeight; g = pDevice; cont = content; menu = new Menu(content, null); camera = new Camera2D(pDevice); debug = content.Load<Texture2D>("overworld_gutter"); tMap = content.Load<TiledMap>("Map/Tazmily/Tazmily"); mapRenderer = new TiledMapRenderer(pDevice); world = new World(Vector2.Zero); //world.ContactManager.OnBroadphaseCollision += BroadphaseHandler; //world.ContactManager.EndContact += EndContactHandler; debugView = new DebugViewXNA(world); debugView.LoadContent(pDevice, content); //debugView.AppendFlags(DebugViewFlags.DebugPanel); //debugView.AppendFlags(DebugViewFlags.PolygonPoints); //debugView.AppendFlags(DebugViewFlags.ContactPoints); //debugView.AppendFlags(DebugViewFlags.AABB); debugView.AppendFlags(DebugViewFlags.Shape); debugView.DefaultShapeColor = Color.Green; //camera.Position = player.body.Position; //Console.WriteLine("Scunt: " + tMap.ObjectLayers.Count); player = new Player(world, content, 16, 23); //npc = new NPC(world, content, colArray, 2, false, 16, 14, new string[] {"Weebs are worse\nthan fortnite\ngamers.", "Where's the lie?" }); //Body b1 = BodyFactory.CreateRectangle(world, 3, 3, 1); blockDims = new List<Vector2>(); MakeCollisionBodies(); npcs = new NPC[] { //new NPC(world, content, player, 1, false, 12, 15, prevState, new string[] { "@You wanna see the special?\n@It's a detective story. Some kind of <Columbo>\n knock-off.\n@Well, ya interested or not?", "@Get outta here." }), new NPC(world, content, player, 1, false, 12, 15, prevState, new string[] { "@Your name Steve Foley? Of course it is.\n You are great. Fantastic.\n@Good job Steve.", "@Get outta here." }), //new NewNPC(world, content, player, 0, true, 18, 18, new string[] {"help"}, 4, 1) }; entityList.Add(player); foreach (NPC n in npcs) entityList.Add(n); }
void LoadCreateDebugView(World world) { //create and configure the debug view _debugView = new DebugViewXNA(world); _debugView.AppendFlags(DebugViewFlags.DebugPanel | DebugViewFlags.AABB | DebugViewFlags.PerformanceGraph | DebugViewFlags.ContactPoints | DebugViewFlags.Controllers); _debugView.DefaultShapeColor = Color.Blue; _debugView.SleepingShapeColor = Color.LightGray; _debugView.LoadContent(screenManager.GraphicsDevice, _content); }
public GameWorld(ChopperGame game) { _content = game.Content; _spriteBatch = game.SpriteBatch; _graphicsDevice = game.GraphicsDevice; _gameInput = game.GameInput; _camera = new Camera2D(_graphicsDevice); _world = new World(new Vector2(0, 10)); _timeStep = (float)game.TargetElapsedTime.TotalSeconds; _debugView = new DebugViewXNA(_world); _debugView.Flags = 0; _debugView.AppendFlags(DebugViewFlags.Shape); _debugView.AppendFlags(DebugViewFlags.Joint); _debugView.SleepingShapeColor = Color.YellowGreen; _crates = new List<Crate>(); }
public GameWorld(ChopperGame game) { _content = game.Content; _spriteBatch = game.SpriteBatch; _graphicsDevice = game.GraphicsDevice; _gameInput = game.GameInput; _camera = new Camera2D(_graphicsDevice); _world = new World(new Vector2(0, 10)); _timeStep = (float)game.TargetElapsedTime.TotalSeconds; _debugView = new DebugViewXNA(_world); _debugView.Flags = 0; _debugView.AppendFlags(DebugViewFlags.Shape); _debugView.AppendFlags(DebugViewFlags.Joint); _debugView.SleepingShapeColor = Color.YellowGreen; _crates = new List <Crate>(); }
public GameWorld(BubbleBobbleGame game) { _content = game.Content; _spriteBatch = game.SpriteBatch; _graphicsDevice = game.GraphicsDevice; _gameInput = game.GameInput; _camera = new Camera2D(_graphicsDevice); // Creates the farseer world with a gravity _world = new World(new Vector2(0, 20)); _timeStep = (float)game.TargetElapsedTime.TotalSeconds; // Setup the debug view _debugView = new DebugViewXNA(_world); _debugView.AppendFlags(DebugViewFlags.Shape); _debugView.AppendFlags(DebugViewFlags.PolygonPoints); _debugView.AppendFlags(DebugViewFlags.CenterOfMass); }
public override void LoadContent(ContentManager content) { this.Content = content; player1.texture = content.Load <Texture2D>("dad_sat"); player2.texture = content.Load <Texture2D>("mom_sat"); table.texture = content.Load <Texture2D>("table"); ending = content.Load <Song>("co"); font = content.Load <SpriteFont>("SpriteFont1"); for (int i = 0; i < N; i++) { ball[i].texture = content.Load <Texture2D>("ball"); } ball[0].texture = content.Load <Texture2D>("ttukbaegi"); ball[1].texture = content.Load <Texture2D>("rice_1"); ball[2].texture = content.Load <Texture2D>("kimchi"); ball[3].texture = content.Load <Texture2D>("kimchi"); ball[4].texture = content.Load <Texture2D>("ttukbaegi"); ball[5].texture = content.Load <Texture2D>("rice_1"); ball[6].texture = content.Load <Texture2D>("rice_2"); ball[7].texture = content.Load <Texture2D>("kimchi"); ball[8].texture = content.Load <Texture2D>("ttukbaegi"); ball[9].texture = content.Load <Texture2D>("kimchi"); baby.texture = this.Content.Load <Texture2D>("baby"); background = this.Content.Load <Texture2D>("background"); view = new DebugViewXNA(world); view.AppendFlags(DebugViewFlags.Shape); view.RemoveFlags(DebugViewFlags.Joint); view.DefaultShapeColor = Color.White; view.SleepingShapeColor = Color.LightGray; view.LoadContent(game.GraphicsDevice, Content); if (Camera == null) { Camera = new Camera2D(game.GraphicsDevice); } else { Camera.ResetCamera(); } glass_sfx = content.Load <SoundEffect>("glass"); hit1_sfx = content.Load <SoundEffect>("hit1"); hit2_sfx = content.Load <SoundEffect>("hit2"); bgm = content.Load <Song>("bgm"); MediaPlayer.Play(bgm); MediaPlayer.IsRepeating = true; help_font = content.Load <SpriteFont>("SpriteFont2"); }
public void LoadContent(GraphicsDevice graphicsDevice, ContentManager content, SpriteFont font) { if (!FarseerEnabled) { return; } //_view.LoadContent(graphicsDevice, SceneManager.GlobalContent); if (DebugView == null) { DebugView = new DebugViewXNA(StaticWorld); DebugView.AppendFlags(DebugViewFlags.Shape); DebugView.AppendFlags(DebugViewFlags.PolygonPoints); DebugView.AppendFlags(DebugViewFlags.PerformanceGraph); DebugView.AppendFlags(DebugViewFlags.AABB); DebugView.DefaultShapeColor = Color.White; DebugView.SleepingShapeColor = Color.LightGray; DebugView.LoadContent(graphicsDevice, content, font); } }
private void EnableOrDisableFlag(DebugViewFlags flag) { if ((debugView.Flags & flag) == flag) { debugView.RemoveFlags(flag); } else { debugView.AppendFlags(flag); } }
public void SwitchDebugViewFlag(DebugViewFlags flag) { if ((_debugView.Flags & flag) == flag) { _debugView.RemoveFlags(flag); } else { _debugView.AppendFlags(flag); } }
public void Initialize(RenderContext context) { //Create new savedata file if it doesn't exist yet if (!File.Exists(SaveDataFile)) { SaveData data = new SaveData(); data.HighestDistance = 0; XmlWriter.SaveScore(data, SaveDataFile); } SaveScore(); // actually loads the score isActive = true; m_ViewPort = context.GraphicsDevice.Viewport; //Load a font TextRenderer.SetFont(context.Content.Load <SpriteFont>("Font/Standard")); //Create player an set him at center of screen m_StartPos = new Vector2(context.ViewPortSize.X * 0.25f, context.ViewPortSize.Y * 0.25f); m_Player = new Player(context, m_StartPos); m_Player.Initialize(context); m_Player.Translate(m_StartPos); context.Player = m_Player; //Generate a random level m_LevelManager = new LevelManager(); m_LevelManager.Initialize(context); //AddParalaxing backgrounds m_BgManager = new BackgroundManager(context); m_BgManager.AddBackgound(new Background("background", new Vector2(0, 0), 1.0f, false, context)); m_BgManager.AddBackgound(new Background("1", new Vector2(60, 20), 1.0f, false, context)); m_BgManager.AddBackgound(new Background("2", new Vector2(100, 70), 1, false, context)); m_BgManager.AddBackgound(new Background("3", new Vector2(200, 40), 1, false, context)); m_BgManager.AddBackgound(new Background("4", new Vector2(300, 50), 1, false, context)); m_BgManager.AddBackgound(new Background("5", new Vector2(400, 200), 1, false, context)); #if (DEBUG) m_MonoDebug = new DebugViewXNA(context.World); m_MonoDebug.AppendFlags(DebugViewFlags.DebugPanel); m_MonoDebug.DefaultShapeColor = Color.Red; m_MonoDebug.SleepingShapeColor = Color.LightGray; m_MonoDebug.LoadContent(context.GraphicsDevice, context.Content); #endif SoundManager.Play("Background", true); HitScreen = new GameSprite("Textures/GUI/hit", context); PickScreen = new GameSprite("Textures/GUI/pickupHit", context); }
/// <summary> /// Call this in LoadContent after all the level is set up /// </summary> public void ExtablishDebugView(GraphicsDevice graphicsDevice, ContentManager content) { //Give your world to debugView DebugView = new DebugViewXNA(LevelWorld); //DebugView have many Property you can add DebugView.RemoveFlags(DebugViewFlags.Shape); DebugView.RemoveFlags(DebugViewFlags.Joint); DebugView.DefaultShapeColor = Color.LightPink; DebugView.SleepingShapeColor = Color.MediumPurple; //add your GraphicsDevice & your ContentManager DebugView.AppendFlags(DebugViewFlags.CenterOfMass); DebugView.AppendFlags(DebugViewFlags.PerformanceGraph); DebugView.AppendFlags(DebugViewFlags.Shape); DebugView.AppendFlags(DebugViewFlags.ContactPoints); DebugView.AppendFlags(DebugViewFlags.PolygonPoints); DebugView.AppendFlags(DebugViewFlags.ContactNormals); DebugView.DefaultShapeColor = Color.White; DebugView.SleepingShapeColor = Color.LightGray; DebugView.DebugPanelPosition = Vector2.Zero; DebugView.PerformancePanelBounds = graphicsDevice.ScissorRectangle; DebugView.LoadContent(graphicsDevice, content); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit aKeyboardState = Keyboard.GetState(); if (aKeyboardState.IsKeyDown(Keys.F12) && previousKeyboardState != aKeyboardState) { if (debugView.Flags.HasFlag(FarseerPhysics.DebugViewFlags.DebugPanel)) { debugView.RemoveFlags(FarseerPhysics.DebugViewFlags.DebugPanel); } else { debugView.AppendFlags(FarseerPhysics.DebugViewFlags.DebugPanel); debugView.DebugPanelPosition = new Vector2(0, 0); } } else if (aKeyboardState.IsKeyDown(Keys.F11) && previousKeyboardState != aKeyboardState) { if (debugView.Enabled) { debugView.Enabled = false; } else if (!debugView.Enabled) { debugView.Enabled = true; } } else if (aKeyboardState.IsKeyDown(Keys.F5) && previousKeyboardState != aKeyboardState) { objectList.Clear(); world.Clear(); lvlBuilder.readLevel("level1.txt"); objectList = lvlBuilder.getLevelObjects(); } else if (aKeyboardState.IsKeyDown(Keys.Escape)) { this.Exit(); } world.Step(Math.Min((float)gameTime.ElapsedGameTime.TotalSeconds, (1f / 30f))); previousKeyboardState = aKeyboardState; // TODO: Add your update logic here foreach (GameObject currObject in objectList) { currObject.Update(); } base.Update(gameTime); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _resources.Load(_gameObjectFactory.getAll()); // TODO: use this.Content to load your game content here _screenCenter = new Vector2(_graphics.GraphicsDevice.Viewport.Width / 2f, _graphics.GraphicsDevice.Viewport.Height / 2f); _debugView = new DebugViewXNA(_world); _debugView.AppendFlags(DebugViewFlags.DebugPanel); _debugView.DefaultShapeColor = Color.Black; _debugView.SleepingShapeColor = Color.LightGray; _debugView.LoadContent(GraphicsDevice, Content); }
void DebugDraw() { Matrix view2 = Matrix.CreateScale(32); //default 32 view2 *= Game1.DebugCam.view; debugActive = true; DebugView = new DebugViewXNA(Game1.world); DebugView.AppendFlags(FarseerPhysics.DebugViewFlags.DebugPanel); DebugView.DefaultShapeColor = Color.Red; DebugView.SleepingShapeColor = Color.Green; DebugView.StaticShapeColor = Color.Violet; DebugView.LoadContent(Game1.graphics.GraphicsDevice, Game1.content); DebugView.RenderDebugData(ref Game1.DebugCam.projection, ref view2); }
protected override void Initialize() { _spriteBatch = new SpriteBatch(GraphicsDevice); _font = Content.Load <SpriteFont>("Fonts/Segoe14"); _mousePosition = Vector2.Zero; DrawCurrentGameObject = false; _selectedItemsDisplay = new SelectedItemsDisplay(GraphicsDevice); _lineTexture = new Texture2D(GraphicsDevice, 1, 1); _lineTexture.SetData <Color>(new Color[] { Color.White }); _jointView = new DebugViewXNA(_gameObject.World); _jointView.DefaultShapeColor = Color.White; _jointView.SleepingShapeColor = Color.LightGray; _jointView.LoadContent(GraphicsDevice, new Viewport(0, 0, this.Size.Width, this.Size.Height), Content); _jointView.AppendFlags(DebugViewFlags.Joint); }
protected override void Initialize() { _world = new World(new Vector2(0, 9.8f)); _debugView = new DebugViewXNA(_world); _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Shape); _debugView.DefaultShapeColor = Color.White; _debugView.SleepingShapeColor = Color.LightGray; _debugView.LoadContent(GraphicsDevice, Content); base.Initialize(); _fluidSimulation = new FluidSimulation(_world, _spriteBatch, _debugFont); _projection = Matrix.CreateOrthographic(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1); _view = Matrix.CreateScale(new Vector3(SCALE, -SCALE, 1)); // Create test geometry Body bottomBody = BodyFactory.CreateBody(_world, new Vector2(0, 7f)); PolygonShape bottomShape = new PolygonShape(1f); bottomShape.SetAsBox(12f, 1f); bottomBody.CreateFixture(bottomShape); Body leftBody = BodyFactory.CreateBody(_world, new Vector2(-11f, 0f)); PolygonShape leftShape = new PolygonShape(1f); leftShape.SetAsBox(1f, 10f); leftBody.CreateFixture(leftShape); Body rightBody = BodyFactory.CreateBody(_world, new Vector2(11f, 0f)); PolygonShape rightShape = new PolygonShape(1f); rightShape.SetAsBox(1f, 10f); rightBody.CreateFixture(rightShape); Body rampBody = BodyFactory.CreateBody(_world, new Vector2(6f, -2f)); PolygonShape rampShape = new PolygonShape(1f); rampShape.SetAsBox(5.5f, 0.5f); rampBody.CreateFixture(rampShape); rampBody.Rotation = -0.25f; Body circleBody = BodyFactory.CreateBody(_world, new Vector2(0, -0.2f)); CircleShape circleShape = new CircleShape(2f, 1f); circleBody.CreateFixture(circleShape); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Initialize camera controls _view = Matrix.Identity; _cameraPosition = Vector2.Zero; _screenCenter = new Vector2(_graphics.GraphicsDevice.Viewport.Width / 2f, _graphics.GraphicsDevice.Viewport.Height / 2f); _batch = new SpriteBatch(_graphics.GraphicsDevice); _font = Content.Load <SpriteFont>("font"); PhysicalWorld.Ground g = new PhysicalWorld.Ground(_world); // create and configure the debug view _debugView = new DebugViewXNA(_world); _debugView.AppendFlags(DebugViewFlags.DebugPanel); _debugView.DefaultShapeColor = Color.White; _debugView.SleepingShapeColor = Color.LightGray; _debugView.LoadContent(GraphicsDevice, Content); }
public GDEntityManager(GDGameScreen scrn) : base(scrn) { PhysicsWorld = new World(Vector2.Zero); #if DEBUG debugView = new DebugViewXNA(PhysicsWorld); debugView.LoadContent(GDOwner.Graphics.GraphicsDevice, GDOwner.Game.Content, Textures.DebugFont); debugView.AppendFlags(DebugViewFlags.Shape); debugView.AppendFlags(DebugViewFlags.DebugPanel); debugView.AppendFlags(DebugViewFlags.PerformanceGraph); debugView.AppendFlags(DebugViewFlags.ContactPoints); debugView.AppendFlags(DebugViewFlags.ContactNormals); debugView.AppendFlags(DebugViewFlags.Controllers); debugView.TextColor = Color.Black; debugView.Enabled = false; #endif }
public PhysicsSystem(GameScreen screen) { this.screen = screen; GnomicGame game = screen.ParentGame; // Todo: pass in a PhysicsSystemSetting with gravity, worldMin and worldMax world = new World( new Vector2(0.0f, 20.0f), new FarseerPhysics.Collision.AABB(Vector2.One * -500.0f, Vector2.One * 500.0f)); debugView = new DebugViewXNA(world); debugView.AppendFlags(DebugViewFlags.Shape); debugView.DefaultShapeColor = Color.White; debugView.SleepingShapeColor = Color.LightGray; debugView.LoadContent(game.GraphicsDevice, game.Content, "GameFont"); projection = Matrix.CreateOrthographicOffCenter( 0f, ConvertUnits.ToSimUnits(game.ScreenWidth), ConvertUnits.ToSimUnits(game.ScreenHeight), 0f, 0f, 1f); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); view = Matrix.Identity; cameraPosition = Vector2.Zero; screenCenter = new Vector2(GraphicsDevice.Viewport.Width / 2f, GraphicsDevice.Viewport.Height / 2f); //Initialiserer debugview physicsDebug = new DebugViewXNA(world); physicsDebug.AppendFlags(DebugViewFlags.DebugPanel); physicsDebug.DefaultShapeColor = Color.White; physicsDebug.SleepingShapeColor = Color.LightGray; physicsDebug.LoadContent(GraphicsDevice, Content); Body body = BodyFactory.CreateRectangle(world, 0.4f, 0.4f, 1); body.BodyType = BodyType.Static; body.Position = new Vector2(Globals.windowWidth/192f, Globals.windowHeight/192f); }
public override void LoadContent() { // We add to the GameServices objects that we want to be able to use accross different classes // without having to pass them explicitly every time. GraphicsDevice = GameServices.GetService<GraphicsDevice>(); Content = GameServices.GetService<ContentManager>(); graphics = GameServices.GetService<GraphicsDeviceManager>(); soundManager = GameServices.GetService<SoundManager>(); ScreenManager.AddScreen(RankScreen, null, false); ScreenManager.AddScreen(PauseScreen, null, false); world = new World(new Vector2(0, 0)); GameServices.AddService<World>(world); this.world.ContactManager.PostSolve += new PostSolveDelegate(PostSolve); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // Create a new track randomRaceTrack = RandomTrack.createTrack(); randomRaceTrack.polygonList = polygonsList; int[] crucialPoints = { 300, 600, 1000 }; Logic = new GameLogic(crucialPoints, randomRaceTrack.curvePointsMiddle.Count); randomRaceTrack.gameLogic = Logic; Logic.DidFinishLap += randomRaceTrack.ResetStickyNotes; mySneezesManager.randomTrack = randomRaceTrack; LoadPaperEffect(); screenRenderer = new ScreenRenderer(); GameServices.AddService<ScreenRenderer>(screenRenderer); Logic.DidEliminateCar += screenRenderer.setSadToPlayer; Logic.DidFinishLap += screenRenderer.setLap; for (int i = 0; i < 4; i++) { Car aCar = new Car(world, Content.Load<Texture2D>("Images/small_car"), Color.White, randomRaceTrack, i, playerIndexes[i]); Cars.Add(aCar); } assetCreator = new AssetCreator(graphics.GraphicsDevice); assetCreator.LoadContent(this.Content); defaultViewport = GraphicsDevice.Viewport; isFullHd=(ScreenManager.preferredHeight!=720); // Single screen mode only cameraFollowing = new Camera(defaultViewport, Vector2.Zero, new Vector2(defaultViewport.Width / 2, defaultViewport.Height / 2), 0.0f, Cars.Count, isFullHd); //ZOOM: //low res: //0.95 for 2 players //0.93 for 3 players //0.91 for 4 players //high res: //0.95 for 4 players GameServices.AddService<Camera>(cameraFollowing); mySneezesManager.camera = cameraFollowing; //generate starting positions and angles int startingPoint = 0; // positionCars(startingPoint); _debugView = new DebugViewXNA(world); _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Shape); _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.DebugPanel); _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.PerformanceGraph); _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Joint); _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.ContactPoints); _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.ContactNormals); _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Controllers); _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.CenterOfMass); _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.AABB); _debugView.DefaultShapeColor = Color.White; _debugView.SleepingShapeColor = Color.LightGray; _debugView.LoadContent(GraphicsDevice, Content); basicVert = new VertexPositionColorTexture[maxNumberOfTriangles]; for (int i = 0; i < maxNumberOfTriangles; i++) basicVert[i].TextureCoordinate = new Vector2(-1); verticesBorders = new VertexPositionColorTexture[randomRaceTrack.curvePointsInternal.Count]; fluid = new Fluid(); fluid.Init(); currentPoses = new Vector2[4]; prevPoses = new Vector2[4]; currentMousePos = new Vector2(100); prevMousePos = new Vector2(0); quad = new QuadRenderComponent(ScreenManager.Game, cameraFollowing, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height); ScreenManager.Game.Components.Add(quad); fluidUpdateThread = new Thread(this.UpdateFluid); fluidUpdateThread.Start(); mySneezesManager.fluid = fluid; fluidEffect = Content.Load<Effect>("Shaders/FluidEffect"); fluidEffect.Parameters["random"].SetValue(randomTex); texInk = new Texture2D(graphics.GraphicsDevice, fluid.m_w, fluid.m_h, true, SurfaceFormat.Color); buffer = new RenderTarget2D(GraphicsDevice, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height, true, SurfaceFormat.Color, GraphicsDevice.PresentationParameters.DepthStencilFormat); //gaussian = new GaussianBlur(ScreenManager.Game); }
public Debug(Game game, World world, Play play) { _physicsDebug = new DebugViewXNA(world); _physicsDebug.LoadContent(game.GraphicsDevice, game.Content); _physicsDebug.AppendFlags(DebugViewFlags.DebugPanel); }
public WorldScreen(Game Game) : base(Game, GeneralManager.ScreenX, GeneralManager.ScreenY) { GeneralManager.LoadAnimation("TestAnim", Vector2.One * 64, 6, 80); GeneralManager.LoadAnimation("PlayerIdle", Vector2.One * 64, 1, 10000); DebugWindow.Visible = false; DebugWindow.AddGUI(FarseerDebugCheck, DebugWindow); AddGUI(DebugWindow); LE = new LightingEngine(); Color a = new Color(ambient, ambient, ambient); LE.SetAmbient(a, a); //LE.SetAmbient(Color.Gray, Color.Gray); Renderer.AddRendererEffect(LE, "LightingEngine"); LoadContent(); Map = new Map(this, tileSize, mapSize); //Renderer.AddPostProcess(new BlurEffect(), "Blur"); SE = new BlurSwitchEffect(); SE.MaxTime = 1f; SE.TurnOffAction = delegate () {Renderer.RemovePostProcess("Switch");}; Renderer.AddPostProcess(SE, "Switch"); Camera.Init(GeneralManager.GetPartialRect(0, 0, 1, 1), new Rectangle(0, 0, tileSize * mapSize, tileSize * mapSize)); PlayerLight = new SpotLight() { IsEnabled = true, Color = new Vector4(0.9f, .7f, .7f, 1f), Power = .6f, LightDecay = 600, Position = new Vector3(500, 400, 20), SpotAngle = 1.5f, SpotDecayExponent = 3, Direction = new Vector3(0.244402379f, 0.969673932f, 0) }; LE.AddLight(PlayerLight); Debug = new FarseerPhysics.DebugViews.DebugViewXNA(Map.PhysicalWorld); Debug.AppendFlags(FarseerPhysics.DebugViewFlags.Shape); Debug.AppendFlags(FarseerPhysics.DebugViewFlags.AABB); Debug.AppendFlags(FarseerPhysics.DebugViewFlags.PerformanceGraph); Debug.AppendFlags(FarseerPhysics.DebugViewFlags.Joint); Debug.AppendFlags(FarseerPhysics.DebugViewFlags.ContactPoints); Debug.DefaultShapeColor = Color.White; Debug.SleepingShapeColor = Color.LightGray; Debug.LoadContent(Parent.GraphicsDevice, Parent.Content); //Weapon w = new Weapon("test", "Gun", 100, 10, Hands.One, 10, 600, 10, 10, 10); //Serializer.Serialize<Weapon>("weapon.xml", w); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { //Steup StartScreen MenuSong = Content.Load<Song>("Sounds/Menu_Song_mixdown"); font = Content.Load<SpriteFont>("Sprites/font"); isActive = false; ScreenList.Add(new FirstScreen(MenuSong,font)); ScreenList.Add(new SecondScreen(MenuSong, font)); ScreenList.Add(new EndScreen()); ScreenList[0].setActive(true); firstbackground = Content.Load<Texture2D>("Sprites/Start_Screen_Background"); //end states p1WinsImage = Content.Load<Texture2D>("Sprites/P1_Wins"); p2WinsImage = Content.Load<Texture2D>("Sprites/P2_Wins"); drawGameImage = Content.Load<Texture2D>("Sprites/Draw"); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); background = Content.Load<Texture2D>("Sprites/Lava_Scrolling_Bkrnd_2048"); foreground = Content.Load<Texture2D>("Sprites/Foreground"); boxTex = Content.Load<Texture2D>("Sprites/ToyBox"); Texture2D carsSpriteSheet = Content.Load<Texture2D>("Sprites/Cars_test"); myBackground = new ScrollingBackground(); myBackground.Load(GraphicsDevice, background); //explosion texture explosionTexture = Content.Load<Texture2D>("Sprites/Explosion_Sprite_Sheet"); //pENCIL wALLS TOP pencilTex = Content.Load<Texture2D>("Sprites/Bottom_pencil"); pencilTexSide = Content.Load<Texture2D>("Sprites/Side_Pencil"); pencilWallTop = new PencilWall[5]; pencilWallTop[0] = new PencilWall(pencilTex, new Vector2(125, 100), world, "up"); pencilWallTop[1] = new PencilWall(pencilTex, new Vector2(465, 100), world, "up"); pencilWallTop[2] = new PencilWall(pencilTex, new Vector2(795, 100), world, "up"); pencilWallTop[3] = new PencilWall(pencilTex, new Vector2(1135, 100), world, "up"); pencilWallTop[4] = new PencilWall(pencilTex, new Vector2(1455, 100), world, "up"); //PencilWalls Bot pencilWallBot = new PencilWall[5]; pencilWallBot[0] = new PencilWall(pencilTex, new Vector2(125, 950), world, "down"); pencilWallBot[1] = new PencilWall(pencilTex, new Vector2(455, 950), world, "down"); pencilWallBot[2] = new PencilWall(pencilTex, new Vector2(785, 950), world, "down"); pencilWallBot[3] = new PencilWall(pencilTex, new Vector2(1125, 950), world, "down"); pencilWallBot[4] = new PencilWall(pencilTex, new Vector2(1445, 950), world, "down"); //PencilWalls Left pencilWallLeft = new PencilWall[3]; pencilWallLeft[0] = new PencilWall(pencilTexSide, new Vector2(100, 130), world, "left"); pencilWallLeft[1] = new PencilWall(pencilTexSide, new Vector2(100, 410), world, "left"); pencilWallLeft[2] = new PencilWall(pencilTexSide, new Vector2(100, 690), world, "left"); pencilWallRight = new PencilWall[3]; pencilWallRight[0] = new PencilWall(pencilTexSide, new Vector2(1775, 130), world, "right"); pencilWallRight[1] = new PencilWall(pencilTexSide, new Vector2(1775, 410), world, "right"); pencilWallRight[2] = new PencilWall(pencilTexSide, new Vector2(1775, 690), world, "right"); //collision spark collisionSpark = Content.Load<Texture2D>("Sprites/SINGLE_Spark_Sprite_Sheet"); //Background music effect = new SoundEffect[3]; effect[0] = Content.Load<SoundEffect>("Sounds/Car_Crash001"); effect[1] = Content.Load<SoundEffect>("Sounds/Car_Crash002"); effect[2] = Content.Load<SoundEffect>("Sounds/Car_Crash003"); //loading // firstbackground = Content.Load<Texture2D>("Sprites/ToyBox"); secondbackground = Content.Load<Texture2D>("Sprites/Players"); CarP1 = Content.Load<Texture2D>("Sprites/Select_cars"); CarP2 = Content.Load<Texture2D>("Sprites/Select_cars"); one = Content.Load<Texture2D>("Sprites/One"); two = Content.Load<Texture2D>("Sprites/Two"); three = Content.Load<Texture2D>("Sprites/Three"); car1 = new AnimatedSprite(carsSpriteSheet, 3, 6,explosionTexture,4,5,car1StartingPos, world, selectP2); car2 = new AnimatedSprite(carsSpriteSheet, 3, 6, explosionTexture, 4, 5, car2StartingPos, world, selectP1); boxPlatform = new BoxPlatform(boxTex, new Vector2(650, 350), world); car1.player1.OnCollision += MyOnCollision; car2.player1.OnCollision += MyOnCollision; //DebugViewXNA view objects _font = Content.Load<SpriteFont>("Sprites/font"); _batch = new SpriteBatch(graphics.GraphicsDevice); _debugView = new DebugViewXNA(world); _debugView.AppendFlags(DebugViewFlags.DebugPanel); _debugView.DefaultShapeColor = Color.White; _debugView.SleepingShapeColor = Color.LightGray; _debugView.LoadContent(GraphicsDevice, Content); // TODO: use this.Content to load your game content here }
/// <summary> /// Initializes screen /// </summary> public override void Initialize() { // Create the scene and add it _camera = new Camera2D(this.Game); _camera.Initialize(); _fxcamera = new Camera2D(this.Game); _fxcamera.Initialize(); _scene = new Scene(this.Game, _camera); _scene.TransitionPosition = 0; _scene.TransitionOnTime = TimeSpan.FromSeconds(1); _scene.TransitionOffTime = TimeSpan.FromSeconds(1); _scene.OffTransition(); _fx = new World(Vector2.UnitY * 10); _fxStaticBody = new Body(_fx) { Restitution = 0, Mass = 0, BodyType = BodyType.Static, Friction = 0.5f/*, Position = ConvertUnits.ToSimUnits(Vector2.UnitX * (_width - DataGrid.WidthInPixels) / 2f + Vector2.UnitY * 150)*/ }; // Create controllers _timeController = new TimeController(this.Game); _pointsController = new PointsController(this.Game); _dataGrid = DataGrid.CreateDataGrid(this.Game, _fxStaticBody, _width / 70 - 1, _height / 49 - 4); _peaController = new PeaController(this.Game); _inputController = new InputController(this.Game); _achievementController = new AchievementController(this.Game); // Initialize controllers _timeController.Initialize(); _pointsController.Initialize(); _dataGrid.Initialize(); _peaController.Initialize(); _inputController.Initialize(); _achievementController.Initialize(); // Register controllers _dataGrid.Register(_peaController); #if DEBUG && _ DataBlock testBlock = _dataGrid.Add(new Point(0, 0), BlockType.Normal); DataBlock testBlock2 = _dataGrid.Add(new Point(0, 1), BlockType.Gel); DataBlock testBlock3 = _dataGrid.Add(new Point(1, 1), BlockType.Normal); DataBlock testBlock4 = _dataGrid.Add(new Point(2, 1), BlockType.RightRamp); DataBlock testBlock5 = _dataGrid.Add(new Point(3, 2), BlockType.Normal); DataBlock testBlock6 = _dataGrid.Add(new Point(DataGrid.Width - 1, DataGrid.Height - 1), BlockType.Normal); #endif // Create the peas DataPea pea1 = new DataPea(this.Game, _fx, _peaController); _pointsController.Register(pea1); _achievementController.Register(pea1); pea1.Initialize(); this.Game.Components.Add(pea1); DataPea pea2 = new DataPea(this.Game, _fx, _peaController); DataPea pea3 = new DataPea(this.Game, _fx, _peaController); DataPea pea4 = new DataPea(this.Game, _fx, _peaController); DataPea pea5 = new DataPea(this.Game, _fx, _peaController); // This needs to be done BEFORE sprites of pea _pointsController.Register(pea2); _pointsController.Register(pea3); _pointsController.Register(pea4); _pointsController.Register(pea5); _achievementController.Register(pea2); _achievementController.Register(pea3); _achievementController.Register(pea4); _achievementController.Register(pea5); pea2.Initialize(); pea3.Initialize(); pea4.Initialize(); pea5.Initialize(); this.Game.Components.Add(pea2); this.Game.Components.Add(pea3); this.Game.Components.Add(pea4); this.Game.Components.Add(pea5); // Create layers _sceneryLayer = new SceneLayer(this.Game, _scene.Camera) { MoveSpeed = 0f, Distance = 0.9f }; _levelLayer = new SceneLayer(this.Game, _scene.Camera) { MoveSpeed = 0f, Distance = 0.6f }; _peasLayer = new SceneLayer(this.Game, _scene.Camera) { MoveSpeed = 0f, Distance = 0.3f }; _hudLayer = new SceneLayer(this.Game, _scene.Camera) { MoveSpeed = 0f, Distance = 0.1f }; // Create sprites _spriteGrid = new SpritesetGrid(_levelLayer) { Position = Vector2.UnitX * (_width - DataGrid.WidthInPixels) / 2f + Vector2.UnitY * 150 }; SpritePea.BaseOffset = _spriteGrid.Position; _peasLayer.Add(new SpritePea(_peasLayer, pea1, _pointsController)); #if !DEBUG || !TEST _peasLayer.Add(new SpritePea(_peasLayer, pea2, _pointsController)); _peasLayer.Add(new SpritePea(_peasLayer, pea3, _pointsController)); _peasLayer.Add(new SpritePea(_peasLayer, pea4, _pointsController)); _peasLayer.Add(new SpritePea(_peasLayer, pea5, _pointsController)); #endif #if DEBUG && TEST for (int i = 0; i < DataGrid.Width; i++) { if (new int[] { 3, 4, 5, 10, 12, 14 }.Contains(i) == false) { DataBlock b = _dataGrid.Add(new Point(i, DataGrid.Height - 1), BlockType.Normal); //_spriteGrid.Add(new SpriteBlock(_levelLayer, b)); if (new int[] { 0 , 1, 2, 5, 8, 15 }.Contains(i)) { b = _dataGrid.Add(new Point(i, DataGrid.Height - 2), BlockType.Normal); //_spriteGrid.Add(new SpriteBlock(_levelLayer, b)); } if (new int[] { 0, 15 }.Contains(i)) { b = _dataGrid.Add(new Point(i, DataGrid.Height - 3), BlockType.Gel); //_spriteGrid.Add(new SpriteBlock(_levelLayer, b)); } if (new int[] { 0, 15 }.Contains(i)) { b = _dataGrid.Add(new Point(i, DataGrid.Height - 4), BlockType.Gel); //_spriteGrid.Add(new SpriteBlock(_levelLayer, b)); } } } DataBlock jump = _dataGrid.Add(new Point(3, 7), BlockType.Normal); //_spriteGrid.Add(new SpriteBlock(_levelLayer, jump)); DataBlock ramp = _dataGrid.Add(new Point(1, 8), BlockType.RightRamp); //_spriteGrid.Add(new SpriteBlock(_levelLayer, ramp)); //DataBlock gel = _dataGrid.Add(new Point(5, 10), BlockType.LeftRamp); //_spriteGrid.Add(new SpriteBlock(_levelLayer, gel)); #else // Some boundary blocks _dataGrid.Add(new Point(0, DataGrid.Height - 1), BlockType.Gel); _dataGrid.Add(new Point(DataGrid.Width - 1, DataGrid.Height - 1), BlockType.Gel); _dataGrid.Add(new Point(0, DataGrid.Height - 2), BlockType.Gel); _dataGrid.Add(new Point(DataGrid.Width - 1, DataGrid.Height - 2), BlockType.Gel); #endif SpriteToolbox toolbox = new SpriteToolbox(_hudLayer) { Position = new Vector2(_width - (1280 - 1220), (Single)Math.Ceiling(150 * (_height / 720f))) }; SpritesetHud hud = new SpritesetHud(_hudLayer, _pointsController, _inputController.State, _width, _height); // Register sprites at inputControllers _inputController.Register(_spriteGrid); _inputController.Register(toolbox); _inputController.Register(_camera, _width, _height); foreach (var blockRow in _dataGrid.Grid) foreach (var block in blockRow) { block.Place(block.BlockType, BlockState.Placed); // Direct placing; _spriteGrid.Add(new SpriteBlock(_levelLayer, block)); } // Add the layers _scene.Add(_sceneryLayer); _scene.Add(_levelLayer); _scene.Add(_peasLayer); _scene.Add(_hudLayer); // Add the content Sprite background = new Sprite(_sceneryLayer, "Graphics/Background"); background.Position = new Vector2(_width / 2f, _height / 2f); background.Origin = new Vector2(1280f / 2f, 720f / 2f); background.Scale = Math.Max(_width / 1280f, _height / 720f); Sprite splate = new Sprite(_sceneryLayer, "Graphics/Plate"); splate.Position = new Vector2(_width / 2f, _height / 2f); splate.Origin = new Vector2(1280f / 2f, 720f / 2f); splate.Scale = Math.Max(_width / 1280f, _height / 720f); _sceneryLayer.Add(background); _sceneryLayer.Add(splate); _levelLayer.Add(_spriteGrid); _hudLayer.Add(toolbox); _hudLayer.Add(hud); // Bottom plate physics var plate = FixtureFactory.AttachRectangle(ConvertUnits.ToSimUnits(_width), ConvertUnits.ToSimUnits(20), 1f, ConvertUnits.ToSimUnits(Vector2.UnitY * (49 * (DataGrid.Height - 3) + _spriteGrid.Position.Y + 5) + (_width / 2 - _spriteGrid.Position.X) * Vector2.UnitX), _fxStaticBody); plate.Restitution = 0; plate.Friction = 0.5f; // Initializes scene and so on base.Initialize(); _scene.Initialize(); _camera.Position = new Vector2(_width / 2f, _height / 2f); _fxcamera.Position = new Vector2(_width / 2f, _height / 2f)- _spriteGrid.Position; // + ConvertUnits.ToSimUnits(_spriteGrid.Position); _camera.Jump2Target(); _fxcamera.Jump2Target(); #if DEBUG && !SILVERLIGHT view = new DebugViewXNA(_fx); view.AppendFlags(FarseerPhysics.DebugViewFlags.CenterOfMass | FarseerPhysics.DebugViewFlags.DebugPanel | FarseerPhysics.DebugViewFlags.PerformanceGraph | FarseerPhysics.DebugViewFlags.PolygonPoints); #endif // Add components this.Game.Components.Add(_peaController); this.Game.Components.Add(_timeController); this.Game.Components.Add(_inputController); this.Game.Components.Add(_pointsController); this.Game.Components.Add(_achievementController); this.Game.Components.Add(_camera); this.Game.Components.Add(_fxcamera); this.Game.Components.Add(_dataGrid); this.Game.Components.Add(_scene); // Add popups _achievementController.OnCompletedAchievement += new AchievementCompletedHandler(_achievementController_OnCompletedAchievement); // Add overlay _overlay = new PauseOverlay(_camera, _width, _height); _overlay.Exiting += new EventHandler(_overlay_Exiting); // Events this.Exited += new EventHandler(PeaScreen_Exited); this.OnEnabledChanged += new BooleanDelegate(PeaScreen_OnEnabledChanged); this.OnVisibleChanged += new BooleanDelegate(PeaScreen_OnVisibleChanged); // Add end _pointsController.OnReachedGoal += new Action(_pointsController_OnReachedGoal); this.IsEnabled = false; this.IsVisible = false; }
private void SetupDebug() { // create and configure the debug view _debugView = new DebugViewXNA ( PhysicsWorld ); _debugView.AppendFlags ( DebugViewFlags.PerformanceGraph ); _debugView.AppendFlags ( DebugViewFlags.CenterOfMass ); _debugView.AppendFlags ( DebugViewFlags.Shape ); _debugView.AppendFlags ( DebugViewFlags.DebugPanel ); //_debugView.AppendFlags(DebugViewFlags.AABB); _debugView.DefaultShapeColor = Color.White; _debugView.SleepingShapeColor = Color.LightGray; _debugView.LoadContent ( GraphicsDevice, Content ); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); if (world == null) { world = new World(new Vector2(0, 9.82f)); } else { world.Clear(); } this.IsMouseVisible = true; lvlBuilder = new LevelBuilder(Content, world); lvlBuilder.readLevel("level1.txt"); backgroundTexture = Content.Load<Texture2D>("cornflowerback"); objectList = lvlBuilder.getLevelObjects(); //FarseerPhysics.Collision font = Content.Load<SpriteFont>("font"); debugView = new DebugViewXNA(world); debugView.LoadContent(this.GraphicsDevice, this.Content); debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Shape); debugView.AppendFlags(FarseerPhysics.DebugViewFlags.PolygonPoints); //debugView.AppendFlags(FarseerPhysics.DebugViewFlags.DebugPanel); debugView.AppendFlags(FarseerPhysics.DebugViewFlags.CenterOfMass); // TODO: use this.Content to load your game content here }
protected override void Initialize() { //primBatch = new PrimitiveBatch(GraphicsDevice); World = new World(new Vector2(0, 9.81f)); Mathe = new Mathe(); Settings = new Settings(graphics); Camera = new Camera(GraphicsDevice.Viewport, Settings.Widescreen); Contents = new Contents(Content, GraphicsDevice); Debug = new DebugView(Contents,Camera); Objectdatabase = new Objectdatabase(Content); Backgrounddatabase = new Backgrounddatabase(Content); Enemydatabase = new Enemydatabase(Content); Animationsmanager = new Animationsmanager(); Keymanager = new Keymanager(Contents, DebugFlag.Inputstats); Player = new Player(Mathe, Contents, World, DebugFlag.PlayerStats); Cursor = new Cursor(Camera, Keymanager, Contents, Settings); Windowmanager = new Windowmanager(Settings, Cursor, DebugFlag.WindowStats, Contents, GraphicsDevice); DepressionHandler = new DyingHope.DepressionHandler(); Itemmanager = new Itemmanager(Mathe, DepressionHandler, Content, Player); Backgroundmanager = new Backgroundmanager(Player, Backgrounddatabase, DebugFlag.BackgrundStats, Contents); Levermanager = new Levermanager(Contents.Meiryo8, Player, Cursor, Mathe, Animationsmanager, Contents); Objectmanager = new Objectmanager(Objectdatabase, Animationsmanager, Player, (DebugFlag.ObjectInformation | DebugFlag.CollisonShape | DebugFlag.ObjectmanagerStats)); Enemymanager = new Enemymanager(Objectmanager, Mathe, Content, Enemydatabase, Player); Windowmanager.Windowdatabase = new Windowdatabase(Contents, Player, Inputmanager); Windowmanager.AddWindow(Windowtype.MainMenue); Eventmanager = new Eventmanager(Mathe, Player, Enemymanager, DepressionHandler, Objectmanager, Objectdatabase, Levermanager); Levelmanager = new Levelmanager(Player, Objectmanager, Animationsmanager, Backgroundmanager, Enemymanager, Itemmanager, Levermanager, Eventmanager, Contents); Editor = new Editor(Windowmanager, Enemymanager, Backgroundmanager, Backgrounddatabase, Objectmanager, Objectdatabase, Eventmanager, Contents, Cursor, Player, Keymanager, Levelmanager, Itemmanager, Levermanager); Debugview = new DebugViewXNA(World); Console.WriteLine(((DebugFlag.ObjectInformation | DebugFlag.CollisonShape | DebugFlag.ObjectmanagerStats)& DebugFlag.ObjectmanagerStats)); light = new SoundObjekt(Settings, Contents.Emitter, Contents.Light, new Vector2(3500 - 576, 700), new Vector2(100, 0), 200); rain = new SoundObjekt(Settings, Contents.Emitter, Contents.Rain, new Vector2(6000 - 576, 0), new Vector2(1000, 0), 400); levelTheme = new List<MSong> { new MSong(Contents.StadtAnfang, 0), new MSong(Contents.StadtLoop, -1), new MSong(Contents.StadtEnde, 0), new MSong(Contents.ParkAnfang, 0), new MSong(Contents.ParkLoop, -1), new MSong(Contents.ParkEnde, 0), new MSong(Contents.SchuleAnfang, 0), new MSong(Contents.SchuleLoop, -1), new MSong(Contents.StadtEnde, 0), new MSong(Contents.MonsterAnfang, 0), new MSong(Contents.MonsterLoop, -1), new MSong(Contents.Ende, 0) }; menueTheme = new List<MSong> { new MSong(Contents.Menue_Theme, 99) }; BackgroundMusic = new BackgroundMusic(Settings, menueTheme); Inputmanager = new Inputmanager(Contents, Camera, Player, Keymanager, Cursor, Enemymanager, Windowmanager, Backgroundmanager, Backgrounddatabase, Objectmanager, Objectdatabase, Eventmanager, Levelmanager, Levermanager, Content, Editor, Debug, DepressionHandler, Mathe, Itemmanager, BackgroundMusic); //Testemitter------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //testEmitter = new Emitter(new Vector2(3000, 850), DebugFlag.Pertikle); //testEmitter.startParticel = 50; //testEmitter.EmitterAngel = new List<Vector2> { new Vector2(180, 180) }; //testEmitter.EmitterRange = new Vector2(1000, 50); //testEmitter.EmitterMaxParticel = 100; //testEmitter.EmitterUpdate = 100f; //testEmitter.EmitterTexture = Contents.Emitter; //testEmitter.ParticelStayOnMax = new Vector2(0, 0); //testEmitter.ParticelLifeDrain = new Vector2(1, 1); //testEmitter.ParticelLifeTime = new Vector2(5000f, 50000f); //testEmitter.ParticelSize = new Vector2(0.1f, 0.5f); //testEmitter.ParticelTexture = new List<Texture2D> { Contents.Nebel, Contents.Nebel2 }; //testEmitter.Origin = new Vector2(Contents.Emitter.Width / 2, Contents.Emitter.Height / 2); //testEmitter.PerticelPower = new Vector2(0.50f, 0.8f); //testEmitter.particelNeverDie = false; //testEmitter.spawnprofile = Spawnprofile.FadeIn; //testEmitter.bewegungsprofil = Bewegungsprofile.Linear; //testEmitter.Start(); //rainEmitter = new Emitter(new Vector2(6000, -10), DebugFlag.Pertikle); //rainEmitter.startParticel = 0; //rainEmitter.particelPerUpdate = new Vector2(1, 100); //rainEmitter.EmitterAngel = new List<Vector2> { new Vector2(270, 270) }; //rainEmitter.EmitterRange = new Vector2(1000, 0); //rainEmitter.EmitterMaxParticel = 60000; //rainEmitter.EmitterUpdate = 10f; //rainEmitter.EmitterTexture = Contents.Emitter; //rainEmitter.ParticelStayOnMax = new Vector2(0, 0); //rainEmitter.ParticelLifeDrain = new Vector2(1, 1); //rainEmitter.ParticelLifeTime = new Vector2(500f, 2000f); //rainEmitter.ParticelSize = new Vector2(0.5f, 1.5f); //rainEmitter.ParticelTexture = new List<Texture2D> { Contents.Rain1 }; //rainEmitter.Origin = new Vector2(Contents.Emitter.Width / 2, Contents.Emitter.Height / 2); //rainEmitter.PerticelPower = new Vector2(10.50f, 20.8f); //rainEmitter.particelNeverDie = false; //rainEmitter.spawnprofile = Spawnprofile.Instant; //rainEmitter.bewegungsprofil = Bewegungsprofile.Linear; //rainEmitter.Start(); menue = new Emitter(new Vector2(GraphicsDevice.Viewport.Width / 2, (GraphicsDevice.Viewport.Height / 2)+20), DebugFlag.Pertikle); menue.startParticel = 0; menue.particelPerUpdate = new Vector2(1, 5); menue.EmitterAngel = new List<Vector2> { new Vector2(0, 360) }; menue.EmitterRange = new Vector2(250, 50); menue.EmitterMaxParticel = 6000; menue.EmitterUpdate = 100f; menue.EmitterTexture = Contents.Emitter; menue.ParticelStayOnMax = new Vector2(0, 100); menue.ParticelLifeDrain = new Vector2(1, 1); menue.ParticelLifeTime = new Vector2(1000f, 3000f); menue.ParticelSize = new Vector2(0.065f, 0.09f); menue.ParticelTexture = new List<Texture2D> { Contents.Partikel1, Contents.Partikel2, Contents.Partikel3 }; menue.Origin = new Vector2(Contents.Emitter.Width / 2, Contents.Emitter.Height / 2); menue.PerticelPower = new Vector2(0.2f, 0.9f); menue.particelNeverDie = false; menue.spawnprofile = Spawnprofile.FadeIn; menue.bewegungsprofil = Bewegungsprofile.LinearRandom; menue.Start(); //Debug------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Debug.Add(Player); Debug.Add(Objectmanager); Debug.Add(Keymanager); Debug.Add(Backgroundmanager); Debug.Add(Windowmanager); Debug.Add(DepressionHandler); //Debug.Add(testEmitter); //Debug.AppendFlag(DebugFlag.PlayerStats, false); //Debug.AppendFlag(DebugFlag.ObjectmanagerStats,false); //Debug.AppendFlag(DebugFlag.ObjectInformation, true); //Debug.AppendFlag(DebugFlag.CollisonShape, true); Debugview.DebugPanelPosition = new Vector2(500, 100); Debugview.AppendFlags(DebugViewFlags.DebugPanel); Debugview.LoadContent(GraphicsDevice, Content); base.Initialize(); }