From 67763e99d0d838e4f588d18f17811b131061b144 Mon Sep 17 00:00:00 2001 From: snsd0805 Date: Sun, 10 Jan 2021 02:15:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=90=83=E5=8F=AF=E4=BB=A5=E5=8F=8D?= =?UTF-8?q?=E5=BD=88=E6=9D=BF=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FPGA_FINAL.v | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/FPGA_FINAL.v b/FPGA_FINAL.v index c32a8dd..ce76c4f 100644 --- a/FPGA_FINAL.v +++ b/FPGA_FINAL.v @@ -78,7 +78,7 @@ module FPGA_FINAL( // 下方操作球的運行 // 除頻用 - if(ballTime<5) + if(ballTime<2) ballTime <= ballTime+1; else //開始判斷球的行進 @@ -104,13 +104,43 @@ module FPGA_FINAL( if(horizonPosition==1) if(ball_position<7) ball_position <= ball_position+1; // 範圍內右移 - else + else + begin horizonPosition = -1; // 超過範圍就轉向左邊 + ball_position <= ball_position-1; + end else if(horizonPosition==-1) if(ball_position>0) ball_position <= ball_position-1; // 範圍內左移 else + begin horizonPosition = 1; // 超過範圍就轉向右邊 + ball_position <= ball_position+1; + end + + // 判斷特殊狀況(碰到板子) + if(ball_y_position==1) + if(ball_position==plat_position) + begin + horizonPosition = -1; + upPosition = 1; + end + else if(ball_position==plat_position+1) + begin + upPosition = 1; + ball_y_position <= ball_y_position+1; + end + else if(ball_position==plat_position+2) + begin + horizonPosition = 1; + upPosition = 1; + end + else + begin + horizonPosition = 0; + ball_y_position <= ball_y_position-1; + end + end end end