Ejemplo n.º 1
0
        protected override void Initialize()
        {
            base.Initialize();

            IsFixedTimeStep   = true;
            TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 10);


            Matrix viewMatrix;
            Matrix projectionMatrix;

            viewMatrix = Matrix.CreateLookAt(
                new Vector3(0.0f, 0.0f, 1.0f),
                Vector3.Zero,
                Vector3.Up
                );

            projectionMatrix = Matrix.CreateOrthographicOffCenter(
                0,
                (float)GraphicsDevice.Viewport.Width,
                (float)GraphicsDevice.Viewport.Height,
                0,
                1.0f, 1000.0f);


            basicEffect = new BasicEffect(GraphicsDevice, null);
            basicEffect.VertexColorEnabled = true;

            basicEffect.View       = viewMatrix;
            basicEffect.Projection = projectionMatrix;

            GraphicsDevice.RenderState.PointSize = 10;

            //currentRound.setUpKeyboardMap();



            //Menu Objects
            for (int i = 0; i < 6; i = i + 2)
            {
                menuObjects[i / 2] = new PhysicsGameObject(applicationPhysicsSimHach, 75, 75, false);
                menuObjects[i / 2].getTextureSet("Default").addTexture(textureStore.menuTextures[i]);
                menuObjects[i / 2].getTextureSet("Default").addTexture(textureStore.menuTextures[i + 1]);
                menuObjects[i / 2].boxBody.Position = new Vector2(graphics.PreferredBackBufferWidth / 2 - (menuObjects[0].getWidth() / 2), (i / 2) * 200 + 200);
                applicationPhysicsSimHach.Remove(menuObjects[i / 2].boxGeom);
            }
            tutorial        = new PhysicsGameObject(applicationPhysicsSimHach, 800, 400, false);
            tutorialOverlay = new PhysicsGameObject(applicationPhysicsSimHach, 800, 400, false);
            foreach (Texture2D tex in textureStore.keyTextures)
            {
                tutorial.boxBody.Position = new Vector2(graphics.PreferredBackBufferWidth / 2 - (menuObjects[0].getWidth() / 2), 200 + 200);
                tutorial.getTextureSet("Default").addTexture(tex);
            }
            tutorialOverlay.boxBody.Position = new Vector2(graphics.PreferredBackBufferWidth / 2 - (menuObjects[0].getWidth() / 2), 200 + 200);
            tutorialOverlay.getTextureSet("Default").addTexture(Content.Load <Texture2D>("Sprites/keyboard/keyboard_lock"));
        }
Ejemplo n.º 2
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
            spriteBatch.Draw(backgroundTexture, new Vector2(0, 0), Color.White);

            //spriteBatch.DrawString(spriteFont, "" + lastGameTime.TotalGameTime.Seconds + ":" + (lastGameTime.TotalGameTime - lastGameTime.ElapsedGameTime).Seconds, new Vector2(10, 10), Color.White);
            //spriteBatch.DrawString(spriteFont, "" + player1.selectedCube.Value.X + ":" + player1.selectedCube.Value.Y, new Vector2(10, 30), Color.White);
            //spriteBatch.DrawString(spriteFont, "" + lol, new Vector2(10, 50), Color.White);

            if (currentRound != null)
            {
                currentRound.floors[0].draw(spriteBatch);
                currentRound.floors[1].draw(spriteBatch);
                currentRound.floors[2].draw(spriteBatch);
                currentRound.floors[3].draw(spriteBatch);

                foreach (PhysicsGameObject phy in currentRound.physicsController.physicsObjects)
                {
                    phy.draw(spriteBatch);
                }

                for (int i = 0; i < currentRound.physicsController.damageTotalPlayer1 / 100; i++)
                {
                    spriteBatch.Draw(textureStore.damageTexture, new Vector2(1024 / 2 - 100 - (i) * 10, 700), null, Color.White, 0, new Vector2(), 0.1f, SpriteEffects.None, 1.0f);
                }
                for (int i = 0; i < currentRound.physicsController.damageTotalPlayer2 / 100; i++)
                {
                    spriteBatch.Draw(textureStore.damageTexture, new Vector2(1024 / 2 + 100 + (i) * 10, 700), null, Color.White, 0, new Vector2(), 0.1f, SpriteEffects.None, 1.0f);
                }
            }


            //If the main menu is active, draw the menuObjects
            if (currentApplicationState == GameState.MainMenu)
            {
                if (tutActive)
                {
                    tutCount = (tutCount + 1) % 7;
                    if (tutCount == 0)
                    {
                        tutorial.getTextureSet("Default").currentTextureListIndex = (tutorial.getTextureSet("Default").currentTextureListIndex + 1) % 7;
                    }
                    tutorial.draw(spriteBatch);
                    tutorialOverlay.draw(spriteBatch);
                }
                else
                {
                    menuObjects[0].draw(spriteBatch);
                    menuObjects[1].draw(spriteBatch);
                    menuObjects[2].draw(spriteBatch);
                }
                //menuObjects[3].draw(spriteBatch);
            }
            else if (currentApplicationState == GameState.Pause)
            {
                if (tutActive)
                {
                    tutCount = (tutCount + 1) % 7;
                    if (tutCount == 0)
                    {
                        tutorial.getTextureSet("Default").currentTextureListIndex = (tutorial.getTextureSet("Default").currentTextureListIndex + 1) % 7;
                    }
                    tutorial.draw(spriteBatch);
                    tutorialOverlay.draw(spriteBatch);
                }
                else
                {
                    menuObjects[0].draw(spriteBatch);
                    menuObjects[2].draw(spriteBatch);
                }
            }

            //spriteBatch.Draw(backgroundTexture, new Vector2(0,0), null, Color.White, 0, new Vector2(0,0), 1.0f, SpriteEffects.None, -0.5f);

            /*foreach (Vector2 vertex in cannon.boxGeom.WorldVertices)
             * {
             *  spriteBatch.DrawString(spriteFont, "" + vertex.X + ":" + vertex.Y, vertex, Color.White);
             * }*/

            if (currentGame != null)
            {
                for (int i = 0; i < currentGame.p1.money; i++)
                {
                    spriteBatch.Draw(textureStore.coinTexture, new Vector2(10, 10 + ((currentGame.p1.money - i) * 10)), null, Color.White, 0, new Vector2(), 0.1f, SpriteEffects.None, 1.0f);
                }
                for (int i = 0; i < currentGame.p2.money; i++)
                {
                    spriteBatch.Draw(textureStore.coinTexture, new Vector2(1024 - 10 - (textureStore.coinTexture.Width * 0.1f), 10 + ((currentGame.p2.money - i) * 10)), null, Color.White, 0, new Vector2(), 0.1f, SpriteEffects.None, 1.0f);
                }
            }

            spriteBatch.End();



            basicEffect.Begin();

            if (currentRound != null)
            {
                foreach (PhysicsGameJoint phy in currentRound.physicsController.physicsJoints)
                {
                    phy.draw(basicEffect, GraphicsDevice);
                }
            }

            //cannon.draw(basicEffect, GraphicsDevice);
            //floor.draw(basicEffect, GraphicsDevice);

            basicEffect.End();

            //GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineStrip, pointList, 0, points);

            base.Draw(gameTime);
        }