public static void startGame() { if (!KeyMap.readFromFile()) { OggBuffer kError = DSound.playOgg(DSound.NSoundPath + "\\kme.ogg"); while (kError.isPlaying()) { if (dxInput.isKeyHeldDown()) { break; } Thread.Sleep(10); } //while kError.stopOgg(); kError = null; } Options.setDifficulty(Options.difficulties.easy); Interaction.clearData(); mainMenu(); if (!Options.requestedShutdown) { Common.startGame(); if (Common.firstTimeLoad) { Common.firstTimeLoad = false; while (!Common.threadNotifier) { Thread.Sleep(6000); } } } }
public static void startGame(bool firstTimeLoad) { if (!firstTimeLoad) { return; } try { textBox1 = new TextBox(); textBox1.Location = new System.Drawing.Point(0, 0); textBox1.Name = "textBox1"; textBox1.ReadOnly = true; textBox1.Size = new System.Drawing.Size(100, 20); textBox1.TabIndex = 0; SapiSpeech.initialize(); DSound.initialize(textBox1.Handle); dxInput.DInputInit(textBox1); DSound.initializeOgg(); Options.readFromFile(); KeyMap.initialize(); //this.Deactivate += new EventHandler(GUI_Deactivate); //this.Activated += new EventHandler(GUI_Activated); if (!Common.isRegistered()) { MessageBox.Show("This game is not registered. Please contact" + " BPCPrograms SD to obtain a license.", "Registration"); } register(); OggBuffer introSound = DSound.playOgg(DSound.SoundPath + "\\i.ogg"); while ((introSound.isPlaying() && !dxInput.isKeyHeldDown())) { Thread.Sleep(5); } introSound.stopOgg(); introSound = null; } catch (Exception err) { MessageBox.Show(err.Message + " " + err.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); } }
private static void buildKeyMapMenu() { string[] devices = { "mainmenu_5_1_1.wav", "mainmenu_5_1_2.wav" }; short dO = Common.sVGenerateMenu("mainmenu_5_1_i.wav", devices); if (dO == -1) { return; } bool mapKeyboard = false; bool mapJoystick = false; if (dO == 0) { mapKeyboard = true; } else { mapJoystick = true; } short index = -1; Key[] r = null; Key[] m = null; ////modifiers will only be assigned if keyboard is used int[] jsKey = null; while (index != 0) { r = null; m = null; jsKey = null; string[] strKeys = null; if (mapKeyboard) { strKeys = KeyMap.getKeyStrings(null); } else { strKeys = KeyMap.getKeyStrings(Vehicle.Action.throttleUp, Vehicle.Action.throttleDown, Vehicle.Action.turnLeft, Vehicle.Action.turnRight, Vehicle.Action.bankLeft, Vehicle.Action.bankRight, Vehicle.Action.rollLeft, Vehicle.Action.rollRight, Vehicle.Action.brakeLeft, Vehicle.Action.brakeRight, Vehicle.Action.highGTurn, Vehicle.Action.ascend, Vehicle.Action.descend, Vehicle.Action.level, Vehicle.Action.togglePointOfView, Vehicle.Action.increaseMusicVolume, Vehicle.Action.decreaseMusicVolume); } index = (short)(Common.sVGenerateMenu("ki.wav", strKeys) + 1); if (index > 0) { if (mapKeyboard) { OggBuffer prompt = DSound.playOgg(DSound.NSoundPath + "\\kmp1.ogg"); while (dxInput.isKeyHeldDown()) { ////wait till the user lets up on enter. Application.DoEvents(); } while (m == null) { m = dxInput.getKeys(); } prompt.stopOgg(); prompt = null; prompt = DSound.playOgg(DSound.NSoundPath + "\\kmp2.ogg"); while ((dxInput.isKeyHeldDown())) { ////wait till the user lets up on enter. Application.DoEvents(); } ////Next, get a key while (r == null) { r = dxInput.getKeys(); } prompt.stopOgg(); prompt = null; if (m[0] == Key.Return) { KeyMap.addKey((Vehicle.Action)index, r[0]); } else { KeyMap.addKey((Vehicle.Action)index, m[0], r[0]); } } else { ////joystick OggBuffer prompt = DSound.playOgg(DSound.NSoundPath + "\\kmp3.ogg"); while (dxInput.isJSButtonHeldDown()) { Application.DoEvents(); } while (jsKey == null) { jsKey = dxInput.getJSKeys(); Application.DoEvents(); } prompt.stopOgg(); prompt = null; KeyMap.addKey((Vehicle.Action)index, dxInput.getJSKeys()[0]); } ////joystick } ////index>=0 } ////Since the parent loop has been broken, the user has pressed escape. ////We need to save the new keymap data to a file now so that it will be restored when the game loads KeyMap.saveToFile(); }
public static void mainMenu() { Common.music = DSound.playOgg(DSound.SoundPath + "\\ms1.ogg", true); string[] m1 = { "mainmenu_1.wav", "mainmenu_2.wav", "mainmenu_3.wav", "mainmenu_5.wav", "mainmenu_4.wav" }; bool exitMenu = false; while (!exitMenu) { short index = Common.sVGenerateMenu("mainmenu_i.wav", m1); switch (index) { case 0: ////start game if (Options.mode == Options.Modes.racing) { if (selectTrack()) { exitMenu = true; } } if (Options.mode == Options.Modes.deathMatch) { exitMenu = true; } if (Options.mode == Options.Modes.mission) { exitMenu = true; } break; case 1: ////select racing mode string[] modeOptions = { "mainmenu_2_1.wav", "mainmenu_2_2.wav", "mainmenu_2_3.wav" }; short modeIndex = Common.sVGenerateMenu("", modeOptions); if (modeIndex == -1) { break; } Options.mode = (Options.Modes)(modeIndex + 1); if (Options.mode == Options.Modes.mission) { Mission.isMission = true; } else { Mission.isMission = false; ////reset in case coming ////out of mission mode } break; case 2: ////speaker test OggBuffer speakerTest = DSound.playOgg(DSound.SoundPath + "\\speakertest.ogg"); while (speakerTest.isPlaying()) { Application.DoEvents(); } speakerTest = null; break; case 3: ////options string[] oArray = { "mainmenu_5_1.wav", "mainmenu_5_2.wav" }; short oIndex = 0; while (oIndex != -1) { oIndex = Common.sVGenerateMenu("mainmenu_5_i.wav", oArray); switch (oIndex) { case 0: ////mapkeys buildKeyMapMenu(); break; case 1: ////switch input device showDevices(); break; } } break; case 4: ////exit Options.requestedShutdown = true; exitMenu = true; break; } } Common.fadeMusic(); if (Options.requestedShutdown) { Options.requestedShutdown = false; Common.shutdown(); return; } }