🔒 Locked
Starting Fist C++ program
Advertisement
Original Post
HELLO PEOPLE!!
I was wondering what I should try and do for my first program. Not something that has to do with 3d graphics and not something too complicated. What are some of the things you guys started with?
______________________________________________________________
"It takes all kinds." -Adam Carolla
There''s this great thing called "Hello world". Try it.
Resist everyone
I am your only friend. Click here for more information.
Resist everyone
I am your only friend. Click here for more information.
quote:
Original post by Ravuya
There''s this great thing called "Hello world". Try it.
Resist everyone
I am your only friend. Click here for more information.![]()
I'' already done that. I even made a math prorgam to solve the quadratic equatoin for me. But i wanna try more than that. that was easy.
______________________________________________________________
"It takes all kinds." -Adam Carolla
quote:
Original post by aftermath
Make a small pong game.
sadly, i think that would be too much for me right now. Unless there is a site out there with a tutorial that can walk me through it to help me understand what everyhting is while i do it.
______________________________________________________________
"It takes all kinds." -Adam Carolla
For something somewhat easy, you could write a text-based tic-tac-toe game. If you haven''t been programming long, it might be a lot of work since you might do things the hard way, but you can still complete it that way. You could make it two player at first, where it prints the board and gets the number of a square 1-9 from a player then does likewise for the other player, then eventually you could try to make a basic AI for it to pick a good square, and then you could try to make a perfect AI that never loses, etc.
Try this:
[edited by - Superpig on January 24, 2004 10:16:35 PM]
#include <ddraw.h>
#define B(x,y,r,p) (p&1<<(((x^(r+1&2?3:0))<<(r*2&2))+((y^(r&2?3:0))*(r&1?1:4))))
#define F(x,y,w,h,c) {RECT R={x,y,x+w,y+h};b.dwFillColor=c;_->Blt(&R,0,0,k,&b);}
char *m="Tetris\0By Pouya Larjani\0Score:\0Next:\0GAME OVER",z[9]; unsigned L=16
,k=16778240,Q=9,I,x=9,n,y,r,p,i,a,t,u,v,e,s[30][20],P[]={1632,75328,83488,74274,
222272,221728,206368};DDBLTFX b={100};LPDIRECTDRAW d;LPDIRECTDRAWSURFACE V,_;HDC
q;HWND W;LOGFONT l={96,48};MSG g;DDSURFACEDESC S={108,33,0,0,0,1,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,0,0,0,{536}};HFONT f=CreateFontIndirect(&l);DDSCAPS c={4};X()
{for(i=1;i<30;i++){a=1;for(I=0;I<20&&aa=s[i][I++]);if(a){for(I=i*20+19;I>=20;s[
I/20][I%20]=s[I/20-1][I--%20]);e++;return 1;}}return 0;}M(int p){return(++p<<21&
1<<23|p<<14&1<<15|p<<7&1<<7)+8355711;}K(int v){return GetAsyncKeyState(v)&32768;
}O(int x,int y,int r,int p){for(I=0;I<L;I++)if(B(I%4,I/4,r,P[p])&&(x+I%4<0||x+I%
4>19||y+I/4<0||y+I/4>29||s[y+I/4][x+I%4]))return 0;return 1;}void G(){v=r;t=x;u=
y;TranslateMessage(&g);DispatchMessage(&g);(g.message==275&&Q)?SetTimer(W,1,1050
-50*((e<100)?e/5:20),0),u++:K(38)?v=r?v-1:P[p]>>16&3:K(37)?t--:K(39)?t++:K(40)?u
++:K(27)?PostQuitMessage(0):0;if(O(t,u,v,p))x=t,y=u,r=v;else if(u-y){for(I=0;I<L
;I++)if(B(I%4,I/4,r,P[p]))s[y+I/4][x+I%4]=1<<23;y?p=n,y=0,n=rand()%7,x=9,r=0:Q=0
;while(X());}}void R(){F(0,0,640,480,1<<15);for(I=0;I<600;I++)F(I%20*L,I/20*L,L,
L,s[I/20][I%20]);for(I=0;I<L;I++){if(B(I%4,I/4,r,P[p]))F((x+I%4)*L,(y+I/4)*L,L,L
,M(p));F(336+I%4*L,400+I/4*L,L,L,B(I%4,I/4,0,P[n])?M(n):0);}_->GetDC(&q);itoa(e,
z,10);SelectObject(q,GetStockObject(13));SetTextColor(q,M(6));SetBkMode(q,0);V->
Restore();TextOut(q,336,120,m+7,L);TextOut(q,336,340,m+24,6);TextOut(q,408,340,z
,strlen(z));TextOut(q,336,380,m+31,5);TextOut(q,444,300,m+37,9-Q);SelectObject(q
,f);TextOut(q,336,20,m,6);_->ReleaseDC(q);V->Flip(0,1);}WINAPI WinMain(HINSTANCE
h,HINSTANCE,char*,int){srand(timeGetTime());WNDCLASS w={0,DefWindowProc,0,0,h,0,
0,0,0,m};RegisterClass(&w);W=CreateWindow(m,m,2432696320,0,0,640,480,0,0,h,0);p=
rand()%7;ShowCursor(0);DirectDrawCreate(0,&d,0);d->SetCooperativeLevel(W,83);d->
SetDisplayMode(640,480,32);d->CreateSurface(&S,&V,0);V->GetAttachedSurface(&c,&_
);n=rand()%7;SetTimer(W,1,0,0);while(g.message!=18)PeekMessage(&g,0,0,0,1)?G():R
();int U=0;V->Release();d->Release();DestroyWindow(W);DeleteObject(f);return U;}
[edited by - Superpig on January 24, 2004 10:16:35 PM]
quote:
Original post by Extrarius
For something somewhat easy, you could write a text-based tic-tac-toe game. If you haven''t been programming long, it might be a lot of work since you might do things the hard way, but you can still complete it that way. You could make it two player at first, where it prints the board and gets the number of a square 1-9 from a player then does likewise for the other player, then eventually you could try to make a basic AI for it to pick a good square, and then you could try to make a perfect AI that never loses, etc.
I like that idea. I''ll try it!
______________________________________________________________
"It takes all kinds." -Adam Carolla
omfg i never wrote a fist program
quote:
Original post by Extrarius
For something somewhat easy, you could write a text-based tic-tac-toe game. If you haven't been programming long, it might be a lot of work since you might do things the hard way, but you can still complete it that way. You could make it two player at first, where it prints the board and gets the number of a square 1-9 from a player then does likewise for the other player, then eventually you could try to make a basic AI for it to pick a good square, and then you could try to make a perfect AI that never loses, etc.
Yeah, I did one of those. Check it out
- CD

Brought to you by Code_Dark
Edit: Fixed the link, which didn't work (damn Geocities)
[edited by - Code_Dark on January 25, 2004 4:06:31 AM]
Hmmm..
Try messing around with structs and classes, make a small text adventure style game - hold all of the info within structs and classes (structs for POD [plain old data] and a class for things like hp, mana, etc.). Make a simple algorithm within all of this (using multi dimensional arrays [two dimensional to save on memory, and for simplicity] within a class or struct, up to you - or perhaps even a union!) to calculate leveling and money and all that jazz.
Try that out, it should be rather easy.
Have fun!
[edited by - Drevay on January 25, 2004 6:19:07 AM]
Try messing around with structs and classes, make a small text adventure style game - hold all of the info within structs and classes (structs for POD [plain old data] and a class for things like hp, mana, etc.). Make a simple algorithm within all of this (using multi dimensional arrays [two dimensional to save on memory, and for simplicity] within a class or struct, up to you - or perhaps even a union!) to calculate leveling and money and all that jazz.
Try that out, it should be rather easy.
Have fun!
[edited by - Drevay on January 25, 2004 6:19:07 AM]
A MMORPG game seems to be a pretty popular choice. So I would recommend making one.
Write some programs that force you to learn all the complicated object-oriented shit you glossed over in you intro C++ book. Also learn about data structures such as linked lists, stacks, and trees.
Then when you learn directX you won''t be like, "OMFG this is complicated!" which is what I was like.
___________________________________________________________
Proceeding on a brutal rampage is the obvious choice.
Where to find the intensity (Updated Jan 23, 2004)
Then when you learn directX you won''t be like, "OMFG this is complicated!" which is what I was like.
___________________________________________________________
Proceeding on a brutal rampage is the obvious choice.
Where to find the intensity (Updated Jan 23, 2004)
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement