Commit 53422023 authored by ktsiam's avatar ktsiam
Browse files

prototype with signals -- no blocks -- no compile

parent 50862e34
......@@ -9,6 +9,7 @@ entity GAME is
clk : in std_logic;
ball_x : out unsigned (9 downto 0);
ball_y : out unsigned (9 downto 0);
lost : out std_logic;
--paddle_x : out unsigned (9 downto 0);
--ball_array : out unsigned(99 downto 0);
);
......@@ -33,18 +34,20 @@ architecture GAME_ARCH of GAME is
constant BRICK_COLS : unsigned (16 downto 0) := 32;
constant BRICK_SIZE : unsigned (16 downto 0) := WIDTH/BRICK_COLS;
signal L : std_logic := '0';
signal R : std_logic := '1';
signal paddle : unsigned (16 downto 0) := 0;
signal ball_x : unsigned (16 downto 0) := 0;
signal ball_y : unsigned (16 downto 0) := HEIGHT; -- y=0 is top
signal ball_vx : unsigned (16 downto 0) := UNIT; -- goes right
signal ball_vy : unsigned (16 downto 0) := -UNIT; -- goes up
signal ball_vx : unsigned (16 downto 0) := UNIT; -- MUST LOWER SIGNIFICANTLY
signal ball_vy : unsigned (16 downto 0) := -UNIT; -- MUST LOWER SIGNIFICANTLY
begin
process (clk) is
if rising_edge(clk) then
-- PADDLE
-- PADDLE (changes 'paddle')
if L = '1' and R = '0' then
paddle <= max (17d"0", paddle-PADDLE_SPEED);
elsif L = '0' and R = '1' then
......@@ -52,7 +55,23 @@ begin
else
paddle <= paddle;
end if;
-- BALL MOVE (changes 'ball_x', 'ball_y')
ball_x <= ball_x + ball_vx;
ball_y <= ball_y + ball_vy;
-- BALL COLLISION (changes 'ball_vx', 'ball_vy')
if (ball_x <= 17d"0" or ball_x >= WIDTH) then
ball_vx <= -ball_vx;
end if;
if (ball_y <= "0" or ball_y >= HEIGHT) then
ball_vy <= -ball_vy;
end if;
-- LOST CONDITION
lost <= '1' when ball_y >= HEIGHT and
(ball_x < paddle or ball_x > paddle+PADDLE_WIDTH) else '0';
end if;
end process;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment