Help can anyone help me this is a space invader game

please help me show the enemy

in my codes

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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#include<stdio.h>
#include<windows.h>

void gotoxy(int x, int y);
void enemy();
void gameover();
void line_display();
void instructions();
void play();
void status();
void ship();
void registration();
void menu();
void bullet();
int main()

 {
    system("color 05");
    int flag=0;
    int y=0;
    char cUname[21]; 
    char ch[1], upass[]="               "; 
    char cAns[1];
              
     do{
     system("cls");
     printf("\n\n\n\n\n\t\t\tEnter user Name: ");
     scanf("%s", cUname);
     printf("\n\t\t\tEnter Password: ");
     scanf("%s", upass);

     if(strcmp(cUname, "aileen")==0 && strcmp(upass, "benz")==0)
              { printf("\n\n\t\t\t    Access Granted\n");
                system("pause>0");
                system("cls");
                menu();

                flag=0;
                }
                else
                {  printf("\n\nACCESS DENIED\n\n");
                   flag=1;
                   
                   system("pause>0");
                }
                
     }while(flag==1); 

          

 }

 

void menu()
{
     char menuopt;

    do
    {
    system("cls");

    printf( "\n\n\n\n\n\t\t\t\t:[B]EGIN: \n"); 
    printf( "\t\t\t\t:[I]NSTRUCTIONS: \n");
    printf( "\t\t\t\t:[E]xit: \n" );

    menuopt =getch();
    switch(menuopt)
    {
                   case 'b':
                        {
                            system("cls");
                            play();
                        }
                   break;
                   case 'i':
                        {
                            system("cls");
                            instructions();
                        }
                   break;

                   case 'e':
                   break;
    } 
    }
    while(menuopt != 'e');  

}
void gotoxy(int x, int y)
 {
     HANDLE Aileen;
     COORD Benz;
     Benz.X = x;
     Benz.Y = y;
     Aileen = GetStdHandle(STD_OUTPUT_HANDLE);
     SetConsoleCursorPosition(Aileen, Benz);
 }

void line_display()
 {
     printf("-=-=-=-=-=-=-=-=");
 }     
  
void gameover()

 {
    gotoxy(39,10);
    system("color 4");
    printf("GAME OVER");

 }

void status()

 {
     system("color 4");
     gotoxy(60,5);
     line_display();
     gotoxy(60,4);
     printf("SCORE: \n");
     gotoxy(60,3);
     printf("LIVES: \n");
     gotoxy(60,2);
     printf("LEVEL: \n");
     gotoxy(60,1);
     line_display();
 }

void ship()

 {
     int y=23,x=30;
     char mov[1];
do{
mov[0]=getch();

    switch(mov[0])
    {
               case 'a':gotoxy(x,y);printf(" ");--x;gotoxy(x,y);printf("X");break;
               case 's':bullet(x);break;
               case 'd':gotoxy(x,y);printf(" ");x++;gotoxy(x,y);printf("X");break;
               case 'p':menu();break;
    }}while(1);
}

void bullet(int x) 
 {
     int y=22;
     char cBullet='^';
     char cBlank=' ';
     
     while(y>=0)
{
     gotoxy(x, y);
     printf("%c", cBullet);
     Sleep(50);
     gotoxy(x, y);
     printf("%c", cBlank);
     y--;
}
}

void enemy()
 {
     int pEnemy ='0';
     int y=2,x=16;
     char cEnemy='0';

     while(x<=30)
{
     gotoxy(x, y);
     printf("%c", cEnemy);
     Sleep(100);

     x--;
}
}
void instructions()                            //output instructions
{
     system("cls");
     printf("\n\n\n\n\n\t\t\t\t:INSTRUCTIONS: \n");
     printf("\t\tpress 'a' to move left");
     printf("\t\tpess 'd' to move right\n");
     printf("\t\tpress 's' to shoot");
     printf("\t\tpress 'p' to stop");    

     getch();
}
void play()
 {

    status();

    ship();
    system("pause>0");
    gameover();
 }


and this is the only libraries i should use....
Last edited on
Try putting the #include <windows.h> before the #include <stdio.h> .
nothing is really different my problem is the codes for my enemy i want it
to look like this:

0 0 0 0
0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0

which will appear going down and randomly....
Topic archived. No new replies allowed.