c++游戏“抽卡世界”开发日志第1期

代码一览

可复制,但勿抄

有那么亿点长,不想看的可以在目录中跳到开发过程部分

#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#define cl "cls"
using namespace std;
int key(){
	int k;
	while(1){
		if(_kbhit()){
			k=getch();
			break;
		}
	}
	return k;
}
void setcolor(int FC, int BC){
    WORD wColor=((BC&0x0F)<<4)+(FC&0x0F);
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),wColor);
    //8,10,3,4,13,6,11,12(字色);10,3,4,13,6,11,12(底色)
}
void strout(const char *n){
	for(int i=0;i<strlen(n);i++){
		cout<<n[i];
		Sleep(50);
	}
}
void strvout(string n){
	 for(int i=0;i<n.size();i++){
		cout<<n[i];
		Sleep(50);
	}
}
void numout(int n){
	int s=0,ss=0;
	while(n){
		s*=10;
		s+=(n%10);
		ss++;
		n/=10;
	}
	for(int i=0;i<ss;i++){
		cout<<s%10;
		Sleep(50);
		s/=10;
	}
}
int main(){
	srand(unsigned(time(NULL)));
	int coin=100,card[16]={},z=1,cnow=1,coinz[16]={10,15,20,30,50,75,100,150,
	225,500,750,1000,1300,1750,2500};
	string cardz[16]={"R","SR","SSR","PR","SPR","LR","SLR","PLR","SP","SSP",
	"SRP","SLP","GP","CP","TP"};
	int ks[16]={4,3,2,3,2,3,1,1,2,1,1,0,1,1,1},ran,sran;
	int colf[16]={8,10,3,4,13,6,11,12,15,15,15,15,15,15,15};
	int colb[16]={0,0,0,0,0,0,0,0,10,3,4,13,6,11,12};
	Sleep(1000);
	strout("沈涵出品\n绝对极品\n");
	Sleep(500);
	strout("欢迎来到——抽卡世界!!!\n");
	Sleep(500);
	cout<<"资源加载中...\n";
	strout("_-|!+=/*&#@\n_-|!+=/*&#@\n_-|!+=/*&#@\n_-|!+=/*&#@\n");
	cout<<"加载完毕!\n按下任意键开始游戏";
	key();
	system(cl);
	cout<<"新手指南:\n";
	Sleep(500);
	strout("你在刚开始时有100个金币\n你可以通过抽卡来得到更多资源\n");
	Sleep(500);
	cout<<"按下c键打开抽卡台\n";
	while(1){
		if(key()=='c'){
			break;
		}
	}
	cnow=1;
	strout("--------抽卡台-------\n");
	for(int i=0;i<z;i++){
		strout("|");
		setcolor(colf[i],colb[i]);
		strvout(cardz[i]);
		setcolor(7,0);
		strout("级卡包:");
		numout(coinz[i]);
		strout("金币");
		for(int j=0;j<ks[i];j++){
			strout(" ");
		}
		strout("|");
		if(cnow-1==i){
			strout("←当前选择");
		}
		strout("\n");
	}
	strout("---------------------\n");
	strout("很好!现在按下n键抽卡");
	while(1){
	    if(key()=='n'){
			break;
		}
	}
	for(int i=0;i<20;i++){
		system(cl);
		ran=rand()%z;
		sran=rand()%3+1;
		cout<<"求签中...\n[";
		for(int j=0;j<i+1;j++){
			cout<<"#";
		}
		for(int j=0;j<19-i;j++){
			cout<<" ";
		}
		cout<<"]";
		Sleep(10);
	}
	Sleep(500);
	system(cl);
	cout<<"太好了!\n";
	Sleep(500);
	strout("你抽到了......");
	Sleep(500);
	setcolor(8,0);
	strvout(cardz[ran]);
	strout("*");
	numout(sran);
	setcolor(7,0);
	strout("!恭喜~");
	return 0;
}

开发过程

看到同学的游戏“赚钱世界2.0.4”

码量428行(也不多嘛

突发奇想:欸!我也做个游戏!

emm...做抽卡吧

说干就干!!!

先把基本函数干了!

基本函数部分

检测键盘

设置单字输出颜色

逐字输出(字符串常量)

逐字输出(字符串变量)

逐字输出(整型)

再来个帅气的开场界面(显出一副装B的样子

主函数部分

开场界面

还要有教程! 

主函数部分

开场界面

新手教程(未完工)

 手酸了,发现自己打了3小时代码才打了129行😅

反正这篇文章也有2289个字了,发文吧!

(水,这篇文章不要太水了)

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值