1.关于五子棋的开发与实现的计算机毕业设计
关于五子棋的毕业设计, 电脑已经深入到日常工作和生活的方方面面,比如文字处理、信息管理、辅助设计、图形图像处理、教育培训以及游戏娱乐等。
Windows系统的推出使电脑从高雅的学术殿堂走入了寻常百姓家,各行各业的人们无须经过特别的训练就能够使用电脑完成许许多多复杂的工作。然而,虽然现在世界上已经充满了花样繁多的各种软件,但它们依然不能满足用户的各种特殊需要,人们还不得不开发适合自己特殊需求的软件。
Java语言作为一种面向对象的编程语言,具有分布式,可移植,高性能,多线程等特点。通过系统的学习,人们就可以使用它开发出功能齐全,满足特殊需求的应用程序。
Java语言易学易用,对学习者掌握技能,开拓思维都有很大的帮助。我作为一名学生,在系统的学习了Java语言之后,经常用它搞一些小程序。
这次课程设计,我就想将学过的Java语言中的各种技术综合起来,编写一个小游戏,既对自己学过的技能进行一次检验,也能系统地将学过的知识复习巩固,具体的还是去三七论文网看看.occo.j2me.game.gobang;import javax.microedition.lcdui.Display;import javax.microedition.midlet.MIDlet;public class Gobang extends MIDlet { GobangCanvas gobang;//定义游戏界面的Canvas类GobangCanvas的对象gobang public Gobang() { super(); gobang=new GobangCanvas(this);//生成GobangCanvas类的对象gobang } protected void startApp(){ Display.getDisplay(this).setCurrent(gobang); //在屏幕上绘出游戏见面gobang } protected void pauseApp(){ } protected void destroyApp(boolean arg0){ }} 游戏界面类:GobangCanvas.javaGobangCanvas类是游戏的核心类,继承自Canvas,此类将完成游戏的逻辑、绘图、控制、互动等所有功能,此类的框架代码如下:package com.occo.j2me.game.gobang;import javax.microedition.lcdui.Canvas;import javax.microedition.lcdui.Command;import javax.microedition.lcdui.CommandListener;import javax.microedition.lcdui.Displayable;import javax.microedition.lcdui.Graphics;public class GobangCanvas extends Canvas implements CommandListener{ protected Gobang gobang; public GobangCanvas(){ } public GobangCanvas(Gobang gobang){ this.gobang=gobang; } protected void paint(Graphics g) { }} 棋子类:Chesses.java此类定义了一个棋子,棋盘上的每一个棋子都对应着一个Chesses的对象,整个棋盘是一个Chesses类型的二维数组,源代码如下:package com.occo.j2me.game.gobang; public class Chesses { boolean isPlayer1; public Chesses() { } public Chesses(boolean isPlayer1) { this.isPlayer1=isPlayer1; }} 添加图形图像到现在,我们已经完成了游戏的一个基本框架,接下来,我们就可以来绘制游戏的每一个部件了首先是五子棋的一些初始设置,添加如下代码到GobangCanvas.java 。 int empty;//游戏界面到屏幕边缘的留空 int canvasW,canvasH;//画布的长和宽 int chessLength;//棋子的直径 int chessMapLength,chessMapGrid,chessGridLength; //棋盘的边长,棋盘一边格子数,每格宽度 int chessMapX,chessMapY;//棋盘左上角x,y坐标 int selectedX,selectedY;//选择框在棋盘格局上的x,y位置 boolean isPlayer1;//是否是玩家1 Chesses[][] chesses;//棋子数组 boolean newGame;//是否是新的游戏 public GobangCanvas(Gobang gobang){ newGame=true; empty=10; canvasW=getWidth()-empty;canvasH=getHeight()-empty; chessMapGrid=15; chesses=new Chesses[chessMapGrid+1][chessMapGrid+1]; if(canvasW>canvasH){ chessMapLength=canvasH-canvasH%chessMapGrid; chessMapX=(canvasW-chessMapLength)/2+empty/2; chessMapY=(canvasH。
6.求高手帮忙写个毕业设计
效果图: 主要代码如下:(如不会贴代码,给我邮箱我给你发整个工程) #include "stdafx.h"#include "五子棋.h"#include "五子棋Dlg.h" #ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endifconst int MAX=12;int a[MAX][MAX];/////////////////////////////////////////////////////////////////////////////// CAboutDlg dialog used for App About class CAboutDlg : public CDialog{public: CAboutDlg(); // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // : //{{AFX_MSG(CAboutDlg) //}}AFX_MSG DECLARE_MESSAGE_MAP()}; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD){ //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) //}}AFX_DATA_MAP} BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) // No message handlers //}}AFX_MSG_MAPEND_MESSAGE_MAP() /////////////////////////////////////////////////////////////////////////////// CMyDlg dialog CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/) : CDialog(CMyDlg::IDD, pParent){ //{{AFX_DATA_INIT(CMyDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);} void CMyDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMyDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP} BEGIN_MESSAGE_MAP(CMyDlg, CDialog) //{{AFX_MSG_MAP(CMyDlg) ON_WM_SYSCOMMAND() ON_WM_DESTROY() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_WM_LBUTTONDOWN() //}}AFX_MSG_MAPEND_MESSAGE_MAP() /////////////////////////////////////////////////////////////////////////////// CMyDlg message handlers BOOL CMyDlg::OnInitDialog(){ CDialog::OnInitDialog(); // Add "About。
" menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control} void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam){ if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID, lParam); }} void CMyDlg::OnDestroy(){ WinHelp(0L, HELP_QUIT); CDialog::OnDestroy();} // If you add a minimize button to your dialog, you will need the code below// to draw the icon. For MFC applications using the document/view model,// this is automatically done for you by the framework. void CMyDlg::OnPaint() { HPEN hpen; HDC hdc; hdc=::GetDC(m_hWnd); hpen=(HPEN)SelectObject(hdc,GetStockObject(BLACK_PEN)); for(int i=0;i<=12;i++){ MoveToEx(hdc,i*40+17,17,NULL); LineTo(hdc,i*40+17,12*40+17); } for(i=0;i<=12;i++){ MoveToEx(hdc,17,i*40+17,NULL); LineTo(hdc,12*40+17,i*40+17); } DeleteObject(hpen); ::ReleaseDC(m_hWnd,hdc); if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); }} // The system calls this to obtain the cursor to display while the user drags// the minimized window.HCURSOR CMyDlg::OnQueryDragIcon(){ return (HCURSOR) m_hIcon;} void CMyDlg::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default HDC hdc。