Cant read my .h file?

Pages: 12
So i cant do this:

print << "Hello":

??

i did

print << "Hello" semicolon and that worked.
In C/C++/Java, to terminate a line of statement is a semi-colon instead of colon. I guess that is the language syntax.
Nevermind i got it :D
Actually using a macro to substitute ; with semicolon is redundant and more typing needed! Why do you want to do so much typing in your program source code?
Im just experimenting with different things, basically just messing around, i dont plan to use this as a practical approach to writing code :)
Great but just a point to know in modern C++, C way of macro substitution is not really recommended due to nasty side-effects that has tripped up even very seasoned programmers. But I believe for simple macro substitution like #define semicolon ; is still acceptable.
What are the nasty side effects?
Google "C macro nasty side effects" and you will see a few articles on that.
Ok so now that i got that covered, i have a text game im working on, the problem is when i go down the character doesnt go straignt down, it goes to the first line and goes down. I think i need to set up an array but im not sure how. i asked on a different forum but they kept giving me all these seriously complex answers that made no sense. So can someone help me with my code and keep it relativley as simple as possible.

Ok so here is the code:

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <windows.h>
#include <fstream>
#include <string>

using namespace std;

void chctrdwn();
void chctrrght();
void clear();

//Global
string character = "O";
//End of Global

int main()
{
    //int up; //W is up
    int down; //S is down.
    //int left; //A is left
    int right; //D is right

    cout << character;

    while(true){
        down=GetAsyncKeyState(0x53);
        if(down){
        //clear();
        chctrdwn();
        }

        right=GetAsyncKeyState(0x44);
        if(right){
        //clear();
        chctrrght();
        }
    }

    return 0;
}

void chctrdwn()
{
    Sleep(150);
    cout << "\n";
    cout << character;
}

void chctrrght()
{
    Sleep(150);
    cout << "" << character;
}

void clear()
{
    system("cls");
}


This is what the charachter is doing:

0000000000000000
0000
0
0
0
0
0
0000000000
0
00000

This is what it should be doing:

1
2
3
4
5
6
7
8
9
10
000000000
        0
        0
        000000000
                0
                0
                0
                00000000

You need to remember the x coordinate of your character and before printing a 0 when you go down, print that many spaces. Though, http://cplusplus.com/articles/G13hAqkS/
Ok where can i find a simple Library to make games?
Topic archived. No new replies allowed.
Pages: 12