Beispiel #1
0
        public override void Initialize()
        {
            // Load model for platform drawable
            Model platformModel = Game.Content.Load <Model>(@"Models\platform");

            // Create platform itself
            platformDrawable = new DrawableComponent(platformModel, camera, Game);

            platformDrawable.LocalTransform *= Matrix.CreateScale(2.5f);
            platformDrawable.LocalTransform *= Matrix.CreateRotationX(MathHelper.ToRadians(-90.0f));
            platformDrawable.LocalTransform *= Matrix.CreateRotationY(MathHelper.ToRadians(45.0f));
            platformDrawable.LocalTransform *= Matrix.CreateRotationY(MathHelper.ToRadians(OrientationAngle));

            platformDrawable.WorldTransform *= Matrix.CreateTranslation(Position);

            // Obtain physics space instance
            ISpace space = (ISpace)Game.Services.GetService(typeof(ISpace));

            // Load model for the balls
            Model ballModel = Game.Content.Load <Model>(@"Models\sphere");

            // Create balls
            for (int n = 0; n < 4; n++)
            {
                // Create entity for the ball
                Entity ballEntity = new Sphere(Position + new Vector3(0.0f, 0.5f, 0.0f), 0.5f);

                ballEntity.PositionUpdateMode = BEPUphysics.PositionUpdating.PositionUpdateMode.Continuous;
                ballEntity.CollisionInformation.CollisionRules.Group = ballsGroup;
                ballEntity.Material.Bounciness = STANDARD_BALL_BOUNCINESS;

                //space.Add(ballEntity);

                // Create drawable for the ball
                DrawableComponent ballDrawable = new DrawableComponent(ballModel, camera, Game);
                ballDrawable.DiffuseColor   = BallColor;
                ballDrawable.LocalTransform = Matrix.CreateScale(0.5f);

                // Create ball instance
                Ball ball = new Ball(ballDrawable, ballEntity, this);

                balls.Add(ball);
            }

            // Set one ball to be active
            currentBall        = balls[0];
            currentBall.Active = true;

            //// Just test for particle systems
            //Model model = Game.Content.Load<Model>(@"Meshes\plane");
            //Texture2D texture = Game.Content.Load<Texture2D>(@"Images\particle01");

            //psystem = new ParticleSystem(model, texture, 1000, Game, camera);
            //psystem.Initialize();
            //pBall = Balls[0];
        }
Beispiel #2
0
        public Ball(DrawableComponent drawable, Entity entity, Platform platform)
        {
            Active = false;

            Drawable = drawable;
            Entity   = entity;
            Platform = platform;

            HitPoints = 1;
        }
Beispiel #3
0
        public override void LoadContent()
        {
            // Load background
            bgTex = screenManager.Game.Content.Load <Texture2D>(@"Images\gui\main_menu_bg");

            // Load menu graphics
            menuTex = screenManager.Game.Content.Load <Texture2D>(@"Images\gui\menu_bg");

            // Load logo
            logoTex = screenManager.Game.Content.Load <Texture2D>(@"Images\gui\blok_title");

            // Load font
            SpriteFont font = screenManager.Game.Content.Load <SpriteFont>(@"Fonts\MenuFont");

            // Create New game button
            Texture2D btnDefTex     = screenManager.Game.Content.Load <Texture2D>(@"Images\gui\button_def");
            Texture2D btnPressedTex = screenManager.Game.Content.Load <Texture2D>(@"Images\gui\button_pressed");

            Button newGameBtn = new Button(new Vector2(90, 215), new Vector2(200, 60), "New game", font);

            buttons.Add(newGameBtn);
            newGameBtn.buttonPressedEvent += new Button.ButtonPressed(NewGameButtonPressed);

            // Create info button
            Button infoBtn = new Button(new Vector2(90, 275), new Vector2(200, 60), "Info", font);

            buttons.Add(infoBtn);
            infoBtn.buttonPressedEvent += new Button.ButtonPressed(InfoButtonPressed);

            // Create camera
            camera = new Camera(screenManager.GraphicsDevice.Viewport);
            camera.Initialize();
            camera.View = Matrix.CreateTranslation(new Vector3(0.0f, 0.0f, -5.0f));

            // Load some simple model to show on the right side of the screen
            model = screenManager.Game.Content.Load <Model>(@"Models\block01");

            Texture2D blockTexture = screenManager.Game.Content.Load <Texture2D>(@"Images\SimpleBlock");

            // Create drawable component to display the model
            cubeDrawable = new DrawableComponent(model, camera, screenManager.Game);
            cubeDrawable.LocalTransform *= Matrix.CreateRotationZ(MathHelper.ToRadians(45.0f));
            cubeDrawable.LocalTransform *= Matrix.CreateRotationX(MathHelper.ToRadians(45.0f));
            cubeDrawable.LightingEnable  = true;
            cubeDrawable.Texture         = blockTexture;
            //cubeDrawable.FogEnable = true;
            cubeDrawable.DiffuseColor = new Vector3(0.0f, 0.7f, 0.7f);
        }
        public override void LoadContent()
        {
            // Load logo
            bgTex      = screenManager.Game.Content.Load <Texture2D>(@"Images\gui\winning_screen_bg");
            resultsTex = screenManager.Game.Content.Load <Texture2D>(@"Images\gui\text_results");
            font       = screenManager.Game.Content.Load <SpriteFont>(@"Fonts\MenuFont");
            model      = screenManager.Game.Content.Load <Model>(@"Models\sphere");

            // Create camera
            camera = new Camera(screenManager.GraphicsDevice.Viewport);
            camera.Initialize();
            camera.View = Matrix.CreateTranslation(new Vector3(0.0f, 0.0f, -5.0f));

            // Create drawable component to display the model
            ballDrawable = new DrawableComponent(model, camera, screenManager.Game);
            ballDrawable.LightingEnable = true;
            ballDrawable.DiffuseColor   = new Vector3(0.0f, 0.7f, 0.7f);
        }
Beispiel #5
0
        public override void LoadContent()
        {
            // Create physics space and add some gravity to it
            space = new Space();

            // Add space instance to game services
            screenManager.Game.Services.AddService(typeof(ISpace), space);

            // Set up space
            space.ForceUpdater.Gravity = new Vector3(0.0f, -9.81f, 0.0f);
            space.DeactivationManager.VelocityLowerLimit = 0.01f;

            // Init view and projection matrices
            camera = new Camera(screenManager.GraphicsDevice.Viewport);
            camera.Initialize();
            // Place camera to appropriate position
            camera.View = Matrix.CreateLookAt(new Vector3(0.0f, 30.0f, 0.0f), new Vector3(0.0f, 0.0f, 0.0f), Vector3.Forward);

            screenManager.Game.Services.AddService(typeof(Camera), camera);

            // Load font
            font = ScreenManager.Game.Content.Load <SpriteFont>(@"Fonts\InfoScreenFont");

            // Load background image
            bgTex = screenManager.Game.Content.Load <Texture2D>(@"Images\bk");

            // Load dimming image
            dimTex = screenManager.Game.Content.Load <Texture2D>(@"Images\dim");

            CreatePlatforms();

            level = new GameLevelEx(screenManager.Game);
            level.LoadLevel(@"Game\Levels\testlvl");

            collisionManager = new CollisionManager(platforms, level);

            model = screenManager.Game.Content.Load <Model>(@"Models\block02");
            c     = new DrawableComponent(model, camera, screenManager.Game);
        }