コード例 #1
0
        public override void Draw()
        {
            float w      = GameEngine.Instance.GraphicsDevice.ScissorRectangle.Width;
            float h      = GameEngine.Instance.GraphicsDevice.ScissorRectangle.Height;
            float scale  = Math.Min(w / 650, h / 650);
            int   shiftw = (int)(w / 2 - Math.Min(w, h) / 2);
            int   shifth = (int)(h / 2 - Math.Min(w, h) / 2);

            if (level.gamestate == Level.GameState.Buffer && level.hidePlayer)
            {
                return;
            }
            base.Draw();

            var flip        = FacingRight ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
            var spriteBatch = Reflexio.GameEngine.Instance.SpriteBatch;

            if (Reflexio.GameEngine.Instance.currentLevel.reflection_pause_remaining_time > 0)
            {
                walk_strip.ResetCurrentFrame();
                idle_strip.ResetCurrentFrame();
                reflection_strip.Draw(spriteBatch, Level.SCALE * Body.Position, Color.White, Body.Rotation,
                                      new Vector2(level.ROW_SCALE, level.COL_SCALE) * Level.SCALE, flip);
            }
            else if (diffY > 0.01 && time_since_changed > MINIMUM_AMT_OF_TIME)
            {
                reflection_strip.ResetCurrentFrame();
                idle_strip.ResetCurrentFrame();
                reflection_strip.ResetCurrentFrame();
                Vector2 origin = new Vector2(jumpDown.Width, jumpDown.Height) / 2;
                spriteBatch.Begin();
                spriteBatch.Draw(jumpDown, GameEngine.shiftAmount + Level.SCALE * Body.Position * scale, null, Color.White, Body.Rotation, origin, new Vector2(level.ROW_SCALE / jumpDown.Width, level.COL_SCALE / jumpDown.Height) * Level.SCALE * scale, flip, 0);
                spriteBatch.End();
            }
            else if (diffY < -0.01 && time_since_changed > MINIMUM_AMT_OF_TIME)
            {
                reflection_strip.ResetCurrentFrame();
                idle_strip.ResetCurrentFrame();
                reflection_strip.ResetCurrentFrame();
                Vector2 origin = new Vector2(jumpUp.Width, jumpUp.Height) / 2;
                spriteBatch.Begin();
                spriteBatch.Draw(jumpUp, GameEngine.shiftAmount + Level.SCALE * Body.Position * scale, null, Color.White, Body.Rotation, origin, new Vector2(level.ROW_SCALE / jumpUp.Width, level.COL_SCALE / jumpUp.Height) * Level.SCALE * scale, flip, 0);
                spriteBatch.End();
            }
            else if (is_walking)
            {
                reflection_strip.ResetCurrentFrame();
                idle_strip.ResetCurrentFrame();
                walk_strip.Draw(spriteBatch, Level.SCALE * Body.Position, Color.White, Body.Rotation,
                                new Vector2(level.ROW_SCALE, level.COL_SCALE) * Level.SCALE, flip);
            }
            else
            {
                walk_strip.ResetCurrentFrame();
                reflection_strip.ResetCurrentFrame();
                idle_strip.Draw(spriteBatch, Level.SCALE * Body.Position, Color.White, Body.Rotation,
                                new Vector2(level.ROW_SCALE, level.COL_SCALE) * Level.SCALE, flip);
            }
        }
コード例 #2
0
        public void Initialize()
        {
            buddydeath = 0;
            // If game is being in full screen update the SCALE

            /*if (GameEngine.Instance.full_screen)
             * {
             *  int min = Math.Min(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height);
             *  GameEngine.Instance.ResizeWindow(min, min);
             *  Vector2 size = GameEngine.Instance.GetWindowSize();
             *  SCALE = size.X < size.Y ? size.X / WIDTH : size.Y / HEIGHT;
             * }
             * else // Else rescale to the size you want
             * {
             *  GameEngine.Instance.ResizeWindow((int)(WIDTH * SCALE), (int)(HEIGHT * SCALE));
             * }*/
            GameEngine.Instance.UpdateShiftAmount();
            ROW_SCALE = WIDTH / NUM_ROWS;
            COL_SCALE = HEIGHT / NUM_COLS;
            AABB aabb = new AABB();

            aabb.LowerBound = new Vector2(-MARGIN, -MARGIN);
            aabb.UpperBound = new Vector2(WIDTH + MARGIN, HEIGHT + MARGIN);
            world           = new World(gravity);
            succeeded       = false;
            World.ContactManager.BeginContact += ContactManager.BeginContact;
            World.ContactManager.EndContact   += ContactManager.EndContact;
            pauseMenu    = new PauseMenu(this);
            gameOverMenu = new GameOverMenu(this);
            gamestate    = GameState.Unzip;
            unzipTexture = new AnimationTexture(GameEngine.Instance.GetTexture("unzip"), 5, 3, 3);
            zipTexture   = new AnimationTexture(GameEngine.Instance.GetTexture("zip"), 5, 3, 3);
            unzipTexture.ResetCurrentFrame();
            zipTexture.ResetCurrentFrame();
            zippedTexture = GameEngine.Instance.GetTexture("zippedbkg");
            haze          = new Texture2D(GameEngine.Instance.GraphicsDevice, 1, 1);
            rect          = new Rectangle(0, 0, (int)(Level.WIDTH * Level.SCALE + GameEngine.shiftAmount.X), (int)(Level.HEIGHT * Level.SCALE + GameEngine.shiftAmount.Y));
            haze.SetData(new Color[] { new Color(0, 0, 0, 255) });
            // Flush all the non-reflectable objects from the previous levels
            ReflectableObject.FlushNonReflectableObjects();
            ContactManager.ClearContactList();
            Block.FlushGameBlocks();

            reflection_color_time = 0;

            reflection_current_blue  = MIN_REFLECTION_COLOR_BLUE;
            reflection_current_green = MIN_REFLECTION_COLOR_GREEN;
            reflection_current_red   = MIN_REFLECTION_COLOR_RED;

            slope_red   = 2 * (MAX_REFLECTION_COLOR_RED - MIN_REFLECTION_COLOR_RED) / (REFLECTION_COLOR_END_TIME);
            slope_green = 2 * (MAX_REFLECTION_COLOR_GREEN - MIN_REFLECTION_COLOR_GREEN) / (REFLECTION_COLOR_END_TIME);
            slope_blue  = 2 * (MAX_REFLECTION_COLOR_BLUE - MIN_REFLECTION_COLOR_BLUE) / (REFLECTION_COLOR_END_TIME);
        }
コード例 #3
0
 public void Animate()
 {
     this.use_animation_texture = true;
     animTexture.ResetCurrentFrame();
 }