// TODO : Move to a lua script void ControlPlayer() { player.angle += Input.deltaMouse.X * Dungeon.deltaTime / 4; player.angle %= Math.PI * 2; float forwardSpeed = Input.movement.Y * Dungeon.deltaTime * 4; float sideSpeed = Input.movement.X * Dungeon.deltaTime * 4; Vector2 vel = Vector2.Zero; vel.X += (float)Math.Cos(player.angle) * -forwardSpeed; vel.Y += (float)Math.Sin(player.angle) * -forwardSpeed; vel.X += (float)Math.Cos(player.angle + Math.PI / 2) * sideSpeed; vel.Y += (float)Math.Sin(player.angle + Math.PI / 2) * sideSpeed; if (!Dungeon.IsBlocking(player.pos + vel)) { player.pos += vel; bobAngle += 5 * vel.Length(); if (bobAngle > Math.PI * 2) { bobAngle = 0; API.PlaySound("Step", 1, 0); } headBob = (int)(Math.Sin(bobAngle) * 4); } }
void DrawMiniMap() { Point offset = new Point(0, 0); // loop through world for (int x = 0; x < Dungeon.width; x++) { for (int y = 0; y < Dungeon.height; y++) { //draw solid blocks if (!Dungeon.IsBlocking(x, y)) { ctx.SetPixel(x + offset.X, y + offset.Y, 0, Color.FromNonPremultiplied(0, 255, 0, 100)); } } } // draw the player ctx.SetPixel((int)player.pos.X + offset.X, (int)player.pos.Y + offset.Y, Color.FromNonPremultiplied(50, 50, 255, 200)); }
/// <summary> /// Checks if the block is a wall /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public static bool IsBlockSolid(int x, int y) { return(Dungeon.IsBlocking(x, y)); }