前提准备条件:安装gcc环境,可以百度也
可以安装这个链接:https://pan.baidu.com/s/1BbXFcBZywK-k-eIkWqY3Ug
提取码:04wp
复制这段内容后打开百度网盘手机App,操作更方便哦,直接解压,然后放到环境变量中。
代码:
主文件:
package main import ( "Clib" "fmt" "math/rand" "os" "time" ) //全局常量 界面大小 const WIDE int = 20 const HIGH int = 20 //存储食物 var food Food //分数 var score = 0 //初始化父类 坐标 type Position struct { X int Y int } type Food struct { Position } //随机食物 func RandomFood() { food.X = rand.Intn(WIDE) + 1 food.Y = rand.Intn(HIGH) //显示食物位置 ShowUI(food.X, food.Y, '#') } func MapInit() { fmt.Fprintf(os.Stderr, ` #-----------------------------------------# | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | #