Here i share with u how to make a game on C++ Using the most simple algorithms etc
to make it jst cpy and paste it to a compiler and Make sure u have egavga.bgi file in the INCLUDE Directory and the Bin Directory then u are DONE
-------------------------------------------------------------------------------------------------------------------------
Currently Doing : Rhy's Line Racing on C++
you can also ask me to make a remake of your 1s1s scratch projects on C++ as C++ isnt able to do multithreading 1s1s is the best solution. Also 1s1s projects get a huge Speed boost on C++
-------------------------------------------------------------------------------------------------------------------------
PONG:
#include<iostream.h>
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<graphics.h>
void ball(int x,int y) // a function that prints the ball everytime :D
{circle(x,y,15);
}
void bat(int y) // the function that prints the bat everytime :D
{ line(5,y+30,5,y-30);
}
void score(int x)// to print the score
{ x=10-x;
outtextxy(400,400,"Miss:");
}
void main()
{
clrscr();
cout<<"Welcome to PONG ";
cout<<"press key to begin";
cout<<"\t\tRules of game\n1.U cannot win so its a survival game\n 2.Ur time will count so try to survive the most time \n 3.U have 10 misses to survive";
getch();
float xvel,yvel;
xvel=2;
yvel=1;
int ballx=200,bally=200;
float ypos=200;// board u reader or editor or Dark
float acc=0;
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
for(int miss=0;miss<=10;)
{ char key;
if(kbhit()) // this checks if keyboard has an input
{ key = getche(); // this feeds the system with the key value
}else
{key = 0;
}
if(key=='q') // Now if u press Q anywhere the program will Quit
exit(0);
if(key=='w'&&ypos>0)
{
acc=acc-30;
}
else if(key=='s'&&ypos<400)
{
acc=acc+30;
}
else
{acc=-(acc/2);
}
ypos=ypos+acc;
ballx=ballx+xvel;
bally=bally+yvel;
if(ballx<10)
{miss--;
ballx=200;
}
if(ballx>600)
{xvel=xvel*-1;
yvel=yvel*-1;
}
if(bally<0||bally>400)
yvel=yvel*-1;
if(ballx<15&&abs(bally-ypos)<20)
{yvel=(yvel*(bally-ypos)/10);
xvel = xvel*-1;
}
cleardevice();// clears the screen
ball(ballx,bally);// draws the ball
bat(ypos);// this draws the bat at the desired position
score(miss);
delay(4);
}
}I will load a version with b8r comments soon
Last edited by fanofcena (2010-04-19 02:26:59)
Offline
Ya.
Um where do you get the programe for c++
Offline
well to get a program for C++ which is called a compiler u need softwares like
VS2008 or TC3.1 or DevC++ or something related to it
all are free to get so its easy i suggest TC3.1 by borland for begginers cause its very supportive
to get it u need to do extensive search on the internet
I got it from ma skools CPU
Offline
here is the TC 3.1 IDE
http://www.4shared.com/file/mK_io5Yp/TC_online.html plz make sure u extract all the files in c: / and to run the ide use
C: /TC/bin/tc.exe
Last edited by fanofcena (2010-04-18 00:55:54)
Offline
fanofcena wrote:
here is the TC 3.1 IDE
http://www.4shared.com/file/mK_io5Yp/TC_online.html plz make sure u extract all the files in c: / and to run the ide use
C: /TC/bin/tc.exe
Uh... fanofcena? Can you kindly, just for one day, use proper grammar? Every time you speak I have to try and decode it and it takes way too long.
Offline
i know how to print on python XD
i know how to mov memory add memory to memory on assembler
i can print something on assembler
one problem with assembler you can't just say like import x
you have to do loads of stuff and you never see output
wow that is pretty good before you know it you'll have written quaqe lol
Offline
if you break it down into.....
(mind melts trying to figure out how it works!)
Offline
floatingmagictree wrote:
fanofcena wrote:
here is the TC 3.1 IDE
http://www.4shared.com/file/mK_io5Yp/TC_online.html plz make sure u extract all the files in c: / and to run the ide use
C: /TC/bin/tc.exeUh... fanofcena? Can you kindly, just for one day, use proper grammar? Every time you speak I have to try and decode it and it takes way too long.
WHAT !!!!!!!!! Ok well that meant that the link contains the IDE for C++ . Plz make sure u extract all the files in the package in the c drive . and to run the ide the standard executable is in Cdrive> >TC> >BIN> >TC.exe
Offline
banana500 wrote:
Wow, that code is sooo complicated for me. XD
Did you write that yourself?
yes i write it my self
cuz i am a C programmer
and actually after learning c++ for an year it was as easy as making something on scratch . i think of making rhys and canthairs projects on C++ cause they are nearly 1s1s and run toooooooooo slow on Scratch
Last edited by fanofcena (2010-04-18 19:53:22)
Offline
cruelty247 wrote:
i know how to print on python XD
i know how to mov memory add memory to memory on assembler
i can print something on assembler
one problem with assembler you can't just say like import x
you have to do loads of stuff and you never see output![]()
wow that is pretty good before you know it you'll have written quaqe lol![]()
aw yes i agree with you C++ can cause brain meltdown . take a tip : use scratch to visualise the code . I generally write the code on Scratch ( in brain ofcourse) then visualise it and then convert it to C++
Offline