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

            //Create a world
            _world = new World();

            /* Circle */
            Vector2 playerPosition = new Vector2(0, _playerBodyRadius);

            // Create the player fixture
            _playerBody          = _world.CreateCircle(_playerBodyRadius, 1f, playerPosition);
            _playerBody.BodyType = BodyType.Dynamic;

            // Give it some bounce and friction
            _playerBody.SetRestitution(0.3f);
            _playerBody.SetFriction(0.5f);


            /* Ground */
            Vector2 groundPosition = new Vector2(0, -(_groundBodySize.Y / 2f));

            // Create the ground fixture
            _groundBody          = _world.CreateRectangle(_groundBodySize.X, _groundBodySize.Y, 1f, groundPosition);
            _groundBody.BodyType = BodyType.Static;

            _groundBody.SetRestitution(0.3f);
            _groundBody.SetFriction(0.5f);
        }
Esempio n. 2
0
        // constructor here
        public Player(
            tainicom.Aether.Physics2D.Common.Vector2 pos,
            tainicom.Aether.Physics2D.Common.Vector2 rect,
            World world)
        {
            this.Position = pos;
            this.Rect     = rect;
            _world        = world;

            // create player fixture
            this._playerBody          = _world.CreateRectangle(Rect.X, Rect.Y, 5f, Position);
            this._playerBody.BodyType = BodyType.Dynamic;

            // bounce and friction
            this._playerBody.SetRestitution(0.1f);
            this._playerBody.SetFriction(0.5f);

            this._playerBody.SleepingAllowed = true;


            // light indicator controls
            CurrentColor = 0;
            IsLMBHolding = false;

            // load textures
            LoadContent();

            OwnColorAmount = 3;
        }
Esempio n. 3
0
        // constructor
        public Platform(
            tainicom.Aether.Physics2D.Common.Vector2 pos,
            tainicom.Aether.Physics2D.Common.Vector2 rect,
            World world)
        {
            this.Position = pos;
            this.Rect     = rect;


            // create platform fixture
            this._platformBody          = world.CreateRectangle(Rect.X, Rect.Y, 1f, Position);
            this._platformBody.BodyType = BodyType.Static;



            // bounce and friction
            this._platformBody.SetRestitution(0.3f);
            this._platformBody.SetFriction(0.8f);


            LoadContent();


            // define rectangle boundary for platform
            this.objRect = new Rectanglef(Position.X - _platformTextureSize.X / 2, Position.Y - _platformTextureSize.Y / 2, _platformTexture.Width, _platformTexture.Height);
        }
Esempio n. 4
0
        public Particle(string PATH, Vector2 Speed, Vector2 Position, int color, World world)
        {
            cube          = Global.content.Load <Texture2D>(PATH);
            speed         = Speed;
            position      = Position;
            initailPos    = Position;
            ColorIndex    = color;
            _world        = world;
            toBeDestroyed = false;

            Rect = new tainicom.Aether.Physics2D.Common.Vector2(0.1f, 0.1f);

            this._particleBody          = world.CreateRectangle(Rect.X, Rect.Y, 1f, new tainicom.Aether.Physics2D.Common.Vector2(Position.X, Position.Y));
            this._particleBody.BodyType = BodyType.Dynamic;
            this._particleBody.SetIsSensor(true);

            // define the rectangle boundary for the particle
            //this.objRect = new Rectanglef(Position.X - cube.Width / 2, Position.Y - cube.Height / 2, cube.Width, cube.Height);
        }
Esempio n. 5
0
        public void HandleInput(
            KeyboardState state,
            DisplayOrientation orientation)
        {
            // player moves left or right
            if (state.IsKeyDown(Keys.D))
            {
                _playerBody.LinearVelocity = new tainicom.Aether.Physics2D.Common.Vector2(1f, 0f);
            }

            if (state.IsKeyDown(Keys.A))
            {
                _playerBody.LinearVelocity = new tainicom.Aether.Physics2D.Common.Vector2(-1f, 0f);
            }

            if (state.IsKeyDown(Keys.Space) && IsLMBHolding)
            {
                rideWave(getColorIndex());
            }

            if (state.IsKeyUp(Keys.Space) && !IsLMBHolding)
            {
                _basePlayerPosition = _playerBody.Position;
            }


            // pause the body if player is choosing color
            if (IsLMBHolding)
            {
                _playerBody.Awake = false;
            }
            else
            {
                _playerBody.Awake = true;
            }


            scrollMouseWheel();

            _oldKeyState = state;
        }
Esempio n. 6
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(_graphics.GraphicsDevice);
            // We use a BasicEffect to pass our view/projection in _spriteBatch
            _spriteBatchEffect = new BasicEffect(_graphics.GraphicsDevice);
            _spriteBatchEffect.TextureEnabled = true;

            _font = Content.Load <SpriteFont>("font");

            // Load sprites
            _playerTexture = Content.Load <Texture2D>("CircleSprite");
            _groundTexture = Content.Load <Texture2D>("GroundSprite");

            // We scale the ground and player textures at body dimensions
            _playerTextureSize = new Vector2(_playerTexture.Width, _playerTexture.Height);
            _groundTextureSize = new Vector2(_groundTexture.Width, _groundTexture.Height);

            // We draw the ground and player textures at the center of the shapes
            _playerTextureOrigin = _playerTextureSize / 2f;
            _groundTextureOrigin = _groundTextureSize / 2f;
        }
Esempio n. 7
0
        protected override void Initialize()
        {
            base.Initialize();


            // Create a world
            _world = new World();

            objRects  = new List <Rectanglef>();
            platforms = new List <Platform>();

            // Create a player
            tainicom.Aether.Physics2D.Common.Vector2 playerPos  = new tainicom.Aether.Physics2D.Common.Vector2(0f, 1f);
            tainicom.Aether.Physics2D.Common.Vector2 playerRect = new tainicom.Aether.Physics2D.Common.Vector2(0.7f, 0.7f);
            player = new Player(playerPos, playerRect, _world);

            // and give that player a velocity to move left or right
            player.Velocity = new tainicom.Aether.Physics2D.Common.Vector2(0.06f, 0);

            // create the wavelength indicator
            // Instanciate Indicator
            indicator = new Indicator(player.CurrentColor, new Vector2(100, 100));

            /* Platforms */
            tainicom.Aether.Physics2D.Common.Vector2 platRect1 = new tainicom.Aether.Physics2D.Common.Vector2(15f, 2f);
            tainicom.Aether.Physics2D.Common.Vector2 platPos1  = new tainicom.Aether.Physics2D.Common.Vector2(0f, -1f);
            platforms.Add(new Platform(platPos1, platRect1, _world));

            tainicom.Aether.Physics2D.Common.Vector2 platRect2 = new tainicom.Aether.Physics2D.Common.Vector2(13f, 1f);
            tainicom.Aether.Physics2D.Common.Vector2 platPos2  = new tainicom.Aether.Physics2D.Common.Vector2(15f, 3f);
            platforms.Add(new Platform(platPos2, platRect2, _world));



            Global.am       = new Animation();
            Global.gameTime = new GameTime();

            PS = new ParticleSystem(15, 0.1f, new Vector2(player._playerBody.Position.X, player._playerBody.Position.Y), player.getColorIndex(), _world);
        }