拼图游戏C语言课设实验报告,C语言拼图游戏实验报告.doc

C语言拼图游戏实验报告

课程设计实验报告

班级:光电104—2 姓名:刘云龙 学号:201058501220

一、实验题目:使用C语言编写一个小游戏(拼图游戏)

二、实验目的:C语言是每一个通信学生的必修课之一,此次课程设计要求我们使用C语言编写一个小游戏,在完成课程设计的过程中,加强了我们对C语言的综合应用。虽然在平时的课堂上积累了很多的理论知识,但在实际应用时还是有很多不明白的地方。为了更好地完成实验要求,通过翻课本,请教同学,在网上查找资料等途径解决了试验中遇到的疑难。在完成实验的过程中,暴露了自己在C语言学习上的很多不足和缺陷,同时也解决了很多平时不明白的地方。

三、实验内容

本次试验选定的实验项目是使用C语言编写一个拼图游戏

以下是拼图游戏的源代码:

// 九宫格拼图Dlg.cpp : implementation file

//

#include "stdafx.h"

#include "九宫格拼图.h"

#include "九宫格拼图Dlg.h"

#include "spell.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

CSpell spell(3, 3, 2, 2);

//

//

void ShowTranBmp(CDC * dc, CBitmap * bmp, COLORREF bgcolor, int x, int y, int w, int h, int bx, int by, int bw, int bh){

CDC mdc;

CDC tdc; // 图像

CDC ddc; // 遮罩

CBitmap tbmp;

CBitmap dbmp;

CBitmap *ob;

CBitmap *tob;

CBitmap *dob;

mdc.CreateCompatibleDC(dc);

tdc.CreateCompatibleDC(dc);

ddc.CreateCompatibleDC(dc);

tbmp.CreateBitmap(bw, bh, 1, 32, NULL);

dbmp.CreateBitmap(bw, bh, 1, 1, NULL);

ob = mdc.SelectObject(bmp);

tob = tdc.SelectObject(&tbmp);

dob = ddc.SelectObject(&dbmp);

tdc.BitBlt(-bx, -by, bw+bx, bh+by, &mdc, 0, 0, SRCCOPY);

tdc.SetBkColor(bgcolor);

ddc.BitBlt(0, 0, bw, bh, &tdc, 0, 0, SRCCOPY);

///

//显示

dc->BitBlt(x, y, w, h, &tdc, 0, 0, SRCINVERT);

dc->BitBlt(x, y, w, h, &ddc, 0, 0, SRCAND);

dc->BitBlt(x, y, w, h, &tdc, 0, 0, SRCINVERT);

mdc.SelectObject(ob);

tdc.SelectObject(tob);

ddc.SelectObject(dob);

}

void ShowTranBmp(CDC * dc, CBitmap * bmp, COLORREF bgcolor, int x, int y, int w, int h){

CDC tdc; // 图像

CDC ddc; // 遮罩

CBitmap dbmp;

CBitmap *tob;

CBitmap *dob;

tdc.CreateCompatibleDC(dc);

ddc.CreateCompatibleDC(dc);

dbmp.CreateBitmap(w, h, 1, 1, NULL);

tob = tdc.SelectObject(bmp);

dob = ddc.SelectObject(&dbmp);

tdc.SetBkColor(bgcolor);

ddc.BitBlt(0, 0, w, h, &tdc, 0, 0, SRCCOPY);

///

//显示

dc->BitBlt(x, y, w, h, &tdc, 0, 0, SRCINVERT);

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值