/// <summary> /// Create a visual rendering object for DDaikontin /// </summary> /// <param name="gameCore"></param> /// <param name="inputs"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="menuFont"></param> public GameRenderer(Core gameCore, InputMappings inputs, Artist <T> artist, Font menuFont, int width, int height) { fromCore = gameCore; input = inputs; g = artist; gameWidth = width; gameHeight = height; MenuFont = menuFont; }
private int[] menuItems = { 6, 1, 1, 1, 1 }; //indexed by core.menuIndex; should match MenuIndex enum public Form1() { InitializeComponent(); //Locate assets by looking up one level until it finds them or goes too far while (!System.IO.Directory.Exists(baseAssetsPath) && baseAssetsPath.Length < 30) { baseAssetsPath = "../" + baseAssetsPath; } baseSoundPath = baseAssetsPath + baseSoundPath; baseFontPath = baseAssetsPath + baseFontPath; //Load font try { fontCollection.AddFontFile(baseFontPath + "vibrocentric rg.ttf"); this.Font = new Font(new FontFamily("vibrocentric", fontCollection), 20, FontStyle.Regular); } catch (Exception e) { MessageBox.Show("Font failed to load: " + e.Message); //Can continue without the font } new Thread(() => { input = new InputMappings(core); artist = new PictureBoxArtist(); renderer = new GameRenderer <System.Drawing.Drawing2D.Matrix>(core, input, artist, this.Font, pictureBox1.Width, pictureBox1.Height); core.MenuLoop = MenuLoop; core.GameLoop = GameLoop; core.MenuDraw = pictureBox1.Invalidate; core.GameDraw = pictureBox1.Invalidate; try { hitSound = core.RegisterSound(baseSoundPath + "sound-hit-1.wav"); menuLoopSound = core.RegisterSound(baseSoundPath + "song-3.wav"); startSound = core.RegisterSound(baseSoundPath + "sound-start-1.wav"); explosionSound = core.RegisterSound(baseSoundPath + "sound-death-1.wav"); playerShootSound = core.RegisterSound(baseSoundPath + "sound-shot-2.wav"); enemyShootSound = core.RegisterSound(baseSoundPath + "sound-shot-3.wav"); gameplayLoopSound = core.RegisterSound(baseSoundPath + "song-2.wav"); } catch (Exception e) //TODO: Handle more properly (one sound at a time) { MessageBox.Show("One or more sounds failed to load: " + e.Message); //Can continue without audio if we at least have ONE sound--everything will play that sound if (hitSound == -1) { throw; } } core.Begin(); Application.Exit(); }).Start(); }