用C或者C++编写一个陆军棋游戏软件设计

用C或者C++编写一个陆军棋游戏软件设计,第1张

/////////////////////////////培大//////////////腊中陪///轮蠢//////

//

// Luffar.H by Yuheng Zhao

//

////////////////////////////////////////////////////

#ifndef _LUFFAR_H_

#define _LUFFAR_H_

#include "shell.h"

// Visa upp informationen

class CMessagePad

{

private:

int x0,y0,x1,y1

int m_nShadow

// ruta d剅 texten ska visas

int mx0,my0,mx1,my1

int m_nLineSpace, m_nLines, m_nCurrentLine

public:

CMessagePad()

void ScrollMessages()

void Draw()

void Message(char* msg)

}

class CPlayer

{

private:

BOOL m_bComputer// Om det 剅 dator som k拦.

int m_nPlayer// Vilken spelare det 剅

public:

CPlayer(int p) {m_bComputer = FALSEm_nPlayer=p}

void ChangePlayer(BOOL com) {m_bComputer = com}

int WhichPlayer() {return m_nPlayer}

BOOL IsComputer() {return m_bComputer}

}

class CBoard

{

private:

// V剅det 0 om platsen 剅 tom, 1 f拦 spelaren 1, 2, f拦 spelare 2

int m_nBoard[MAX_X][MAX_Y]

// Var schackbr刣e ligger p?sk剅men.

int x0,y0,x1,y1// Positionen p?br刣et

int m_nMargin// Hur stor Marginal det br刣et ska ha

int m_nShadow// Hur l唍gt skuggan det ska vara

int m_nCellX// Storleken p?en cell p?br刣et

int m_nCellY

CPlayer* m_pPlayer1

CPlayer* m_pPlayer2

int m_nWhoBegins

CPlayer* m_pCurrentPlayer

BOOL m_bIsEmpty

// Skapa bilder i minnet och anv刵da PutImage() sedan

void CreateImages()

void *m_pImage1, *m_pImage2

CPoint m_lastPt

CPoint m_nextlPt// N剆t sista punkten

// Kalkylera ut hur m唍ga i rad det finns i ett visst h唋l

int Calculate(int x,int y,Direction d,int player=-1)

CPoint Analyse(int x, int y, int count,int param=0)

char msg[30]

CPoint RandomPoint()

CPoint Think()

CPoint GetEndPoint(int x, int y, Direction d, BOOL&closed)// Returnera punkten efter den sista punkten i en viss rad

CPoint FindDangerPt(int player)

BOOL m_bSearchAll

CPoint SearchAll(int,int, int param=0)

public:

CBoard(CPlayer* p1,CPlayer* p2)

~CBoard()

void ResetBoard()

void Draw()

int Go()// L唗 current player g拦a n剆ta drag, returnera vinnare om det finns

int GetWinner()

void ShowWinner(int x,int y,Direction start,int player=-1)

}

#endif

------------------------------------------------------------------------

////////////////////////////////////////////////////

//

// Mouse.h by Yuheng Zhao

//

////////////////////////////////////////////////////

#ifndef _MOUSE_H_

#define _MOUSE_H_

void InitMouse()

void ShowPoint()

void SetPoint(unsigned int x,unsigned int y)

void HidePoint()

void HidePointXY(unsigned int cordx,unsigned int cordy,unsigned int x,unsigned int y)

void ReleaseXY(int &xcordi,int &ycordi,unsigned int bbutt)

void PressXY(int &xcordi,int &ycordi,unsigned int bbutt)

void ReadMouse(int &x,int &y,int &b)

void Limits(unsigned int minx,unsigned maxX,unsigned miny,unsigned maxY)

int MouseSize()

#endif

--------------------------------------------------------------------------------

////////////////////////////////////////////////////

//

// Shell.H by Yuheng Zhao

//

////////////////////////////////////////////////////

#ifndef _SHELL_H_

#define _SHELL_H_

#include "luffar.h"

void InitGraphics()

void Cls()

void DrawBackground()

char ReadKey()

void Rectangle(int,int,int,int,int,BOOL shadow=FALSE,int deep=0)

void WaitDlg(int nMode=0, int nDelay=0)

int ShowWinDlg(CPlayer* winner)

void IntToChar(int, char*)

void Message(char*)

#endif

-----------------------------------------------------------

////////////////////////////////////////////////////

//

// Types.H by Yuheng Zhao

//

////////////////////////////////////////////////////

#ifndef _TYPES_H_

#define _TYPES_H_

#include <iostream.h>

#include <graphics.h>// c++ grafik,Inte sj刲v gjorda. ( ska 刵d?inte g拦a n唃ot grafisk avancerat sak )

#include <stdlib.h>

#include <process.h>

#include <string.h>

#include <alloc.h>

#include <dos.h>

#define MAX_X 19

#define MAX_Y 19

#define SCR_MAX_X 639

#define SCR_MAX_Y 479

#define NOCOLOR -1

#define BLACK 0

#define BLUE 1

#define GREEN 2

#define CYAN 3

#define RED 4

#define MAGENTA 5

#define BROWN 6

#define LGRAY 7

#define DGRAY 8

#define LBLUE 9

#define LGREEN 10

#define LCYAN 11

#define LRED 12

#define LMAGENTA 13

#define YELLOW 14

#define WHITE 15

enum BOOL{TRUE=1, FALSE=0}

enum Direction {LEFT,UPLEFT,UP,UPRIGHT,RIGHT,DOWNRIGHT,DOWN,DOWNLEFT}

class CPoint

{

public:

int x,y

CPoint() {x=-1y=-1}

CPoint(int xx,int yy) {x=xxy=yy}

CPoint(const CPoint* pt) {x=pt->xy=pt->y}

BOOL operator== (const CPoint&pt) const

const CPoint&operator= (const CPoint&pt)

}

class CRect

{

public:

int x0,y0,x1,y1

CRect(int xx0,int yy0,int xx1,int yy1) {x0=xx0y0=yy0x1=xx1y1=yy1}

CRect(const CRect* r) {x0=r->x0y0=r->y0x1=r->x1y1=r->y1}

const CRect&operator= (const CRect&pt)

BOOL PtInRect(const CPoint&pt)

void Draw(int,int lineColor=NOCOLOR,BOOL shadow=FALSE,int deep=0)

}

class CButton

{

public:

CRect m_Rect

char* m_pchName

BOOL m_bPressed

CButton(const CRect&rect,char* ch)

~CButton() {delete m_pchName}

void Draw()

// Kolla om n唃on har klickat p?knappen

BOOL Clicked(int,int,int)

void SetWindowText(char*)

}

#endif

想要完好军旗可以从以下三点入手:

第一,学习军棋基础入门知识,比如什么棋子能吃什么棋,哪些棋子只能直走不能拐弯等,这些都需要各位玩家提前弄清楚,避免孙衡塌在游戏中出错。另外在掌握一些最基本的知识之后,就开始利用这些游戏规则去试试看,看看自己对军棋游戏的基础知识掌握得够不够。最后就是在任何时候,都要学会灵活运用军棋游戏规则,这才是各位玩家拦祥们下棋的重中之重。

二:参与实践过程。在掌握基础的入门知识以后,则圆就要加大训练了,这里我建议各位玩家最好多跟高手接触接触,因为只有跟着掌握一起下棋一起试玩,才知道自己还欠缺哪些内容。其次在跟高手一起下棋的时候,你就会知道他们下军棋的干货内容,这也算是满满的干货了,比自己看一百次理论知识强多了。所以一定要多跟比自己厉害的人一起下军棋,虽然产生的结果不是很好,但只要次数够多,你下军棋的能力也会快速提升。

三:复盘与总结。当然了,想要下好军棋,就是及时进行复盘自己学过的军棋内容,对目前输的方法和赢得结果进行总结,看看有哪些地方是需要自己再去琢磨的,又有哪些地方是需要自己改正的。及时对这些内容进行排查,才能让自己的棋技一直持续增长,而且还会开发出更多下军棋的技巧。所以复盘与总结是需要一直进行的,而且在没事的时候多多看看自己复盘的内容,你才能对自己的棋技进行查漏补缺。

首先,要玩游戏首要的要先了解游戏的规则,要认识陆战棋也是一样,陆战棋也叫军棋,需两一玩,双方各均有25个棋,分别为军欧著科旗、司令、军长各一,师长、旅长、团长、营长、炸d各扮棚二,连长、排长、工兵、地雷各三

棋子与棋子这间吃法的规则依次为:

司令>军长>师长>旅长>团长>营长>连长>排长>工兵

当小棋遇大棋时除了逃只能被吃,若相同的棋子相遇时则是同归于尽,工兵可排除地雷,其他棋子是不能排雷,在地雷与其他棋子相遇时,若在可行棋的一方可选择炸对方或者高开,相陪缓反则主动权在对方。

军棋依次在棋盘上的摆法:

军棋棋盘的路线有:铁路线、公路线,每方包括5个行营、23个兵站、2个大本营

兵站上是棋子的摆放位置,铁路线是棋子的快行路线,若棋子只要在直线上或者弧型弯路上棋子行走可不限步数

棋盘上的公路线则是慢行线,在每次行棋哄脂时只能移动一步,中间的行营是棋子保护区,若棋子站在行营中时可以不受的攻击,同时在行营区的棋子行棋时每次只能移动一步芦缺模大本营处,是军旗所在位置,一边可随意摆放其他的任何棋子,工兵是比较特殊的存在,若处于铁路线上并线上没有其他的棋的话可直接飞行抵达棋盘上任何位置上

游戏规则,立起来的走法:

自己的棋盘棋位置可近观自己的想法进行排列,这就要看个人的排兵战略来取胜,

获胜的方法有,当炸掉对方军棋为胜,逼得对方无路可走时获胜,吃光对方所有的棋时为胜。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/12305626.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存