Grids+Movement

Me and a few other kids are in a coding class and have been given the project to create a game. We thought a simple tron game would be easy enough. Sadly we were far from wrong. We have many thoughts on how to make it work, but we lack the coding to do so. The two biggest things we need right now is a working grid that we can easily add different variables to and a way to move said variables across the grid and the screen.

This is what we have so far for creating the grid.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int grid(int x, int y,char array)
      {
          const WORD colors[] = {0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F,0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6};
          HANDLE hstdin  = GetStdHandle( STD_INPUT_HANDLE  );
	      HANDLE hstdout = GetStdHandle( STD_OUTPUT_HANDLE );
	      WORD   index   = 0;
	      SetConsoleTextAttribute( hstdout, 0x7f );
           for(x = 0 ; x<=80; x++)
             {
              array[x][y] ='x';
              array[x][y]=printf(" ");
              for(y = 0 ; y<=26; y++)
                     {
                      array[x][y] ='y';
                      array[x][y]=printf(" ");
                     }
             } 
          
      }

And here's the movement system
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
char dir;
       std::cin>>dir;
       switch(dir)
       {
       case 'w':
            x=x-80;
            array[x][y] =printf("A");
            array[x-1][y] =printf("#");
            refresh(x,y,array);
            break;
       case 'a':
            x=x-1;
            array[x][y] =printf("<");
            array[x-1][y] =printf("#");
            break;
       case 's':
            x=x+80;
            array[x][y] =printf("V");
            array[x-1][y] =printf("#");
            break;
       case 'd':
            x=x+1;
            array[x][y] = printf(">");
            array[x-1][y] = printf("#");
            break;
       }

Neither of which are working of course. We have looked everywhere for answers, but found nothing so I come here to ask for help. None of us have any clue what the heck we are doing.

Oh and incase you are interested heres the whole 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <iostream>
int gridz(int x, int y,char array[]);
int refresh(int x, int y,char array[]);
int main(void)
    {
    int dummy,x=0,y=0;
    char array[80][26];
    // for(x = 0 ; x<25; x++)
   //  {
    gridz(x,y,array);

//}
    const WORD colors[] = {0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F,0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6};
    HANDLE hstdin  = GetStdHandle( STD_INPUT_HANDLE  );
	HANDLE hstdout = GetStdHandle( STD_OUTPUT_HANDLE );
	WORD   index   = 0;
	
    SetConsoleTextAttribute( hstdout, 0x7f );
   	x=2;
   	y=20;       	
    char up='w';
                 
        char dir;
       std::cin>>dir;
       switch(dir)
       {
       case 'w':
            x=x-80;
            array[x][y] =printf("A");
            array[x-1][y] =printf("#");
            refresh(x,y,array);
            break;
       case 'a':
            x=x-1;
            array[x][y] =printf("<");
            array[x-1][y] =printf("#");
            break;
       case 's':
            x=x+80;
            array[x][y] =printf("V");
            array[x-1][y] =printf("#");
            break;
       case 'd':
            x=x+1;
            array[x][y] = printf(">");
            array[x-1][y] = printf("#");
            break;
       }
refresh(x,y,array);
            scanf("%d",&dummy);
             return 0;
}           
      int gridz(int x, int y,char array)
      {
          const WORD colors[] = {0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F,0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6};
          HANDLE hstdin  = GetStdHandle( STD_INPUT_HANDLE  );
	      HANDLE hstdout = GetStdHandle( STD_OUTPUT_HANDLE );
	      WORD   index   = 0;
	      SetConsoleTextAttribute( hstdout, 0x7f );
           for(x = 0 ; x<=80; x++)
             {
              array[x][y] ='x';
              array[x][y]=printf(" ");
              for(y = 0 ; y<=26; y++)
                     {
                      array[x][y] ='y';
                      array[x][y]=printf(" ");
                     }
             } 
          
      }
      
      int refresh(int x, int y,char array1[],char array2[])
      {
          const WORD colors[] = {0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F,0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6};
          HANDLE hstdin  = GetStdHandle( STD_INPUT_HANDLE  );
	      HANDLE hstdout = GetStdHandle( STD_OUTPUT_HANDLE );
	      WORD   index   = 0;
	      SetConsoleTextAttribute( hstdout, 0x7f );
           for(x = 0 ; x<80; x++)
             {
              array[x][y] ='x';
              array[x][y]=printf(" ");
              for(y = 0 ; y<26; y++)
                     {
                      array[x][y] ='y';
                      array[x][y]=printf(" ");
                     }
             } 
          
      }
Topic archived. No new replies allowed.