コード例 #1
0
ファイル: Game1new.cs プロジェクト: delebrindel/Kino
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

//            applause[0] = Content.Load<SoundEffect>("applause-2"); // Loads the sound effect
            applause[0] = Content.Load<SoundEffect>("woof"); // Loads the sound effect
            applause[1] = Content.Load<SoundEffect>("yipee"); // Loads the sound effect
            applause[5] = Content.Load<SoundEffect>("fandab"); // Loads the sound effect
            applause[2] = Content.Load<SoundEffect>("woop"); // Loads the sound effect
            applause[3] = Content.Load<SoundEffect>("yeah"); // Loads the sound effect
            applause[4] = Content.Load<SoundEffect>("yeah2"); // Loads the sound effect

            // TODO: use this.Content to load your game content here
            mainfont = Content.Load<SpriteFont>("andynew"); // Load font
            digfont = Content.Load<SpriteFont>("quartz4"); // Load font
            fontwhite = Content.Load<SpriteFont>("miramonte9"); // Load font

            background = new graphic2d(Content, "kinectbackground", displaywidth, displayheight);
            gamebackground1 = new graphic2d(Content, "game screen 3", displaywidth, displayheight);
            gamebackground1.stretch2fit(displaywidth, displayheight);
            gamebackground2 = new graphic2d(Content, "game screen 4", displaywidth, displayheight);
            gamebackground2.stretch2fit(displaywidth, displayheight);
            gamebackground3 = new graphic2d(Content, "game screen 5", displaywidth, displayheight);
            gamebackground3.stretch2fit(displaywidth, displayheight);


            gamelogo = new sprite2d(Content, "kinect angles", displaywidth / 2, displayheight - 100, 0.4f, Color.White, true);
            gamelogo.rect.Y = displayheight-gamelogo.rect.Height/2;

            mousepointer1 = new sprite2d(Content, "X-Games-Cursor", 0, 0, 0.15f, Color.White, true);
            mousepointer2 = new sprite2d(Content, "X-Games-Cursor-Highlight", 0, 0, 0.15f, Color.White, true);

            hand[0] = new sprite2d(Content, "conniehand", displaywidth/4, 84, 0.5f, Color.White, true);
            hand[1] = new sprite2d(Content, "conniehand", (displaywidth / 4)*3, 84, 0.5f, Color.White, true);

            menuoptions[0, 0] = new sprite2d(Content, "player1", displaywidth / 2, 180, 1, Color.White, true);
            menuoptions[0, 1] = new sprite2d(Content, "player1over", displaywidth / 2, 180, 1, Color.White, true);
            menuoptions[1, 0] = new sprite2d(Content, "player2", displaywidth / 2, 260, 1, Color.White, true);
            menuoptions[1, 1] = new sprite2d(Content, "player2over", displaywidth / 2, 260, 1, Color.White, true);
            menuoptions[2, 0] = new sprite2d(Content, "options", displaywidth / 2, 340, 1, Color.White, true);
            menuoptions[2, 1] = new sprite2d(Content, "optionsover", displaywidth / 2, 340, 1, Color.White, true);
            menuoptions[3, 0] = new sprite2d(Content, "highscores", displaywidth / 2, 420, 1, Color.White, true);
            menuoptions[3, 1] = new sprite2d(Content, "highscoreover", displaywidth / 2, 420, 1, Color.White, true);
            menuoptions[4, 0] = new sprite2d(Content, "exit", displaywidth / 2, 500, 1, Color.White, true);
            menuoptions[4, 1] = new sprite2d(Content, "exitover", displaywidth / 2, 500, 1, Color.White, true);
            for (int i = 0; i < numberofoptions; i++)
                menuoptions[i, 0].updateobject();

            backbutton[0] = new sprite2d(Content, "xboxControllerBack", 60, 60, 1, Color.White, true);
            backbutton[1] = new sprite2d(Content, "backglow", 60, 60, 1, Color.White, true);

            typeoptions[0, 0] = new sprite2d(Content, "angles1", 100, 140, 1, Color.White, true);
            typeoptions[0, 1] = new sprite2d(Content, "angles2", 100, 140, 1, Color.White, true);
            typeoptions[1, 0] = new sprite2d(Content, "percentages1", 250, 140, 1, Color.White, true);
            typeoptions[1, 1] = new sprite2d(Content, "percentages2", 250, 140, 1, Color.Yellow, true);
            typeoptions[2, 0] = new sprite2d(Content, "decimal1", 400, 140, 1, Color.White, true);
            typeoptions[2, 1] = new sprite2d(Content, "decimal2", 400, 140, 1, Color.White, true);
            typeoptions[3, 0] = new sprite2d(Content, "fractions1", 550, 140, 1, Color.White, true);
            typeoptions[3, 1] = new sprite2d(Content, "fractions2", 550, 140, 1, Color.Yellow, true);
            typeoptions[4, 0] = new sprite2d(Content, "all1", 700, 140, 1, Color.White, true);
            typeoptions[4, 1] = new sprite2d(Content, "all2", 700, 140, 1, Color.Yellow, true);
            for (int i = 0; i < numberoftypes; i++)
                typeoptions[i, 0].updateobject();

            leveloptions[0, 0] = new sprite2d(Content, "easy", 200, 220, 1, Color.White, true);
            leveloptions[0, 1] = new sprite2d(Content, "easy2", 200, 220, 1, Color.White, true);
            leveloptions[1, 0] = new sprite2d(Content, "medium", 400, 220, 1, Color.White, true);
            leveloptions[1, 1] = new sprite2d(Content, "medium2", 400, 220, 1, Color.Yellow, true);
            leveloptions[2, 0] = new sprite2d(Content, "hard", 600, 220, 1, Color.White, true);
            leveloptions[2, 1] = new sprite2d(Content, "hard2", 600, 220, 1, Color.White, true);
            for (int i = 0; i < numberoflevels; i++)
                leveloptions[i, 0].updateobject();

            lefthanded[0, 0] = new sprite2d(Content, "p1left", 300, 300, 1, Color.White, true);
            lefthanded[0, 1] = new sprite2d(Content, "p1lefthigh", 300, 300, 1, Color.White, true);
            lefthanded[0, 2] = new sprite2d(Content, "p1right", 300, 300, 1, Color.White, true);
            lefthanded[0, 3] = new sprite2d(Content, "p1rightglow", 300, 300, 1, Color.White, true);
            lefthanded[0, 0].updateobject();
            lefthanded[1, 0] = new sprite2d(Content, "p2left", 500, 300, 1, Color.White, true);
            lefthanded[1, 1] = new sprite2d(Content, "p2lefthigh", 500, 300, 1, Color.White, true);
            lefthanded[1, 2] = new sprite2d(Content, "p2right", 500, 300, 1, Color.White, true);
            lefthanded[1, 3] = new sprite2d(Content, "p2rightglow", 500, 300, 1, Color.White, true);
            lefthanded[1, 0].updateobject();

            questionsto = new sprite2d(Content, "questions2ask", 340, 400, 1, Color.White, true);
            questionspinner[0] = new sprite2d(Content, "spinner", 500, 400, 1, Color.White, true);
            questionspinner[1] = new sprite2d(Content, "spinnerup", 500, 400, 1, Color.White, true);
            questionspinner[2] = new sprite2d(Content, "spinnerdown", 500, 400, 1, Color.White, true);
            questionspinner[1].updateobject();
            questionspinner[2].updateobject();
            questionspinner[1].bbox.Max.Y -= questionspinner[1].rect.Height / 2;
            questionspinner[2].bbox.Min.Y += questionspinner[2].rect.Height / 2;

            savepicbutton[0, 0] = new sprite2d(Content, "savepicson", 400, 500, 1, Color.White, true);
            savepicbutton[0, 1] = new sprite2d(Content, "savepicsonglow", 400, 500, 1, Color.White, true);
            savepicbutton[1, 0] = new sprite2d(Content, "savepicturesoff", 400, 500, 1, Color.White, true);
            savepicbutton[1, 1] = new sprite2d(Content, "savepicturesoffglow", 400, 500, 1, Color.White, true);
            savepicbutton[0, 0].updateobject();

            fullscreenbutton[0, 0] = new sprite2d(Content, "full screen off", 700, 60, 1, Color.White, true);
            fullscreenbutton[0, 1] = new sprite2d(Content, "fullscreenoffglow", displaywidth - (fullscreenbutton[0, 0].rect.Width / 2), fullscreenbutton[0, 0].rect.Height / 2, 1, Color.White, true);
            fullscreenbutton[1, 0] = new sprite2d(Content, "full screen on", fullscreenbutton[0, 1].rect.X, fullscreenbutton[0, 1].rect.Y, 1, Color.White, true);
            fullscreenbutton[1, 1] = new sprite2d(Content, "fullscreenonglow", fullscreenbutton[0, 1].rect.X, fullscreenbutton[0, 1].rect.Y, 1, Color.White, true);
            fullscreenbutton[0, 0].position = fullscreenbutton[0, 1].position;
            fullscreenbutton[0, 0].updateobject();
            
            funnypics = new Texture2D[questions2ask];

            aline1 = new angleart(Content, "line3", displaywidth / 4, displayheight / 2, 1f, Color.White, true);
            aline2 = new angleart(Content, "line4", (displaywidth / 4) * 3, displayheight / 2, 1f, Color.White, true);

            gamer[0] = new players();
            gamer[1] = new players();

            if (File.Exists(@"options.txt"))
            {
                StreamReader sr = new StreamReader(@"options.txt");	// Open the file

                String line;		// Create a string variable to read each line into
                if (!sr.EndOfStream)
                {
                    line = sr.ReadLine();	// Read the first line in the text file
                    questions2ask = (int)Convert.ToDecimal(line);	// This converts line to numeric
                }
                if (!sr.EndOfStream)
                {
                    line = sr.ReadLine();	// Read the first line in the text file
                    delaybetween = (int)Convert.ToDecimal(line);	// This converts line to numeric
                } 
                if (!sr.EndOfStream)
                {
                    line = sr.ReadLine();	// Read the first line in the text file
                    roundlength = (int)Convert.ToDecimal(line);	// This converts line to numeric
                } 
                if (!sr.EndOfStream)
                {
                    line = sr.ReadLine();	// Read the first line in the text file
                    bonuspoints = (int)Convert.ToDecimal(line);	// This converts line to numeric
                }
                if (!sr.EndOfStream)
                {
                    line = sr.ReadLine();	// Read the first line in the text file
                    gamemode = (int)Convert.ToDecimal(line);	// This converts line to numeric
                }
                if (!sr.EndOfStream)
                {
                    line = sr.ReadLine();	// Read the first line in the text file
                    skilllevel = (int)Convert.ToDecimal(line);	// This converts line to numeric
                }
                if (!sr.EndOfStream)
                {
                    line = sr.ReadLine();	// Read the first line in the text file
                    saveallpics = (Convert.ToDecimal(line)==1);	// This converts line to numeric then boolean
                }
                if (!sr.EndOfStream)
                {
                    line = sr.ReadLine();	// Read the first line in the text file
                    cameraangle = (int)Convert.ToDecimal(line);	// This converts line to numeric
                }
                
                sr.Close();			// Close the file
            }

            loadhighscores("highscore" + gamemode.ToString("0") + skilllevel.ToString("0") + questions2ask.ToString("00") + ".txt");

            if (!Directory.Exists(Content.RootDirectory + "\\..\\pictures"))
                Directory.CreateDirectory(Content.RootDirectory + "\\..\\pictures");

            // Set up Kinect to stream video
            kinectSensor.ElevationAngle = cameraangle;

            kinectRGBVideo = new Texture2D(GraphicsDevice, 640, 480);
            //vframe = new Texture2D(GraphicsDevice, kinectRGBVideo.Width, kinectRGBVideo.Height);
            //vcolour = new Color[kinectRGBVideo.Height * kinectRGBVideo.Width];
          
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: delebrindel/Kino
        public void updatemenu(float gtime)
        {
            Random randomiser = new Random();

            if (mousepointer1.position == mousepointer1.oldposition)
            {
                if (screensavertimer >= 0)
                {
                    screensavertimer -= gtime;
                    if (picnames.Count() > 0)
                    {
                        screensavepic.rect.X++;
                        screensavepic.rect.Y++;
                        screensavesize -= 0.002f;
                        screensavepic.rect.Width = (int)((float)screensavepic.image.Width * screensavesize);
                        screensavepic.rect.Height = (int)((float)screensavepic.image.Height * screensavesize);
                    }
                }
            }
            else
            {
                screensavertimer = screensavertime;
            }

            if (screensavertimer < 0)
            {
                screensavesize = 1.2f;
                loadfilenames();
                if (picnames.Count() > 0)
                {
                    string filename = Content.RootDirectory + "\\..\\pictures\\" + picnames[randomiser.Next(picnames.Count())];
                    screensavertimer = timebetweenpics;
                    if (File.Exists(@filename))
                        screensavepic = new graphic2d(graphics, Content, filename, displaywidth, displayheight);
                }
                else
                    screensavertimer = screensavertime;
            }

            optionselected = -1;

            // Check for mousepointer being over a menu option
            for (int i = 0; i < numberofoptions; i++)
            {
                // Check for mouse over a menu option
                if (mousepointer1.bsphere.Intersects(menuoptions[i, 0].bbox))
                {
                    optionselected = i;
                    if (mouse.LeftButton == ButtonState.Pressed)
                        gamestate = optionselected;
                }
            }

            // Start 1 player game
            if (gamestate == 0)
            {
                numberofplayers = 1;
                aline1.rect.X = displaywidth / 2;
                gamebackground1.image = Content.Load<Texture2D>("game screen 3b");
                gamebackground2.image = Content.Load<Texture2D>("game screen 4b");
                gamebackground3.image = Content.Load<Texture2D>("game screen 5b");

                reset();
            }
            // Start 2 player game
            if (gamestate == 1)
            {
                numberofplayers = 2;
                aline1.rect.X = displaywidth / 4;
                gamebackground1.image = Content.Load<Texture2D>("game screen 3");
                gamebackground2.image = Content.Load<Texture2D>("game screen 4");
                gamebackground3.image = Content.Load<Texture2D>("game screen 5");
                reset();
            }
            // Load options screen
            if (gamestate == 2)
            {
                mousereleased = false;
                savehighscores("highscore" + gamemode.ToString("0") + skilllevel.ToString("0") + questions2ask.ToString("00") + ".txt");
            }
        }