Пример #1
0
        public PauseState(StateStack stack, Context context)
            : base(stack, context)
        {
            RenderWindow window = mContext.window;

            mBackgroundSprite = new Sprite();
            mPausedText = new Text();
            mInstructionText = new Text();

            mPausedText.Font = mContext.fonts.get(FontID.Main);
            mPausedText.DisplayedString = "Game Paused";
            mPausedText.CharacterSize = 70;
            mPausedText.centerOrigin();
            mPausedText.Position = new Vector2f(0, 0);

            mInstructionText.Font = mContext.fonts.get(FontID.Main);
            mInstructionText.DisplayedString = "(Press Backspace to return to main menu)";
            mInstructionText.centerOrigin();
            mInstructionText.Position = new Vector2f(0, 0);

            backgroundShape = new RectangleShape();
            backgroundShape.FillColor = new Color(0, 0, 0, 150);
            backgroundShape.Position = window.GetView().Center;
            backgroundShape.centerOrigin();
            backgroundShape.Size = window.GetView().Size;
        }
Пример #2
0
        public GameApplication()
        {
            mWindow = new RenderWindow(new VideoMode(640, 480), "SFML App", Styles.Close);
            mWindow.SetKeyRepeatEnabled(false);

            mPlayer = new Player();

            mTextures = new ResourceHolder<Texture, ResourceID>();
            mTextures.load(ResourceID.TitleScreen, "Media/Textures/TitleScreen.png");
            mTextures.load(ResourceID.ButtonNormal, "Media/Textures/ButtonNormal.png");
            mTextures.load(ResourceID.ButtonSelected, "Media/Textures/ButtonSelected.png");
            mTextures.load(ResourceID.ButtonPressed,"Media/Textures/ButtonPressed.png");

            mFonts = new ResourceHolder<Font, FontID>();
            mFonts.load(FontID.Main, "Media/Sansation.ttf");

            mStateStack = new StateStack(new State.Context(mWindow,mTextures,mFonts,mPlayer));
            eventqueue = new Queue<Event>();

            registerStates();
            mStateStack.pushState(StateID.Title);

            mWindow.Closed += onClosed;
            mWindow.GainedFocus += gainedFocus;
            mWindow.LostFocus += lostFocus;
            mWindow.KeyPressed += keyPressed;
        }
Пример #3
0
        public SettingState(StateStack stack, Context context):base(stack,context)
        {
            mBindingButtons = new Button[(int)Player.Action.ActionCount];
            mBindingLabels = new Label[(int)Player.Action.ActionCount];

            mGUIContainer = new Container();
            mBackgroundSprite = new Sprite();
            mBackgroundSprite.Texture = mContext.textures.get(ResourceID.TitleScreen);

            addButtonLabels(Player.Action.MoveUp, 150, "Move Up", context);
            addButtonLabels(Player.Action.MoveLeft,200,"Move Left",context);
            addButtonLabels(Player.Action.MoveDown, 250, "Move Down", context);
            addButtonLabels(Player.Action.MoveRight,300,"Move Right",context);

            updateLabels();

            Button backButton = new Button(context.fonts,context.textures);
            backButton.Position = new Vector2f(80,375);
            backButton.setText("Back");
            backButton.setCallback(() =>
            {
                requestStackPop();
            });

            mGUIContainer.pack(backButton);
        }
Пример #4
0
        public MenuState(StateStack stack, Context context)
            : base(stack, context)
        {
            mGUIContainer = new Container();


            mBackgroundSprite = new Sprite(context.textures.get(ResourceID.TitleScreen));
            mViewBounds = new IntRect(0, 0, (int)mContext.window.Size.X, (int)mContext.window.Size.Y);
            Vector2f center = new Vector2f(mContext.window.Size.X / 2, mContext.window.Size.Y / 2);
            mView = mContext.window.DefaultView;
            mView.Center = center;


            Button playButton = new Button(context.fonts, context.textures);
            playButton.Position = new Vector2f(100, 250);
            playButton.setText("Play");
            playButton.setCallback(() =>
                {
                    requestStackPop();
                    requestStackPush(StateID.Game);
                });
            

            Button settingsButton = new Button(context.fonts, context.textures);
            settingsButton.Position = new Vector2f(100, 300);
            settingsButton.setText("Settings");
            settingsButton.setCallback(() =>
            {
                requestStackPush(StateID.Setting);
            });
            

            Button exitButton = new Button(context.fonts, context.textures);
            exitButton.Position = new Vector2f(100, 350);
            exitButton.setText("Exit");
            exitButton.setCallback(() =>
            {
                requestStackPop();
            });
            mGUIContainer.pack(playButton);
            mGUIContainer.pack(settingsButton);
            mGUIContainer.pack(exitButton);
        }
Пример #5
0
        public TitleState(StateStack stack, Context context)
            : base(stack, context)
        {

            mTextEffectTime = Time.Zero;
            mShowText = true;

            mText = new Text();
            mText.Font = mContext.fonts.get(FontID.Main);
            mText.DisplayedString = "Press any key to start";
            //sets origin to center
            FloatRect bounds = mText.GetLocalBounds();
            mText.centerOrigin();
            mText.Position = mContext.window.getCenter();



            mBackgroundSprite = new Sprite(mContext.textures.get(ResourceID.TitleScreen));

        }
Пример #6
0
 public State(StateStack stack, Context context) 
 {
     mStack = stack;
     mContext = context;
 }
Пример #7
0
 public State(StateStack stack, Context context)
 {
 }
Пример #8
0
 public GameState(StateStack stack, Context context)
     : base(stack, context)
 {
     mWorld = new World(mContext);
     mPlayer = context.player;
 }