Exemplo n.º 1
0
        public static void Draw(Vector2i pos)
        {
            Gl.glPushMatrix();

            Gl.glTranslatef(pos.X, pos.Y, 0);
            if (pos.Y <= 0) {
                Gl.glColor3f(0.449f,0.797f,0.301f); //nice green grass
            } else if (pos.Y <= 12) {
                Gl.glColor3f(0.797f,0.570f,0.301f); //brown trees
            } else {
                Gl.glColor3f(0.684f,0.852f,0.859f); //blue sky
            }

            Gl.glBegin(Gl.GL_TRIANGLE_STRIP);

            Gl.glVertex2f(0, 0.0f); //bottom left
            Gl.glVertex2f(0.9f, 0.0f); //bottom right

            Gl.glVertex2f(0, 0.5f); //top left
            Gl.glVertex2f(0.9f, 0.5f); //top right

            Gl.glEnd();

            Gl.glBegin(Gl.GL_TRIANGLES);

            for (int i = 0 ; i < 3 ; i++) {
                float offset = i * 0.3f;
                Gl.glVertex2f(0 + offset, 0.5f);
                Gl.glVertex2f(0.15f + offset, 0.9f);
                Gl.glVertex2f(0.3f + offset, 0.5f);
            }

            Gl.glEnd();
            Gl.glPopMatrix();
        }
Exemplo n.º 2
0
 public StarryBackground(Vector2i _size)
 {
     Layer = Layer.Blurry;
     Random rand = new Random(42);
     for (int i = 0 ; i < points.Length ; i++) {
         points[i] = new Vector3f((float)rand.NextDouble() * _size.X,
                                  (float)rand.NextDouble() * _size.Y,
                                  ((float)rand.NextDouble() - 1f)*100000f - 1f);
     }
     for (int i = 0 ; i < stars.Length ; i++) {
         stars[i] = new Vector3f((float)rand.NextDouble() * _size.X,
                                  (float)rand.NextDouble() * _size.Y,
                                  ((float)rand.NextDouble() - 1f)*100000f - 1f);
     }
 }
Exemplo n.º 3
0
        public static void Draw(Vector2i pos)
        {
            Gl.glPushMatrix();

            Gl.glTranslatef(pos.X, pos.Y, 0);
            if (pos.Y <= 0) {
                Gl.glColor3f(0.449f,0.797f,0.301f); //nice green grass
            } else if (pos.Y <= 12) {
                Gl.glColor3f(0.797f,0.570f,0.301f); //brown trees
            } else {
                Gl.glColor3f(0.684f,0.852f,0.859f); //blue sky
            }

            Gl.glBegin(Gl.GL_TRIANGLE_STRIP);

            Gl.glVertex2f(0, 0.7f);
            Gl.glVertex2f(0.9f, 0.7f);
            Gl.glVertex2f(0, 0.9f);
            Gl.glVertex2f(0.9f, 0.9f);

            Gl.glEnd();
            Gl.glPopMatrix();
        }
Exemplo n.º 4
0
 public SpikyTile(Vector2i position)
 {
     m_position = position;
 }
Exemplo n.º 5
0
        public override void Setup(Game _game, UserInput _keyboard, ScreenMessage _message)
        {
            base.Setup(_game, _keyboard, _message);

            deathTimer = 0;
            startTimer = 0;
            winTimer = 0;

            if (_message.Level != null) {
                m_tilemap = _message.Level;
            } else {
                m_tilemap = new TileMap(levelFile);
            }

            m_size = new Vector2i(m_tilemap.Width, m_tilemap.Height);
            Bounds.Right = m_size.X;
            Bounds.Top = m_size.Y;
            m_house = new ObjectHouse(m_tilemap);

            StarryBackground bg = new StarryBackground(m_tilemap.Size);
            m_house.AddDrawable(bg);

            gangsterNo1 = new Hero(m_keyboard, m_house);
            gangsterNo1.Position = new Vector2f(1f, 10f);
            gangsterNo1.PlaceInWorld(m_tilemap);
            m_house.AddDrawable(gangsterNo1);
            m_house.AddUpdateable(gangsterNo1);
            m_house.Add<IShootable>(gangsterNo1);
            m_game.SetCameraSubject(gangsterNo1);

            m_tilemap.Create(m_house, _game);
            m_house.AddDrawable(m_tilemap);

            //			Text score = new Text("Left: 00");
            //			score.updateAction = (_d) => {
            //				score.Contents = "Left: " + m_house.GetAllDrawable<Target>().Count().ToString("00");
            //			};
            //			score.SetHUD(_game.Camera);
            //			score.TopRight();
            //
            //			m_house.AddUpdateable(score);
            //			m_house.AddDrawable(score);
            //
            //			Score score_pic = new Score(gangsterNo1);
            //			score_pic.SetHUD(_game.Camera);
            //			score_pic.TopLeft();
            //
            //			m_house.AddUpdateable(score_pic);
            //			m_house.AddDrawable(score_pic);
            //
            //
            //			pixelly_fx_buffer
            //				= new ScreenSprite(
            //					new Vector2i(Game.SmallScreenWidth, Game.SmallScreenHeight),
            //					new Vector2i(Game.ScreenWidth, Game.ScreenHeight),
            //				    new Vector2i(Game.Width, Game.Height)) {
            //				CaptureLayer = Layer.Pixelly,
            //				Layer = Layer.Normal,
            //				Scaling = Sprite.ScaleType.Pixelly,
            //				Feedback = 0.9f,
            //				Priority = Priority.Front
            //			};
            //			pixelly_fx_buffer.updateAction = () => {
            //				pixelly_fx_buffer.Position = -_game.Camera.LastOffset;
            //			};
            //
            //			m_house.AddDrawable(pixelly_fx_buffer);
            //			m_house.AddUpdateable(pixelly_fx_buffer);
            //			m_house.Add<IGrabing>(pixelly_fx_buffer);
            //
            //			blurry_fx_buffer
            //				= new ScreenSprite(
            //					new Vector2i(Game.SmallScreenWidth/2, Game.SmallScreenHeight/2),
            //					new Vector2i(Game.ScreenWidth, Game.ScreenHeight),
            //				    new Vector2i(Game.Width, Game.Height)) {
            //				CaptureLayer = Layer.Blurry,
            //				Layer = Layer.Normal,
            //				Scaling = Sprite.ScaleType.Blurry,
            //				Feedback = 0.9f,
            //				Priority = Priority.Back
            //			};
            //			blurry_fx_buffer.SetHUD(_game.Camera);
            //
            //			m_house.AddDrawable(blurry_fx_buffer);
            //			m_house.AddUpdateable(blurry_fx_buffer);
            //			m_house.Add<IGrabing>(blurry_fx_buffer);
            //
            death_fx_buffer
                = new Effect(
                    new Vector2i(Game.SmallScreenWidth/2, Game.SmallScreenHeight/2),
                    new Vector2i(Game.ScreenWidth, Game.ScreenHeight),
                    new Vector2i(Game.Width, Game.Height)) {
                CaptureLayer = Layer.Normal,
                Layer = Layer.FX,
                Feedback = 1f,
                Priority = Priority.Front
            };
            death_fx_buffer.SetHUD(_game.Camera);
            death_fx_buffer.SetSpinning(15);
            death_fx_buffer.SetZooming(-0.2f);
            //
            //
            //
            //
            //			start_fx_buffer
            //				= new ScreenSprite(
            //				    new Vector2i(Game.SmallScreenWidth/2, Game.SmallScreenHeight/2),
            //					new Vector2i(Game.ScreenWidth, Game.ScreenHeight),
            //				    new Vector2i(Game.Width, Game.Height)) {
            //				CaptureLayer = Layer.Normal,
            //				Layer = Layer.FX,
            //				Priority = Priority.Front,
            //				Scaling = Sprite.ScaleType.Pixelly
            //			};
            //			start_fx_buffer.SetHUD(_game.Camera);
            //			start_fx_buffer.SetFading(1f, new float[]{0,0,0,1}, new float[]{0,0,0,0});
            //			start_fx_buffer.SetPixelling(new InverseLogAnimator(0.5f),
            //			                             new Vector2i(2, 2),
            //			                             start_fx_buffer.CaptureSize);
            //			start_fx_buffer.SetBackground(new float[]{0,0,0,1f});
            //			m_house.AddDrawable(start_fx_buffer);
            //			m_house.AddUpdateable(start_fx_buffer);
            //			m_house.Add<IGrabing>(start_fx_buffer);
            //
            //			welcome_message = new Text(_message.Message);
            //			welcome_message.SetHUD(m_game.Camera);
            //			welcome_message.CentreOn(Game.Size.ToF()/2);
            //			welcome_message.Priority = Priority.Front;
            //			welcome_message.Layer = Layer.FX;
            //			welcome_message.Transparency = 0f;
            //			m_house.AddDrawable(welcome_message);
        }
Exemplo n.º 6
0
 public Vector2f ScreenPxToGameCoords(Vector2i _px)
 {
     return new Vector2f(
         (float)_px.X / (Tile.Size*Zoom) - m_camera.ViewOffset.X,
         (float)(ScreenHeight-_px.Y) / (Tile.Size*Zoom) - m_camera.ViewOffset.Y);
 }
Exemplo n.º 7
0
 public FloorTile(Vector2i _position)
 {
     m_position = _position;
 }
Exemplo n.º 8
0
        public override void Setup(Game _game, UserInput _keyboard, ScreenMessage _message)
        {
            base.Setup(_game, _keyboard, _message);

            deathTimer = 0;
            startTimer = 0;
            winTimer = 0;

            m_tilemap = new TileMap(levelFile);

            m_size = new Vector2i(m_tilemap.Width, m_tilemap.Height);
            Bounds.Right = m_size.X;
            Bounds.Top = m_size.Y;
            m_house = new ObjectHouse(m_tilemap);

            StarryBackground bg = new StarryBackground(m_tilemap.Size);
            bg.Layer = Layer.Pixelly;
            m_house.AddDrawable(bg);

            gangsterNo1 = new Hero(m_keyboard, m_house);
            gangsterNo1.Position = m_tilemap.locationData.start.point;
            gangsterNo1.PlaceInWorld(m_tilemap);
            m_house.AddDrawable(gangsterNo1);
            m_house.AddUpdateable(gangsterNo1);
            m_house.Add<IShootable>(gangsterNo1);
            m_game.SetCameraSubject(gangsterNo1);

            m_tilemap.Create(m_house, _game);
            m_house.AddDrawable(m_tilemap);
            m_tilemap.Priority = Priority.Middle;

            endzone = m_tilemap.locationData.end.box;

            // fx

            // pixelly
            pixellyEffect
                = new Effect(
                    new Vector2i(Game.SmallScreenWidth/2, Game.SmallScreenHeight/2),
                    new Vector2i(Game.ScreenWidth, Game.ScreenHeight),
                    new Vector2i(Game.Width, Game.Height)){
                CaptureLayer = Layer.Pixelly,
                Layer = Layer.FX,
                Priority = Priority.Back,
                Scaling = Sprite.ScaleType.Pixelly
            };
            pixellyEffect.SetHUD(_game.Camera);
            m_house.AddDrawable(pixellyEffect);
            m_house.AddUpdateable(pixellyEffect);
            m_house.Add<IGrabing>(pixellyEffect);

            // fading
            fadingEffect
                = new Effect(
                    new Vector2i(Game.ScreenWidth, Game.ScreenHeight),
                    new Vector2i(Game.ScreenWidth, Game.ScreenHeight),
                    new Vector2i(Game.Width, Game.Height)){
                CaptureLayer = Layer.Blurry | Layer.Pixelly | Layer.Normal | Layer.FX,
                Layer = Layer.Fade,
                Priority = Priority.Front
            };

            fadingEffect.SetHUD(_game.Camera);
            fadingEffect.SetFading(1f, new Colour(0,0,0,1), new Colour(0,0,0,0));
            fadingEffect.SetBackground(new Colour(0,0,0,1f));
            m_house.AddDrawable(fadingEffect);
            m_house.AddUpdateable(fadingEffect);
            m_house.Add<IGrabing>(fadingEffect);

            // messages
            welcome_message = new Text("Welcome to the Magnum House...");
            welcome_message.SetHUD(m_game.Camera);
            welcome_message.CentreOn(Game.Size.ToF()/2);
            welcome_message.Priority = Priority.Front;
            welcome_message.Layer = Layer.Normal;
            welcome_message.Transparency = 0f;
            m_house.AddDrawable(welcome_message);
        }
Exemplo n.º 9
0
 public static void Draw(Vector2i pos)
 {
     Draw(pos, 0, 0);
 }
Exemplo n.º 10
0
 public Tile(Vector2i _position)
 {
     m_position = _position;
 }