protected override void Draw() { double framerate = Editor.GetFrameRate; KeyboardState ks = Keyboard.GetState(); base.Draw(); Matrix transformMatrix = cam.Camera.GetViewMatrix(); BackgroundColor = Color.Black; Editor.graphics.Clear(BackgroundColor); Input.MousePosition = MousePositionTranslated; Sgml.currentRoom = currentRoom; if (DrawGrid) { Color c = Color.Black; c.A = 128; Editor.spriteBatch.Begin(transformMatrix: transformMatrix); for (float i = 0; i < 768; i += GridSizeRender.Y) { for (float j = 0; j < 1024; j += GridSizeRender.X) { i = (float)Math.Round(i); j = (float)Math.Round(j); Editor.spriteBatch.DrawRectangle(new RectangleF(j, i, GridSizeRender.X, GridSizeRender.Y), c, 1); } } Editor.spriteBatch.End(); } foreach (RoomLayer rl in roomLayers) { if (rl.LayerType == RoomLayer.LayerTypes.typeTile) { Color c = Color.White; c.A = 128; Editor.spriteBatch.Begin(transformMatrix: transformMatrix); int xIndex = 0; int yIndex = 0; for (float i = 0; i < 768; i += GridSizeRender.Y) { for (float j = 0; j < 1024; j += GridSizeRender.X) { xIndex++; i = (float)Math.Round(i); j = (float)Math.Round(j); } yIndex++; xIndex = 0; } foreach (Tile t in ((TileLayer)rl).Tiles) { Editor.spriteBatch.Draw(t.SourceTexture, new Vector2(t.PosX * 32, t.PosY * 32), t.DrawRectangle, Color.White); } Editor.spriteBatch.End(); } } Matrix view = cam.Camera.GetViewMatrix(); Matrix projection = m; basicEffect.World = world; basicEffect.View = view; basicEffect.Projection = projection; basicEffect.VertexColorEnabled = true; foreach (RoomLayer rl in roomLayers.ToList()) { if (rl.Visible) { // ------------ positions doesn't matter here ------------- // Layer is tile if (rl is TileLayer) { Editor.spriteBatch.Begin(transformMatrix: transformMatrix); foreach (Tile t in ((TileLayer)rl).Tiles) { Editor.spriteBatch.Draw(t.SourceTexture, new Vector2(t.PosX * 32, t.PosY * 32), t.DrawRectangle, Color.White); } Editor.spriteBatch.End(); } // Layer is object if (rl is ObjectLayer) { foreach (GameObject o in ((ObjectLayer)rl).Objects.ToList()) { List <GameObject> possibleColliders = sh.ObjectsNearby(o); // already works for bruteforce /* foreach (GameObject g2 in possibleColliders) * { * if (g2 == o) * { * continue; * } * * if (g2.GetType() == typeof(Object3)) * { * if (ColliderCircle.CircleInCircle((ColliderCircle)g2.Colliders[0], (ColliderCircle)o.Colliders[0])) * { * if (g2 != o && (o.Colliders[0] as ColliderCircle).Position.X != 0 && (g2.Colliders[0] as ColliderCircle).Position.X != 0) * { * ((Object3) g2).color = Color.Red; * // ColliderCircle.ResolveCircleCircleCollisionElastic(g2, o); * } * } * else * { * //((Object3)g2).color = Color.White; * } * }*/ o.PositionPrevious = o.Position; o.EvtDraw(Editor.spriteBatch, Editor.Font, o.Sprite.Texture, vertexBuffer, basicEffect, transformMatrix); RectangleF r = new RectangleF(o.Position, new Size2(o.Sprite.ImageRectangle.Width, o.Sprite.ImageRectangle.Height)); if (o == clickedObject || r.Intersects(selectionRectangle) || selectedRectangleObjects.Contains(o)) { Editor.spriteBatch.Begin(transformMatrix: transformMatrix); Editor.spriteBatch.DrawRectangle( new RectangleF(o.Position, new Size2(o.Sprite.ImageRectangle.Width, o.Sprite.ImageRectangle.Height)), Color.White, 2); Editor.spriteBatch.End(); } } } } } if (ks.IsKeyDown(Keys.LeftControl)) { Editor.spriteBatch.Begin(transformMatrix: transformMatrix); Editor.spriteBatch.DrawRectangle(selectionRectangle, Color.White, 2); Editor.spriteBatch.End(); } Editor.spriteBatch.Begin(); Editor.spriteBatch.DrawString(Editor.Font, framerate.ToString("F1"), new Vector2(10, 10), Color.White); Editor.spriteBatch.End(); killClick = false; Input.KeyboardStatePrevious = Keyboard.GetState(); Input.Clear(); }