2 Replies - 377 Views - Last Post: 05 February 2013 - 07:32 PM Rate Topic: -----

#1 kaljsdsadf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-February 13

program flashes then only debug window shows when runnning

Posted 02 February 2013 - 02:20 PM

the code is only a five level puzzle game. I am using SDL, opengl, C++, and codeblocks with the mingw32 compiler to make it. I know it has nothing to with SDL becuase I have installed a Devpack for SDL. also i can only execute it once then I must restart the IDE to run it again.
#include "SDL.h"
#include "SDL_opengl.h"
#include <iostream>
#include <math.h>

using namespace std;

bool checkCollision(float Ax,float Ay,float Aw,float Ah,int Bx, int By, int Bw, int Bh)
{
    if (Ay + Ah < By ) return false;
   else if (Ay > By + Bh) return false;
   else if (Ax + Aw < Bx) return false;
   else if (Ax > Bx + Bw ) return false;
   else if (Ax + Aw > Bx) return true;

    return true;
}
/*bool check (float px, float py, float ph, float pw, int obx[], int oby[],int obh[],int obw[])// use arrays with numbers then during check intriment a variable inside array []
{
    int c = 0;
    int b = 0;
    int a = 0;
    int i = 0;
    int counter = 0;
    int fx = 0;
    while (checkCollision(px,py,ph,pw,obx[c],oby[b],obh[a],obw[i]) == false && (c <= 13 || b <= 11 || a <= 13 || i <= 10))
    {

        if (counter == 1 + fx)
        {
            c++;
            if (checkCollision(px,py,ph,pw,obx[c],oby[b],obh[a],obw[i]) == true)
            {
                return true;
            }
        }
        else if (counter == 2 + fx)
        {
            b++;
            if (checkCollision(px,py,ph,pw,obx[c],oby[b],obh[a],obw[i]) == true)
            {
                return true;
            }
        }
        else if (counter == 3 + fx)
        {
            a++;
            if (checkCollision(px,py,ph,pw,obx[c],oby[b],obh[a],obw[i]) == true)
            {
                return true;
            }
        }
        else if (counter == 4 + fx)
        {
            i++;
            if (checkCollision(px,py,ph,pw,obx[c],oby[b],obh[a],obw[i]) == true)
            {
                return true;
            }
        }
        counter++;
        fx+=4;
    }
    return false;
}*/
int main(int argc, char* argv[])
{
    SDL_Init( SDL_INIT_EVERYTHING );

   SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8);
   SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8);
   SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8);
   SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8);
   SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, 32);
   SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16);
   SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1);

    SDL_WM_SetCaption( "stack 52" , NULL );

    SDL_SetVideoMode( 600,400,32, SDL_OPENGL);

    glClearColor(1,1,1,1); // RGBA

    glViewport(0,0,600,400);

    glShadeModel(GL_SMOOTH);

    glMatrixMode(GL_PROJECTION);

    glLoadIdentity();

    glEnable(GL_DEPTH_TEST);

    cout << "open gl is running";

    SDL_Event event;

    bool isRunning = true, isAlive = true;
    float xpers = 15;
    float ypers = 375;
    float wpers = 12.5;
    float hpers = 26;
    int moves = 52;
    int r = 0;
    int g = 0;
    int b = 0;
    int T = 0;

    struct LineVector

    {
        float x;
        float y;
    };

    bool left = false;
    bool right = false;
    bool up = false;
    bool lvl1 = true;
    bool lvl2,lvl3,lvl4,lvl5 = false;

    //main loop
    while ( isRunning )

    {
         while (SDL_PollEvent(&event) )
        {

        //EVENTS

                if (event.type == SDL_QUIT)

                {
                    isRunning = false;
                }


                if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_ESCAPE)
                {
                    isRunning = false;
                }
                int c = 1;
            if (event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_SPACE)
            {

                while (c <= 2)
                {
                    ypers = ypers + 150;
                    xpers = xpers + 60;
                    LineVector Gravity;
                    Gravity.x = +0.0f;  //Since gravity acts only in vertical direction
                    Gravity.y = -9.8f;

                }
                // will add wall jump by setting collision detection for the map with variable

                up = true;
            }


            if (event.type == SDL_KEYDOWN)
            {

                if(event.key.keysym.sym == SDLK_RIGHT)
                {
                    right = true;
                }

                else if (event.key.keysym.sym == SDLK_LEFT)
                {
                    left = true;
                }
            }
            else if (event.type == SDL_KEYUP)
            {
                if (event.key.keysym.sym == SDLK_RIGHT)
                {
                    right = false;
                }

                else if (event.key.keysym.sym == SDLK_LEFT)
                {
                    left = false;
                }
            }

            }

            if (moves == 48)
            {
                hpers = 24;
                //insert new pic after each
            }

            if (moves == 44)
            {
                hpers = 22;
            }

            if (moves == 40)
            {
                hpers = 20;
            }

            if (moves == 36)
            {
                hpers = 18;
            }

            if (moves == 32)
            {
                hpers = 16;
            }

            if (moves == 28)
            {
                hpers = 14;
            }

            if (moves == 24)
            {
                hpers = 12;
            }

            if (moves == 20)
            {
                hpers = 10;
            }

            if (moves == 16)
            {
                hpers = 8;
            }

            if (moves == 12)
            {
                hpers = 6;
            }

            if (moves == 8)
            {
                hpers = 4;
            }

            if (moves == 4)
            {
                hpers = 2;
            }

            if (moves == 0)
            {
                hpers = 0;
                isRunning = false;
            }
            //event logic



        //LOGIC
        if (isRunning == false)
        {
            SDL_Quit();
        }

        if (right == true)
        {
            xpers += 50;
            moves--;

        }

        if (left == true)
        {
            xpers -= 50;
            moves--;
        }

        if (up == true)
        {
            moves--;
        }

        if (lvl1 == false)
        {
            lvl2 = true;
        }

        if (lvl2 == false)
        {
            lvl3 = true;
        }

        if (lvl3 == false)
        {
            lvl4 = true;
        }

        if (lvl4 == false)
        {
            lvl5 = true;
        }

        if (lvl5 == true)
        {
            SDL_Quit();
        }
        if (xpers >= 600 - wpers || xpers <= 0)
        {
            xpers = -xpers;
        }
        if (ypers < 0 - hpers || ypers >= 400)
        {
            ypers = -ypers;
        }

        //rendering to the screen


        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        glPushMatrix();

        glOrtho(0,600,400,0,-1,1);

        while (isAlive)
        {
            glColor4ub(255,49,3,255);

            glBegin(GL_QUADS);// GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP, GL_QUADS, GL_TRIANGLES, GL_POLIGON

            glVertex2f (xpers,ypers);
            glVertex2f (xpers + wpers,ypers);
            glVertex2f (xpers + wpers,ypers + hpers);
            glVertex2f (xpers,ypers + hpers);

            glEnd();
             LineVector Gravity;
                Gravity.x = +0.0f;  //Since gravity acts only in vertical direction
                Gravity.y = -9.8f;


                    ypers -= Gravity.y;

        }


    while (lvl1 == true)
    {
       float eox[8] = {0,75,35,85,130,155,455,450};
        float seox[9] = {75,115,25,125,110,155,160,450,549};
        float eoy[8] = {375,350,250,225,200,125,100,70};
        float seoy[9] = {375,275,360,350,225,200,175,100,70};

        glBegin(GL_LINES);

        glColor4ub (0,0,0,255);

        glVertex2f (eox[0],eoy[0]);//startu
        glVertex2f (seox[0],seoy[0]);//u

        glEnd();

        glBegin(GL_LINES);

        glColor4ub (0,0,0,255);

        glVertex2f (eox[1],eoy[0]);//eoxu
        glVertex2f (seox[1],seoy[1]);//u

        glEnd();

        glBegin(GL_LINES);
        glColor4ub(0,0,0,255);

        glVertex2f (eox[0],eoy[1]);//eoxu
        glVertex2f (seox[2],seoy[2]);//u

        glEnd();

        glBegin(GL_LINES);

        glColor4ub (0,0,0,255);

        glVertex2f (eox[2],eoy[1]);//eoxu
        glVertex2f (seox[0],seoy[3]);//u

        glEnd();

        glBegin(GL_LINE_STRIP);

        glColor4ub (0,0,0,255);

        glVertex2f (eox[1],eoy[2]);//eoxu
        glVertex2f (seox[3],seoy[5]);//u
        glVertex2f (eox[3],eoy[2]);//eoxu
        glVertex2f (seox[4],seoy[0]);

        glEnd();

        glBegin(GL_LINES);
        glVertex2f (eox[4], eoy[3]);//eoxu
        glVertex2f (seox[5],seoy[5]);//u

        glEnd();

        glBegin(GL_QUADS);
        glColor4ub (r = 205, g = 133,b = 63 ,255);

        glVertex2f (eox[5],eoy[6]);//eoxu
        glVertex2f (seox[6],seoy[6]);//u
        glVertex2f (eox[6],eoy[5]);//eoxu
        glVertex2f (seox[7],seoy[7]);//u

        glEnd();

        glBegin(GL_LINES);
      glColor4ub (r = 0, g = 0,b = 0 ,255);

        glVertex2f (eox[7],eoy[6]);//eoxu
        glVertex2f (seox[7],seoy[8]);//u

        glEnd();

        glBegin(GL_LINES);
        glColor4ub (0,0,0 ,255);

        glVertex2f (eox[7],eoy[7]);//eoxu
        glVertex2f (seox[8],seoy[8]);//

        glEnd();

            int xx = 370;
            int inc = 549;

        for (int d = 0; d <= 2; d++)
        {
            glBegin(GL_TRIANGLES);
            glColor4ub (0,0,0 ,255);

            glVertex2f (inc + 8.5,xx);//top
            glVertex2f (inc + 17,xx + 30);//far point
            glVertex2f (inc, xx + 30);//near point
            inc += 17;

            glEnd();

            while (xx == 370)
            {
                SDL_Quit();
            }
         }


         if ((xpers >= 530) && (ypers = 0))
            {
                lvl1 = false;
                xpers = 31;
                ypers = 300;
                hpers = 26;
            }
            while ((r == 205) && (g == 133) && (b == 63))
            {
                SDL_Delay(100);
                xpers = xpers - 10;
                while (lvl5 == true && xpers > 150)
                {
                    xpers -= 5;
                }
            }
            while (checkCollision(xpers,ypers,wpers,hpers,eox[T],seox[T],eoy[T],seoy[T]) == true)
            {
                if ((ypers + hpers > eoy[T]) || (ypers < seoy[T]))
                {
                    ypers = -ypers;
                }
                if ((xpers + wpers > eox[T]) || (xpers < seox[T]))
                {
                    xpers = -xpers;
                    if (up == true)
                    {
                        int x = 1;
                        while (x == 1)
                        {
                            ypers -= 150;
                        }
                    }
                }
                T++;
            }


    }
         while (lvl2)
    {
            float twox[6] = {31,221,371,391,411,561};//6
            float twoy[3] = {300,200,100};
            float two_x[6] = {181,371,221,391,411,561};
            float two_y[5] = {300,400,200,250,100};

             for (int d = 10; d >= 0; d--)
             {
                 int xx = 0;
                 int yy = 1.5 * xx;
                 glBegin(GL_TRIANGLES);

                glColor4ub(0,0,0,255);
                glVertex2f(0,0 + xx);
                xx += 40;
                glVertex2f(30,0 + xx);
                glVertex2f(0,0 + yy);

             }
            glBegin(GL_QUADS);
            glColor4ub(0,0,0,255);

            glVertex2f(twox[0],twoy[0]);
            glVertex2f(two_x[0],twoy[0]);
            glVertex2f(two_x[0],two_y[0]);
            glVertex2f(twox[0],two_y[0]);

            glEnd();
                int xx = 20;

            for (int d=0;d<=2;d++)
            {
                glBegin(GL_TRIANGLES);

                glVertex2f(181 + xx - 20,400);
                glVertex2f(181 + .5 * xx,370);
                glVertex2f(181 + xx,400);
                xx = 40;
                glEnd();
            }

             glBegin(GL_QUADS);
            glColor4ub(0,0,0,255);

            glVertex2f(twox[1],twoy[1]);
            glVertex2f(two_x[1],two_y[2]);
            glVertex2f(twox[2],twoy[1]);
            glVertex2f(two_x[2], two_y[1]);

            xx = 20;
            glEnd();
            for (int d=0;d<=2;d++)
            {

                glBegin(GL_TRIANGLES);

                glVertex2f(371 + xx - 20,400);
                glVertex2f(371 + .5 * xx,370);
                glVertex2f(371 + xx,400);
                xx = 40;
                glEnd();
            }

            glBegin(GL_LINES);

            glVertex2f(twox[3],twoy[1]);
            glVertex2f(two_x[3],two_y[3]);

            glEnd();

            glBegin(GL_LINES);

            glVertex2f(twox[3],twoy[1]);
            glVertex2f(two_x[3],0);

            glEnd();

            glBegin(GL_QUADS);

            glVertex2f(twox[4],twoy[2]);
            glVertex2f(two_x[5],two_y[4]);
            glVertex2f(twox[5],twoy[1]);
            glVertex2f(two_x[4], two_y[1]);

            glEnd();

            xx = 20;
            for (int d=0;d<=2;d++)
            {

                glBegin(GL_TRIANGLES);

                glVertex2f(561 + xx - 20,400);
                glVertex2f(561 + .5 * xx,370);
                glVertex2f(561 + xx,400);
                xx = 40;
                glEnd();
            }

             if ((xpers >= 530) && (ypers == 0))
            {
                lvl2 = false;
                xpers = 0;
                ypers = 320;
                hpers = 26;
            }
            T = 0;
            while (checkCollision(xpers,ypers,wpers,hpers,twox[T],twoy[T],two_x[T],two_y[T]) == true)
            {

                if ((ypers + hpers > twoy[T]) || (ypers < two_y[T]))
                {
                    ypers = -ypers;
                    if (up == true)
                    {
                        int x = 1;
                        while (x == 1)
                        {
                            ypers -= 150;
                        }
                    }
                }
                if ((xpers + wpers > twox[T]) || (xpers < two_x[T]))
                {
                    xpers = -xpers;

                }
                T++;
            }
         }
    while (lvl3)
    {
            for (int d = 1; d <= 30; d++)
            {
                glBegin(GL_TRIANGLES);
                float incrimentTwenty = 0;
                glVertex2f (incrimentTwenty, 400);

                incrimentTwenty += 20;

                glVertex2f (incrimentTwenty + 10,370);
                glVertex2f (incrimentTwenty + 20,400);

                glEnd();
            }
            struct blocks
            {
                float x1;
                float y1;
                float x2;
                float y2;
            };

            blocks one;
            one.x1 = 0;
            one.y1 = 80;
            one.x2 = 100;
            one.y2 = 30;

            glBegin(GL_QUADS);

            glVertex2f (one.x1, one.y1);
            glVertex2f (one.x1 + one.x2, one.y1);
            glVertex2f (one.x1 + one.x2, one.y1 + one.y2);
            glVertex2f (one.x1, one.y1 + one.y2);

            glEnd();

            while (one.x1 >= 0)
            {one.x1 += 15;}

            while(one.x1 + one.x2 >= 600)
            {one.x1 -= 15;}

             blocks two;
            two.x1 = 0;
            two.y1 = 320;
            two.x2 = 100;
            two.y2 = 30;

            glBegin(GL_QUADS);

            glVertex2f (two.x1, two.y1);
            glVertex2f (two.x1 + two.x2, two.y1);
            glVertex2f (two.x1 + two.x2, two.y1 + two.y2);
            glVertex2f (two.x1, two.y1 + two.y2);

            glEnd();
            while(checkCollision(xpers,ypers,wpers,hpers,two.x1,two.x2,two.y1,two.y2))
            {
                if ((ypers + hpers > two.y1) || (ypers < two.y1 + two.y2))
                {
                    ypers = -ypers;
                    if (up == true)
                    {
                        int x = 1;
                        while (x == 1)
                        {
                            ypers -= 150;
                        }
                    }
                }
                if ((xpers + wpers > two.x1) || (xpers < two.x2 + two.x1))
                {
                    xpers = -xpers;
                }
            }

            while(checkCollision(xpers,ypers,wpers,hpers,one.x1,one.x2,one.y1,one.y2))
            {
                    if ((ypers + hpers > one.y1) || (ypers < one.y1 + one.y2))
                    {
                        ypers = -ypers;
                        if (up == true)
                        {
                            int x = 1;
                            while (x == 1)
                            {
                                ypers -= 150;
                            }
                        }
                    }
                    if ((xpers + wpers > one.x1) || (xpers < one.x2 + one.x1))
                    {
                        xpers = -xpers;
                    }
            }


            while (two.x1 >= 0)
            {two.x1 += 20;}

            while(two.x1 + two.x2 > 600)
            {two.x1 -= 20;}

            //add springs when collision is added

             if ((xpers >= 530) && (ypers == 0))
            {
                lvl3 = false;
                xpers = 575;
                ypers = 50;
                hpers = 26;
            }
        }

        while (lvl4)
        {
            int x1 = 550;
            int y1 = 0;
            int y2 = 50;
            int x2 = 0;


            while (y2 == 50)
            {
                int counter = 1;
                counter++;

                if (counter % 10 != 0)
                {
                    glBegin(GL_LINES);

                    glVertex2f(x1,y2);
                    glVertex2f(x1,y1);

                    glEnd();
                }
                else
                {
                    glBegin(GL_LINES);

                    glVertex2f(0,0);
                    glVertex2f(0,0);

                    glEnd();
                }
                if ((ypers + hpers > y1) || (ypers < y1 + y2))
                {
                    ypers = -ypers;
                    if (up == true)
                    {
                        int x = 1;
                        while (x == 1)
                        {
                            ypers -= 150;
                        }
                    }
                }
                if ((xpers + wpers > x1) || (xpers < x2 + x1))
                {
                    xpers = -xpers;
                }

            }
            float x[7] = {600,550,200,525,510,525,517};
            float y[3] = {50,133,325};
            float xx[4] = {0,200,0,510};
            float yy[3] = {50,133,325};

            glBegin(GL_LINES);

            glVertex2f(x[0],y[0]);//x1,y1
            glVertex2f(xx[0],yy[0]);//xx1,yy1

            glEnd();

            glBegin(GL_LINES);

            glColor4ub (r = 205, g = 133,b = 63 ,255);

            glVertex2f(x[1],y[0]);//x2,y1
            glVertex2f(xx[1],yy[1]);

            glEnd();

            glBegin(GL_LINES);

            glVertex2f(xx[1],y[1]);
            glVertex2f(xx[2],yy[1]);

            glEnd();

            glBegin(GL_TRIANGLES);

            glVertex2f(x[3],y[2]);
            glVertex2f(xx[3],yy[2]);
            glVertex2f(x[4],y[2]);

            glEnd();

            glBegin(GL_TRIANGLES);// button to connect

            glVertex2f(x[5],y[2]);
            glVertex2f(xx[3],yy[2]);
            glVertex2f(x[6],y[2]);

            glEnd();

            if ((xpers == x[6]) && (ypers == y[2]))
            {
                xpers += 30;
                ypers -= 40;
            }
            T = 0;so 
        while (checkCollision(xpers,ypers,wpers,hpers,x[T],y[T],xx[T],yy[T]))
        {
            if ((ypers + hpers > y[T]) && (ypers < yy[T]))//come back to this to fix object var to progress through
                {
                    ypers = -ypers;
                    if (up == true)
                    {
                        //int xas = 1;
                        for (int xas = 1; xas < 2; xas++)
                        {
                            ypers -= 150;
                        }
                        //xas++;
                    }
                }
                if ((xpers + wpers > x[T]) && (xpers < xx[T]))
                {
                    xpers = -xpers;
                }
            T++;
        }
            if (ypers >= 140 && ypers <= 250)
            {
                if (xpers == 0)
                {
                    lvl4 = false;
                    xpers = 150;
                    ypers = 350;
                }
            }
    }
        while (lvl5)
        {
            int xs[13] = {0,249,249,299,300,350,400,380,420,600,560,500,520};
            int ys[12] = {0,400,270,320,350,270,220,170,250,70,0};
            int hs[12] = {50,249,299,350,300,400,380,420,560,600,520,500};
            int ws[10] = {340,270,320,350,270,220,170,250,70,0};

            int x = 100;
            float y = (1/250) * (x - 150) + 380;
            float height = 0;
            float width = 0;


                    glBegin(GL_LINE_STRIP);//since the arc is not a closed curve, this is a strip now

                    glColor4ub(r = 205,g = 133,b = 63,255);

                    // int y = (1/250) * (x - 150) + 380;

            for(int ii = 100; ii < 200; ii++)
            {
                    glVertex2f(x,y);
                    x++;
                    glVertex2f(x,y);

            }
                glEnd();

            while (checkCollision(xpers,ypers,wpers,hpers,x,y,height,width))
            {
                if (ypers + hpers <= y)
                {
                    ypers -= ypers;

                    if (up == true)
                    {
                        int xas = 1;
                        while (x == 1)
                        {
                            ypers -= 150;
                        }
                        xas++;
                }
                else if (xpers + wpers <= x)
                {
                    xpers -= xpers;
                }
            }

            glBegin(GL_LINES);

            glVertex2f(xs[0],ys[0]);
            glVertex2f(hs[0],ws[0]);

            glEnd();

            glBegin(GL_LINES);

            glVertex2f(xs[1],ys[1]);
            glVertex2f(hs[0],ws[0]);

            glEnd();

            int flo = 3;

         for (int n = 0;n < 117;n++)
         {

             glBegin(GL_TRIANGLES);

             glVertex2f(246 + flo,0);
             glVertex2f(249 + flo,20);
             glVertex2f(249 + flo,0);

             glEnd();

             flo += 3;
         }
            glBegin(GL_QUADS);

            glColor4ub(0,255,0,255);

            glVertex2f(xs[2],ys[2]);
            glVertex2f(hs[1],ws[1]);
            glVertex2f(xs[3],ys[3]);
            glVertex2f(hs[1],ws[2]);

            glEnd();

            glBegin(GL_QUADS);

            glColor4ub(0,255,0,255);

            glVertex2f(xs[4],ys[3]);
            glVertex2f(hs[3],ws[2]);
            glVertex2f(xs[5],ys[4]);
            glVertex2f(hs[4],ws[3]);

            glEnd();


            glBegin(GL_QUADS);

            glColor4ub(0,255,0,255);

            glVertex2f(xs[5],ys[3]);
            glVertex2f(hs[5],ws[2]);
            glVertex2f(xs[6],ys[4]);
            glVertex2f(hs[3],ws[3]);

            glEnd();


            glBegin(GL_QUADS);

            glColor4ub(0,255,0,255);

            glVertex2f(xs[7],ys[5]);
            glVertex2f(hs[7],ws[4]);
            glVertex2f(xs[8],ys[6]);
            glVertex2f(hs[6],ws[5]);

            glEnd();


            glBegin(GL_QUADS);

            glColor4ub(0,255,0,255);

            glVertex2f(xs[9],ys[7]);// gg = 600, xi = 170
            glVertex2f(hs[8],ws[6]);// uu = 560, rp = 170
            glVertex2f(xs[10],ys[8]);// yl = 560, mn = 250
            glVertex2f(hs[9],ws[7]);// ad = 600, eke = 250

            glEnd();


            glBegin(GL_QUADS);

            glColor4ub(0,255,0,255);

            glVertex2f(xs[11],ys[9]);// jdf = 500, gk = 70
            glVertex2f(hs[10],ws[8]);// yiu = 520, fj = 70
            glVertex2f(xs[12],ys[10]);// to = 520, ks = 0
            glVertex2f(hs[11],ws[9]);// wnf = 500, sls = 0

            glEnd();

             if ((xpers >= 530) && (ypers == 0))
            {
                lvl5 = false;
            }
            T = 0;
        while (checkCollision(xpers,ypers,wpers,hpers,xs[T],ys[T],hs[T],ws[T]) == true)
        {
            if ((ypers + hpers > ys[T]) || (ypers < ws[T]))
                {
                    ypers = -ypers;
                    if (up == true)
                    {
                        int x = 1;
                        while (x == 1)
                        {
                            ypers -= 150;
                        }
                    }
                }
                if ((xpers + wpers > xs[T]) && (xpers < hs[T]))
                {
                    xpers = -xpers;
                }
                T++;
        }
    }

        glPopMatrix();

        SDL_GL_SwapBuffers();
        SDL_Delay(1);


    }
    }
    std::cin.get();

    SDL_Quit();

    return 0;
}




Is This A Good Question/Topic? 0
  • +

Replies To: program flashes then only debug window shows when runnning

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5529
  • View blog
  • Posts: 11,843
  • Joined: 02-June 10

Re: program flashes then only debug window shows when runnning

Posted 02 February 2013 - 03:50 PM

Dude... There's over a 1,000 lines of code here.
Did you do any debugging at all? Or is this just a full program dump and basically saying "Here, do my debugging for me" ?

This massive block of
if (moves == 4)
0246            {
0247                hpers = 2;
0248            }



All of those follow the same pattern so why not replace all that crap with one line:

hypers = moves / 2;


The repetitive stuff of
if (lvl3 == false)
0294        {
0295            lvl4 = true;
0296        }



Could become a lot simpler and easier to read as
lvl4 = !lvl3;


You have this ever ending loop at 325-344.
I'm going to bet it never gets out of this and since this is all single threaded - well, you're stuck in a loop.


With all these while loops, I'd bet your just stuck in one of them.

Have you done a breakpoint and walked through the execution during runtime?
Was This Post Helpful? 0
  • +
  • -

#3 kaljsdsadf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-February 13

Re: program flashes then only debug window shows when runnning

Posted 05 February 2013 - 07:32 PM

I have set the breakpoints and removed all non essential while loops. the only ones that still repeat are the level due to the fact that they are character dependant. it still does not show anything but a blank debug screen.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1