1 Replies - 473 Views - Last Post: 26 April 2012 - 12:41 PM Rate Topic: -----

#1 sywashere  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-April 12

C++ ERROR Process terminated with status 0 (0 minutes, 0 seconds)

Posted 26 April 2012 - 07:50 AM

Hi,

I am using Codeblocks 10.05 and i have recently been making a pong clone game using sdl, this is my first major project in C++ and using SDL. I have finished my writing code and have successfully compiled it with no errors, while writing my code i ran the compile and ran the program at different stages with no problems but now that i have finished coding i can compile the code but when it runs there is no output on the screen.

the code below is my main.cpp file.

 

#include <SDL/SDL.h>
002 #include <SDL/SDL_ttf.h>
003 #include <iostream>
004 #include "ball.h"
005 #include "Paddle.h"
006 //#include "110ct.h"
007 
008 SDL_Surface* load_image(const char* c, Uint32 colorkey=0)
009 {
010    SDL_Surface* tmp=SDL_LoadBMP(c);
011    if(colorkey!=0)
012    {
013       SDL_SetColorKey(tmp, SDL_SRCCOLORKEY, colorkey);
014    }
015    return tmp;
016 }
017 
018 int main()
019 {
020      SDL_Surface*screen;
021      SDL_WM_SetCaption("110CT PONG", NULL);
022      TTF_Font* font;
023      TTF_Init();
024      font=TTF_OpenFont("handsean.ttf",20);
025      SDL_Color color = {0,0,0};
026      const int FPS = 30 ;
027      const int width = 640;
028      const int height = 480;
029      screen=SDL_SetVideoMode(width,height,32,SDL_SWSURFACE);
030      SDL_Event event;
031      Uint32 start;
032      bool running=true;
033      bool arr[4] = {0,0,0,0};
034      paddle player1(load_image("paddle.bmp"), 0,220,10,60,3);
035      paddle player2(load_image("paddle.bmp"), width-20,220,10,60,3);
036      ball ball1(load_image("ball.bmp", SDL_MapRGB(screen->format, 0x44,0xf1,0x40)),320,240,20,20,3,3);
037 
038      while (running)
039      {
040              start=SDL_GetTicks();
041                //handle events
042                while (SDL_PollEvent(&event))
043                {
044                              switch(event.type)
045                              {
046                                case SDL_QUIT:
047                                         running=false;
048                                         break;
049                                case SDL_KEYDOWN:
050                                         switch(event.key.keysym.sym)
051                                         {
052                                               case SDLK_UP:
053                                                        arr[0]=1;
054                                                        break;
055                                               case SDLK_DOWN:
056                                                        arr[1]=1;
057                                                        break;
058                                               case SDLK_a:
059                                                        arr[2]=1;
060                                                        break;
061                                               case SDLK_z:
062                                                        arr[3]=1;
063                                                        break;
064                                               }
065                                               break;
066                                case SDL_KEYUP:
067                                         switch(event.key.keysym.sym)
068                                         {
069                                               case SDLK_UP:
070                                                        arr[0]=0;
071                                                        break;
072                                               case SDLK_DOWN:
073                                                        arr[1]=0;
074                                                        break;
075                                               case SDLK_a:
076                                                        arr[2]=0;
077                                                        break;
078                                               case SDLK_z:
079                                                        arr[3]=0;
080                                                        break;
081                                         }
082                              }
083                }
084      //algorithms
085      if (arr[0])
086              player2.moveUp();
087      else if(arr[1])
088              player2.moveDown();
089      if (arr[2])
090              player1.moveUp();
091      else if (arr[3])
092              player1.moveDown();
093 
094      ball1.move(player1.getRect(),player2.getRect());
095 
096      switch(ball1.isOut())
097      {
098              case 1:
099              player2.incscore();
100              player1.reset(0,220,10,60,3);
101              player2.reset(width-20,220,10,60,3);
102              ball1.reset(320,240,20,20,3,3);
103              break;
104 
105              case 2:
106              player1.incscore();
107              player1.reset(0,220,10,60,3);
108              player2.reset(width-20,220,10,60,3);
109              ball1.reset(320,240,20,20,3,3);
110              break;
111      }
112 
113 
114 
115 
116      //render
117      SDL_FillRect(screen,&screen->clip_rect,SDL_MapRGB(screen->format,0xff,0xff,0xff));
118      player1.display();
119      player2.display();
120      ball1.display();
121 
122      char c[5];
123      SDL_Rect tmp = {10,0};
124      sprintf(c,"%d",player1.getScore());
125      SDL_Surface* text=TTF_RenderText_Solid(font,c,color);
126      SDL_BlitSurface(text,NULL,screen,&tmp);
127 
128 
129      tmp.x=width-40;
130      sprintf(c,"%d",player2.getScore());
131      text=TTF_RenderText_Solid(font,c,color);
132      SDL_BlitSurface(text,NULL,screen,&tmp);
133      SDL_FreeSurface(text);
134 
135      SDL_Flip(screen);
136 
137      //regulate FPS
138      if (1000/FPS>(SDL_GetTicks()-start))
139      SDL_Delay(1000/FPS-(SDL_GetTicks()-start));
140 
141    }
142 
143    TTF_CloseFont(font);
144    TTF_Quit();
145    SDL_Quit();
146 
147 }




after compiling the command line reads :

Checking for existence: C:\Users\Sylvester\Desktop\110CT PROJECT (PONG)\PONG.exe
Executing: "C:\Users\Sylvester\Desktop\110CT PROJECT (PONG)\PONG.exe" (in C:\Users\Sylvester\Desktop\110CT PROJECT (PONG)\.)
Process terminated with status 0 (0 minutes, 0 seconds)

has anyone got experience with this problem and can possibly help me

thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: C++ ERROR Process terminated with status 0 (0 minutes, 0 seconds)

#2 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 928
  • View blog
  • Posts: 3,997
  • Joined: 14-February 08

Re: C++ ERROR Process terminated with status 0 (0 minutes, 0 seconds)

Posted 26 April 2012 - 12:41 PM

When you say "no output" can you be a little more specific?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1