From ee117b8c99a7fc733b352fe2eaeb83b43fdfe720 Mon Sep 17 00:00:00 2001 From: eeeXun Date: Sun, 10 Jan 2021 20:51:05 +0800 Subject: [PATCH 1/4] fix score number position --- FPGA_FINAL.v | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FPGA_FINAL.v b/FPGA_FINAL.v index 55f0d3b..661c32d 100644 --- a/FPGA_FINAL.v +++ b/FPGA_FINAL.v @@ -323,12 +323,12 @@ module FPGA_FINAL( if(count_digit_enable == 0) begin count_digit_enable = 1; - COM = 2'b10; + COM = 2'b01; end else begin count_digit_enable = 0; - COM = 2'b01; + COM = 2'b10; end end From f2ed938dca049e6cc2c5f3dbe8f70a884642f3c3 Mon Sep 17 00:00:00 2001 From: snsd0805 Date: Sun, 10 Jan 2021 21:03:28 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E9=80=B2=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FPGA_FINAL.v | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/FPGA_FINAL.v b/FPGA_FINAL.v index 55f0d3b..1a06ba0 100644 --- a/FPGA_FINAL.v +++ b/FPGA_FINAL.v @@ -211,7 +211,7 @@ module FPGA_FINAL( if(blockSecond[ball_position]==1) begin count_digit <= count_digit + 1'b1; - if(count_digit == 4'b1010) + if(count_digit == 4'b1001) begin count_digit <= 4'b0; count_ten = 1; @@ -235,7 +235,7 @@ module FPGA_FINAL( if(blockFirst[ball_position]==1) begin count_digit <= count_digit + 1'b1; - if(count_digit == 4'b1010) + if(count_digit == 4'b1001) begin count_digit <= 4'b0; count_ten = 1; @@ -323,12 +323,12 @@ module FPGA_FINAL( if(count_digit_enable == 0) begin count_digit_enable = 1; - COM = 2'b10; + COM = 2'b01; end else begin count_digit_enable = 0; - COM = 2'b01; + COM = 2'b10; end end From 954463448811602199e57988f1311357057eeac3 Mon Sep 17 00:00:00 2001 From: eeeXun Date: Mon, 11 Jan 2021 03:38:47 +0800 Subject: [PATCH 3/4] add bonus ball --- FPGA_FINAL.v | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 3 deletions(-) diff --git a/FPGA_FINAL.v b/FPGA_FINAL.v index 1a06ba0..a5d918c 100644 --- a/FPGA_FINAL.v +++ b/FPGA_FINAL.v @@ -25,7 +25,12 @@ module FPGA_FINAL( reg handsOn; // bool,紀錄球現在丟出去了沒 reg gameOverFlag; - + + reg showBonus; // bool 顯示額外球 + reg [2:0] Bonus_x; // 額外球的位子x + reg [2:0] Bonus_y; // 額外球的位子x + + reg ball_is_on_the_gronud; // 檢查球是否沒被盤子接住 initial begin @@ -47,7 +52,9 @@ module FPGA_FINAL( horizonPosition = 0; // 預設為 正中間方向 gameOverFlag = 0; - + + showBonus = 0; + ball_is_on_the_gronud = 0; end @@ -59,6 +66,7 @@ module FPGA_FINAL( integer ballTime; + integer doubleTime; // 判斷 所有操作 always @(posedge buttonclk) begin @@ -86,6 +94,8 @@ module FPGA_FINAL( upPosition = 1; // 預設為 向上 horizonPosition = 0; // 預設為 正中間方向 + showBonus = 0; + ball_is_on_the_gronud = 0; end @@ -116,7 +126,7 @@ module FPGA_FINAL( - // 下方操作球的運行 + // 下方操作球的運 行 // 除頻用 if(ballTime<2) ballTime <= ballTime+1; @@ -196,6 +206,8 @@ module FPGA_FINAL( begin horizonPosition = 0; ball_y_position <= ball_y_position-1; + showBonus = 0; + ball_is_on_the_gronud = 1; life = life*2; // 扣除生命值 if(life==3'b000) @@ -252,6 +264,57 @@ module FPGA_FINAL( end end end + + // Bonus ball 除頻 , 每五秒從左邊射一發 + if(doubleTime<50 && showBonus == 0 && handsOn == 0 && ball_is_on_the_gronud == 0) + begin + doubleTime <= doubleTime+1; + Bonus_x = plat_position ; + Bonus_y = 1; + end + else + begin + if(handsOn == 0) + begin + doubleTime <= 0; + showBonus = 1; + if(Bonus_y == 7) + begin + showBonus = 0; + end + if(Bonus_y < 7) + begin + Bonus_y = Bonus_y + 1; + end + + // Bonus ball 撞到第一排磚塊 + if((Bonus_y == 6 && blockSecond[Bonus_x] == 1)) + begin + count_digit <= count_digit + 1'b1; + if(count_digit == 4'b1001) + begin + count_digit <= 4'b0; + count_ten = 1; + end + blockSecond[Bonus_x] = 0; + showBonus = 0; + end + + // Bonus ball 撞到第二排磚塊 + if((Bonus_y == 7 && blockFirst[Bonus_x] == 1)) + begin + count_digit <= count_digit + 1'b1; + if(count_digit == 4'b1001) + begin + count_digit <= 4'b0; + count_ten = 1; + end + blockFirst[Bonus_x] = 0; + showBonus = 0; + end + end + // Bonus ball + end end end @@ -319,6 +382,24 @@ module FPGA_FINAL( //開始畫磚塊 led[16:23] = {~blockFirst[row], ~blockSecond[row], 6'b111111}; + // 畫 Bonus ball + if(showBonus == 1) + if(row==Bonus_x) + begin + reg [7:0] map; + case(Bonus_y) + 3'b000: map = 8'b11111110 ; + 3'b001: map = 8'b11111101 ; + 3'b010: map = 8'b11111011 ; + 3'b011: map = 8'b11110111 ; + 3'b100: map = 8'b11101111 ; + 3'b101: map = 8'b11011111 ; + 3'b110: map = 8'b10111111 ; + 3'b111: map = 8'b01111111 ; + endcase + led[8:15] = map; + end + // 顯示分數 if(count_digit_enable == 0) begin From b8a5d93c7688f6f1d9c8739ea2df6b553f58ffa0 Mon Sep 17 00:00:00 2001 From: eeeXun Date: Mon, 11 Jan 2021 03:53:29 +0800 Subject: [PATCH 4/4] Let digit of ten can show decimal number --- FPGA_FINAL.v | 71 +++++++++++++++++++++------------------------------- 1 file changed, 28 insertions(+), 43 deletions(-) diff --git a/FPGA_FINAL.v b/FPGA_FINAL.v index a5d918c..a52c9b3 100644 --- a/FPGA_FINAL.v +++ b/FPGA_FINAL.v @@ -27,10 +27,8 @@ module FPGA_FINAL( reg gameOverFlag; reg showBonus; // bool 顯示額外球 - reg [2:0] Bonus_x; // 額外球的位子x - reg [2:0] Bonus_y; // 額外球的位子x - - reg ball_is_on_the_gronud; // 檢查球是否沒被盤子接住 + reg Bonus_x, Bonus_y; // 額外球的位子 + initial begin @@ -54,7 +52,7 @@ module FPGA_FINAL( gameOverFlag = 0; showBonus = 0; - ball_is_on_the_gronud = 0; + end @@ -95,7 +93,6 @@ module FPGA_FINAL( horizonPosition = 0; // 預設為 正中間方向 showBonus = 0; - ball_is_on_the_gronud = 0; end @@ -206,8 +203,6 @@ module FPGA_FINAL( begin horizonPosition = 0; ball_y_position <= ball_y_position-1; - showBonus = 0; - ball_is_on_the_gronud = 1; life = life*2; // 扣除生命值 if(life==3'b000) @@ -265,28 +260,17 @@ module FPGA_FINAL( end end - // Bonus ball 除頻 , 每五秒從左邊射一發 - if(doubleTime<50 && showBonus == 0 && handsOn == 0 && ball_is_on_the_gronud == 0) - begin + // + if(doubleTime<200 && showBonus == 0 && handsOn == 0) doubleTime <= doubleTime+1; - Bonus_x = plat_position ; - Bonus_y = 1; - end else begin if(handsOn == 0) begin doubleTime <= 0; showBonus = 1; - if(Bonus_y == 7) - begin - showBonus = 0; - end - if(Bonus_y < 7) - begin - Bonus_y = Bonus_y + 1; - end - + Bonus_x = plat_position + 1; + Bonus_y = 1; // Bonus ball 撞到第一排磚塊 if((Bonus_y == 6 && blockSecond[Bonus_x] == 1)) begin @@ -299,21 +283,21 @@ module FPGA_FINAL( blockSecond[Bonus_x] = 0; showBonus = 0; end - - // Bonus ball 撞到第二排磚塊 - if((Bonus_y == 7 && blockFirst[Bonus_x] == 1)) - begin - count_digit <= count_digit + 1'b1; - if(count_digit == 4'b1001) - begin - count_digit <= 4'b0; - count_ten = 1; - end - blockFirst[Bonus_x] = 0; - showBonus = 0; - end end - // Bonus ball + // Bonus ball 撞到第二排磚塊 + if((Bonus_y == 7 && blockFirst[Bonus_x] == 1)) + begin + count_digit <= count_digit + 1'b1; + if(count_digit == 4'b1001) + begin + count_digit <= 4'b0; + count_ten = 1; + end + blockSecond[Bonus_x] = 0; + showBonus = 0; + end + else + Bonus_y <= Bonus_y + 1; end end end @@ -378,16 +362,13 @@ module FPGA_FINAL( end else led[8:15] = 8'b11111111; - - //開始畫磚塊 - led[16:23] = {~blockFirst[row], ~blockSecond[row], 6'b111111}; - + // 畫 Bonus ball if(showBonus == 1) if(row==Bonus_x) begin reg [7:0] map; - case(Bonus_y) + case(ball_y_position) 3'b000: map = 8'b11111110 ; 3'b001: map = 8'b11111101 ; 3'b010: map = 8'b11111011 ; @@ -397,9 +378,13 @@ module FPGA_FINAL( 3'b110: map = 8'b10111111 ; 3'b111: map = 8'b01111111 ; endcase - led[8:15] = map; + led[0:7] = map; + led[16:23] = map; end + //開始畫磚塊 + led[16:23] = {~blockFirst[row], ~blockSecond[row], 6'b111111}; + // 顯示分數 if(count_digit_enable == 0) begin