public void RenderWipe(DoomApplication app, WipeEffect wipe) { this.RenderApplication(app); var scale = this.screen.Width / 320; for (var i = 0; i < this.wipeBandCount - 1; i++) { var x1 = this.wipeBandWidth * i; var x2 = x1 + this.wipeBandWidth; var y1 = Math.Max(scale * wipe.Y[i], 0); var y2 = Math.Max(scale * wipe.Y[i + 1], 0); var dy = (float)(y2 - y1) / this.wipeBandWidth; for (var x = x1; x < x2; x++) { var y = (int)MathF.Round(y1 + dy * ((x - x1) / 2 * 2)); var copyLength = this.screen.Height - y; if (copyLength > 0) { var srcPos = this.screen.Height * x; var dstPos = this.screen.Height * x + y; Array.Copy(this.wipeBuffer, srcPos, this.screen.Data, dstPos, copyLength); } } } this.RenderMenu(app); this.Display(this.palette[0]); }
public void RenderMenu(DoomApplication app) { if (app.Menu.Active) { this.menu.Render(app.Menu); } }
public void Render(DoomApplication app) { //var watch = System.Diagnostics.Stopwatch.StartNew(); RenderApplication(app); //Console.WriteLine("RenderApplication: {0} s", (float)(watch.ElapsedMilliseconds) / 1000); //watch.Restart(); RenderMenu(app); //Console.WriteLine("RenderMenu: {0} s", (float)(watch.ElapsedMilliseconds) / 1000); //watch.Restart(); var colors = palette[0]; if (app.State == ApplicationState.Game && app.Game.State == GameState.Level) { colors = palette[GetPaletteNumber(app.Game.World.ConsolePlayer)]; } else if (app.State == ApplicationState.Opening && app.Opening.State == OpeningSequenceState.Demo && app.Opening.DemoGame.State == GameState.Level) { colors = palette[GetPaletteNumber(app.Opening.DemoGame.World.ConsolePlayer)]; } else if (app.State == ApplicationState.DemoPlayback && app.DemoPlayback.Game.State == GameState.Level) { colors = palette[GetPaletteNumber(app.DemoPlayback.Game.World.ConsolePlayer)]; } Display(colors); }
public QuitConfirm(DoomMenu menu, DoomApplication app) : base(menu) { this.app = app; this.random = new DoomRandom(DateTime.Now.Millisecond); this.endCount = -1; }
public void RenderApplication(DoomApplication app) { //var watch = System.Diagnostics.Stopwatch.StartNew(); if (app.State == ApplicationState.Opening) { openingSequence.Render(app.Opening); } else if (app.State == ApplicationState.DemoPlayback) { RenderGame(app.DemoPlayback.Game); } else if (app.State == ApplicationState.Game) { RenderGame(app.Game); } //Console.WriteLine("RenderApplication 1st part: {0} s", (float)(watch.ElapsedMilliseconds) / 1000); //watch.Restart(); if (!app.Menu.Active) { if (app.State == ApplicationState.Game && app.Game.State == GameState.Level && app.Game.Paused) { var scale = screen.Width / 320; screen.DrawPatch( pause, (screen.Width - scale * pause.Width) / 2, 4 * scale, scale); } } //Console.WriteLine("RenderApplication 2nd part: {0} s", (float)(watch.ElapsedMilliseconds) / 1000); //watch.Restart(); }
public void Render(DoomApplication app) { RenderApplication(app); RenderMenu(app); var colors = palette[0]; if (app.State == ApplicationState.Game && app.Game.State == GameState.Level) { colors = palette[GetPaletteNumber(app.Game.World.ConsolePlayer)]; } else if (app.State == ApplicationState.Opening && app.Opening.State == OpeningSequenceState.Demo && app.Opening.DemoGame.State == GameState.Level) { colors = palette[GetPaletteNumber(app.Opening.DemoGame.World.ConsolePlayer)]; } else if (app.State == ApplicationState.DemoPlayback && app.DemoPlayback.Game.State == GameState.Level) { colors = palette[GetPaletteNumber(app.DemoPlayback.Game.World.ConsolePlayer)]; } Display(colors); }
public void RenderApplication(DoomApplication app) { if (app.State == ApplicationState.Opening) { openingSequence.Render(app.Opening); } else if (app.State == ApplicationState.DemoPlayback) { RenderGame(app.DemoPlayback.Game); } else if (app.State == ApplicationState.Game) { RenderGame(app.Game); } if (!app.Menu.Active) { if (app.State == ApplicationState.Game && app.Game.State == GameState.Level && app.Game.Paused) { var scale = screen.Width / 320; screen.DrawPatch( pause, (screen.Width - scale * pause.Width) / 2, 4 * scale, scale); } } }
public void Render(DoomApplication app) { if (app.State == ApplicationState.Opening) { openingSequence.Render(app.Opening); } else if (app.State == ApplicationState.Game) { RenderGame(app.Game); } if (app.Menu.Active) { menu.Render(app.Menu); } var screenData = screen.Data; var p = MemoryMarshal.Cast <byte, uint>(sfmlTextureData); for (var i = 0; i < p.Length; i++) { p[i] = colors[screenData[i]]; } sfmlTexture.Update(sfmlTextureData, (uint)screen.Height, (uint)screen.Width, 0, 0); sfmlWindow.Draw(sfmlSprite, sfmlStates); sfmlWindow.Display(); }
public void Render(DoomApplication app) { this.RenderApplication(app); this.RenderMenu(app); var colors = this.palette[0]; if (app.State == ApplicationState.Game && app.Game.State == GameState.Level) { colors = this.palette[SfmlRenderer.GetPaletteNumber(app.Game.World.Options.Player)]; } this.Display(colors); }
public void RenderApplication(DoomApplication app) { if (app.State == ApplicationState.Opening) { this.openingSequence.Render(app.Opening); } else if (app.State == ApplicationState.Game) { this.RenderGame(app.Game); } if (!app.Menu.Active) { if (app.State == ApplicationState.Game && app.Game.State == GameState.Level && app.Game.Paused) { var scale = this.screen.Width / 320; this.screen.DrawPatch(this.pause, (this.screen.Width - scale * this.pause.Width) / 2, 4 * scale, scale); } } }
private static bool IsPressed(KeyBinding keyBinding) { foreach (var key in keyBinding.Keys) { if (DoomApplication.IsKeyPressed(key)) { return(true); } } foreach (var mouseButton in keyBinding.MouseButtons) { if (Mouse.IsButtonPressed((Mouse.Button)mouseButton)) { return(true); } } return(false); }
public DoomMenu(DoomApplication app) { this.app = app; this.options = app.Options; this.thisIsShareware = new PressAnyKey(this, DoomInfo.Strings.SWSTRING, null); this.saveFailed = new PressAnyKey(this, DoomInfo.Strings.SAVEDEAD, null); this.nightmareConfirm = new YesNoConfirm(this, DoomInfo.Strings.NIGHTMARE, () => app.NewGame(GameSkill.Nightmare, this.selectedEpisode, 1)); this.endGameConfirm = new YesNoConfirm(this, DoomInfo.Strings.ENDGAME, () => app.EndGame()); this.quitConfirm = new QuitConfirm(this, app); this.skillMenu = new SelectableMenu( this, "M_NEWG", 96, 14, "M_SKILL", 54, 38, 2, new SimpleMenuItem("M_JKILL", 16, 58, 48, 63, () => app.NewGame(GameSkill.Baby, this.selectedEpisode, 1), null), new SimpleMenuItem("M_ROUGH", 16, 74, 48, 79, () => app.NewGame(GameSkill.Easy, this.selectedEpisode, 1), null), new SimpleMenuItem("M_HURT", 16, 90, 48, 95, () => app.NewGame(GameSkill.Medium, this.selectedEpisode, 1), null), new SimpleMenuItem("M_ULTRA", 16, 106, 48, 111, () => app.NewGame(GameSkill.Hard, this.selectedEpisode, 1), null), new SimpleMenuItem("M_NMARE", 16, 122, 48, 127, null, this.nightmareConfirm) ); if (DoomApplication.Instance.IWad == "doom" || DoomApplication.Instance.IWad == "freedoom") { this.episodeMenu = new SelectableMenu( this, "M_EPISOD", 54, 38, 0, new SimpleMenuItem("M_EPI1", 16, 58, 48, 63, () => this.selectedEpisode = 1, this.skillMenu), new SimpleMenuItem("M_EPI2", 16, 74, 48, 79, () => this.selectedEpisode = 2, this.skillMenu), new SimpleMenuItem("M_EPI3", 16, 90, 48, 95, () => this.selectedEpisode = 3, this.skillMenu), new SimpleMenuItem("M_EPI4", 16, 106, 48, 111, () => this.selectedEpisode = 4, this.skillMenu) ); } else { if (DoomApplication.Instance.IWad == "doom1") { this.episodeMenu = new SelectableMenu( this, "M_EPISOD", 54, 38, 0, new SimpleMenuItem("M_EPI1", 16, 58, 48, 63, () => this.selectedEpisode = 1, this.skillMenu), new SimpleMenuItem("M_EPI2", 16, 74, 48, 79, null, this.thisIsShareware), new SimpleMenuItem("M_EPI3", 16, 90, 48, 95, null, this.thisIsShareware) ); } else { this.episodeMenu = new SelectableMenu( this, "M_EPISOD", 54, 38, 0, new SimpleMenuItem("M_EPI1", 16, 58, 48, 63, () => this.selectedEpisode = 1, this.skillMenu), new SimpleMenuItem("M_EPI2", 16, 74, 48, 79, () => this.selectedEpisode = 2, this.skillMenu), new SimpleMenuItem("M_EPI3", 16, 90, 48, 95, () => this.selectedEpisode = 3, this.skillMenu) ); } } var sound = this.options.Sound; var music = this.options.Music; this.volume = new SelectableMenu( this, "M_SVOL", 60, 38, 0, new SliderMenuItem("M_SFXVOL", 48, 59, 80, 64, sound.MaxVolume + 1, () => sound.Volume, vol => sound.Volume = vol), new SliderMenuItem("M_MUSVOL", 48, 91, 80, 96, music.MaxVolume + 1, () => music.Volume, vol => music.Volume = vol) ); var renderer = this.options.Renderer; var userInput = this.options.UserInput; this.optionMenu = new SelectableMenu( this, "M_OPTTTL", 108, 15, 0, new SimpleMenuItem("M_ENDGAM", 28, 32, 60, 37, null, this.endGameConfirm, () => app.State == ApplicationState.Game), new ToggleMenuItem( "M_MESSG", 28, 48, 60, 53, "M_MSGON", "M_MSGOFF", 180, () => renderer.DisplayMessage ? 0 : 1, value => renderer.DisplayMessage = value == 0 ), new SliderMenuItem( "M_SCRNSZ", 28, 80 - 16, 60, 85 - 16, renderer.MaxWindowSize + 1, () => renderer.WindowSize, size => renderer.WindowSize = size ), new SliderMenuItem( "M_MSENS", 28, 112 - 16, 60, 117 - 16, userInput.MaxMouseSensitivity + 1, () => userInput.MouseSensitivity, ms => userInput.MouseSensitivity = ms ), new SimpleMenuItem("M_SVOL", 28, 144 - 16, 60, 149 - 16, null, this.volume) ); this.load = new LoadMenu( this, "M_LOADG", 72, 28, 0, new TextBoxMenuItem(48, 49, 72, 61), new TextBoxMenuItem(48, 65, 72, 77), new TextBoxMenuItem(48, 81, 72, 93), new TextBoxMenuItem(48, 97, 72, 109), new TextBoxMenuItem(48, 113, 72, 125), new TextBoxMenuItem(48, 129, 72, 141) ); this.save = new SaveMenu( this, "M_SAVEG", 72, 28, 0, new TextBoxMenuItem(48, 49, 72, 61), new TextBoxMenuItem(48, 65, 72, 77), new TextBoxMenuItem(48, 81, 72, 93), new TextBoxMenuItem(48, 97, 72, 109), new TextBoxMenuItem(48, 113, 72, 125), new TextBoxMenuItem(48, 129, 72, 141) ); this.help = new HelpScreen(this); if (DoomApplication.Instance.IWad == "doom2" || DoomApplication.Instance.IWad == "freedoom2" || DoomApplication.Instance.IWad == "plutonia" || DoomApplication.Instance.IWad == "tnt") { this.main = new SelectableMenu( this, "M_DOOM", 94, 2, 0, new SimpleMenuItem("M_NGAME", 65, 67, 97, 72, null, this.skillMenu), new SimpleMenuItem("M_OPTION", 65, 83, 97, 88, null, this.optionMenu), new SimpleMenuItem("M_LOADG", 65, 99, 97, 104, null, this.load), new SimpleMenuItem( "M_SAVEG", 65, 115, 97, 120, null, this.save, () => !(app.State == ApplicationState.Game && app.Game.State != GameState.Level) ), new SimpleMenuItem("M_QUITG", 65, 131, 97, 136, null, this.quitConfirm) ); } else { this.main = new SelectableMenu( this, "M_DOOM", 94, 2, 0, new SimpleMenuItem("M_NGAME", 65, 59, 97, 64, null, this.episodeMenu), new SimpleMenuItem("M_OPTION", 65, 75, 97, 80, null, this.optionMenu), new SimpleMenuItem("M_LOADG", 65, 91, 97, 96, null, this.load), new SimpleMenuItem( "M_SAVEG", 65, 107, 97, 112, null, this.save, () => !(app.State == ApplicationState.Game && app.Game.State != GameState.Level) ), new SimpleMenuItem("M_RDTHIS", 65, 123, 97, 128, null, this.help), new SimpleMenuItem("M_QUITG", 65, 139, 97, 144, null, this.quitConfirm) ); } this.current = this.main; this.active = false; this.tics = 0; this.selectedEpisode = 1; this.saveSlots = new SaveSlots(); }
public static void Main(string[] args) { using var engine = new DoomApplication(new SfmlPlatform(), new CommandLineArgs(args)); engine.Run(); }
public void BuildTicCmd(TicCmd cmd) { var keyForward = IsPressed(config.key_forward); var keyBackward = IsPressed(config.key_backward); var keyStrafeLeft = IsPressed(config.key_strafeleft); var keyStrafeRight = IsPressed(config.key_straferight); var keyTurnLeft = IsPressed(config.key_turnleft); var keyTurnRight = IsPressed(config.key_turnright); var keyFire = IsPressed(config.key_fire); var keyUse = IsPressed(config.key_use); var keyRun = IsPressed(config.key_run); var keyStrafe = IsPressed(config.key_strafe); weaponKeys[0] = DoomApplication.IsKeyPressed(DoomKey.Num1); weaponKeys[1] = DoomApplication.IsKeyPressed(DoomKey.Num2); weaponKeys[2] = DoomApplication.IsKeyPressed(DoomKey.Num3); weaponKeys[3] = DoomApplication.IsKeyPressed(DoomKey.Num4); weaponKeys[4] = DoomApplication.IsKeyPressed(DoomKey.Num5); weaponKeys[5] = DoomApplication.IsKeyPressed(DoomKey.Num6); weaponKeys[6] = DoomApplication.IsKeyPressed(DoomKey.Num7); cmd.Clear(); var strafe = keyStrafe; var speed = keyRun ? 1 : 0; var forward = 0; var side = 0; if (config.game_alwaysrun) { speed = 1 - speed; } if (keyTurnLeft || keyTurnRight) { turnHeld++; } else { turnHeld = 0; } int turnSpeed; if (turnHeld < PlayerBehavior.SlowTurnTics) { turnSpeed = 2; } else { turnSpeed = speed; } if (strafe) { if (keyTurnRight) { side += PlayerBehavior.SideMove[speed]; } if (keyTurnLeft) { side -= PlayerBehavior.SideMove[speed]; } } else { if (keyTurnRight) { cmd.AngleTurn -= (short)PlayerBehavior.AngleTurn[turnSpeed]; } if (keyTurnLeft) { cmd.AngleTurn += (short)PlayerBehavior.AngleTurn[turnSpeed]; } } if (keyForward) { forward += PlayerBehavior.ForwardMove[speed]; } if (keyBackward) { forward -= PlayerBehavior.ForwardMove[speed]; } if (keyStrafeLeft) { side -= PlayerBehavior.SideMove[speed]; } if (keyStrafeRight) { side += PlayerBehavior.SideMove[speed]; } if (keyFire) { cmd.Buttons |= TicCmdButtons.Attack; } if (keyUse) { cmd.Buttons |= TicCmdButtons.Use; } // Check weapon keys. for (var i = 0; i < weaponKeys.Length; i++) { if (weaponKeys[i]) { cmd.Buttons |= TicCmdButtons.Change; cmd.Buttons |= (byte)(i << TicCmdButtons.WeaponShift); break; } } if (useMouse) { UpdateMouse(); var ms = 0.5F * config.mouse_sensitivity; var mx = (int)MathF.Round(ms * mouseX); var my = (int)MathF.Round(ms * mouseY); forward += my; if (strafe) { side += mx * 2; } else { cmd.AngleTurn -= (short)(mx * 0x8); } } if (forward > PlayerBehavior.MaxMove) { forward = PlayerBehavior.MaxMove; } else if (forward < -PlayerBehavior.MaxMove) { forward = -PlayerBehavior.MaxMove; } if (side > PlayerBehavior.MaxMove) { side = PlayerBehavior.MaxMove; } else if (side < -PlayerBehavior.MaxMove) { side = -PlayerBehavior.MaxMove; } cmd.ForwardMove += (sbyte)forward; cmd.SideMove += (sbyte)side; }