module game_rule_setter(rst,clk,p1_point,p2_point,rule ,p1_size,p2_size,b_clk);
input rst,clk;
input [3:0]p1_point,p2_point;
input [2:0]rule;//0:size,1:speed
output [7:0]p1_size,p2_size;
output b_clk;
reg [7:0]p1_size,p2_size;
reg b_clk;
reg [31:0]count,clock,shrink;
always@(posedge clk,negedge rst)
begin
    if(!rst)
    begin
        clock<=32'd100000;
        count<=32'd0;
        p1_size<=8'd200;
        p2_size<=8'd200;
    end
    else
    begin
        if(count==clock)
        begin
            count<=32'd0;
            //let ball move faster
            clock<=clock-(32'd4)*rule[1];
            b_clk<=1'b1;
            //let player smaller
            //(it may have bug when ball faster,player shrink faster,need fix)
            shrink<=shrink+1;
            if(!(shrink%40))
            begin
                p1_size<=p1_size-rule[0]*(p1_size>60);
                p2_size<=p2_size-rule[0]*(p2_size>60);
            end
        end
        else
        begin
            count<=count+32'd1;
            b_clk=1'b0;
        end
        //end game,player disappear
        if((rule[2]&&((p1_point+p2_point)>=5))||((p1_point+p2_point)>=3))
        begin
            if(p1_point>p2_point)
                p2_size<=0;
            else
                p1_size<=0;
        end
    end
end
endmodule