Let digit of ten can show decimal number

This commit is contained in:
eeeXun 2021-01-11 03:53:29 +08:00
parent 9544634488
commit b8a5d93c76

View File

@ -27,10 +27,8 @@ module FPGA_FINAL(
reg gameOverFlag; reg gameOverFlag;
reg showBonus; // bool 顯示額外球 reg showBonus; // bool 顯示額外球
reg [2:0] Bonus_x; // 額外球的位子x reg Bonus_x, Bonus_y; // 額外球的位子
reg [2:0] Bonus_y; // 額外球的位子x
reg ball_is_on_the_gronud; // 檢查球是否沒被盤子接住
initial initial
begin begin
@ -54,7 +52,7 @@ module FPGA_FINAL(
gameOverFlag = 0; gameOverFlag = 0;
showBonus = 0; showBonus = 0;
ball_is_on_the_gronud = 0;
end end
@ -95,7 +93,6 @@ module FPGA_FINAL(
horizonPosition = 0; // 預設為 正中間方向 horizonPosition = 0; // 預設為 正中間方向
showBonus = 0; showBonus = 0;
ball_is_on_the_gronud = 0;
end end
@ -206,8 +203,6 @@ module FPGA_FINAL(
begin begin
horizonPosition = 0; horizonPosition = 0;
ball_y_position <= ball_y_position-1; ball_y_position <= ball_y_position-1;
showBonus = 0;
ball_is_on_the_gronud = 1;
life = life*2; // 扣除生命值 life = life*2; // 扣除生命值
if(life==3'b000) if(life==3'b000)
@ -265,28 +260,17 @@ module FPGA_FINAL(
end end
end end
// Bonus ball 除頻 每五秒從左邊射一發 //
if(doubleTime<50 && showBonus == 0 && handsOn == 0 && ball_is_on_the_gronud == 0) if(doubleTime<200 && showBonus == 0 && handsOn == 0)
begin
doubleTime <= doubleTime+1; doubleTime <= doubleTime+1;
Bonus_x = plat_position ;
Bonus_y = 1;
end
else else
begin begin
if(handsOn == 0) if(handsOn == 0)
begin begin
doubleTime <= 0; doubleTime <= 0;
showBonus = 1; showBonus = 1;
if(Bonus_y == 7) Bonus_x = plat_position + 1;
begin Bonus_y = 1;
showBonus = 0;
end
if(Bonus_y < 7)
begin
Bonus_y = Bonus_y + 1;
end
// Bonus ball 撞到第一排磚塊 // Bonus ball 撞到第一排磚塊
if((Bonus_y == 6 && blockSecond[Bonus_x] == 1)) if((Bonus_y == 6 && blockSecond[Bonus_x] == 1))
begin begin
@ -299,21 +283,21 @@ module FPGA_FINAL(
blockSecond[Bonus_x] = 0; blockSecond[Bonus_x] = 0;
showBonus = 0; showBonus = 0;
end 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 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 end
end end
@ -379,15 +363,12 @@ module FPGA_FINAL(
else else
led[8:15] = 8'b11111111; led[8:15] = 8'b11111111;
//開始畫磚塊
led[16:23] = {~blockFirst[row], ~blockSecond[row], 6'b111111};
// Bonus ball // Bonus ball
if(showBonus == 1) if(showBonus == 1)
if(row==Bonus_x) if(row==Bonus_x)
begin begin
reg [7:0] map; reg [7:0] map;
case(Bonus_y) case(ball_y_position)
3'b000: map = 8'b11111110 ; 3'b000: map = 8'b11111110 ;
3'b001: map = 8'b11111101 ; 3'b001: map = 8'b11111101 ;
3'b010: map = 8'b11111011 ; 3'b010: map = 8'b11111011 ;
@ -397,9 +378,13 @@ module FPGA_FINAL(
3'b110: map = 8'b10111111 ; 3'b110: map = 8'b10111111 ;
3'b111: map = 8'b01111111 ; 3'b111: map = 8'b01111111 ;
endcase endcase
led[8:15] = map; led[0:7] = map;
led[16:23] = map;
end end
//開始畫磚塊
led[16:23] = {~blockFirst[row], ~blockSecond[row], 6'b111111};
// 顯示分數 // 顯示分數
if(count_digit_enable == 0) if(count_digit_enable == 0)
begin begin