c++ word game

Pages: 1234
Jul 26, 2009 at 12:13pm
Heres how it works, every poster adds one line of code OR deletes one line of code. It has to make sense, but it does not have to compile until the thread is done (whenever we get bored). Using Dev-c++ for this. I'll start us off with a bit. You can also add onto an existing line. Please state what you are changing when you post :)

1
2
3
4
5
6
7
8
9
10
11
12
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
 int i;

    system("PAUSE");
    return EXIT_SUCCESS;
}


Remember, add/edit to or remove only one line, the idea is to see if we can work together on this :)
Last edited on Jul 26, 2009 at 12:35pm
Jul 26, 2009 at 12:30pm
I'd start removing line 10: http://www.cplusplus.com/forum/articles/11153/ http://www.cplusplus.com/forum/articles/7312/
1
2
3
4
5
6
7
8
9
10
11
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int i;

    return EXIT_SUCCESS;
}
Jul 26, 2009 at 12:34pm
Thats fine, I just pasted from my compiler for a template. anyways, adding time:
1
2
3
4
5
6
7
8
9
10
11
12
#include <cstdlib>
#include <iostream>
#include <time.h>

using namespace std;

int main(int argc, char *argv[])
{
    int i;

    return EXIT_SUCCESS;
}
Jul 26, 2009 at 6:46pm
Inserting an srand(), so that we can have some fun with the time header.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <cstdlib>
#include <iostream>
#include <time.h>

using namespace std;

int main(int argc, char *argv[])
{
    srand( time(0) );
    int i;

    return EXIT_SUCCESS;
}
Jul 26, 2009 at 6:49pm
popping Math in there, just in case.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <cstdlib>
#include <iostream>
#include <time.h>
#include <math.h>
using namespace std;

int main(int argc, char *argv[])
{
    srand( time(0) );
    int i;

    return EXIT_SUCCESS;
}
Jul 26, 2009 at 7:57pm
Lets use the standard headers, and have some fun :D
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>
using namespace std;

int main(int argc, char *argv[])
{
    srand( time(0) );
    int i;
    
    do {
    
    return EXIT_SUCCESS;
}
Jul 26, 2009 at 7:59pm
Ill let you have some fun with the do loop. I'll make use of rand().

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>
using namespace std;

int main(int argc, char *argv[])
{
    srand( time(0) );
    int i;
    int rNum = rand() % 10 + 1;

    do {
    
    return EXIT_SUCCESS;
}
Jul 26, 2009 at 8:07pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>
using namespace std;

int main(int argc, char *argv[])
{
    srand( time(0) );
    int i;
    int rNum = rand() % 10 + 1;
    // Do-while loop to    
    do {
    
    return EXIT_SUCCESS;
}
Jul 26, 2009 at 8:11pm
I'm curious about your loop, so i'll leave it. I like games though so:

edit: R0mai you twerp! you changed two at once, didn't catch that... oh well, to late now lol

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>
using namespace std;

class Player {

int main(int argc, char *argv[])
{
    srand( time(0) );
    int i;
    int rNum = rand() % 10 + 1;
    // Do-while loop to    
    do {
    
    return EXIT_SUCCESS;
}
Last edited on Jul 26, 2009 at 8:16pm
Jul 26, 2009 at 8:21pm
sry about that
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>
using namespace std;

class Player {
public:

int main(int argc, char *argv[])
{
    srand( time(0) );
    int i;
    int rNum = rand() % 10 + 1;
    // Do-while loop to    
    do {
    
    return EXIT_SUCCESS;
}
Jul 26, 2009 at 8:22pm
haha, no problem. Not a big cheat :P

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>
using namespace std;

class Player {
public:

private:

int main(int argc, char *argv[])
{
    srand( time(0) );
    int i;
    int rNum = rand() % 10 + 1;
    // Do-while loop to    
    do {
    
    return EXIT_SUCCESS;
}
Jul 26, 2009 at 8:33pm
I wonder what kind of freaky game gonna come out of this :D
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>
using namespace std;

class Player {
public:

private:
    unsigned health_;

int main(int argc, char *argv[])
{
    srand( time(0) );
    int i;
    int rNum = rand() % 10 + 1;
    // Do-while loop to    
    do {
    
    return EXIT_SUCCESS;
}
Jul 26, 2009 at 8:37pm
It seems this is growing fast
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>
using namespace std;

class Player {
    public:
        explicit Player ( unsigned initial_health = 100 ) : health_ ( initial_health )  { }
    private:
        unsigned health_;

int main(int argc, char *argv[])
{
    srand( time(0) );
    int i;
    int rNum = rand() % 10 + 1;
    // Do-while loop to    
    do {
    
    return EXIT_SUCCESS;
}
Last edited on Jul 26, 2009 at 8:38pm
Jul 26, 2009 at 8:40pm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>
using namespace std;

class Player {
    public:
        explicit Player ( unsigned initial_health = 100 ) : health_ ( initial_health )  { }
    private:
        unsigned health_;
};

int main(int argc, char *argv[])
{
    srand( time(0) );
    int i;
    int rNum = rand() % 10 + 1;
    // Do-while loop to    
    do {
    
    return EXIT_SUCCESS;
}

EDIT : oops code tags
Last edited on Jul 26, 2009 at 8:41pm
Jul 26, 2009 at 10:44pm
I'm gonna remove "using std namespace" for good practice lol :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>

class Player {
    public:
        explicit Player ( unsigned initial_health = 100 ) : health_ ( initial_health )  { }
    private:
        unsigned health_;

int main(int argc, char *argv[])
{
    srand( time(0) );
    int i;
    int rNum = rand() % 10 + 1;
    // Do-while loop to    
    do {
    
    return EXIT_SUCCESS;
}
Jul 27, 2009 at 1:01am
I think we need to have a player
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>

class Player {
    public:
        explicit Player ( unsigned initial_health = 100 ) : health_ ( initial_health )  { }
    private:
        unsigned health_;

int main(int argc, char *argv[])
{
    Player Havoc(75);
    srand( time(0) );
    int i;
    int rNum = rand() % 10 + 1;
    // Do-while loop to    
    do {
    
    return EXIT_SUCCESS;
}


Points to whomever can tell me where i got that from.
Jul 27, 2009 at 2:55am
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>

class Player {
    public:
        explicit Player ( unsigned initial_health = 100 ) : health_ ( initial_health )  { }
    private:
        unsigned health_;
        bool isDead;

int main(int argc, char *argv[])
{
    Player Havoc(75);
    srand( time(0) );
    int i;
    int rNum = rand() % 10 + 1;
    // Do-while loop to    
    do {
    
    return EXIT_SUCCESS;
}


Are any graphics APIs allowed lol? :)
Jul 27, 2009 at 2:59am
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>

class Player {
    public:
        explicit Player ( unsigned initial_health = 100 ) : health_ ( initial_health )  { }
    private:
        unsigned health_;
        bool isDead;
};

int main(int argc, char *argv[])
{
    Player Havoc(75);
    srand( time(0) );
    int i;
    int rNum = rand() % 10 + 1;
    // Do-while loop to    
    do {
    
    return EXIT_SUCCESS;
}


I think it is time we added the "};" at the end of the class.

Sure, you can add graphics, but try to make it semi-understandable.
Jul 27, 2009 at 6:35am
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>

class Player {
    public:
        explicit Player ( unsigned initial_health = 100 ) : health_ ( initial_health ), isDead ( false )  { }
    private:
        unsigned health_;
        bool isDead;
};

int main(int argc, char *argv[])
{
    Player Havoc(75);
    srand( time(0) );
    int i;
    int rNum = rand() % 10 + 1;
    // Do-while loop to    
    do {
    
    return EXIT_SUCCESS;
}


Go go update constructor!
Jul 27, 2009 at 10:05am
I have already added the }; once in my previous post, then it disappeared :(

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <cmath>

class Player {
    public:
        explicit Player ( unsigned initial_health = 100 ) : health_ ( initial_health ), isDead ( false )  { }
        
        void heal( unsigned cure ) {
        
        
    private:
        unsigned health_;
        bool isDead;
};

int main(int argc, char *argv[])
{
    Player Havoc(75);
    srand( time(0) );
    int i;
    int rNum = rand() % 10 + 1;
    // Do-while loop to    
    do {
    
    return EXIT_SUCCESS;
}
Pages: 1234