public override void OnLoad(BWindow Window) { base.OnLoad(Window); // Initialising our player Player = new Player( new Vector2((Level.playerStartPos.X + 0.5f) * AppInfo.GRIDSIZE, (Level.playerStartPos.Y + 0.5f) * AppInfo.GRIDSIZE), BGraphics.LoadTexture("Characters/player.png"), BMovementType.FollowPath ); // Initialise the navmesh this.NavMesh = new BNavigationGrid(0, 0, Level.Width, Level.Height, AppInfo.GRIDSIZE, (int)(Player.CollisionBox.Width * 1.25f), (int)(Player.CollisionBox.Height * 1.25f)); NavMesh.Update(Level); // Initialise our camera settings Camera.SetPosition(Player.position); Camera.Zoom = 1.0f; // Lets put some fences in the game for (int i = 0; i < 6; i++) { Level.CreateEntity(new Fence(new Vector2(500 + (i * 32), 600), Textures[1], new Vector2(32f), new RectangleF(256f, 0, 256f, 256f))); } }
public void Render() { GL.Clear(ClearBufferMask.ColorBufferBit); GL.ClearColor(Color.Black); BGraphics.Begin(Window.GameWindow.Width, Window.GameWindow.Height); Draw(); Window.GameWindow.SwapBuffers(); }
public override void OnLoad(BWindow Window) { base.OnLoad(Window); // Initialise our menu buttons BMenuButton[] buttons = new BMenuButton[] { new BMenuButton(SwitchState, BGraphics.LoadTexture("Textures/Menu/play.png"), 300f, 300f, 250f, 60f), new BMenuButton(Window.ExitWindow, BGraphics.LoadTexture("Textures/Menu/quit.png"), 300f, 380f, 250f, 60f) }; InitialiseMenu(buttons); }
public override void InitialiseLevel() { base.InitialiseLevel(); // Initialising our textures (We can have up to 255 images. Make the most of this by using sprite sheets.) Textures[0] = BGraphics.LoadTexture("Textures/terrain_default.png"); Textures[1] = BGraphics.LoadTexture("Textures/entities_default.png"); // Initialising our blocks (We can have up to 254 blocks, id 1 to 254) Blocks.Initialise(); // Initialising our level Level = new BLevel("test_map"); }
public override void Draw() { BGraphics.Draw( spritesheet, this.position - (new Vector2(DrawBox.Width / 2f, DrawBox.Height / 1.35f)), new Vector2((DrawBox.Width / currentSprite.Width), (DrawBox.Height / currentSprite.Height)), Color.Transparent, Vector2.Zero, currentSprite ); if (AppSettings.SETTING_COLLISION_DEBUG) { BGraphics.DrawRec(this.position - (new Vector2(CollisionBox.Width, CollisionBox.Height) / 2f), CollisionBox, Color.AliceBlue); } }
public override void Draw() { Camera.ApplyTransform(); base.Draw(); for (int x = 0; x < Level.Width; x++) { for (int y = 0; y < Level.Height; y++) { RectangleF source = Level[x, y].TexturePosition; BGraphics.Draw(Textures[0], new Vector2(x * AppInfo.GRIDSIZE, y * AppInfo.GRIDSIZE), new Vector2((float)AppInfo.GRIDSIZE / AppInfo.TILESIZE), Color.Transparent, Vector2.Zero, source); } } List <BEntity> renderOrder = new List <BEntity>(); renderOrder.AddRange(Level.Entities); if (Player != null) { renderOrder.Add(Player); } renderOrder = renderOrder.OrderBy(x => x.GroundLevel).ToList <BEntity>(); foreach (BEntity entity in renderOrder) { if (entity == null) { return; } entity.Draw(); } if (AppSettings.SETTING_NAVIGATION_DEBUG) { for (int x = 0; x < NavMesh.Width; x++) { for (int y = 0; y < NavMesh.Height; y++) { var color = Color.Green; if (NavMesh[x, y].Obstructed) { color = Color.Red; } else if (!NavMesh[x, y].Visited) { color = Color.Black; } BGraphics.DrawRec(new Vector2(x * NavMesh.TileSizeX, y * NavMesh.TileSizeY), new RectangleF(x * NavMesh.TileSizeX, y * NavMesh.TileSizeY, NavMesh.TileSizeX, NavMesh.TileSizeY), color); } } } if (AppSettings.SETTING_PATHFINDING_DEBUG) { if (NavMesh.DestNode != null) { BPathNode pathNode = NavMesh.DestNode; BGraphics.DrawRec(new Vector2(pathNode.X * NavMesh.TileSizeX, pathNode.Y * NavMesh.TileSizeY), new RectangleF(pathNode.X * NavMesh.TileSizeX, pathNode.Y * NavMesh.TileSizeY, NavMesh.TileSizeX, NavMesh.TileSizeY), Color.Orange); while (pathNode.Parent != null) { BGraphics.DrawRec(new Vector2(pathNode.X * NavMesh.TileSizeX, pathNode.Y * NavMesh.TileSizeY), new RectangleF(pathNode.X * NavMesh.TileSizeX, pathNode.Y * NavMesh.TileSizeY, NavMesh.TileSizeX, NavMesh.TileSizeY), Color.Yellow); pathNode = pathNode.Parent; } } } }