C++ Game Source: Mongolians Welcome!

  • Context: C/C++ 
  • Thread starter Thread starter sharavsambuu
  • Start date Start date
  • Tags Tags
    C++ Game Source
Click For Summary

Discussion Overview

The discussion revolves around sharing C++ game source code, specifically focusing on a "SNAKE" game created by a participant. The conversation includes requests for ideas and contributions from others, as well as references to open-source game code.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • One participant invites others to share their C++ game source code, specifically mentioning a "SNAKE" game they have created.
  • The "SNAKE" game source code is provided, which includes various functions for game mechanics such as movement and drawing graphics.
  • Another participant suggests that there is a wealth of open-source game code available, particularly games released under the GNU GPL license.
  • There is a request for ideas on what games to create or share, indicating an interest in collaborative development.

Areas of Agreement / Disagreement

Participants appear to agree on the interest in sharing C++ game source code, but there is no consensus on specific game ideas or the direction of future contributions.

Contextual Notes

The discussion includes technical details about the C++ code and its dependencies, such as the use of the TURBOC compiler and graphics libraries, which may not be universally applicable. There are also assumptions about the participants' familiarity with DOS programming and the specific environment required to compile the provided code.

Who May Find This Useful

Individuals interested in C++ programming, game development, and open-source software may find this discussion beneficial.

sharavsambuu
Messages
5
Reaction score
0
Сайн байна уу? Хэрвээ энд манай Монголчууд ордог бол. хэ хэ
Та нар энд C++ дээр хийсэн жижиг сажиг тоглоомынхоо соорсыг энд тавьж болно шүү!

Hello all.
Lets putting here you c++ game source!

sorry my bad english!
 
Technology news on Phys.org
Ok. Let's do it. Any ideas?
 
My first source of "SNAKE game"

I'm just writing in DOS. You may compile it by TURBOC compiler.

//name: Snake
//author : Sharavsambuu

#include stdio.h
#include conio.h
#include iostream.h
#include graphics.h
#include dos.h
#include stdlib.h

#define X 200
#define Y 150
#define audio 0

class nud{
int urt;
public :
void move_up();
void move_down();
void move_right();
void move_left();
void urt_anh();
void urt_nem();
int len();
};
struct snake{
int x,y;
} a[500];
int x1,y1,score=0,delays,bool;
void draw_pane(int x,int y,int Ox,int Oy){
setcolor(BLACK);
for(int i=x;i<=x+Ox;i++){ if (i%5==0){ line(i,y,i,y+Oy); } } for(int j=y;j<=y+Oy;j++){ if (j%5==0){ line(x,j,x+Ox,j); } } } void bud_nogoon(int x,int y){ setcolor(GREEN); for (int i=Y+5*y+1;i<=Y+5*y+4;i++){ line(X+5*x+1,i,X+5*x+4,i); } } void bud_shar(int x,int y){ setcolor(YELLOW); for (int i=Y+5*y+1;i<=Y+5*y+4;i++){ line(X+5*x+1,i,X+5*x+4,i); } } void bud_tsenher(int x,int y){ setcolor(BLUE); for (int i=Y+5*y+1;i<=Y+5*y+4;i++){ line(X+5*x+1,i,X+5*x+4,i); } } void bud_tsagaan(int x,int y){ setcolor(WHITE); for (int i=Y+5*y+1;i<=Y+5*y+4;i++){ line(X+5*x+1,i,X+5*x+4,i); } } void bud_random(int x,int y){ setcolor(10+random(30-10)); for (int i=Y+5*y+1;i<=Y+5*y+4;i++){ line(X+5*x+1,i,X+5*x+4,i); } } void sanamsargui_tseg(int n){ l6: x1=random(50); y1=random(30); for (int i=0;i0;i--){a=a[i-1];
if (i%2==1){
bud_nogoon(a.x,a.y);}
else bud_shar(a.x,a.y);
}
a[0].x=n;a[0].y=m; bud_random(a[0].x,a[0].y);
bud_tsagaan(a[urt-1].x,a[urt-1].y);
nosound();
}
}
void nud :: move_down(){
while ((!kbhit())){ sound(audio);
delay(delays);
if (check(urt)==1){
bool=1;
break;
}
if (a[0].y>=29){a[0].y=0;}
if ((a[0].x==x1)&&(a[0].y==y1)){
urt++;
score+=2;
sanamsargui_tseg(urt);
bud_tsenher(x1,y1);
}
a[0].y++;
int n=a[0].x,m=a[0].y;
for (int i=urt-1;i>0;i--){a=a[i-1];
if (i%2==1){
bud_nogoon(a.x,a.y);}
else bud_shar(a.x,a.y);}
a[0].x=n;a[0].y=m; bud_random(a[0].x,a[0].y);
bud_tsagaan(a[urt-1].x,a[urt-1].y);
nosound();
}
}
void nud :: move_right(){
while ((!kbhit())) { sound(audio);
delay(delays);
if (check(urt)==1){
bool=1;
break;
}
if (a[0].x>=49){a[0].x=0;}
if ((a[0].x==x1)&&(a[0].y==y1)){
urt++;
score+=2;
sanamsargui_tseg(urt);
bud_tsenher(x1,y1);
}
a[0].x++;
int n=a[0].x,m=a[0].y;
for (int i=urt-1;i>0;i--){a=a[i-1];
if (i%2==1){
bud_nogoon(a.x,a.y);}
else bud_shar(a.x,a.y);}
a[0].x=n;a[0].y=m; bud_random(a[0].x,a[0].y);
bud_tsagaan(a[urt-1].x,a[urt-1].y);
nosound();
}
}
void nud :: move_left(){
while ((!kbhit())) { sound(audio);
delay(delays);
if (check(urt)==1){
bool=1;
break;
}
if (a[0].x<=0){a[0].x=49;} if ((a[0].x==x1)&&(a[0].y==y1)){ urt++; score+=2; sanamsargui_tseg(urt); bud_tsenher(x1,y1); } a[0].x--; int n=a[0].x,m=a[0].y; for (int i=urt-1;i>0;i--){a=a[i-1];
if (i%2==1){
bud_nogoon(a.x,a.y);}
else bud_shar(a.x,a.y);}
a[0].x=n;a[0].y=m; bud_random(a[0].x,a[0].y);
bud_tsagaan(a[urt-1].x,a[urt-1].y);
nosound();
}
}
void main(){
l1:
bool=0;
Game_start();
int driver=DETECT, mode;
initgraph(&driver,&mode,"c:\\sharav_snack\\bgi");
randomize();
draw_pane(X,Y,X+70,Y+50);
Game();
Game_Over();
switch (getche()){
case 'r': {closegraph();score=0;goto l1; }
case 'R': {closegraph();score=0;goto l1; }
case 'q': {closegraph(); exit(0); break;}
case 'Q': {closegraph(); exit(0); break;}
}
closegraph();
}
 
You can find tons and tons of source code in the open source world. Just look for games that were released under the GNU GPL license.
 

Similar threads

  • · Replies 16 ·
Replies
16
Views
5K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 22 ·
Replies
22
Views
3K
  • · Replies 29 ·
Replies
29
Views
8K
  • · Replies 12 ·
Replies
12
Views
2K
Replies
69
Views
11K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K