Hello everyone,
I am developing a brick breaking game in VHDL. For this project, I have
successfully implemented a image generator and a VGA synchronizer.
However, I am having problems with the game logic. In this game, bricks
are supposed to be destroyed when the ball hits. When a collision is
observed, the ball should change its direction. So as to realize this, I
wrote the following code:
1 | process(refresh_tick,ball_x,ball_y,xv_reg,yv_reg)
|
2 | begin
|
3 | ball_x_next <=ball_x;
|
4 | ball_y_next <=ball_y;
|
5 | xv_next<=xv_reg;
|
6 | yv_next<=yv_reg;
|
7 | if refresh_tick = '1' then
|
8 | if ball_y> 400 and ball_x > (bar_l -ball_u) and ball_x < (bar_l +120) then --the ball hits the bar
|
9 | yv_next<= -y_v ;
|
10 | elsif ball_y <= 0 then--The ball hits the wall
|
11 | yv_next<= y_v;
|
12 | elsif ball_x <= 0 then --The ball hits the left side of the screen
|
13 | xv_next<= x_v;
|
14 | elsif ball_x >= 640 then
|
15 | xv_next<= -x_v ; --The ball hits the right side of the screen
|
16 | elsif is_ball_on_bricks_area and bricks_collection(current_brick_row, current_brick_column) = '1' then
|
17 | yv_next <= y_v;
|
18 | bricks_collection(current_brick_row, current_brick_column) <= '0';
|
19 | end if;
|
20 | ball_x_next <=ball_x +xv_reg;
|
21 | ball_y_next <=ball_y+yv_reg;
|
22 | end if;
|
23 | end process;
|
In this game, I define bricks as a 2D array:
type brick_array is array (0 to 4, 0 to 9) of std_logic;
signal bricks_collection : brick_array := (others => (others =>
'1'));
So, when a collision is detected, the destroyed brick is assigned as '0'
and ball change its direction yv_next <= y_v; Unfortunately, only one of
them is executed during the run time which is at this case
bricks_collection(current_brick_row, current_brick_column) <= '0';. I
know that the logic I came up with works, that is, collisions are
detected successfully.
These statements under the last elsif statement should be run
concurrently. But they are not. How do I make them run concurrently?
So I know that in a process if I do something like this, the second
assignment takes place at the second clock tick:
process(clk)
begin
a <= b;
b <= c;
end process;
Is this a similar problem?