Example #1
0
        public EntBalloon()
        {
            double r = rand.NextDouble() * Math.PI * 2;
            Color c = new Color((float)Math.Cos(r) * 0.5f + 0.5f, (float)Math.Cos(r + Math.PI * 2.0 / 3) * 0.5f + 0.5f, (float)Math.Cos(r - Math.PI * 2.0 / 3) * 0.5f + 0.5f);

            resistance = 1;
            sprite = defaultSprite;
            wobble = rand.NextDouble() * Math.PI * 2f;
            color = c;
            wrapX = true;
            wrapY = true;

            resistance = 1;

            set = null;
            size *= 3 / 4.0f;
        }
Example #2
0
        public EntBalloon(bool g = false)
        {
            double r = rand.NextDouble() * Math.PI * 2;
            Color c = new Color((float)Math.Cos(r) * 0.5f + 0.5f, (float)Math.Cos(r + Math.PI * 2.0 / 3) * 0.5f + 0.5f, (float)Math.Cos(r - Math.PI * 2.0 / 3) * 0.5f + 0.5f);

            resistance = 1;
            model = defaultModel;
            size = model.Meshes[0].BoundingSphere.Radius;
            wobble = rand.NextDouble() * Math.PI * 2f;
            rotation = rand.NextDouble() * Math.PI * 2f;
            color = c;
            wrapX = true;

            gravity = g;
            wrapY = !gravity;

            resistance = 1;

            set = null;
            size *= 3 / 4.0f;
        }
Example #3
0
        public void init(Game g, Vector2 v)
        {
            caller = g;
            windowSize = v;

            entities = new EntManager();
            entities.gameWidth = ((int)windowSize.X);
            entities.gameHeight = ((int)windowSize.Y);

            Epc = new EntPC();
            Epc.position = Vector3.Zero;
            Epc.resistance = 0.8f;
            Epc.font = EntPC.defaultFont;
            entities.add(Epc);

            int numsets = 5;
            for (int i = 0; i < numsets; ++i)
            {
                Vector3 p = new Vector3((float)Math.Cos(Math.PI * 2 * i / numsets), (float)Math.Sin(Math.PI * 2 * i / numsets), (float)(Ent.rand.NextDouble() * 2.0 - 1.0));
                EntBalloonSet e = new EntBalloonSet(p * 8);
                e.velocity = p * 0.1f;
                entities.add(e);
            }

            startballoons = 0;
            foreach (Ent e in entities.Ents)
            {
                if (e is EntBalloon) startballoons++;
            }
        }
Example #4
0
        public override void think(GameTime gt)
        {
            base.think(gt);
            foreach (Ent e in entities.Ents)
            {
                if (e is EntText)
                    entities.queueRemove(e);
            }
            entities.dequeAll();

            Epc.lives = float.PositiveInfinity;
            //hab1 = hab2 = hab3 = true;

            double currentTime = gt.TotalGameTime.TotalMilliseconds;

            if (Keyboard.GetState().IsKeyDown(Keys.Z) || (GamePad.GetState(PlayerIndex.One).Buttons.B == ButtonState.Pressed))
            {
                if ((currentTime - lastFired) > 200)
                {
                    lastFired = currentTime;

                    for (double i = 0; i < 2 * Math.PI; i += Math.PI / 7)
                    {
                        for (double j = 0; j < 2 * Math.PI; j += Math.PI / 7)
                        {
                            // create bullet and fire it;
                            Quaternion r = Quaternion.CreateFromYawPitchRoll((float)Ent.rand.NextDouble() - 0.5f, (float)Ent.rand.NextDouble() - 0.5f, (float)Ent.rand.NextDouble() - 0.5f);
                            EntBullet Ebullet = new EntBullet(Epc, Quaternion.CreateFromYawPitchRoll((float)i, (float)j, 0) * r);
                            entities.add(Ebullet);
                        }

                    }
                }

            }

            if (entities.Ents.Count < 100)
            {
                if (Ent.rand.NextDouble() < 0.01)
                {
                    double angle = Ent.rand.NextDouble() * Math.PI * 2;

                    EntBalloonSet Eballoonset = new EntBalloonSet(Vector3.One * -EntBalloonSet.defaultSprite.Width);
                    Eballoonset.velocity = new Vector3((float)Math.Cos(angle), (float)Math.Sin(angle), 0) * 0.1f;
                    entities.add(Eballoonset);
                }

                if (Ent.rand.NextDouble() < 0.01)
                {
                    EntAirBalloon e = new EntAirBalloon();
                    entities.add(e);
                }
            }

            /*
            if (Keyboard.GetState().IsKeyDown(Keys.P))
            {

                EntBalloon Eballoon = new EntBalloon();
                entities.add(Eballoon);

                Eballoon.position = Epc.position;
                Eballoon.velocity = Vector2.Zero;

            }

            if (Keyboard.GetState().IsKeyDown(Keys.O))
            {
                if ((currentTime - lastFired) > 200)
                {
                    lastFired = currentTime;

                    EntBalloonSet Eballoonset = new EntBalloonSet(Epc.position);
                    entities.add(Eballoonset);
                }
            }
            */
            if (Keyboard.GetState().IsKeyDown(Keys.H) || (GamePad.GetState(PlayerIndex.One).Buttons.X == ButtonState.Pressed))
            {
                if ((currentTime - lastFired) > 200)
                {
                    lastFired = currentTime;

                    EntAirBalloon e = new EntAirBalloon();
                    entities.add(e);

                }
            }

            if (Keyboard.GetState().IsKeyDown(Keys.G) || (GamePad.GetState(PlayerIndex.One).Buttons.Y == ButtonState.Pressed))
            {
                if ((currentTime - lastFired) > 200)
                {
                    lastFired = currentTime;
                    EntPaperPlane e = new EntPaperPlane();
                    entities.add(e);

                }
            }
        }
Example #5
0
        public void init(Game g, Vector2 v)
        {
            caller = g;
            windowSize = v;

            entities = new EntManager();
            entities.gameWidth = ((int)windowSize.X);
            entities.gameHeight = ((int)windowSize.Y);

            Epc = new EntPC();
            Epc.position = windowSize / 2;
            Epc.resistance = 0.8f;
            Epc.font = EntPC.defaultFont;
            entities.add(Epc);

            int numsets = 7;
            for (int i = 0; i < numsets; ++i)
            {
                Vector2 p = new Vector2((float)Math.Cos(Math.PI * 2 * i / numsets), (float)Math.Sin(Math.PI * 2 * i / numsets));
                EntBalloonSet e = new EntBalloonSet(p * 256 + windowSize / 2);
                e.velocity = new Vector2(p.Y, -p.X) * 4;
                entities.add(e);
            }

            startballoons = 0;
            foreach (Ent e in entities.Ents)
            {
                if (e is EntBalloon) startballoons++;
            }

            clouds = new List<Vector2>();

            for (int i = 0; i < 20; ++i) {
                clouds.Add(new Vector2((float)Ent.rand.NextDouble(), (float)Ent.rand.NextDouble()) * (windowSize - new Vector2(cloud.Width, cloud.Height)));
            }
        }