GhaseM.M
پنج شنبه 10 اردیبهشت 1388, 11:19 صبح
سلام
من می خوام یه بازی بنویسم که در ابتدای برنامه درجه و سرعت رو از کاربر بگیره بعد از گوشه صفحه با همون زاویه ای که کاربر خواسته یه توپ حرکت کنه و به صورت منحنی(حرکت پرتابی) به طرف دیگر صفحه بره. کلا موضوع بازیش اینه که 2 تا آدمک در 2 طرف صفحه هستند با پرتاب شدن توپ از یک طرف صفحه به طرف دیگر اگر توپ به آدمک دومی خورد کاربر برنده بشه! من مشکلم در حرکت منحنی وار توپ پرتاب شده است. فرمولش هم هست ولی مشکل اینه که توپ روی یک منحنی حرکت نمیکنه! من کدم رو می زارم. ببخشید اگر یکم مبتدی وار نوشتم چون هنوز تازه کارم! :-؟
#include <conio.h>
#include <iostream.h>
#include <graphics.h>
#include <math.h>
#include <dos.h>
void main()
{
double grad;
double speed;
cout << "Please Enter The Grad:";
cin >> grad;
cout << "\n";
cout << "Please Enter The Speed:";
cin >> speed;
int d=0,n=0;
initgraph(&d,&n," ");
setcolor(4);
double h= speed*speed*sin(grad)*sin(grad)/20;
double r=speed*speed*sin(2*grad)/10;
for (int t=0;t<h;t++)
{
line(20,479,20,449);
circle(20,429,20);
line(619,479,619,449);
circle(619,429,20);
double x = speed * cos(grad) * t;
double y = -5 * t * t + speed * sin(grad) * t;
gotoxy(x,y);
cout << "X";
delay(speed);
cleardevice();
}
for (int q=h;q<r;q++)
{
line(20,479,20,449);
circle(20,429,20);
line(619,479,619,449);
circle(619,429,20);
double x = speed * cos(grad) * q;
double y = -5 * q * q + speed * sin(grad) * q;
gotoxy(x,y);
cout << "X";
delay(speed);
cleardevice();
}
getch();
}
من می خوام یه بازی بنویسم که در ابتدای برنامه درجه و سرعت رو از کاربر بگیره بعد از گوشه صفحه با همون زاویه ای که کاربر خواسته یه توپ حرکت کنه و به صورت منحنی(حرکت پرتابی) به طرف دیگر صفحه بره. کلا موضوع بازیش اینه که 2 تا آدمک در 2 طرف صفحه هستند با پرتاب شدن توپ از یک طرف صفحه به طرف دیگر اگر توپ به آدمک دومی خورد کاربر برنده بشه! من مشکلم در حرکت منحنی وار توپ پرتاب شده است. فرمولش هم هست ولی مشکل اینه که توپ روی یک منحنی حرکت نمیکنه! من کدم رو می زارم. ببخشید اگر یکم مبتدی وار نوشتم چون هنوز تازه کارم! :-؟
#include <conio.h>
#include <iostream.h>
#include <graphics.h>
#include <math.h>
#include <dos.h>
void main()
{
double grad;
double speed;
cout << "Please Enter The Grad:";
cin >> grad;
cout << "\n";
cout << "Please Enter The Speed:";
cin >> speed;
int d=0,n=0;
initgraph(&d,&n," ");
setcolor(4);
double h= speed*speed*sin(grad)*sin(grad)/20;
double r=speed*speed*sin(2*grad)/10;
for (int t=0;t<h;t++)
{
line(20,479,20,449);
circle(20,429,20);
line(619,479,619,449);
circle(619,429,20);
double x = speed * cos(grad) * t;
double y = -5 * t * t + speed * sin(grad) * t;
gotoxy(x,y);
cout << "X";
delay(speed);
cleardevice();
}
for (int q=h;q<r;q++)
{
line(20,479,20,449);
circle(20,429,20);
line(619,479,619,449);
circle(619,429,20);
double x = speed * cos(grad) * q;
double y = -5 * q * q + speed * sin(grad) * q;
gotoxy(x,y);
cout << "X";
delay(speed);
cleardevice();
}
getch();
}