C++课程设计日志

ANvDbg 2011-11-28 08:31:48
期末的课程设计不想做什么学生学籍,学生信息,学生成绩之类的,感觉好无聊,打算做一个深海潜艇的小游戏,七天为限,每天都上传当天做的东东,作为第一次做进行像样的程序的纪念:
第一天:课程设计实现内容分析

界面设计:一个30*30的二位数组ocen[30][30]

本船图标:$~~~$
敌船图标:(~~~)
本船子弹:$
敌船子弹:#

实现功能:
1.本船允许左右移动,每次位移为1个单位,允许发射子弹,间隔为3秒,初始位置为左顶格
2.敌船允许左右对发,只能沿当前位置向对面固定速度移动,每5秒从当前位置向本船当前位置发射一枚子弹
3.本船子弹为竖直下落,本船和敌船的子弹允许抵消
4.达到指定分数后按照时间来计算排名
有待扩展的内容:分数达到一定后允许提升关卡

类:地图类,本船类,敌船类,本船子弹类,敌船子弹类,分数类,计时类

本船类:
成员函数:构造,析构,发射子弹,被摧毁,移动
数据成员:模型
问题:模型算不算数据成员?

敌船类:
成员函数:构造,析构,发射子弹,被摧毁,移动
数据成员:模型
问题同上

地图类:
二位数组ocen

本船子弹类
成员函数:移动路线,击中,抵消
数据成员:模型

敌船子弹类
成员函数:移动路线,击中,抵消,移动
数据成员:模型

分数类
成员函数:增加分数,清零,记录,比较结束分数
数据成员:分数

计时类
返回结束时间,包括通关和被击中

有待开发:
通关到下一关
如何实现特殊子弹——————-跟踪弹和高速弹,发射方式为随机,出现关卡至少为第二关

明天就要开始编写程序了,晚上好好构思一下,感觉学的东西真的不够用了
...全文
363 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ANvDbg 2011-12-04
  • 打赏
  • 举报
回复
晚上截稿,做了一周,是什么样就是什么样吧
寒拓冰 2011-12-01
  • 打赏
  • 举报
回复
真的不错,看好楼主
ANvDbg 2011-11-30
  • 打赏
  • 举报
回复
修改一下昨天的代码 并附带上今天的成果:
//Fight.h
#include <iostream>
#include <string.h>

using namespace std;

typedef int status;

//functions,which are defined in Ocenfight.cpp
class Ocen
{
public:
Ocen();
void giveOcen();
char Sea[24][70];
int i;
int j;
};

class myBoot:public Ocen
{
public:
myBoot();
void setMyBoot();
void myMove(char c); //移动
int x1, x2, y1, y2;
};

class armyBoot
{
public:
armyBoot(){};
~armyBoot();
armyBoot(char *army);
void InitarmyBoot(char armysite);
char armyMove();
private:
char *Army;
char Armysite;
};

class myBullet
{
public:
myBullet(){};
~myBullet();
myBullet(char *bul); //初始化我的子弹模型
char myBulletMove();
status myBulletHit(); //击中 包括抵消和击中敌人
status armyDestory();
private:
char *bul;
};

class armyBullet
{
public:
armyBullet(){};
~armyBullet();
armyBullet(char *bul);
char myBulletMove();
status armyBulletHit();
status myDestory(); //destory my boot
private:
char *bul;
};

class score
{
public:
score(){};
~score();
score(int score);
int scoreCount();
private:
int Score;
};

//Fight.cpp
#include <iostream>
#include <string.h>
#include "Fight.h"
using namespace std;

Ocen::Ocen()
{
for(i = 0; i < 1; i++)
{
for(j = 0; j < 70; j++)
Sea[i][j] = '*';
}
for(i = 1; i < 23; i++)
{
for(j = 0; j < 70; j++)
Sea[i][j] = ' ';
}
for(i = 23; i < 24; i++)
{
for(j = 0; j < 70; j++)
Sea[i][j] = '*';
}
}

void Ocen::giveOcen()
{
for(i = 0; i < 24; i++)
{
for(j = 0; j < 70; j++)
{
cout << Sea[i][j];
}
cout << endl;
}
}

myBoot::myBoot()
{
Sea[2][1] = '$';
Sea[2][2] = '~';
Sea[2][3] = '~';
Sea[2][4] = '~';
Sea[2][5] = '$';
}

void myBoot::setMyBoot()
{
x1 = 2;
y1 = 1;
x2 = 2;
y2 = 5;
}

void myBoot::myMove(char c)
{
switch(c)
{
case 'a' :
if(x1 == x2)
{
Sea[x1][y1] = ' ';
Sea[x2][y2-1] = '$';
y2--;
y1--;
break;
}
if(x1 != x2)
if(x2 > x1)
{
Sea[x1][y1] = ' ';
Sea[x2][y2-1] = '$';
y2--;
x1++;
break;
}
if(x2 < x1)
{
Sea[x1][y1] = ' ';
Sea[x1][y2-1] = '$';
y2--;
x1--;
break;
}
case 'd' :
if(x1 == x2)
{
Sea[x1][y1] = ' ';
Sea[x2][y2+1] = '$';
y2++;
y1++;
break;
}
if(x1 != x2)
{
if(x2 < x1)
{
Sea[x1][y1] = ' ';
Sea[x2][y2+1] = '$';
y2++;
x1--;
break;
}
if(x2 > x1)
{
Sea[x1][y1] = ' ';
Sea[x2][y2+1] = '$';
y2++;
x1++;
break;
}
}
}
}

//main.cpp
#include <iostream>
#include <conio.h>
#include <stdlib.h>
#include <windows.h>
#include <string>
#include <ctime>
#include "Fight.h"
using namespace std;



int main()
{
string str="color ",e,f;
int h=2,t;
cout<<"请选择窗口背景颜色:"<<endl;
cout<<"0.黑色"<<'\n'<<"1.蓝色"<<'\n'<<"2.绿色"<<'\n'<<"3.湖蓝色"<<'\n'<<"4.红色"<<'\n'<<"5.紫色"<<'\n'<<"6.黄色"<<'\n'<<"7.白色"<<'\n'<<"8.灰色"<<'\n'<<"9.淡蓝色"<<endl;
cin>>e;
str=str+e;
cout<<"请选择前景颜色:"<<endl;
cout<<"A.淡绿色"<<'\n'<<"B.淡浅绿色"<<'\n'<<"C.淡红色"<<'\n'<<"D.淡紫色"<<'\n'<<"E.淡黄色"<<'\n'<<"F.亮白色"<<endl;
cin>>f;
str=str+f;
system(str.c_str());
Ocen ocen;
ocen.giveOcen();
myBoot myboot;
myboot.setMyBoot();

return 0;
}

今天感觉好了一点,搜集了不少的代码添加到程序里,终于实现了地图,本船和敌船都可以实现了,明天要把子弹类完善起来。
beigu 2011-11-29
  • 打赏
  • 举报
回复
我前些天也刚做完一个课程设计,因为学的不精,做了两星期(+熬夜)才做出来的。书到用时方恨少啊!
ANvDbg 2011-11-29
  • 打赏
  • 举报
回复
磨磨蹭蹭一天下来就把头文件给写了,还不知道里面有多少错误,只能等函数写完以后慢慢测试了,感觉就像是在造原子弹,学的东西感觉完全不够用

#ifndef OCENFIGHT_H_INCLUDED
#define OCENFIGHT_H_INCLUDED

#include <iostream>
#include <string>

using namespace std;

typedef int status;

//functions,which are defined in Ocenfight.cpp
class Ocen
{
public:
Ocen(){}; //default constructor
~Ocen(); //destory constructor
Ocen(char* sea); //constructor that initializes the background Ocen
private:
char *Sea; //backgroud for Ocen
};

class myBoot
{
public:
myBoot(){};
~myBoot();
myBoot(char *my);
void InitMyBoot(char mysite); //本船的初始化位置
status myDestory(); //摧毁
//返回一个二位的数组点能否用CHAR?
char myMove(); //移动
private:
char *My; //本船模型
char Mysite; //本船位置
};

class armyBoot
{
public:
armyBoot(){};
~armyBoot();
armyBoot(char *army);
void InitarmyBoot(char armysite);
status armyDestory();
char armyMove();
private:
char *Army;
char Armysite;
};

class myBullet
{
public:
myBullet(){};
~myBullet();
myBullet(char *bul); //初始化我的子弹模型
status myBulletHit(); //击中 包括抵消和击中敌人
private:
char *bul;
};

class armyBullet
{
public:
armyBullet(){};
~armyBullet();
armyBullet(char *bul);
status armyBullet();
private:
char *bul;
};

class score
{
public:
score(){};
~score();
score(int score);
int scoreCount();
private:
int Score;
};

//计时类如何实现

#endif // OCENFIGHT_H_INCLUDED


明天要加油了,这样的进度很不容乐观
羽飞 2011-11-28
  • 打赏
  • 举报
回复
顶一个
楼主强悍,当年我直接就上,写的一塌糊涂

64,644

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧