C/C++ Graphic in motion

Pages: 12
Hey guys,
I think that i will use this forum for some time. Its my first year in informatics and i will need to learn C/C++ to graduate. I have 3 years to do that, still, i don't think thats enough.
Well, thing is our professor told us to make some graphics in motion and i thought to make a plane (with lines and geometric forms) fly from left to right and make it drop stuff ( packages or bombs , i don't care) or maybe make it go into a building and then the building should collapse or something... Something in that area.
Besides this, some functions(i think) or some values sould be extracted from a text file (*.txt) when the compiled *.exe is accessed.
Thing is ... i don't even know where to start so i thought of posting in here. Maybe someone with some extra time would type such a "scene"(program).

Thank you!
> or maybe make it go into a building and then the building should collapse or something

Excuse me? Not cool, man!
Maybe someone with some extra time would type such a "scene"(program).
LOL. I wouldn't hold my breath.

Your teacher is a dick if he told you to make graphics in an introductory course to C++.
Last edited on
@Hammurabi - its just something that i need to do for a graphic, thats all i see in that.

@helios - tell me about it ... Few of my class mates finished high school informatics and i guess she's to bored to teach us everything from the start.


I still need to do it. I have one week to finish it.
Oh, if people can't do this, maybe something that i could use to get to this scene.
Maybe a moving car or a moving horse , something that goes from left to right. I'm thinking of changing the lines coordonates to make it look like a plane... Uh , i wish i would just know C/C++!!!
I have one week to finish it.
I have serious doubts that you'll be able to finish it in that time, but this is where you need to go: http://www.libsdl.org/
Last edited on
or maybe make it go into a building and then the building should collapse or something

Are you serious? tbh if i was your teacher i wouldn't even accept that out of respect for what happened...
@helios - Other already finished it in 3-4 days.
@mcleano - People die of drug addiction every day, people die of street weapons, still, many movie stars plays this scene in many movies. Different singers sing about many bad things. I only see an C/C++ project that i need to do.

Besides, i can change the scenario , i only need something near by so i can use.

Please people, stay on topic or just not write at all.

Thank you.
Mr. Other presumably knows more C++ than you.
@Hammurabi - Yes, they do. To bad they r not willing to help others. (Other=few smart colleagues* with C/C++ knowledge) (Others = me and the rest :) )
Last edited on
This is quite off-topic, but I think I can guess Costinkara's native tongue is Spanish. If not Spanish, some other Romance language.
A short similar example. I only need that square to be a plane. I could try to draw it myself but i don't know how that coordonate stuff if working.

Besides that , some values should be extracted from a *.txt file.

Jesus, my teacher is "crazy"! :)


#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<math.h>

float xa=100.0,ya=100.0,xb=200.0,yb=100.0,xc=200.0,yc=200.0,xd=100.0,yd=200.0;

deseneaza_patrat(float xa,float ya,float xb,float yb,float xc,float yc,float xd,float yd)
{
for(int i=0;i<=2;i++)
{line(xa+i,ya+i,xb+i,yb+i);
line(xb+i,yb+i,xc+i,yc+i);
line(xc+i,yc+i,xd+i,yd+i);
line(xd+i,yd+i,xa+i,ya+i);
}
return 0;
}

scalare(float xa,float ya,float xb,float yb,float xc,float yc,float xd,float yd) //scalare simpla
{

for(int i=0;i<=2;i++)

{line(xa*i,ya*i,xb*i,yb*i);
line(xb*i,yb*i,xc*i,yc*i);
line(xc*i,yc*i,xd*i,yd*i);
line(xd*i,yd*i,xa*i,ya*i);
}
return 0;
}

void rotatia()
{
float xa1,ya1,xb1,yb1,xc1,yc1,xd1,yd1;
int fix=150,fiy=150,i;
float a=6.282/360;

xa1=xa;
xb1=xb;
xc1=xc;
xd1=xd;
ya1=ya;
yb1=yb;
yc1=yc;
yd1=yd;
for(i=0;i<360;i++)
{
setcolor(15);
line(xa1,ya1,xb1,yb1);
line(xb1,yb1,xc1,yc1);
line(xc1,yc1,xd1,yd1);
line(xd1,yd1,xa1,ya1);
delay(20);
setcolor(0);
line(xa1,ya1,xb1,yb1);
line(xb1,yb1,xc1,yc1);
line(xc1,yc1,xd1,yd1);
line(xd1,yd1,xa1,ya1);
xa1=fix+(xa1-fix)*cos(a)-(ya1-fiy)*sin(a);
xb1=fix+(xb1-fix)*cos(a)-(yb1-fiy)*sin(a);
xc1=fix+(xc1-fix)*cos(a)-(yc1-fiy)*sin(a);
xd1=fix+(xd1-fix)*cos(a)-(yd1-fiy)*sin(a);
ya1=fiy+(ya1-fiy)*cos(a)+(xa1-fix)*sin(a);
yb1=fiy+(yb1-fiy)*cos(a)+(xb1-fix)*sin(a);
yc1=fiy+(yc1-fiy)*cos(a)+(xc1-fix)*sin(a);
yd1=fiy+(yd1-fiy)*cos(a)+(xd1-fix)*sin(a);
fix++;
xa1++;
xb1++;
xc1++;
xd1++;
}
setcolor(15);
line(xa1,ya1,xb1,yb1);
line(xb1,yb1,xc1,yc1);
line(xc1,yc1,xd1,yd1);
line(xd1,yd1,xa1,ya1);
}



void main()
{int gd=DETECT,gm;

initgraph(&gd,&gm,"c:\\borlandc\\bgi");

//deseneaza_patrat(xa,ya,xb,yb,xc,yc,xd,yd);
//scalare(xa,ya,xb,yb,xc,yc,xd,yd);

rotatia();

getch();
closegraph();
clrscr();
}
Last edited on
closed account (S6k9GNh0)
or maybe make it go into a building and then the building should collapse or something

Are you serious? tbh if i was your teacher i wouldn't even accept that out of respect for what happened...


Well on account of that being years ago and this having absolutely NOTHING to do with it, I would honestly think you were a bad teacher.
I think I can guess Costinkara's native tongue is Spanish

Is that because of the word "informatics"? It kind of stands out.
Last edited on
Well on account of that being years ago and this having absolutely NOTHING to do with it, I would honestly think you were a bad teacher.

Ok mate... i'm not here to argue with you, i'm here to give and receive advie from you and on that note i'm just gonna leave this topic alone.

@Costinkara ... Good luck with your project.
Is that because of the word "informatics"? It kind of stands out.
And "colegs". In Spanish, "colleagues" is "colegas", although it's somewhat of a false friend.

In any case, it looks like I wasn't so far off. He seems to be Italian.
Last edited on
@helios, @Hammurabi , i would appreciate if you stop posting in my thread.

Thank you.
I have a feeling you won't have a problem with people posting in this thread.
That is if your the only one.
A friend helped me find this graphic. Now all i need to do is transform this into a plane :)
If anybody can lay a hand i would really appreciate.


//Author: Karanth Srihari
//Email ID: hari_karanth@indiatimes.com

#include<graphics.h>
#include<stdlib.h>
#include<conio.h>
#include<dos.h>

void main()
{
int gd=DETECT,gm,i,j,p,q,x,y,flag;
struct arccoordstype arcinfo;
initgraph(&gd,&gm,"c:\\tc");
y=getmaxy()/2;
i=0;
p=0;
q=0;
j=0;
flag=0;
setcolor(WHITE);
for(int k=0;k<500;k++)
putpixel(random(620),random(419),15);
while(!kbhit())
{
line(0+i,y+20,0+i,y-20); /*triangle*/
line(0+i,y+20,20+i,y);
line(0+i,y-20,20+i,y);

ellipse(80+i,y,10-p,350+p,60,25);
line(140+i,y+3,130+i,y+8);
line(130+i,y+8,140+i,y-5);

if(flag==0)
p=p+2;
if(flag==1)
p=p-2;

circle(120+i,y-6,5);

line(60+i,y-25,30+i,y-45+j);
line(30+i,y-45+j,100+i,y-25);
line(60+i,y+25,30+i,y+45+q);
line(30+i,y+45+q,100+i,y+25);
i=i+3;
if(i>=638)
i=0;

if(flag==0)
j=j-2,q=q+2;

if(flag==1)
j=j+2,q=q-2;

if(j<=-10)
flag=1;
else if(j>=0)
flag=0;

delay(100);
cleardevice();
}

getch();
closegraph();

}

Is that because of the word "informatics"? It kind of stands out.
And "colegs". In Spanish, "colleagues" is "colegas", although it's somewhat of a false friend.

In any case, it looks like I wasn't so far off. He seems to be Italian.

Actually it's romanian.I should know :)

Anyway Costinkara, why don't you do something simpler, like a polygon that changes the number of sides and the color every half second and does that from 3 sides to 100 sides, incrementally.That should be enough for the beginning.
What I don't understand is why in the first ear do they ask you to make programs with graphics??Shouldn't that be left for the second, or third ear???
It seems that your teacher is rushing things a little.You should take it slower, learn at least the basic concepts of C++, make a lot of console programs, interesting and fun ones if possible, and then learn how to make programs with GUI.

And if you want to make programs with GUI, please don't use proprietary libraries such as MFC, NET, Windows API or MS DOS libraries. Use nonmonopolistic libraries instead, like FLTK or WxWidgets for C++.
FLTK is small and fast but it only has features to make GUI, no networking, multimedia, etc.You can use other libraries for those.WxWidgets on the other hand has features not just for GUI, but for networking, printing, etc. But it's slower and larger in size.
You should ask your professor to take it slower, unless it is assumed you already know C++ and you should learn only GUI programs from now on.Which I doubt it.
Good luck!
Last edited on
Pages: 12