Ejemplo n.º 1
0
        protected void DrawSegment(string name, Vector2f pos, Vector2f scroll, RenderTexture tex, bool shadow)
        {
            Spr = TextureMan.GetSprite(name, shadow);

            Spr.Position = pos;
            if (shadow)
            {
                Spr.Position = new Vector2f(pos.X - 2, pos.Y - 2);
            }
            Spr.Position -= scroll;

            Spr.Origin = new Vector2f(8, 8);
            Spr.Scale  = new Vector2f(1 * scaleX, 1 * scaleY);

            tex.Draw(Spr);
        }
Ejemplo n.º 2
0
        void DrawGameWonScreen(RenderTexture buffer)
        {
            spr.Texture  = gameWonTexture;
            spr.Position = new Vector2f(0, 0);
            spr.Color    = new Color(255, 255, 255, 255);
            buffer.Draw(spr);

            for (int i = 0; i < starField.Count(); i++)
            {
                string texture = "star";

                if ((i + menuC) % 20 <= 5)
                {
                    texture = "star";
                }
                if ((i + menuC) % 20 > 5 && (i + menuC) % 20 <= 10)
                {
                    texture = "star2";
                }
                if ((i + menuC) % 20 > 10 && (i + menuC) % 20 <= 15)
                {
                    texture = "star3";
                }
                if ((i + menuC) % 20 > 15)
                {
                    texture = "star2";
                }

                star          = TextureMan.GetSprite(texture, false);
                star.Position = starField[i];
                buffer.Draw(star);
            }

            spr.Texture  = gameWonTextTexture;
            spr.Position = new Vector2f(0, 0);

            if (menuC < 120)
            {
                spr.Position = new Vector2f(0, 120 - menuC);
                //     spr.Scale = new Vector2f((120-menuC) / 100 + 1, (120-menuC) / 100 + 1);
            }

            spr.Color = new Color(255, 255, 255, 255);
            //  spr.Scale = new Vector2f(1, 1);
            buffer.Draw(spr);
        }
Ejemplo n.º 3
0
        public virtual void Draw(RenderTexture tex, Vector2f scroll, bool shadow)
        {
            Spr = TextureMan.GetSprite(CurrentTex, shadow);

            Spr.Position = Position - scroll;

            if (shadow)
            {
                Spr.Position = new Vector2f(Spr.Position.X - 2, Spr.Position.Y - 2);
            }

            Spr.Origin = new Vector2f(8, 8 - bounceC / 3);

            if (Flipped)
            {
                Spr.Scale = new Vector2f(-1 * scaleX, 1 * scaleY);
            }
            else
            {
                Spr.Scale = new Vector2f(1 * scaleX, 1 * scaleY);
            }

            tex.Draw(Spr);
        }
Ejemplo n.º 4
0
        public void StartTrainBoxApp()
        {
            Level.PrepareEntityTypes();

            bool quit = false;

            TextureMan.LoadTextures();
            TextureMan.CreateShadows();

            bufferSpr = new Sprite();

            buffer = new RenderTexture(320, 120);
            buffer.Clear(Color.Black);

            menu.Active = true;
            menu.State  = Menu.MenuState.Intro;
            menu.CounterReset();
            menu.LoadLevelInfo();

            while (true)
            {
                if (fullScreen)
                {
                    screenSizeX = 1366;
                    screenSizeY = 768;
                }
                else
                {
                    screenSizeX = 960;
                    screenSizeY = 540;
                }

                if (fullScreen)
                {
                    window = new RenderWindow(new VideoMode(screenSizeX, screenSizeY),
                                              "Super Starbox", Styles.Fullscreen);
                }
                else
                {
                    window = new RenderWindow(new VideoMode(screenSizeX, screenSizeY),
                                              "Super Starbox", Styles.Titlebar);
                }

                window.SetMouseCursorVisible(!fullScreen);

                window.SetVisible(true);
                window.Closed += new EventHandler(OnClosed);
                window.SetFramerateLimit(60);

                window.LostFocus   += new EventHandler(OnLostFocus);
                window.GainedFocus += new EventHandler(OnGainedFocus);

                bool editorButtonTrigger = false;

                SoundMan.PlayMusic();

                while (true)
                {
                    buffer.Clear(Color.Black);

                    if (!menu.Active)
                    {
                        level.DrawLevel(buffer);
                    }


                    if (fadeOut != 0)
                    {
                        RectangleShape rect = new RectangleShape();

                        rect.Position  = new Vector2f(0, 0);
                        rect.Size      = new Vector2f(320, 120);
                        rect.FillColor = new Color(0, 0, 0, (byte)fadeOut);

                        buffer.Draw(rect);
                    }

                    if (menu.Active)
                    {
                        menu.Draw(buffer);
                    }
                    if (editor.Active)
                    {
                        editor.Draw(buffer);
                    }

                    buffer.Display();

                    bufferSpr.Texture = buffer.Texture;
                    bufferSpr.Scale   = new Vector2f((screenSizeX / 320f) * screenScale, (screenSizeY / 120f) * screenScale);

                    bufferSpr.Origin   = new Vector2f(160, 60);
                    bufferSpr.Position = new Vector2f(screenSizeX / 2, screenSizeY / 2);

                    if (screenShake > 0)
                    {
                        bufferSpr.Position = new Vector2f(bufferSpr.Position.X + (float)new Random().Next(-200, 200) / 75,
                                                          bufferSpr.Position.Y + (float)new Random().Next(-200, 200) / 75);
                    }

                    if (gameState == GameState.ResetFadeOut)
                    {
                        bufferSpr.Rotation = gameStateC / 2;

                        screenScale = 1f + (float)gameStateC / 50f;
                    }

                    if (gameState == GameState.LevelFinished)
                    {
                        bufferSpr.Rotation = gameStateC / 2;

                        screenScale = 1f + (float)gameStateC / 25f;
                    }

                    if (gameState == GameState.ResetFadeIn)
                    {
                        bufferSpr.Rotation = (50 - gameStateC) / 2;

                        screenScale = 1f + (float)(50 - gameStateC) / 50f;
                    }

                    if (gameState == GameState.GamePlay || menu.Active)
                    {
                        screenScale        = 1;
                        bufferSpr.Rotation = 0;
                    }

                    window.DispatchEvents();
                    window.Clear(Color.Black);
                    window.Draw(bufferSpr);
                    window.Display();


                    if (Keyboard.IsKeyPressed(Keyboard.Key.F4))
                    {
                        fullScreen = !fullScreen;
                        break;
                    }

                    if (Keyboard.IsKeyPressed(Keyboard.Key.F10) && false)
                    {
                        if (!menu.Active)
                        {
                            if (!editorButtonTrigger)
                            {
                                editor.Active = !editor.Active;
                                if (editor.Active)
                                {
                                    editor.LevelName = levelName;
                                    level.ResetLevel();
                                    level.ResetScrollBounds();
                                    CollisionMan.Entities = level.GetEntities();
                                    EntityFinder.Entities = level.GetEntities();
                                    editor.Level          = level;
                                }
                                else
                                {
                                    levelName = editor.LevelName;
                                    level     = editor.Level;
                                    level.FindScrollBounds();
                                    gameState = GameState.StartLevel;
                                }
                            }
                        }
                        editorButtonTrigger = true;
                    }
                    else
                    {
                        editorButtonTrigger = false;
                    }

                    if (!editor.Active && !menu.Active)
                    {
                        GameLoop();
                    }

                    if (editor.Active)
                    {
                        if (windowHasFocus)
                        {
                            editor.Loop(window);
                        }
                    }
                    if (menu.Active)
                    {
                        if (windowHasFocus)
                        {
                            menu.Loop(window);
                        }

                        if (menu.State == Menu.MenuState.Quit)
                        {
                            quit = true;
                            break;
                        }

                        if (menu.State == Menu.MenuState.StartLevel)
                        {
                            levelName = menu.LevelName;

                            menu.Active = false;
                            level.LoadLevel(levelName);

                            gameStateC = 0;
                            gameState  = GameState.ResetFadeIn;
                            fadeOut    = 255;

                            CollisionMan.Entities = level.GetEntities();
                            EntityFinder.Entities = level.GetEntities();
                        }
                    }
                }

                window.Dispose();
                if (quit)
                {
                    break;
                }
            }

            menu.SaveLevelInfo();
        }