Professional Documents
Culture Documents
Game
Game
use ieee.std_logic_1164.all;
entity ball_shooter is
port(
clk : in std_logic;
reset : in std_logic;
up : in std_logic;
down : in std_logic;
left : in std_logic;
right : in std_logic;
x_ball_green : out std_logic;
y_ball_green : out std_logic;
x_ball_red : out std_logic;
y_ball_red : out std_logic
);
end ball_shooter;
begin
-- Xử lý đồng hồ
process(clk)
begin
if clk'event and clk = '1' then
if reset = '1' then
x_ball_green_reg <= (others => '0');
y_ball_green_reg <= (others => '0');
x_ball_red_reg <= (others => '0');
y_ball_red_reg <= (others => '0');
else
-- Cập nhật vị trí quả bóng xanh
if up = '1' then
y_ball_green_reg <= y_ball_green_reg + 1;
elsif down = '1' then
y_ball_green_reg <= y_ball_green_reg - 1;
end if;
end behavioral;