在网上了一个c语言源代码,游戏源码游戏里面很多.c.h文件,大全代码请问我要怎么编译才能运行起来
首先读一下readme文件,闯关闯关ugui源码下载看一下这个游戏的游戏源码游戏编译环境是怎么样的,是大全代码运行在win下还是linux,然后在正确的环境下使用游戏代码中的Makefile文件来编译这个游戏。我假设它是linux pppd 源码vc6编写的,那么可以这么做。我的vc6文件目录位于C:\Program Files (x)\Microsoft Visual Studio\VC\Bin。在命令提示符下进入这个目录后,运行目录下的struts源码编译vars.bat设置环境,再用cd命令转到游戏代码目录,执行nmake /f makefile,看一下编译结果,如果正确的话,就会生成可执行文件了。如果不对,要么适当修改游戏代码,要么调整一下Makefile文件的内容,这是细活,得慢慢琢磨。
用c++来编写一个小游戏的源代码,要-行就可以了,可以再vc环境下运行就可。。。本人急需!~!~!
//作者:小斌
#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
//using namespace std;
const char LEFT=0x4b;
const char RIGHT=0x4d;
const char DOWN=0x;
const char UP=0x;
const char ESC=0x1b;
const char ENTER=0x0d;
const int BX=;
const int BY=;
const int SQ=;
const int SQCL=;
const int BkCl=BLUE;
const int SHAP1=2;
const int SHAP2=3;
const int SHAP3=4;
const int SHAP4=5;
void drawxiao(int &x, int &y)
{
int a=x*SQ+BX, b=y*SQ+BY;
setfillstyle(1, SQCL);
bar(a+1, b+1, a+SQ-1, b+SQ-1);
}
void clearxiao(int &x, int &y)
{
int a=x*SQ+BX, b=y*SQ+BY;
setfillstyle(1, BkCl);
bar(a+1, b+1, a+SQ-1, b+SQ-1);
}
void goleft(int &x, int &y)
{
if(x>0)
{
clearxiao(x, y);
drawxiao(--x, y);
}
}
void goright(int &x, int &y)
{
if(x<7)
{
clearxiao(x, y);
drawxiao(++x, y);
}
}
void godown(int &x, int &y)
{
if(y<7)
{
clearxiao(x, y);
drawxiao(x, ++y);
}
}
void goup(int &x, int &y)
{
if(y>0)
{
clearxiao(x, y);
drawxiao(x, --y);
}
}
void end()
{
closegraph();
exit(1);
}
void move(int &x, int &y)
{
int n=1;
drawxiao(x, y);
while(n)
switch(getch())
{
case LEFT :goleft(x, y); break;
case RIGHT :goright(x, y); break;
case DOWN :godown(x, y); break;
case UP :goup(x, y); break;
case ENTER :n=0; break;
case ESC :end();
}
}
void qipan()
{
int i;
setbkcolor(BkCl);
setfillstyle(1, );
for(i=0; i<9; i++)
{
line(BX, i*SQ+BY, BX+8*SQ, i*SQ+BY);
line(i*SQ+BX, BY, i*SQ+BX, BY+8*SQ);
}
}
void shap1(int x, int y)
{
int a=x*SQ+BX, b=y*SQ+BY;
setfillstyle(1, SHAP1);
bar(a+1, b+1, a+SQ-1, b+2*SQ-1);
bar(a-SQ+1, b+1+SQ, a, b-1+2*SQ);
}
void shap2(int x, int y)
{
int a=x*SQ+BX, b=y*SQ+BY;
setfillstyle(1, SHAP2);
bar(a+1, b+1, a+SQ-1, b+2*SQ-1);
bar(a+SQ, b+SQ+1, a+2*SQ-1, b+2*SQ-1);
}
void shap3(int x, int y)
{
int a=x*SQ+BX, b=y*SQ+BY;
setfillstyle(1, SHAP3);
bar(a+1, b+1, a+2*SQ-1, b+SQ-1);
bar(a+SQ+1, b+SQ, a+2*SQ-1, b+2*SQ-1);
}
void shap4(int x, int y)
{
int a=x*SQ+BX, b=y*SQ+BY;
setfillstyle(1, SHAP4);
bar(a+1, b+1, a+2*SQ-1, b+SQ-1);
bar(a+1, b+SQ, a+SQ-1, b+2*SQ-1);
}
void chessboard(int size, int tr, int tc, int dr, int dc)
{
if(size>=2)
{
size=size/2;
if(dc<tc+size)//左边半个棋盘
{
if(dr<tr+size)//左上
{
shap1(tr+size, tc+size-1);
chessboard(size, tr, tc, dr, dc);
chessboard(size, tr+size, tc, tr+size, tc+size-1);
}
else//左下
{
shap2(tr+size-1, tc+size-1);
chessboard(size, tr, tc, tr+size-1, tc+size-1);
chessboard(size, tr+size, tc, dr, dc);
}
chessboard(size, tr, tc+size, tr+size-1, tc+size);
chessboard(size, tr+size, tc+size, tr+size, tc+size);
}
else//在右边半个棋盘
{
if(dr<tr+size)//右上
{
shap3(tr+size-1, tc+size-1);
chessboard(size, tr, tc+size, dr, dc);
chessboard(size, tr+size, tc+size, tr+size, tc+size);
}
else//右下
{
shap4(tr+size-1, tc+size-1);
chessboard(size, tr, tc+size, tr+size-1, tc+size);
chessboard(size, tr+size, tc+size, dr, dc);
}
chessboard(size, tr, tc, tr+size-1, tc+size-1);
chessboard(size, tr+size, tc, tr+size, tc+size-1);
}
}
}
int main()
{
int driver=DETECT, mode;
int x=0, y=0;
initgraph(&driver, &mode, "C:\\JMSOFT\\DRV");
qipan();//画棋盘
move(x, y);//移动特殊方格
chessboard(8, 0, 0, x, y);//覆盖棋盘
getch();
return 0;
}
急求VC源代码
(1)
#include<iostream>
using namespace std;
int main()
{
float num1,num2;
char ch;
begin:
cout<<"请输入第1个数:\n";
cin>>num1;
cout<<"请输入运算符:\n";
cin>>ch;
cout<<"请输入第2个数:\n";
cin>>num2;
switch(ch)
{
case '+':
cout<<"结果:"<<num1+num2<<endl;
break;
case '-':
cout<<"结果:"<<num1-num2<<endl;
break;
case '*':
cout<<"结果:"<<num1*num2<<endl;
break;
case '/':
if(int(num2)!=0)
{
cout<<"结果:"<<num1/num2<<endl;
}
else
{
cout<<"除数不能为0,请重新输入.\n";
goto begin;
}
break;
default:
cout<<"你输入的运算符错误,请重新输入.\n";
goto begin;
}
getchar();
return 0;
}
(2)
#include <iostream>
#include<string>
using namespace std;
int main()
{
char num1[];
char num2[];
char ch;
int n=0;
int i=0;
float count=0;
string inStr;
begin:
cout<<"请输入:";
cin>>inStr;
memset(num1,0,);
memset(num2,0,);
for(i=0; inStr[i]!='\0'; i++)
{
if(inStr[i]=='+' ||inStr[i]=='-' ||inStr[i]=='*' ||inStr[i]=='/' )
{
break;
}
else
{
num1[i]=inStr[i];
}
}
ch=inStr[i];
i++;
for(; inStr[i]!='\0'; i++)
{
if(inStr[i]=='+' ||inStr[i]=='-' ||inStr[i]=='*' ||inStr[i]=='/' )
{
break;
}
else
{
num2[n]=inStr[i];
n++;
}
}
switch(ch)
{
case '+':
count=float(atoi(num1))+float(atoi(num2));
break;
case '-':
count=float(atoi(num1))-float(atoi(num2));
break;
case '*':
count=float(atoi(num1))*float(atoi(num2));
break;
case '/':
if(atoi(num2)!=0)
{
count=float(atoi(num1))/float(atoi(num2));
}
else
{
cout<<"除数不能为0"<<endl;
goto begin;
}
break;
}
cout<<"结果是:"<<count<<endl;
}
祝你好运了!!!!!!!!!!!!!
2024-11-29 23:46
2024-11-29 22:52
2024-11-29 22:02
2024-11-29 22:02
2024-11-29 21:23