Exemplo n.º 1
0
        public override void OnDraw(RendererBase rendererToDrawWith)
        {
            ImageSequence menuBackground = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "CreditsScreen");

            rendererToDrawWith.Render(menuBackground.GetImageByIndex(0), 0, 0);

            base.OnDraw(rendererToDrawWith);
        }
Exemplo n.º 2
0
 public override void OnDraw(Graphics2D graphics2D)
 {
     if (imageSequence != null)
     {
         graphics2D.Render(imageSequence.GetImageByIndex(CurrentFrame % imageSequence.NumFrames), 0, 0);
     }
     base.OnDraw(graphics2D);
 }
Exemplo n.º 3
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageSequence menuBackground = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "CreditsScreen");

            graphics2D.Render(menuBackground.GetImageByIndex(0), 0, 0);

            base.OnDraw(graphics2D);
        }
Exemplo n.º 4
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageSequence background = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "GameBackground");

            graphics2D.Render(background.GetImageByIndex(0), 0, 0);

            m_Playfield.Draw(graphics2D);

            base.OnDraw(graphics2D);
        }
Exemplo n.º 5
0
        public override void OnDraw(RendererBase rendererToDrawWith)
        {
            ImageSequence menuBackground = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuBackground");

            rendererToDrawWith.Render(menuBackground.GetImageByIndex(0), 0, 0);

            ImageSequence planetOnMenu = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "PlanetOnMenu");

            rendererToDrawWith.Render(planetOnMenu.GetImageByRatio(planetRatio.Read()), 620, 360);

            base.OnDraw(rendererToDrawWith);
        }
Exemplo n.º 6
0
        public PlayfieldView(rect_d bounds)
        {
            Bounds = bounds;

            backgroundImageSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "Map1Background");
            backgroundImage = backgroundImageSequence.GetImageByIndex(0);

            ImageSequence menuButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MenuButtonFromGame");
            ButtonWidget menuButton = new ButtonWidget(400, 12, new ThreeImageButtonView(menuButtonSequence.GetImageByIndex(0), menuButtonSequence.GetImageByIndex(1), menuButtonSequence.GetImageByIndex(2)));
            AddChild(menuButton);
            menuButton.ButtonClick += new ButtonWidget.ButtonEventHandler(EscapeMenu);

            playerViews[0] = new PlayerView(new rect_d(400, 300, 800, 600));
            playerViews[1] = new PlayerView(new rect_d(400, 0, 800, 300));
            playerViews[2] = new PlayerView(new rect_d(0, 300, 400, 600));
            playerViews[3] = new PlayerView(new rect_d(0, 0, 400, 300));
        }
Exemplo n.º 7
0
        public PlayfieldView(rect_d bounds)
        {
            Bounds = bounds;

            backgroundImageSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "Map1Background");
            backgroundImage         = backgroundImageSequence.GetImageByIndex(0);

            ImageSequence menuButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MenuButtonFromGame");
            ButtonWidget  menuButton         = new ButtonWidget(400, 12, new ThreeImageButtonView(menuButtonSequence.GetImageByIndex(0), menuButtonSequence.GetImageByIndex(1), menuButtonSequence.GetImageByIndex(2)));

            AddChild(menuButton);
            menuButton.ButtonClick += new ButtonWidget.ButtonEventHandler(EscapeMenu);

            playerViews[0] = new PlayerView(new rect_d(400, 300, 800, 600));
            playerViews[1] = new PlayerView(new rect_d(400, 0, 800, 300));
            playerViews[2] = new PlayerView(new rect_d(0, 300, 400, 600));
            playerViews[3] = new PlayerView(new rect_d(0, 0, 400, 300));
        }
Exemplo n.º 8
0
        public void DrawScore(RendererBase destRenderer)
        {
            int           playerSequenceIndex = GetPlayerIndex();
            ImageSequence scoreSequence       = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "ScoreNumbers");
            string        score = m_Score.ToString();
            int           x     = 43;
            int           y     = 577;

            switch (playerSequenceIndex)
            {
            case 0:
                break;

            case 1:
                x = 700;
                break;

            case 2:
                x = 45;
                y = 5;
                break;

            case 3:
                x = 700;
                y = 5;
                break;

            default:
                break;
            }

            for (int i = 0; i < score.Length; i++)
            {
                int         digit       = (int)(score[i] - '0');
                ImageBuffer numberImage = scoreSequence.GetImageByIndex(digit);
                destRenderer.Render(numberImage, x, y);
                x += numberImage.Width();
            }
        }
Exemplo n.º 9
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            ImageSequence menuBackground = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuBackground");

            graphics2D.Render(menuBackground.GetImageByIndex(0), 0, 0);

            ImageSequence planetOnMenu = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "PlanetOnMenu");

            graphics2D.Render(planetOnMenu.GetImageByRatio(planetRatio.Read()), 620, 360);

            ImageSequence shipOnMenu = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "Player1Ship");

            int    numFrames          = shipOnMenu.NumFrames;
            double animationRatio0to1 = shipRatio.Read();
            double curFrameDouble     = (numFrames - 1) * animationRatio0to1;
            int    curFrameInt        = shipOnMenu.GetFrameIndexByRatio(animationRatio0to1);
            double curFrameRemainder  = curFrameDouble - curFrameInt;
            double anglePerFrame      = MathHelper.Tau / numFrames;
            double angleForThisFrame  = curFrameRemainder * anglePerFrame;

            graphics2D.Render(shipOnMenu.GetImageByIndex(curFrameInt), 177, 156, angleForThisFrame, 1, 1);

            base.OnDraw(graphics2D);
        }
Exemplo n.º 10
0
        public void Draw(Graphics2D currentRenderer)
        {
            foreach (Rock aRock in m_RockList)
            {
                aRock.Draw(currentRenderer);
            }

            foreach (Player aPlayer in m_PlayerList)
            {
                aPlayer.DrawBullets(currentRenderer);
            }

            foreach (SequenceEntity aSequenceEntity in m_SequenceEntityList)
            {
                aSequenceEntity.Draw(currentRenderer);
            }

            foreach (Player aPlayer in m_PlayerList)
            {
                aPlayer.Draw(currentRenderer);
            }

            ImageSequence hud = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), (m_PlayerList.Count).ToString() + "PlayerHUD");

            currentRenderer.Render(hud.GetImageByIndex(0), 400, 300);

            foreach (Player aPlayer in m_PlayerList)
            {
                aPlayer.DrawScore(currentRenderer);
            }
#if false
            Gl.glMatrixMode(Gl.GL_PROJECTION);                                              // Select The Projection Matrix
            Gl.glLoadIdentity();                                                            // Reset The Projection Matrix
            Glu.gluPerspective(45, Entity.GameWidth / (double)Entity.GameHeight, 0.1, 100); // Calculate The Aspect Ratio Of The Window
            Gl.glMatrixMode(Gl.GL_MODELVIEW);                                               // Select The Modelview Matrix

            float scale = .08f;
            Gl.glLoadIdentity();                                                // Reset The Current Modelview Matrix

            Gl.glLightf(Gl.GL_LIGHT0, Gl.GL_CONSTANT_ATTENUATION, 0.0f);
            Gl.glLightf(Gl.GL_LIGHT0, Gl.GL_LINEAR_ATTENUATION, 0.0f);
            Gl.glLightf(Gl.GL_LIGHT0, Gl.GL_QUADRATIC_ATTENUATION, 0.0002f);
            float[] position = new float[] { -10.5f, 10.0f, 20.0f, 1.0f };

            Gl.glScalef(scale, scale, scale);
            Gl.glTranslatef(0, 0, -160);                                      // Move Left 1.5 Units And Into The Screen 6.0
            Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, position);
            Gl.glTranslatef((float)m_Player.Position.x - 200, (float)m_Player.Position.y - 200, 0);
            Gl.glRotatef((float)((m_Player.m_Rotation - Math.PI / 2) / Math.PI * 180), 0, 0, 1);                                        // Rotate The Triangle On The Y axis ( NEW )
            Gl.glShadeModel(Gl.GL_FLAT);

            Gl.glClearDepth(1);                                                 // Depth Buffer Setup
            Gl.glEnable(Gl.GL_DEPTH_TEST);                                      // Enables Depth Testing
            Gl.glDepthFunc(Gl.GL_LEQUAL);                                       // The Type Of Depth Testing To Do

            Gl.glDisable(Gl.GL_CULL_FACE);
#endif

#if USE_GLSL
            String[] vertexSource = System.IO.File.ReadAllLines("..\\..\\GameData\\marble.vert");
            vertexSource = new string[] { "void main(void) { gl_Position = ftransform(); } " };
            vertexSource = new string[] { "varying vec3 normal, lightDir, eyeVec; void main() { normal = gl_NormalMatrix * gl_Normal; vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex); lightDir = vec3(gl_LightSource[0].position.xyz - vVertex); eyeVec = -vVertex; gl_Position = ftransform(); }" };

            int vertexShader = Gl.glCreateShader(Gl.GL_VERTEX_SHADER);
            Gl.glShaderSource(vertexShader, vertexSource.Length, vertexSource, null);
            Gl.glCompileShader(vertexShader);

            int goodCompile;
            Gl.glGetShaderiv(vertexShader, Gl.GL_COMPILE_STATUS, out goodCompile);

            String[] fragmentSource = System.IO.File.ReadAllLines("..\\..\\GameData\\marble.frag");
            fragmentSource = new string[] { "void main(void) { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); }" };
            fragmentSource = new string[] { "varying vec3 normal, lightDir, eyeVec; void main (void) { vec4 final_color = (gl_FrontLightModelProduct.sceneColor * gl_FrontMaterial.ambient) + (gl_LightSource[0].ambient * gl_FrontMaterial.ambient); vec3 N = normalize(normal); vec3 L = normalize(lightDir); float lambertTerm = dot(N,L); if(lambertTerm > 0.0) { final_color += gl_LightSource[0].diffuse * gl_FrontMaterial.diffuse * lambertTerm; vec3 E = normalize(eyeVec); vec3 R = reflect(-L, N); float specular = pow( max(dot(R, E), 0.0), gl_FrontMaterial.shininess ); final_color += gl_LightSource[0].specular * gl_FrontMaterial.specular * specular; } gl_FragColor = final_color; }" };

            int fragmentShader = Gl.glCreateShader(Gl.GL_FRAGMENT_SHADER);
            Gl.glShaderSource(fragmentShader, fragmentSource.Length, fragmentSource, null);
            Gl.glCompileShader(fragmentShader);

            Gl.glGetShaderiv(fragmentShader, Gl.GL_COMPILE_STATUS, out goodCompile);

            int shaderProgram;
            shaderProgram = Gl.glCreateProgram();
            Gl.glAttachShader(shaderProgram, fragmentShader);
            Gl.glAttachShader(shaderProgram, vertexShader);
            Gl.glLinkProgram(shaderProgram);
            Gl.glGetProgramiv(shaderProgram, Gl.GL_LINK_STATUS, out goodCompile);

            System.Text.StringBuilder infoLog = new System.Text.StringBuilder();
            int length;
            Gl.glGetShaderInfoLog(shaderProgram, 500, out length, infoLog);

            Gl.glUseProgram(shaderProgram);
#endif
            //m_Ship.Render();

#if USE_GLSL
            Gl.glUseProgram(0);
            Gl.glDetachShader(shaderProgram, fragmentShader);
            Gl.glDetachShader(shaderProgram, vertexShader);
            Gl.glDeleteShader(fragmentShader);
            Gl.glDeleteShader(vertexShader);
            Gl.glDeleteProgram(shaderProgram);
#endif
        }
Exemplo n.º 11
0
        public override void OnDraw(RendererBase rendererToDrawWith)
        {
            ImageBuffer levelMap = playfield.LevelMap;
            int         offset;

            byte[] buffer = levelMap.GetBuffer(out offset);

            if (!haveDrawnWalls)
            {
                RendererBase backgroundRenderer = BackgroundImage.NewRenderer();
                rect_i       boundsI            = BackgroundImage.GetBoundingRect();
                rect_d       bounds             = new rect_d(boundsI.Left, boundsI.Bottom, boundsI.Right, boundsI.Top);
                backgroundRenderer.SetClippingRect(bounds);
                ImageSequence wallTileSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "WallTile");
                for (int y = 0; y < levelMap.Height(); y++)
                {
                    for (int x = 0; x < levelMap.Width(); x++)
                    {
                        if (buffer[levelMap.GetBufferOffsetXY(x, y)] == 0)
                        {
                            int index = 0;
                            // what type of wall
                            if (x < levelMap.Width() - 1 &&
                                buffer[levelMap.GetBufferOffsetXY(x + 1, y + 0)] == 0)
                            {
                                index |= 8;
                            }

                            if (y < levelMap.Height() - 1 &&
                                buffer[levelMap.GetBufferOffsetXY(x + 0, y + 1)] == 0)
                            {
                                index |= 4;
                            }

                            if (x > 0 &&
                                buffer[levelMap.GetBufferOffsetXY(x - 1, y + 0)] == 0)
                            {
                                index |= 2;
                            }

                            if (y > 0 &&
                                buffer[levelMap.GetBufferOffsetXY(x + 0, y - 1)] == 0)
                            {
                                index |= 1;
                            }

                            backgroundRenderer.Render(wallTileSequence.GetImageByIndex(index), x * 16, y * 16);
                        }
                    }
                }
                haveDrawnWalls = true;
            }

            //for (int i = 0; i < 1; i++)
            for (int i = 0; i < numPlayers; i++)
            {
                playerViews[i].SetRendererPreDraw(BackgroundImage, rendererToDrawWith, playfield.PlayerList[i]);

                rendererToDrawWith.Render(BackgroundImage, 0, 0);

                foreach (SequenceEntity aSequenceEntity in playfield.SequenceEntityList)
                {
                    aSequenceEntity.Draw(rendererToDrawWith);
                }

                foreach (Player aPlayer in playfield.PlayerList)
                {
                    aPlayer.Draw(rendererToDrawWith);
                }

                playfield.sword.Draw(rendererToDrawWith);
                playfield.key.Draw(rendererToDrawWith);
                playfield.shield.Draw(rendererToDrawWith);

                playerViews[i].SetRendererPostDraw(rendererToDrawWith);
            }

            ImageSequence hud = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), (playfield.PlayerList.Count).ToString() + "PlayerHUD");

            rendererToDrawWith.Render(hud.GetImageByIndex(0), 400, 300);

            foreach (Player aPlayer in playfield.PlayerList)
            {
                aPlayer.DrawScore(rendererToDrawWith);
            }

            rendererToDrawWith.Line(0.5, 300.5, 800.5, 300.5, new RGBA_Bytes(255, 20, 20));
            rendererToDrawWith.Line(400.5, 0.5, 400.5, 600.5, new RGBA_Bytes(255, 20, 20));

            base.OnDraw(rendererToDrawWith);
        }
Exemplo n.º 12
0
        public MainMenu(RectangleDouble bounds)
        {
            BoundsRelativeToParent = bounds;

            ImageSequence startButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuStartButton");
            Button        StartGameButton     = new Button(400, 310, new ButtonViewThreeImage(startButtonSequence.GetImageByIndex(0), startButtonSequence.GetImageByIndex(1), startButtonSequence.GetImageByIndex(2)));

            AddChild(StartGameButton);
            StartGameButton.Click += OnStartGameButton;

            ImageSequence creditsButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuCreditsButton");
            Button        creditsGameButton     = new Button(400, 230, new ButtonViewThreeImage(creditsButtonSequence.GetImageByIndex(0), creditsButtonSequence.GetImageByIndex(1), creditsButtonSequence.GetImageByIndex(2)));

            AddChild(creditsGameButton);
            creditsGameButton.Click += OnShowCreditsButton;

            ImageSequence exitButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuExitButton");
            Button        exitGameButton     = new Button(400, 170, new ButtonViewThreeImage(exitButtonSequence.GetImageByIndex(0), exitButtonSequence.GetImageByIndex(1), exitButtonSequence.GetImageByIndex(2)));

            AddChild(exitGameButton);
            exitGameButton.Click += OnExitGameButton;
        }
Exemplo n.º 13
0
        public CreditsMenu(RectangleDouble bounds)
        {
            BoundsRelativeToParent = bounds;

            ImageSequence cancelButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "NumPlayersCancelButton");
            Button        cancelGameButton     = new Button(400, 200, new ButtonViewThreeImage(cancelButtonSequence.GetImageByIndex(0), cancelButtonSequence.GetImageByIndex(1), cancelButtonSequence.GetImageByIndex(2)));

            AddChild(cancelGameButton);
            cancelGameButton.Click += OnCancelMenuButton;
        }
Exemplo n.º 14
0
        public MainMenu(rect_d bounds)
        {
            Bounds = bounds;

            ImageSequence startButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuStartButton");
            ButtonWidget  StartGameButton     = new ButtonWidget(400, 310, new ThreeImageButtonView(startButtonSequence.GetImageByIndex(0), startButtonSequence.GetImageByIndex(1), startButtonSequence.GetImageByIndex(2)));

            AddChild(StartGameButton);
            StartGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnStartGameButton);

            ImageSequence creditsButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuCreditsButton");
            ButtonWidget  creditsGameButton     = new ButtonWidget(400, 230, new ThreeImageButtonView(creditsButtonSequence.GetImageByIndex(0), creditsButtonSequence.GetImageByIndex(1), creditsButtonSequence.GetImageByIndex(2)));

            AddChild(creditsGameButton);
            creditsGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnShowCreditsButton);

            ImageSequence exitButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuExitButton");
            ButtonWidget  exitGameButton     = new ButtonWidget(400, 170, new ThreeImageButtonView(exitButtonSequence.GetImageByIndex(0), exitButtonSequence.GetImageByIndex(1), exitButtonSequence.GetImageByIndex(2)));

            AddChild(exitGameButton);
            exitGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnExitGameButton);
        }
Exemplo n.º 15
0
        public CreditsMenu(rect_d bounds)
        {
            Bounds = bounds;

            ImageSequence cancelButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "NumPlayersCancelButton");
            ButtonWidget  cancelGameButton     = new ButtonWidget(400, 200, new ThreeImageButtonView(cancelButtonSequence.GetImageByIndex(0), cancelButtonSequence.GetImageByIndex(1), cancelButtonSequence.GetImageByIndex(2)));

            AddChild(cancelGameButton);
            cancelGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnCancelMenuButton);
        }
Exemplo n.º 16
0
        public PlayfieldView(RectangleDouble bounds)
        {
            BoundsRelativeToParent = bounds;

            ImageSequence menuButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MenuButtonFromGame");
            Button        menuButton         = new Button(400, 12, new ButtonViewThreeImage(menuButtonSequence.GetImageByIndex(0), menuButtonSequence.GetImageByIndex(1), menuButtonSequence.GetImageByIndex(2)));

            AddChild(menuButton);
            menuButton.Click += EscapeMenu;
        }
Exemplo n.º 17
0
        public HowManyPlayersMenu(RectangleDouble bounds)
        {
            BoundsRelativeToParent = bounds;
            ImageSequence onePlayerButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "OnePlayerButton");
            Button        onePlayerGameButton     = new Button(270, 310, new ButtonViewThreeImage(onePlayerButtonSequence.GetImageByIndex(0), onePlayerButtonSequence.GetImageByIndex(1), onePlayerButtonSequence.GetImageByIndex(2)));

            AddChild(onePlayerGameButton);
            onePlayerGameButton.Click += OnStartOnePlayerGameButton;

            ImageSequence twoPlayerButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "TwoPlayerButton");
            Button        twoPlayerGameButton     = new Button(400, 310, new ButtonViewThreeImage(twoPlayerButtonSequence.GetImageByIndex(0), twoPlayerButtonSequence.GetImageByIndex(1), twoPlayerButtonSequence.GetImageByIndex(2)));

            AddChild(twoPlayerGameButton);
            twoPlayerGameButton.Click += OnStartTwoPlayerGameButton;

            ImageSequence fourPlayerButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "FourPlayerButton");
            Button        fourPlayerGameButton     = new Button(530, 310, new ButtonViewThreeImage(fourPlayerButtonSequence.GetImageByIndex(0), fourPlayerButtonSequence.GetImageByIndex(1), fourPlayerButtonSequence.GetImageByIndex(2)));

            AddChild(fourPlayerGameButton);
            fourPlayerGameButton.Click += OnStartFourPlayerGameButton;

            ImageSequence cancelButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "NumPlayersCancelButton");
            Button        cancelGameButton     = new Button(400, 210, new ButtonViewThreeImage(cancelButtonSequence.GetImageByIndex(0), cancelButtonSequence.GetImageByIndex(1), cancelButtonSequence.GetImageByIndex(2)));

            AddChild(cancelGameButton);
            cancelGameButton.Click += OnCancelMenuButton;
        }