kasra_9nor
دوشنبه 23 فروردین 1389, 17:46 عصر
با سلام خدمت شما دوستان بسیار عزیز
من تویک قسمتش گیر کردم...اونم اینه که نقطه برخورد را چگونه تشخیص بدم..؟؟
منظورم اینه که از کجا بفهمم که الان توپ به راکت خورده؟؟؟
ممنون
#include <graphics.h>
#include <math.h>
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <conio.h>
void design(); // keshidane mostatil
void erase(); // pak kardane mostatil
void arrow(); // jahate up & down
void toop(); // harkate toop az samte chap
int x=220,y=260;
void main()
{
int gmode,gdrive=DETECT;
initgraph(&gdrive,&gmode,"c:\\tc\\bgi");
rectangle(0,220,10,260);
while(1){
toop();
arrow();
}
}
void design() //---------design
{
setcolor(WHITE);
rectangle(0,x,10,y);
}
void erase() //--------erase
{
setcolor(BLACK);
rectangle(0,x,10,y);
}
void arrow() //-------arrow key
{
char a,b;
a = getche();
if ( a == 0)
b = getch();
if ( a==0 && b ==72)//up
{
erase();
x -= 30 ;
y -= 30;
design();
}
else if (a==0 && b ==80)//down
{
erase();
x += 30;
y += 30;
design();
}
}
void toop() //-----------harkate toop random
{
int i,x;
x =random(270)+10;
for (i=0;i<=64;i++)
{
setcolor(WHITE);
circle( (630-(i*10)) , x , 10);
delay(50);
setcolor(BLACK);
circle( (630-(i*10)) , x , 10);
}
}
من تویک قسمتش گیر کردم...اونم اینه که نقطه برخورد را چگونه تشخیص بدم..؟؟
منظورم اینه که از کجا بفهمم که الان توپ به راکت خورده؟؟؟
ممنون
#include <graphics.h>
#include <math.h>
#include <dos.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <conio.h>
void design(); // keshidane mostatil
void erase(); // pak kardane mostatil
void arrow(); // jahate up & down
void toop(); // harkate toop az samte chap
int x=220,y=260;
void main()
{
int gmode,gdrive=DETECT;
initgraph(&gdrive,&gmode,"c:\\tc\\bgi");
rectangle(0,220,10,260);
while(1){
toop();
arrow();
}
}
void design() //---------design
{
setcolor(WHITE);
rectangle(0,x,10,y);
}
void erase() //--------erase
{
setcolor(BLACK);
rectangle(0,x,10,y);
}
void arrow() //-------arrow key
{
char a,b;
a = getche();
if ( a == 0)
b = getch();
if ( a==0 && b ==72)//up
{
erase();
x -= 30 ;
y -= 30;
design();
}
else if (a==0 && b ==80)//down
{
erase();
x += 30;
y += 30;
design();
}
}
void toop() //-----------harkate toop random
{
int i,x;
x =random(270)+10;
for (i=0;i<=64;i++)
{
setcolor(WHITE);
circle( (630-(i*10)) , x , 10);
delay(50);
setcolor(BLACK);
circle( (630-(i*10)) , x , 10);
}
}