课件编号4142900

第十四课 抓球游戏 教案

日期:2024-05-05 科目:信息技术 类型:初中教案 查看:78次 大小:119063Byte 来源:二一课件通
预览图 1/1
第十四,抓球,游戏,教案
  • cover
第十四课 抓球游戏 教案 1.进一步熟悉逻辑运算符“and”的使用方法。 2.进一步熟悉事件驱动程序的编写方法。 抓球游戏的算法比较简单,不需要流程图,学生可以直接编写程序代码。 小球跳动的位置坐标由下面的命令随机产生: x=Math.GetRandomNumber(GraphicsWindow.Width)、 y=Math.GetRandomNumber(GraphicsWindow.Height) 在上面的命令中,随机函数的参数是GraphicsWindow.Width和 GraphicsWindow.Height,这样就保证了不管在程序的运行过程中如何改变图形 窗口的大小,小球的位置坐标始终在图形窗口中。21·cn·jy·com 1、抓球游戏: ball=shapes.AddEllipse(20,20) GraphicsWindow.BrushColor="red" GraphicsWindow.MouseDown = OnMD While ("true") x=Math.GetRandomNumber(GraphicsWindow.Width) y=Math.GetRandomNumber(GraphicsWindow.Height) Shapes.Move(ball,x ,y) Program .Delay (1000) EndWhile Sub OnMD xMS = GraphicsWindow.MouseX yMS = GraphicsWindow.MouseY If xMS>=x and xMS<=x+20 and yMS>=y and yMS<=y+20 then 21世纪教育网版权所有 GraphicsWindow.FillEllipse(x, y, 20, 20) GraphicsWindow.ShowMessage ("点中了!","你真棒!") EndIf EndSub 2、编写一个拉幕布的程序。点击鼠标把幕布拉上,再点鼠标把幕布拉开。 GraphicsWindow.MouseDown=onMD i=1 Sub onMD If i=1 Then For x=0 To GraphicsWindow.Width GraphicsWindow.PenColor =GraphicsWindow.GetRandomColor() GraphicsWindow.DrawLine(x,0,x,GraphicsWindow.Height) 21cnjy.com Program.Delay(10) EndFor i=0 Else GraphicsWindow.PenColor ="white" For x=0 To GraphicsWindow.Width GraphicsWindow.DrawLine(x,0,x,GraphicsWindow.Height) 21教育网 Program.Delay(10) EndFor i=1 EndIf EndSub

~~ 您好,已阅读到文档的结尾了 ~~