c语言汉字"下冰雹啦"编码是什么

c语言汉字"下冰雹啦"编码是什么,第1张

一般情况下,C/C++支持的是ASCII,不过汉字编码中,GB2312与ASCII是兼容的,所以可以在C中获得汉字的GB2312编汪陆没码悉镇,汉字是2个字节的,有高8位和低8位

采困纳用16进制表示,“下”是CFC2,“冰”是B1F9,“雹”是B1A2,“啦”是C0B2

'新建窗体,添加picture1,timer1,label1,option1(0-3)

’以下保存在模块module1.bas中:

Public Type stdball

ox As Integer

oy As Integer

ballcolor As ColorConstants

speed As Integer

End Type

Public Type stdspark

posx As Integer

posy As Integer

angle As Integer

sparkcolor As ColorConstants

speed As Integer

size As Integer

End Type

Public Type stdsparks

ox As Integer

oy As Integer

spark(9) As stdspark

End Type

'以下保存在窗体代码中:

Dim ball(9) As stdball, sparks(9) As stdsparks, x0 As Single, y0 As Single

Const pi = 3.14159265

Private Sub Form_Load()

initialgame 2, 1

End Sub

Private Sub picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)

For i = 0 To 9

If (x - ball(i).ox) ^ 2 + (y - ball(i).oy) ^ 2 <400 Then

initialspark i

initialball i

Label1.Tag = Split(Label1.Tag, "*")(0) + 1 &"*" &Split(Label1.Tag, "*")(1)

Label1.Caption = "分数:" &Split(Label1.Tag, "*")(0) &vbCrLf &"皮启能量:" &Split(Label1.Tag, "*")(1)

If Split(Label1.Tag, "*")(0) = 25 Then MsgBox "好样的,继续努力!"

If Split(Label1.Tag, "*")(0) = 50 Then MsgBox "太棒了,再射中50个你就过关了,努力啊!"

If Split(Label1.Tag, "*")(0) = 100 Then

MsgBox "恭喜你过关了,增加难度,再继滑握纤续!"

initialgame 3, 0

End If

If Split(Label1.Tag, "*")(0) = 150 Then initialgame 4, 0

Exit Sub

End If

Next

If Split(Label1.Tag, "*")(0) >0 Then Label1.Tag = Split(Label1.Tag, "*")(0) - 1 &"*" &Split(Label1.Tag, "信仿*")(1)

Label1.Caption = "分数:" &Split(Label1.Tag, "*")(0) &vbCrLf &"能量:" &Split(Label1.Tag, "*")(1)

End Sub

Private Sub picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)

x0 = x: y0 = y

End Sub

Private Sub Option1_Click(index As Integer)

initialgame index + 1, 0

End Sub

Private Sub Timer1_Timer()

Picture1.BackColor = Picture1.BackColor

For i = 0 To 9

drawball i

drawspark i

Next

End Sub

Sub initialball(ByVal index As Integer) '初始化圆球

Dim awx() As Integer, n As Integer '将游戏窗口picture1沿x轴等分15段(每段50),10个球随机占用这15段,为保证每一段内只有一个球,awx()用来存储未被占用的断的中点x(圆球球心)坐标

For x = 0 To 14 '计算存储未被占用的段

For i = 0 To 9

If ball(i).ox = x * 50 + 25 Then Exit For

Next

If i = 10 Then

ReDim Preserve awx(n)

awx(n) = x * 50 + 25

n = n + 1

End If

Next

ball(index).ox = awx(Int(Rnd * n)) '随机选择未被占用的段

ball(index).oy = Int(Rnd * (-100))

ball(index).speed = Int(Rnd * Me.Tag + 1) '下落速度

ball(index).ballcolor = QBColor(Int(Rnd * 15)) '颜色

End Sub

Sub initialspark(ByVal index As Integer) '初始化火花

sparks(index).ox = ball(index).ox '爆炸圆心

sparks(index).oy = ball(index).oy

For i = 0 To 9

sparks(index).spark(i).posx = ball(index).ox '火花位置

sparks(index).spark(i).posy = ball(index).oy

sparks(index).spark(i).angle = Int(Rnd * 361) * pi / 180 '角度

sparks(index).spark(i).sparkcolor = ball(index).ballcolor '颜色

sparks(index).spark(i).speed = Int(Rnd * 15 + 10) '速度

sparks(index).spark(i).size = Int(Rnd * 12 + 5) '大小

Next

End Sub

Sub drawball(ByVal index As Integer) '画圆球

Picture1.FillStyle = 0 '实体填充

Picture1.FillColor = ball(index).ballcolor '填充颜色

Picture1.DrawWidth = 1 '线宽1

ball(index).oy = ball(index).oy + ball(index).speed '计算圆球y轴位置

Picture1.Circle (ball(index).ox, ball(index).oy), 20, vbWhite

Picture1.FillColor = vbWhite '高光颜色

Picture1.Circle (ball(index).ox + 15 * Cos((3625 - 2 * ball(index).oy) * pi / 2900), ball(index).oy - 15 * Sin((3625 - 2 * ball(index).oy) * pi / 2900)), 3, vbWhite

Picture1.DrawWidth = 4

Picture1.Circle (ball(index).ox, ball(index).oy), 15, vbWhite, (2175 + ball(index).oy) * pi / 1450, ball(index).oy * pi / 1450 'pi * 3 / 2, 2 * pi

If (x0 - ball(index).ox) ^ 2 + (y0 - ball(index).oy) ^ 2 <400 Then '计算被瞄准的圆球

Picture1.DrawWidth = 1

Picture1.FillColor = vbRed

Picture1.Circle (ball(index).ox, ball(index).oy), 3, vbWhite

Picture1.FillStyle = 1 '透明填充

Picture1.Circle (ball(index).ox, ball(index).oy), 30, vbRed

Picture1.Line (ball(index).ox - 30, ball(index).oy)-(ball(index).ox + 30, ball(index).oy), vbRed

Picture1.Line (ball(index).ox, ball(index).oy - 30)-(ball(index).ox, ball(index).oy + 30), vbRed

End If

If ball(index).oy - 25 >Picture1.ScaleHeight Then '判断落地

initialball index

If Split(Label1.Tag, "*")(1) >1 Then '能量减1

Label1.Tag = Split(Label1.Tag, "*")(0) &"*" &Split(Label1.Tag, "*")(1) - 1

Label1.Caption = "分数:" &Split(Label1.Tag, "*")(0) &vbCrLf &"能量:" &Split(Label1.Tag, "*")(1)

Else

Label1.Caption = "分数:" &Split(Label1.Tag, "*")(0) &vbCrLf &"能量:0"

MsgBox "你失败了,别灰心,降低难度,请重来!"

initialgame IIf(Me.Tag >1, Me.Tag - 1, 1), 1

End If

End If

End Sub

Sub drawspark(ByVal index As Integer) '画火花

If sparks(index).ox <>0 And sparks(index).oy <>0 Then

isout = 1

For i = 0 To 9

If Abs(sparks(index).spark(i).posx - sparks(index).ox) <100 And Abs(sparks(index).spark(i).posy - sparks(index).oy) <50 Then

isout = 0

sparks(index).spark(i).posx = sparks(index).spark(i).posx + sparks(index).spark(i).speed * Cos(sparks(index).spark(i).angle)

sparks(index).spark(i).posy = sparks(index).spark(i).posy - sparks(index).spark(i).speed * Sin(sparks(index).spark(i).angle)

Picture1.DrawWidth = sparks(index).spark(i).size

Picture1.PSet (sparks(index).spark(i).posx, sparks(index).spark(i).posy), sparks(index).spark(i).sparkcolor

End If

Next

If isout = 1 Then sparks(index).ox = 0: sparks(index).oy = 0

End If

End Sub

Sub initialgame(ByVal level As Integer, ByVal isclear As Integer) '初始化游戏

Option1(0).Caption = "简单"

Option1(1).Caption = "中等"

Option1(2).Caption = "较难"

Option1(3).Caption = "高级"

Option1(level - 1).Value = True '设置单选框选中当前难度级别

Timer1.Interval = 20

Me.ScaleMode = 3'像素模式

Picture1.ScaleMode = 3 '设置游戏窗口信息

Picture1.AutoRedraw = True

Picture1.Width = 760

Picture1.Height = 500

If isclear = 1 Then '清零积分和能量

Label1.Caption = "分数:0" &vbCrLf &"能量:5"

Label1.Tag = "0*5"

End If

Me.Tag = level '保存当前等级

For i = 0 To 9 '初始化球圆球信息

initialball i

Next

End Sub

class CUserWnd

{

public:

BOOL SetButtonInfo(const std::vector<UserData::ButtonInfo>&vtBtnInfo)

BOOL SetTextInfo(const std::vector<UserData::TextInfo>&vtTxtInfo)

BOOL SetProgressInfo(const std::vector<CProgress>&vtPrgInfo)

BOOL SetBackground(UserData::BackgroundInfo bkInfo)

...

}

然后对于不同功能的界面,我们只需要设置不同的数值即可:

//背光窗口

pWndBacklight->SetButtonInfo(vtBtnInfo1)

pWndBacklight->SetTextInfo(vtTxtInfo1)

pWndBacklight->SetBackground(bkInfo1)

//电池窗塌迟口

pWndBattery->SetButtonInfo(vtBtnInfo2)

pWndBattery->SetTextInfo(vtTxtInfo2)

pWndBattery->SetBackground(bkInfo2)

这丛简样我们只需要团郑李一个窗口类,就能实现变化各异的界面。

在这里还有一点需要提一下,一般来说,我们显示界面和功能的实现应该分开,这样代码看起来就不会变得杂乱无章。我们可以采用这么一种做法,定义一个CCommand类,主要是执行按钮的相关功能 *** 作,然后窗口类继承于该类即可:

class CCommand

{

protected:

BOOL ExecuteCmd(UserData::CtrlIndex ctrlIndex,DWORD dwParam)

....

}

BOOL CCommand::ExecuteCmd(UserData::CtrlIndex ctrlIndex,DWORD dwParam)

{

switch(ctrlIndex)

{

case UserData::BTN_EXIT:

{

return OnCmdExit()

}

case UserData::BTN_EXPLORER:

{

//Execute the explorer and then exit the application

CCommon::Execute(m_Option.GetPathTab(Option::PATH_EXPLORER).c_str())

}

...

}

}

//窗口的继承

class CUserWnd:

public CCommand

{

...

}

.

希望能够帮助你 ^_^ 也希望能够选为最佳答案!


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

原文地址: http://www.outofmemory.cn/yw/12365660.html

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

发表评论

登录后才能评论

评论列表(0条)

保存