[try Beta version]
Not logged in

 
football game errors!

Jan 8, 2013 at 2:16pm
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
//v=0 is for up to down, v=1 for down to up
//k=0 for lft to rite , k=1 for right to lft
//no graphics sc1/2 are scores
#include<iostream.h>
#include<conio.h>
#include<dos.h>
void display(int y,int t,int r,int h,int g,int f,int i,int j,int sc1,int sc2)
{clrscr();
gotoxy(1,1);
cout<<"  ------------------------------";
gotoxy(1,11);
cout<<"  ------------------------------";
gotoxy(i,j); cout<<"*";
gotoxy(3,2);cout<<"|";
gotoxy(3,3);cout<<"|";
gotoxy(3,4);cout<<"|";
gotoxy(3,5);cout<<"|";
gotoxy(3,6);cout<<"|";
gotoxy(3,7);cout<<"|";
gotoxy(3,8);cout<<"|";
gotoxy(3,9);cout<<"|";
gotoxy(3,10);cout<<"|";
gotoxy(32,2);cout<<"|";
gotoxy(32,3);cout<<"|";
gotoxy(32,4);cout<<"|";
gotoxy(32,5);cout<<"|";
gotoxy(32,6);cout<<"|";
gotoxy(32,7);cout<<"|";
gotoxy(32,8);cout<<"|";
gotoxy(32,9);cout<<"|";
gotoxy(32,10);cout<<"|";
gotoxy(4,5);cout<<"|";
gotoxy(4,6);cout<<"|";
gotoxy(4,7);cout<<"|";
gotoxy(31,5);cout<<"|";
gotoxy(31,6);cout<<"|";
gotoxy(31,7);cout<<"|";
gotoxy(20,y)  ; cout<<"0";
gotoxy(20,y+1); cout<<"|";
gotoxy(20,y+2); cout<<"0";
gotoxy(20,y+3); cout<<"|";
gotoxy(20,y+4); cout<<"0";
gotoxy(20,y+5); cout<<"|";
gotoxy(20,y+6); cout<<"0";
gotoxy(10,t)  ; cout<<"0";
gotoxy(10,t+1); cout<<"|";
gotoxy(10,t+2); cout<<"0";
gotoxy(10,t+3); cout<<"|";
gotoxy(10,t+4); cout<<"0";
gotoxy(25,g)  ; cout<<"X";
gotoxy(25,g+1); cout<<"|";
gotoxy(25,g+2); cout<<"X";
gotoxy(25,g+3); cout<<"|";
gotoxy(25,g+4); cout<<"X";
gotoxy(15,h)  ; cout<<"X";
gotoxy(15,h+1); cout<<"|";
gotoxy(15,h+2); cout<<"X";
gotoxy(15,h+3); cout<<"|";
gotoxy(15,h+4); cout<<"X";
gotoxy(15,h+5); cout<<"|";
gotoxy(15,h+6); cout<<"X";
gotoxy(5,r)  ; cout<<"0";
gotoxy(30,f)  ; cout<<"X";
gotoxy(3,15);cout<<"Team A:"<<sc1<<"  Team B:"<<sc2;}
void main()
{clrscr();
int sc1=0,sc2=0,y=3,t=4,r=6,h=3,g=4,f=6,i=17,j=5,k=0,v=0; char a,s;
for (i=17,j=5;i<=30,i>=3,j>=3,j<=10;)
{delay(300);
display(y,t,r,h,g,f,i,j,sc1,sc2);
if(i==3){if(j==4||j==5||j==6){k=0;i=17;j=5;sc1++;
gotoxy(15,4);cout<<"        ";gotoxy(15,5);cout<<" GOAL!! ";gotoxy(15,6);cout<<"      ";getch();}}
if(i==31){if(j==4||j==5||j==6){k=1;i=17;j=5;sc2++;
gotoxy(15,4);cout<<"        ";gotoxy(15,5);cout<<" GOAL!! ";gotoxy(15,6);cout<<"      ";getch();}}
if(sc1==5){gotoxy(3,16);cout<<"GAME OVER!!  TEAM A WINS!!";getch();break;}
if(sc2==5){gotoxy(3,16);cout<<"GAME OVER!!  TEAM B WINS!!";getch();break;}
if(j==10)v=1;
if(j==2)v=0;
if(v==0) j++;
if(i==4)k=0;
if(i==31)k=1;
if(v==1) j--;
if(k==0) i++;
if(k==1) i--;
if(i==21&&v==0&&k==1)
{if(j==y-1||j==y+1||j==y+3||j==y+5){v=1;k=0;}}
if(i==11&&v==0&&k==1)
{if(j==t-1||j==t+1||j==t+3){v=1;k=0;}}
if(i==6&&v==0&&k==1)
{if(j==r-1){v=1;k=0;}}
if(i==16&&v==0&&k==1)
{if(j==h-1||j==h+1||j==h+3||j==h+5){v=1;k=0;}}
if(i==26&&v==0&&k==1)
{if(j==g-1||j==g+1||j==g+3){v=1;k=0;}}
if(i==31&&v==0&&k==1)
{if(j==f-1){v=1;k=0;}}

if(i==19&&v==0&&k==0)
{if(j==y-1||j==y+1||j==y+3||j==y+5){v=1;k=1;}}
if(i==9&&v==0&&k==0)
{if(j==t-1||j==t+1||j==t+3){v=1;k=1;}}
if(i==4&&v==0&&k==0)
{if(j==r-1){v=1;k=1;}}
if(i==14&&v==0&&k==0)
{if(j==h-1||j==h+1||j==h+3||j==h+5){v=1;k=1;}}
if(i==24&&v==0&&k==0)
{if(j==g-1||j==g+1||j==g+3){v=1;k=1;}}
if(i==29&&v==0&&k==0)
{if(j==f-1){v=1;k=1;}}

if(i==21&&v==1&&k==1)
{if(j==y+1||j==y+3||j==y+5||j==y+7){v=0;k=0;}}
if(i==11&&v==1&&k==1)
{if(j==t+1||j==t+3||j==t+5){v=0;k=0;}}
if(i==6&&v==1&&k==1)
{if(j==r+1){v=0;k=0;}}
if(i==16&&v==1&&k==1)
{if(j==h+1||j==h+3||j==h+5||j==h+7){v=0;k=0;}}
if(i==26&&v==1&&k==1)w
{if(j==g+1||j==g+3||j==g+5){v=0;k=0;}}
if(i==31&&v==1&&k==1)
{if(j==f+1){v=0;k=0;}}


if(i==19&&v==1&&k==0)
{if(j==y+1||j==y+3||j==y+5||j==y+7){v=0;k=1;}}
if(i==9&&v==1&&k==0)
{if(j==t+1||j==t+3||j==t+5){v=0;k=1;}}
if(i==4&&v==1&&k==0)
{if(j==r+1){v=0;k=1;}}
if(i==14&&v==1&&k==0)
{if(j==h+1||j==h+3||j==h+5||j==h+7){v=0;k=1;}}
if(i==24&&v==1&&k==0)
{if(j==g+1||j==g+3||j==g+5){v=0;k=1;}}
if(i==29&&v==1&&k==0)
{if(j==f+1){v=0;k=1;}}

if(i==20){if(j==y-1||j==y+1||j==y+3||j==y+5) v=1;}
if(i==10){if(j==t-1||j==t+1||j==t+3) v=1;}
if(i==5){if(j==r-1) v=1;}
if(i==20){if(j==y+1||j==y+3||j==y+5||j==y+7) v=0;}
if(i==10){if(j==t+1||j==t+3||j==t+5) v=0;}
if(i==5){if(j==r+1) v=0;}
if(i==15){if(j==h-1||j==h+1||j==h+3||j==h+5) v=1;}
if(i==25){if(j==g-1||j==g+1||j==g+3) v=1;}
if(i==30){if(j==f-1) v=1;}
if(i==15){if(j==h+1||j==h+3||j==h+5||j==h+7) v=0;}
if(i==25){if(j==g+1||j==g+3||j==g+5) v=0;}
if(i==30){if(j==f+1) v=0;}


if(i==21){if(j==y||j==y+2||j==y+4||j==y+6) k=0;}
if(i==11){if(j==t||j==t+2||j==t+4) k=0;}
if(i==6){if(j==r) k=0;}
if(i==19){if(j==y||j==y+2||j==y+4||j==y+6) k=1;}
if(i==9){if(j==t||j==t+2||j==t+4) k=1;}
if(i==14){if(j==h||j==h+2||j==h+4||j==h+6) k=1;}
if(i==24){if(j==g||j==g+2||j==g+4) k=1;}
if(i==29){if(j==f) k=1;}
if(i==16){if(j==h||j==h+2||j==h+4||j==h+6) k=0;}
if(i==26){if(j==g||j==g+2||j==g+4) k=0;}
if(kbhit())
{a=getch();
if(a=='2'&&y<4) {y++;v=1;}
else if(a=='8'&&y>2) {y--;v=0;}
if(a=='2'&&t<6) {t++;v=1;}
else if(a=='8'&&t>2) {t--;v=0;}
if(a=='2'&&r<10){r++;v=1;}
else if(a=='8'&&r>2) {r--;v=0;}
if(a=='s'&&h<4) {h++;v=1;}
else if(a=='w'&&h>2) {h--;v=0;}
if(a=='s'&&g<6) {g++;v=1;}
else if(a=='w'&&g>2) {g--;v=0;}
if(a=='s'&&f<10) {f++;v=1;}
else if(a=='w'&&f>2) {f--;v=0;}
}
}
getch();
}


my football game keeps blink every 7-8 seconds and passes above the player. im not able to understand what the problem is. Plz help!
Jan 8, 2013 at 2:49pm
Mother of God :O
http://weknowmemes.com/wp-content/uploads/2011/12/mother-of-god-meme.jpg

You should really just burn this and start over. Like literally print this out, set it on fire, delete from your machine, and redo this.
Jan 8, 2013 at 4:32pm
sry im newbie to c++
ive gt a project in school
so i made dis
Jan 8, 2013 at 4:34pm
This is practically unreadable. The formatting is awful, huge series of chained if's, an absurd amount of goto's. I would not even turn this in. I'd scrap this and start over now
Jan 8, 2013 at 4:47pm
how shud i replace the gotos with coz i dunno a btr alternate
coz its a drawing in text format
n i dunno hw to use graphics.h
its shows a list of errors when i copy an example
Last edited on Jan 8, 2013 at 4:52pm
Jan 8, 2013 at 10:48pm
You could replace the ridiculous amount of gotoxy() by using NCurses. If you're programming on Windows, there's a similar library you can use (I believe it's called PDCurses). As with every new library, you may have problems early on, but I can assure you that it will make your job A LOT easier once you get used to it.
Jan 9, 2013 at 6:07am
sry bt im only alowd to use standard library in turbo c++
Jan 9, 2013 at 9:53am
You have so many errors.
1. Its looking like you have closed your mind and used if statement everywhere.
2. You could have used loops in gotoxy statements.
3. Give better variable names than a b c d .....
4. Use switch when checking keystrokes.
5. if a = 27(ESC) end the game.
6. Put delay after calling display function.
7. You don't need to make the complete board everytime.
8. Reduce delay to 200.
9. Use graphics.h, your teacher won't stop you from doing that. You can learn it from http://programmingsimplified.com
Last edited on Jan 9, 2013 at 10:19am
Jan 9, 2013 at 2:46pm
Graphics.h isn't a standard header. I would not recommend that. Though this assignment seems stupid; Design a football game with graphics in the terminal? The terminal isn't meant for games -_-
Jan 13, 2013 at 4:49pm
@ResidentBiscuit this is what we have to in India in schools, we cannot use any libraries or anything and graphics.h is the last thing allowed in schools to make our projects not look dull.
Topic archived. No new replies allowed.