- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
snake1(国外英语资料)
snake1(国外英语资料)
伪代码:
各种定义
architecture of snake snake _ 1 ice
component 分频器
gate (clk: in std _ logic; - - 系统时钟
clk0: _ out std logic; - - 游戏控制时钟1hz
clk1: _ out std logic - - 1khz分频时钟
);
than component;
type all _ state ice (开始 / 复位, 游戏中, 死亡结束)
signal 游戏状态, 下一状态: all _ state;
各种信号定义
begin
process (clk) 状态寄存
begin
if时钟上升沿到来then
游戏状态 = 下一状态
than if
than process
process (clk) 输出逻辑
begin
if时钟上升沿到来then
case游戏状态 ice
when 开始 / 复位 = 显示蛇, 老鼠, 墙, 倒计时和得分的初始状态
when 游戏中 = 显示蛇和老鼠的动态, 墙的静态, 倒计时和得分
when 死亡结束 = 全屏灭, 保留显示得分, 倒计时清零
when 赢了 = 全屏亮, 保留分数, 倒计时清零
than case
than if
than process
process (clk0) 次态逻辑
begin
if游戏控制时钟的上升沿到来then
case复位键状态 ice
when 1 = 开始 / 复位
游戏初始化
when 0 =
if撞墙then
蛇死亡, 游戏结束
else
蛇正常移动, 游戏中
case倒计时重置is
when 重置 = count = 0; 倒计时重置 = 0;
when 不重置 = if (count = 4) then
count = 0;
倒计时状态 = 结束;
else
count = count + 1;
倒计时状态 = 未结束;
than if;
case倒计时状态 ice
when 未结束 =
if吃到老鼠then
if分数最高then
下一状态 = 赢了
else
增加得分
than if
产生新老鼠
倒计时重置 = 1;
than if
when 结束 =
产生新老鼠
倒计时重置 = 1;
than case
case方向按键状态is
when 上 = case 蛇的当前方向 ice
when 下 = h1 = h1 - 1;
when others = h1 = h1 + 1; 蛇的当前方向 = 上;
when 下 = case 蛇的当前方向 ice
when 上 = h1 = h1 + 1;
when others = h1 = h1 - 1; 蛇的当前方向 = 下;
when 左 = case 蛇的当前方向 ice
when 右 = l1 = l1 + 1;
when others = l1 = l1 - 1; 蛇的当前方向 = 左;
when 右 = case 蛇的当前方向 ice
when 左 = l1 = l1 - 1;
when others = l1 = l1 + 1; 蛇的当前方向 = 右;
when others = case 蛇的当前方向 ice
when 上 = h1 = h1 + 1;
when 下 = h1 = h1 - 1;
when 左 = l1 = l1 - 1;
when 右 = l1 = l1 + 1;
than case
蛇移动
than if
than case
than if
than process
ps: 时间仓促,
Game functions need to be improved, and there may be a minor problem with the mouse generation algorithm
The countdown status is DTM,1ends, and0 is not over
Count down count, COUNT
Reset the TIM by countdown
Display control C
Score: SCORE
Game status game_state:start start / reset, game game, dead dead end, win win
Next status next_state
The direction key key:, 0001, 0010, 0100 left, 1000 right
The snakes current direction is dir:, 00
文档评论(0)