Subversion Repositories AndroidProjects

Rev

Rev 220 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.gebauz.Bauzoid.gamestates;

import com.gebauz.Bauzoid.app.Game;
import com.gebauz.Bauzoid.app.GameObject;
import com.gebauz.Bauzoid.graphics.Graphics;
import com.gebauz.Bauzoid.graphics.renderstates.RenderStates;
import com.gebauz.Bauzoid.math.Vector4;

/** Game state base class. */
public abstract class BaseGameState extends GameObject
{
        private Vector4 mFadeInColor = new Vector4(0, 0, 0, 0);
        private Vector4 mFadeOutColor = new Vector4(0, 0, 0, 0);
        private boolean mDoFadeIn = false;
        private boolean mDoFadeOut = false;
       
        /** Constructor. */
        public BaseGameState(Game game)
        {
                super(game);
        }
       
        /** Called when game state is initialized. */
        public abstract void init();
       
        /** Called when game state is exited and destroyed. */
        public abstract void exit();
       
        /** Update game logic. */
        public abstract void update(float deltaTime);
       
        /** Update game logic during fading for animations that may continue even during fading. */
        public void updateFading(float deltaTime) {}
       
        /** Render the game. */
        public abstract void render();
       
        /** Called when the surface has been destroyed and recreated. */
        public void onSurfaceChanged(int w, int h) {}
       
        /** Check if the specific game state requires fading in. */
        public final boolean doFadeIn()
        {
                return mDoFadeIn;
        }
       
        /** Check if the specific game state requires fading out. */
        public final boolean doFadeOut()
        {
                return mDoFadeOut;
        }
       
        /** Set fading modes. */
        public final void setFading(boolean fadeIn, boolean fadeOut)
        {
                mDoFadeIn = fadeIn;
                mDoFadeOut = fadeOut;
        }
       
        /** Set fade in color. */
        public final void setFadeInColor(Vector4 fadeInColor)
        {
                mFadeInColor = fadeInColor;
        }
       
        /** Get fade in color. */
        public final Vector4 getFadeInColor()
        {
                return mFadeInColor;
        }
       
        /** Set fade out color. */
        public final void setFadeOutColor(Vector4 fadeOutColor)
        {
                mFadeOutColor = fadeOutColor;
        }
       
        /** Get fade out color. */
        public final Vector4 getFadeOutColor()
        {
                return mFadeOutColor;
        }
       
        /** Convenience getter. */
        public final Graphics getGraphics()
        {
                return getGame().getGraphics();
        }
       
        /** Convenience getter. */
        public final RenderStates getRenderStates()
        {
                return getGraphics().renderStates;
        }
       
}