PDA

View Full Version : حرکت دادن آدمک در ++c



موفقیت 8
جمعه 03 آذر 1385, 13:31 عصر
سلام خسته نباشید
من آدمکم رو بوسیله کلاس نوشتم
همشمون رو توی یک برنامه هم اینکه می خوام هر کدوم رو جدا جدا بنویسم و cpp. کنم
فقط مشکل من اینه که نمی تونم حرکتش بدم
با for و delay می خواستم حرکت بدم نتونستم
فقط باید این آدمک به 3 تا دایره که وسط صفحه است مثلا مختصات 200 و 200 اگه برخورد کنه یکی از 3 تا دایره ای که به عنوان جون آدمک گذاشته شده بره و پاک بشه
این آدمک در همه جهات هم حرکت کنه
هم این که از همون نقطه که با د ایره اول برخورد کرده به راهش ادامه بده و از اول شروع نکنه
امیدوارم تونسته باشم مفهوم این برنامه رو گفته باشم
موفق باشید

powerboy2988
جمعه 03 آذر 1385, 13:50 عصر
میشه سورسه برنامه رو بزارین؟

موفقیت 8
یک شنبه 05 آذر 1385, 22:08 عصر
این برنامه منه
البته خیلی رنگارنگه
من فقط می خوام حرکتش بدم
که به این دایره های وسط که می رسه اون دایره های پائین اولیش پاک بشه بعد به دایره دوم که می رسه دایره پائیینی دومیش پاک بشه به همین ترتیب
ممنون
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <dos.h>
void faal()
{
int j,f,l,a;
l=0;
union REGS i,o;
i.x.ax=0;
int86(0x33,&i,&o);
i.x.ax=1;
int86(0x33,&i,&o);
}
class linne
{
private:
int s;
int d;
int f;
int g;
int collor;
public:
void set_collor(int z)
{
collor=z;
}
void set_first(int z,int x)
{
s=z;
d=x;
}
void set_end(int z,int x)
{
f=z;
g=x;
}
void show_liner()
{
setcolor(collor);
line(s,d,f,g);
}
};//end of class liner
class ellips
{
private:
int colore;
int rx;
int ry;
int x1;
int y1;
int a;
int b;
public:
void set_color(int q)
{
colore=q;
}
void set_center(int q,int u)
{
x1=q;
y1=u;
}
void set_size(int q,int u)
{
rx=q;
ry=u;
}
void set_sizze(int q,int u)
{
a=q;
b=u;
}
void show_ellips()
{
setcolor(colore);
setfillstyle(1,colore);
ellipse(x1,y1,a,b,rx,ry);
//floodfill(x1,y1,15);
}
};//end of class ellips
class circl
{
private:
int r;
int x;
int y;
int color;
public:
void set_center(int w,int z)
{
x=w;
y=z;
}
void set_size(int w)
{
r=w;
}
void set_color(int w)
{
color=w;
}
void show_circle()
{
setcolor(15);
setfillstyle(1,color);
circle(x,y,r);
floodfill(x,y,15);
}
};//end of class circle*/

int main(void)
{

/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int stangle = 220, endangle = 5000;
int radius = 20;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");

/* read result of initialization */
errorcode = graphresult();
/* an error occurred */
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
faal();
circl w4,w5,w6,w7,w8,w9,w10,w11,w12,w13,w14;
/*goshe chap*/
w4.set_center(30,50);
w4.set_size(5);
w4.set_color(15);
w4.show_circle();
/*goshe rast*/
w5.set_center(90,50);
w5.set_size(5);
w5.set_color(15);
w5.show_circle();
/*daste rast*/
w6.set_center(102,84);
w6.set_size(8);
w6.set_color(0);
w6.show_circle();
/*daste chap*/
w7.set_center(20,84);
w7.set_size(8);
w7.set_color(0);
w7.show_circle();
/*bini*/
w8.set_center(60,55);
w8.set_size(2);
w8.set_color(4);
w8.show_circle();
/*cheshme rast*/
w9.set_center(75,45);
w9.set_size(3);
w9.set_color(1);
w9.show_circle();
/*halghe cheshme chap*/
w10.set_center(47,45);
w10.set_size(3);
w10.set_color(1);
w10.show_circle();
/*soorat*/
w11.set_center(60,50);
w11.set_size(25);
w11.set_color(0);
w11.show_circle();
w12.set_center(540,450);
w12.set_size(10);
w12.set_color(7);
w12.show_circle();
w13.set_center(560,450);
w13.set_size(10);
w13.set_color(7);
w13.show_circle();
w14.set_center(580,450);
w14.set_size(10);
w14.set_color(7);
w14.show_circle();
/* body */
ellips e1,e2,e3;
e1.set_center(60,125);
e1.set_size(30,50);
e1.set_sizze(220,219);
e1.set_color(2);
e1.show_ellips();
/*pa rast*/
e1.set_center(80,180);
e1.set_size(19,7);
e1.set_sizze(310,304);
e1.set_color(11);
e1.show_ellips();
/*pa chap*/
e1.set_center(40,180);
e1.set_size(18,7);
e1.set_sizze(310,304);
e1.set_color(11);
e1.show_ellips();

linne l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11;
/*line daste rast*/
l1.set_first(85,100);
l1.set_end(96,90);
l1.set_collor(14);
l1.show_liner();
/*line daste rast*/
l2.set_first(34,100);
l2.set_end(26,90);
l2.set_collor(14);
l2.show_liner();
/*tare moo chap*/
l3.set_first(60,25);
l3.set_end(60,35);
l3.set_collor(6);
l3.show_liner();
/*tare moo rast*/
l4.set_first(60,25);
l4.set_end(70,35);
l4.set_collor(6);
l4.show_liner();
/*tare moo miyany*/
l5.set_first(60,25);
l5.set_end(50,35);
l5.set_collor(6);
l5.show_liner();
l6.set_first(30,280);
l6.set_end(70,320);
l6.set_collor(15);
l6.show_liner();
l7.set_first(70,280);
l7.set_end(30,320);
l7.set_collor(15);
l7.show_liner();
l8.set_first(470,380);
l8.set_end(430,420);
l8.set_collor(15);
l8.show_liner();
l9.set_first(430,380);
l9.set_end(470,420);
l9.set_collor(15);
l9.show_liner();
l10.set_first(380,80);
l10.set_end(420,120);
l10.set_collor(15);
l10.show_liner();
l11.set_first(420,80);
l11.set_end(378,120);
l11.set_collor(15);
l11.show_liner();
setcolor(14);
outtextxy(380,100,"DANGER");
setcolor(14);
outtextxy(430,400,"DANGER");
setcolor(14);
outtextxy(30,300,"DANGER");
/* draw arc */
setcolor(5);
arc(60, 50, stangle, endangle, radius);
/*circles*/
setcolor(12);
circle(400,100,30);
setcolor(90);
circle(50,300,30);
setcolor(4);
circle(450,400,30);
outtextxy(537,448,"1");
outtextxy(557,448,"2");
outtextxy(577,448,"3");

/* clean up */
getch();
closegraph();
return 0;
}

/* rectangle(right-25,top+3,right-5,top+22);
line(right-21,top+20,right-9,top+5);
line(right-21,top+5,right-9,top+20);*/

powerboy2988
یک شنبه 05 آذر 1385, 23:40 عصر
بهتر نیست اینجوری بنویسی


#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <dos.h>
void faal()
{
int j,f,l,a;
l=0;
union REGS i,o;
i.x.ax=0;
int86(0x33,&i,&o);
i.x.ax=1;
int86(0x33,&i,&o);
}
class linne
{
private:
int s;
int d;
int f;
int g;
int collor;
public:
void set_collor(int z)
{
collor=z;
}
void set_first(int z,int x)
{
s=z;
d=x;
}
void set_end(int z,int x)
{
f=z;
g=x;
}
void show_liner()
{
setcolor(collor);
line(s,d,f,g);
}
};//end of class liner
class ellips
{
private:
int colore;
int rx;
int ry;
int x1;
int y1;
int a;
int b;
public:
void set_color(int q)
{
colore=q;
}
void set_center(int q,int u)
{
x1=q;
y1=u;
}
void set_size(int q,int u)
{
rx=q;
ry=u;
}
void set_sizze(int q,int u)
{
a=q;
b=u;
}
void show_ellips()
{
setcolor(colore);
setfillstyle(1,colore);
ellipse(x1,y1,a,b,rx,ry);
//floodfill(x1,y1,15);
}
};//end of class ellips
class circl
{
private:
int r;
int x;
int y;
int color;
public:
void set_center(int w,int z)
{
x=w;
y=z;
}
void set_size(int w)
{
r=w;
}
void set_color(int w)
{
color=w;
}
void show_circle()
{
setcolor(15);
setfillstyle(1,color);
circle(x,y,r);
floodfill(x,y,15);
}
};//end of class circle*/

int main(void)
{

/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int stangle = 220, endangle = 5000;
int radius = 20;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");

/* read result of initialization */
errorcode = graphresult();
/* an error occurred */
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
faal();
circl w4,w5,w6,w7,w8,w9,w10,w11,w12,w13,w14;
/*goshe chap*/
w4.set_center(30,50);
w4.set_size(5);
w4.set_color(15);
w4.show_circle();
/*goshe rast*/
w5.set_center(90,50);
w5.set_size(5);
w5.set_color(15);
w5.show_circle();
/*daste rast*/
w6.set_center(102,84);
w6.set_size(8);
w6.set_color(0);
w6.show_circle();
/*daste chap*/
w7.set_center(20,84);
w7.set_size(8);
w7.set_color(0);
w7.show_circle();
/*bini*/
w8.set_center(60,55);
w8.set_size(2);
w8.set_color(4);
w8.show_circle();
/*cheshme rast*/
w9.set_center(75,45);
w9.set_size(3);
w9.set_color(1);
w9.show_circle();
/*halghe cheshme chap*/
w10.set_center(47,45);
w10.set_size(3);
w10.set_color(1);
w10.show_circle();
/*soorat*/
w11.set_center(60,50);
w11.set_size(25);
w11.set_color(0);
w11.show_circle();
w12.set_center(540,450);
w12.set_size(10);
w12.set_color(7);
w12.show_circle();
w13.set_center(560,450);
w13.set_size(10);
w13.set_color(7);
w13.show_circle();
w14.set_center(580,450);
w14.set_size(10);
w14.set_color(7);
w14.show_circle();
/* body */
ellips e1,e2,e3;
e1.set_center(60,125);
e1.set_size(30,50);
e1.set_sizze(220,219);
e1.set_color(2);
e1.show_ellips();
/*pa rast*/
e1.set_center(80,180);
e1.set_size(19,7);
e1.set_sizze(310,304);
e1.set_color(11);
e1.show_ellips();
/*pa chap*/
e1.set_center(40,180);
e1.set_size(18,7);
e1.set_sizze(310,304);
e1.set_color(11);
e1.show_ellips();

linne l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11;
/*line daste rast*/
l1.set_first(85,100);
l1.set_end(96,90);
l1.set_collor(14);
l1.show_liner();
/*line daste rast*/
l2.set_first(34,100);
l2.set_end(26,90);
l2.set_collor(14);
l2.show_liner();
/*tare moo chap*/
l3.set_first(60,25);
l3.set_end(60,35);
l3.set_collor(6);
l3.show_liner();
/*tare moo rast*/
l4.set_first(60,25);
l4.set_end(70,35);
l4.set_collor(6);
l4.show_liner();
/*tare moo miyany*/
l5.set_first(60,25);
l5.set_end(50,35);
l5.set_collor(6);
l5.show_liner();
l6.set_first(30,280);
l6.set_end(70,320);
l6.set_collor(15);
l6.show_liner();
l7.set_first(70,280);
l7.set_end(30,320);
l7.set_collor(15);
l7.show_liner();
l8.set_first(470,380);
l8.set_end(430,420);
l8.set_collor(15);
l8.show_liner();
l9.set_first(430,380);
l9.set_end(470,420);
l9.set_collor(15);
l9.show_liner();
l10.set_first(380,80);
l10.set_end(420,120);
l10.set_collor(15);
l10.show_liner();
l11.set_first(420,80);
l11.set_end(378,120);
l11.set_collor(15);
l11.show_liner();
setcolor(14);
outtextxy(380,100,"DANGER");
setcolor(14);
outtextxy(430,400,"DANGER");
setcolor(14);
outtextxy(30,300,"DANGER");
/* draw arc */
setcolor(5);
arc(60, 50, stangle, endangle, radius);
/*circles*/
setcolor(12);
circle(400,100,30);
setcolor(90);
circle(50,300,30);
setcolor(4);
circle(450,400,30);
outtextxy(537,448,"1");
outtextxy(557,448,"2");
outtextxy(577,448,"3");

/* clean up */
getch();
closegraph();
return 0;
}

/* rectangle(right-25,top+3,right-5,top+22);
line(right-21,top+20,right-9,top+5);
line(right-21,top+5,right-9,top+20);*/

--------------------
نمی دونم چرا کارت گرافیکیم جواب نمی ده

موفقیت 8
دوشنبه 06 آذر 1385, 09:06 صبح
powerbor2988 سلام
دوست گرامی
در مورد حرکت دادن این آدمک شما می شه به من کمک کنید تا این رو حرکتش بدم
تا هم من خوشحال بشم و هم شما!!!!
( حالا نمی دونم شما خوشحالی برای شما این جا چه معنی داره:متعجب: )
به هر حال از شما می خوام که منو راهنمایی کنید
اگه دوستان دیگر هم می تونن ممنون می شم
فعلا

powerboy2988
دوشنبه 06 آذر 1385, 23:14 عصر
چشم سعی می کنم خوشحالی من اینجا از خوش حالی شما هستش

leG_big
چهارشنبه 15 آذر 1385, 21:24 عصر
جستجو تو emule

موفقیت 8
پنج شنبه 23 آذر 1385, 23:02 عصر
چشم سعی می کنم خوشحالی من اینجا از خوش حالی شما هستش

سلام
دوست عزیز سئوال رو شما جوابش رو می دونید چون اکثر این هایی که اینجا هستن یه جورایی خیلی مهندس هستن شما هم از اون ها
جواب این سئوال رو منتظرم