Compiler ERROR [Process terminated with status 0 (0 minutes, 0 seconds)]

Started by
5 comments, last by Endurion 11 years, 12 months ago
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.



#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 }


I compile the program and get no output the command line log 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.
Advertisement
This isn't a compiler error; it sounds like a bug in your program. Have you tried running it under a debugger?

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Try searching through your program and finding all possible points where main() terminates. Then try to figure out what is causing your program to say bai and then fix it.
what
This is kind of wierd, I also use Code::blocks and I need to define the main function with arguments like

int main(int argc, char* argv[])

for it to even compile.. othervise it starts nagging about undefined reference to SDL_main..
I also can't see any point of return from your main function.

I don't know if that is what is wrong but try changing the signature of main to the one above and add return 0; at the bottom of your main function and maybe it'll work.
I didnt really go through the rest of the code becaus I dont think it is related to any SDL-related syntax.
You didn't even initialize SDL. Look up [font=courier new,courier,monospace]SDL_Init[/font], the window won't work if you don't initialize the video subsystem =P

This is kind of wierd, I also use Code::blocks and I need to define the main function with arguments like

int main(int argc, char* argv[])

for it to even compile.. othervise it starts nagging about undefined reference to SDL_main..

That's only needed if you link with the SDL_main library. This is needed for platforms that don't have [font=courier new,courier,monospace]main[/font] as the entry point (i.e. Windows and smartphones). I personally stopped bothering with stuff like that when I found out MinGW can handle [font=courier new,courier,monospace]main[/font] as the entry point even for GUI programs (without forcing a console to pop up), but it's still needed with Visual Studio.
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

I personally stopped bothering with stuff like that when I found out MinGW can handle main as the entry point even for GUI programs (without forcing a console to pop up), but it's still needed with Visual Studio.

[strike]/SUBSYSTEM:Console[/strike].

Wait, nevermind.
You can also change the entry point function with Visual Studio, it's usually in the project properties.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement