vfp小游戏程序问题请教
本人只是学了vfp的基础知识,现在想做一个小游戏,实现字体的颜色随机变换,比如“红”字,字体颜色是其他颜色例如蓝色,然后随机变换成其他字,颜色也随机变,实现计数器变换10次,我想知道用vfp可不可以完成呢?有没有高手可以分享一下方法?
[解决办法]
Public oform1oform1=Newobject("form1")oform1.ShowReturnDefine Class form1 As Form Top = 0 Left = 0 Height = 250 Width = 343 DoCreate = .T. Caption = "Form1" Name = "Form1" Add Object label1 As Label With ; AutoSize = .F., ; FontSize = 30, ; Alignment = 2, ; BackStyle = 0, ; Caption = "", ; Height = 64, ; Left = 36, ; Top = 20, ; Width = 256, ; Name = "Label1" Add Object timer1 As Timer With ; Top = 144, ; Left = 120, ; Height = 23, ; Width = 23, ; Enabled = .F., ; Interval = 2000, ; && 变换间隔为 2 秒 Name = "Timer1" Add Object command1 As CommandButton With ; Top = 144, ; Left = 168, ; Height = 25, ; Width = 60, ; Caption = "开始变换", ; Name = "Command1" Procedure Load Public aHZ(5),gnChangeNum aHZ(1)='红' aHZ(2)='黄' aHZ(3)='蓝' aHZ(4)='白' aHZ(5)='黑' gnChangeNum=0 Create Cursor t1 (nColor I) Insert Into t1 Values (255) && 红色 Insert Into t1 Values (65535) && 黄色 Insert Into t1 Values (16711680) && 蓝色 Insert Into t1 Values (16777215) && 白色 Insert Into t1 Values (0) && 黑色 Rand(-1) Endproc Procedure timer1.Timer If gnChangeNum<10 && 变换次数为10 Thisform.Label1.Caption=aHz(Int(5*Rand()+1)) && 因为是 5 个字,所以随机数为 1-5 Select t1 Go (Int(5*Rand()+1)) && 因为是 5 种颜色,所以随机数为 1-5 Thisform.Label1.ForeColor=nColor gnChangeNum=gnChangeNum+1 Thisform.Command1.Caption=Transform(gnChangeNum) Else This.Enabled=.F. Thisform.Command1.Caption='开始变换' Thisform.Command1.Enabled=.T. Endif Endproc Procedure command1.Click This.Enabled=.F. Thisform.Timer1.Enabled=.T. gnChangeNum=0 EndprocEnddefine
[解决办法]
添加五个按钮:
Add Object command2 As CommandButton With ; && command3 ..如此类推
Top = 144, ; &&这系列坐标自行定义
Left = 168, ;
Height = 25, ;
Width = 60, ;
BackColor =255, ; &&这是红色,其他类推
Name = "Command2" && command3 ..如此类推