Exemple #1
0
        static void moverAsteroid(int value)//move o asteroid em time
        {
            // Muda a direção quando chega na borda esquerda ou direita
            if (ax > 0.5f || ax < -1.5f)
            {
                xstep = -xstep;
            }
            // Muda a direção quando chega na borda superior ou inferior
            if (ay <= -1.5f)
            {
                ay = 0.7f;
            }

            // Move o quadrado
            ax += xstep;
            ay -= ystep;

            cy -= 0.001f;


            if (cy <= -1.0f)
            {
                cy = 0.7f;
            }


            // Redesenha o quadrado com as novas coordenadas
            Glut.glutPostRedisplay();
            Glut.glutTimerFunc(1, moverAsteroid, 1);

            rot -= 1;// Velocidade do giro do asteroid
            // Redesenha o quadrado com as novas coordenadas
            //Glut.glutPostRedisplay();
            //Glut.glutTimerFunc(10, moverAsteroid, 1);
        }
Exemple #2
0
        static void Timer(int value)
        {
            if (!colisao)
            {
                iceZ      += 0.1f;
                pontuacao += 1;
                if ((((iceX + 0.1f) > (b - 0.25f)) && ((iceX + 0.1f) < (b + 0.25f))) && (iceZ >= 2.5f))
                {
                    colisao = true;
                    Console.WriteLine("\nJogador: " + jogador);
                    Console.WriteLine("Pontuação: " + pontuacao);
                    Console.WriteLine("\nPressione F1 para jogar novamente...");
                }

                if (iceZ >= 3.4f)
                {
                    iceZ = 0.0f;
                    iceX = NextFloat(random);
                    if (clock > 10)
                    {
                        clock -= 10;
                    }
                }
                Glut.glutPostRedisplay();
                Glut.glutTimerFunc(clock, Timer, 1);
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            scene = new Scene.Scene(800, 600);

            menuList.Add(new InfoMenu(300, scene.HEIGHT - 20, 0, bottomHeight + 20));
            menuList.Add(new BottomMenu(scene.WIDTH, bottomHeight, 0, 0));

            Glut.glutInit();

            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGBA | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(scene.WIDTH + menuList[0].WIDTH, scene.HEIGHT + menuList[1].HEIGHT);

            Glut.glutInitWindowPosition(100, 10);
            int id = Glut.glutCreateWindow("Scene Editor");

            Init();
            Glut.glutDisplayFunc(new Glut.DisplayCallback(Draw));
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(KeyboardHandle));
            Glut.glutMouseFunc(new Glut.MouseCallback(MouseHandle));
            Glut.glutMouseWheelFunc(new Glut.MouseWheelCallback(MouseWheelHandle));
            //Glut.glutReshapeFunc(new Glut.ReshapeCallback(Resize));
            Glut.glutTimerFunc(1000 / 60, Update, 0);

            Glut.glutMainLoop();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            try
            {
                init();
                Glut.glutDisplayFunc(Draw);
                Glut.glutReshapeFunc(reshape);
                Glut.glutKeyboardFunc(new Glut.KeyboardCallback(pressKey));
                Glut.glutSpecialFunc(new Glut.SpecialCallback(specialKey));

                Glut.glutIgnoreKeyRepeat(1);
                Glut.glutKeyboardUpFunc(new Glut.KeyboardUpCallback(releaseKey));

                Glut.glutTimerFunc(33, on_timer, 0);
                Glut.glutMainLoop();
            }
            catch (FileReadException e)
            {
                Console.WriteLine(e.exception);
            }
            catch
            {
                Console.WriteLine("Some unknow expection...=(");
            }
        }
Exemple #5
0
        static void TeclasEspeciais(int key, int x, int y)
        {
            switch (key)
            {
            case Glut.GLUT_KEY_LEFT:
                if (b > -1.1f)
                {
                    b -= 0.1f;
                }
                break;

            case Glut.GLUT_KEY_RIGHT:
                if (b < 1.1f)
                {
                    b += 0.1f;
                }
                break;

            case Glut.GLUT_KEY_F1:
                colisao   = false;
                pontuacao = 0;
                iceZ      = 0.0f;
                iceX      = NextFloat(random);
                clock     = 150;

                Glut.glutTimerFunc(clock, Timer, 1);
                break;
            }
            Glut.glutPostRedisplay();
        }
        public void Timer(int value)
        {
            // Muda a direção quando chega na borda esquerda ou direita
            if (tz < -30.7)
            {
                tz = 13;
            }

            // Muda a direção quando chega na borda superior ou inferior
            if (ty > 3.7 || ty < 0)
            {
                movementVelocityY = -movementVelocityY;
            }

            // Move o quadrado
            tz += movementVelocityZ;
            ty += movementVelocityY;
            tx += movementVelocityX;

            //Console.WriteLine("TZ: " + tz + " TY: " + ty + " TX: " + tx);

            // Redesenha o quadrado com as novas coordenadas
            Glut.glutPostRedisplay();
            Glut.glutTimerFunc(1, Timer, 1);
        }
Exemple #7
0
        //Tempo
        static void Timer(int value)
        {
            rot -= 7;

            Glut.glutPostRedisplay();
            Glut.glutTimerFunc(1, Timer, 1);
        }
Exemple #8
0
        void MainProcess(int value)
        {
            if (!previousStateDrawed)
            {
                return;                       //если вдруг не успели отрисоваться за время кадра, подождем следующего тика
            }
            previousStateDrawed = false;

            Glut.glutTimerFunc(Config.TimePerFrame, MainProcess, 0);//сразу засекаем следующие миллисекунды

            Frame frame = _game.Process(_keyboardState);

            _keyboardState.StepEnded(); //игра считала кнопки, время классу сделать плановые действия

            //рисуем, если есть что рисовать
            if (frame == null)
            {
                CloseWindow();
            }
            else
            {
                Painter.DrawFrame((Frame)frame, _textureCodes);
            }

            previousStateDrawed = true; //справились с рисованием
        }
Exemple #9
0
        static void Init()
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DEPTH | Glut.GLUT_DOUBLE | Glut.GLUT_RGB);
            Glut.glutInitWindowSize(1024, 700);
            //Glut.glutInitWindowPosition(150, 0);
            Glut.glutInitWindowPosition(150, 0);
            Glut.glutCreateWindow("Computação Gráfica");

            ContentManager.SetModelList("modelos\\");
            ContentManager.LoadModels();
            Load3dsModels();

            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();

            SetupLight();

            Glu.gluPerspective(35.0f, 1.0, 0.001, 100.0);
            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Glu.gluLookAt(0.0, 1.0, 8.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

            Gl.glClearColor(0.498039f, 1, 0.831373f, 0.0f);
            Glut.glutTimerFunc(1, airplane.Timer, 1);

            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Glut.glutDisplayFunc(Render);

            RegisterFuncs();

            Glut.glutMainLoop();
        }
Exemple #10
0
 static void Timer(int value)
 {
     rot += 10f;
     // Redesenha o quadrado com as novas coordenadas
     Glut.glutPostRedisplay();
     Glut.glutTimerFunc(100, Timer, 1);
 }
Exemple #11
0
        private static void RenderTimer(int index)
        {
            if (MainLoop.GameObjectsArray.Count != 0 || MainLoop.BackendObjectArray.Count != 0)
            {
                Glut.glutPostRedisplay();

                Glut.glutTimerFunc(1000 / 60, RenderTimer, 0);
            }
        }
Exemple #12
0
        static void Update(int value)
        {
            UpdateClass.Run(value, camera: scene.SceneCamera,
                            objects: scene.SceneFigures,
                            lights: scene.SceneLights);
            Glut.glutPostRedisplay();

            Glut.glutTimerFunc(1000 / 60, Update, value);
        }
Exemple #13
0
        static void TimerLuz(int value)
        {
            if (bit == false)
            {
                bit = true;
                //Recebe();
            }

            Glut.glutTimerFunc(1000, TimerLuz, 1);
        }
Exemple #14
0
 public static void Main()
 {
     Glut.glutInit();
     Glut.glutInitWindowSize(1000, 1000);
     Glut.glutCreateWindow("Snow_Man");
     Init_graphics();
     Glut.glutDisplayFunc(OnDisplay);
     Glut.glutReshapeFunc(OnReshape);
     Glut.glutTimerFunc(20, Update, 1);
     Glut.glutKeyboardFunc(UpdateKeys);
     Glut.glutMainLoop();
 }
Exemple #15
0
 static void Main(string[] args)
 {
     Glut.glutInit();
     Glut.glutInitDisplayMode(Glut.GLUT_SINGLE | Glut.GLUT_RGB);
     Glut.glutInitWindowSize(800, 400);
     Glut.glutInitWindowPosition(100, 100);
     Glut.glutCreateWindow("Sobrevivendo");
     Inicializa();
     Glut.glutDisplayFunc(DesenhaJogo);
     Glut.glutSpecialFunc(Mover);
     Glut.glutTimerFunc(100, Timer, 1);
     Glut.glutMainLoop();
 }
Exemple #16
0
        ///////////////////////////////////////////////
        /////////////////CONSTRUCTORS//////////////////
        ///////////////////////////////////////////////


        /*********************************************/


        ///////////////////////////////////////////////
        ////////////////////METHODS////////////////////
        ///////////////////////////////////////////////

        public override void InitGlSetting()
        {
            Glut.glutInit();
            Glut.glutInitWindowSize(this.width, this.height); //setting window size
            Glut.glutInitWindowPosition(this.x, this.y);      //setting window position
            Glut.glutCreateWindow(this.name);                 //creating a window with some name
            Gl.glEnable(Gl.GL_TEXTURE_2D);

            this.InitGraphSetting();

            Glut.glutDisplayFunc(this.DrawFunc);               //rendering method setting
            Glut.glutTimerFunc(1000 / FPS, this.TimerFunc, 0); //SET SPEED OF RENDERING HERE
            Glut.glutReshapeFunc(this.WindowReshape);          //on window reshape method setting
        }
Exemple #17
0
        static void CreateWindow()
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGBA);
            Glut.glutInitWindowSize(_widowSize, _widowSize);
            Glut.glutCreateWindow("LB4: Glass sphere");
            InitializeViewAppearance();

            Glut.glutReshapeFunc(Reshape);
            Glut.glutDisplayFunc(Redraw);
            Glut.glutTimerFunc(0, Timer, 0);

            Glut.glutMainLoop();
        }
Exemple #18
0
        static void Main(string[] args)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_SINGLE | Glut.GLUT_RGB);
            Glut.glutInitWindowSize(600, 600);
            Glut.glutInitWindowPosition(100, 100);
            Glut.glutCreateWindow("Projeto");
            Inicializa();
            Glut.glutDisplayFunc(Desenha);
            Glut.glutSpecialFunc(Teclasnave);

            Glut.glutTimerFunc(300, moverAsteroid, 1);
            Glut.glutMainLoop();
        }
Exemple #19
0
        static void Main(string[] args)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGB);
            Glut.glutInitWindowSize(600, 600);
            Glut.glutCreateWindow("OPENGL LB1");
            Init();

            Glut.glutReshapeFunc(Reshape);
            Glut.glutDisplayFunc(Display);
            Glut.glutTimerFunc(0, Timer, 0);

            Glut.glutMainLoop();
        }
Exemple #20
0
        public void InitGlSetting(int width, int height, int posX, int posY, string name, int FPS)
        {
            Glut.glutInit();
            Glut.glutInitWindowSize(width, height);  //setting window size
            Glut.glutInitWindowPosition(posX, posY); //setting window position
            Glut.glutCreateWindow(name);             //creating a window with some name
            Gl.glEnable(Gl.GL_TEXTURE_2D);

            this.InitGraphSetting();

            Glut.glutDisplayFunc(Redraw);             //rendering method setting
            Glut.glutTimerFunc(1000 / FPS, Timer, 0); //SET SPEED OF RENDERING HERE
            Glut.glutReshapeFunc(WindowReshape);      //on window reshape method setting
        }
Exemple #21
0
        static void CreateWindow()
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGB);
            Glut.glutInitWindowSize(800, 600);
            Glut.glutCreateWindow("LB3: Pyramid");
            InitializeViewAppearance();

            Glut.glutReshapeFunc(Reshape);
            Glut.glutDisplayFunc(Redraw);
            Glut.glutTimerFunc(0, Timer, 0);

            Glut.glutMainLoop();
        }
Exemple #22
0
 static void Main()
 {
     Glut.glutInit();
     Glut.glutInitDisplayMode(Glut.GLUT_SINGLE | Glut.GLUT_RGB);
     Glut.glutInitWindowSize(650, 650);
     Glut.glutInitWindowPosition(100, 100);
     Glut.glutCreateWindow("Tiro ao Alvo");
     Glut.glutDisplayFunc(desenha);
     Glut.glutSpecialFunc(Mover);
     Glut.glutKeyboardFunc(new Glut.KeyboardCallback(Teclado));  //Chama  as  funcoes  do teclado
     Glut.glutTimerFunc(100, Timer, 1);
     Glut.glutTimerFunc(1000, TimerLuz, 1);
     inicializa();
     Glut.glutMainLoop();
 }
Exemple #23
0
        public void SetMainLoop()
        {
            //отлов действий пользователя
            Glut.glutMotionFunc(ClickedMotion);
            Glut.glutMouseFunc(Mouse);
            Glut.glutPassiveMotionFunc(PassiveMotion);
            Glut.glutKeyboardFunc(Key);
            Glut.glutKeyboardUpFunc(KeyUp);
            Glut.glutSpecialFunc(KeySpecial);
            Glut.glutSpecialUpFunc(KeySpecialUp);

            //старт игрового цикла
            Glut.glutTimerFunc(Config.TimePerFrame, MainProcess, 0);
            Glut.glutMainLoop();
        }
 static void Main(string[] args)
 {
     Glut.glutInit();
     Glut.glutInitDisplayMode(Glut.GLUT_DEPTH | Glut.GLUT_DOUBLE | Glut.GLUT_RGB);
     Glut.glutInitWindowSize(600, 600);
     Glut.glutInitWindowPosition(100, 100);
     Glut.glutCreateWindow("Desvie dos obstaculos");
     Inicializa();
     Gl.glEnable(Gl.GL_DEPTH_TEST);
     Glut.glutDisplayFunc(Desenha);
     Glut.glutSpecialFunc(TeclasBola);
     Glut.glutTimerFunc(50, MoverPedra, 1);
     luz();
     Glut.glutMainLoop();
 }
Exemple #25
0
 static void timerright(int p)
 {
     //point();
     if (p > 5)
     {
         angley += 1.5f;
         Glut.glutPostRedisplay();
         Glut.glutTimerFunc(10, timerright, p - 1);
     }
     else if (p > 0)
     {
         angley += 1.5f;
         Glut.glutPostRedisplay();
         Glut.glutTimerFunc(30, timerright, p - 1);
     }
 }
Exemple #26
0
        static void Main()
        {
            Console.WriteLine("Para iniciar o jogo pressione F1!\n");
            Console.Write("Digite seu nome: ");
            jogador = Console.ReadLine();

            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DEPTH | Glut.GLUT_DOUBLE | Glut.GLUT_RGB);
            Glut.glutCreateWindow("Boat Escape");

            Glut.glutTimerFunc(clock, Timer, 1);

            inicializa();
            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Glut.glutDisplayFunc(desenha);
            Glut.glutSpecialFunc(TeclasEspeciais);
            Glut.glutMainLoop();
        }
Exemple #27
0
        static void Main()
        {
            Glut.glutInit();

            Glut.glutInitDisplayMode(Glut.GLUT_SINGLE | Glut.GLUT_RGB);
            Glut.glutInitWindowSize(500, 300);
            Glut.glutInitWindowPosition(10, 10);
            Glut.glutCreateWindow("PONG");
            Inicializa();
            Glut.glutPassiveMotionFunc(rend.MoveMouse);
            Glut.glutTimerFunc(33, Timer, 1);
            Glut.glutDisplayFunc(rend.Desenha);
            Glut.glutReshapeFunc(AlteraTamanhoJanela);
            Glut.glutKeyboardFunc(evento.GerenciaTeclado);
            Glut.glutSpecialFunc(TeclasEspeciais);



            Glut.glutMainLoop();
        }
Exemple #28
0
        public static void Build()
        {
            for (int i = 0; i < _keysArrayUp.Length; i++)
            {
                _keysArrayUp[i] = true;
            }

            Glut.glutDisplayFunc(OnDisplay);

            Glut.glutReshapeFunc(OnReshape);

            Glut.glutCloseFunc(OnClose);

            Glut.glutKeyboardFunc(OnKeyboard);

            Glut.glutKeyboardUpFunc(OnKeyboardUp);


            Glut.glutTimerFunc(100, RenderTimer, 0);
        }
        static int pontoJogador2 = 0;           // Contador pontos jogador2.@@
        #endregion

        static void Main(string[] args)
        {
            Console.Write("Futebol 2D");
            Console.WriteLine("Informe o nome do Primeiro Jogador: ");
            jogador1 = Console.ReadLine();
            Console.WriteLine("Informe o nome do segundo jogador: ");
            jogador2 = Console.ReadLine();

            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_SINGLE | Glut.GLUT_RGB);
            Glut.glutInitWindowSize(800, 400);
            Glut.glutInitWindowPosition(100, 100);
            Glut.glutCreateWindow("Copa do Mundo");
            inicialize();
            Glut.glutDisplayFunc(desenhar);
            Glut.glutSpecialFunc(moverGoleiroBrasil);
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(moverGoleiroAlemanha));
            Glut.glutTimerFunc(100, Timer, 1);
            Glut.glutMainLoop();
        }
Exemple #30
0
        static void Timer(int value)
        {
            if (start)
            {
                evento.Mover();
                evento.Colisao(rightplayer);
                evento.Colisao2(leftplayer);
                evento.ColisaoJanela(203, 383);
                evento.ColisaoBarras(leftplayer);
                evento.ColisaoBarras(rightplayer);
                evento.Reiniciar();
            }
            else if (!start)
            {
                rend.DesenhaStart(true);
            }



            Glut.glutPostRedisplay();
            Glut.glutTimerFunc(50, Timer, value + 1);
        }