Sputnik12
Newbie level 5
I am very new to FPGA programming in vivado (Verilog), and I am trying to make a simple game. The game has a player traverse through a labyrinth and therefore when the player collides with the walls in the labyrinth the player must stop. I tried the brute force method of hard coding every single wall the player collides with and disabled the relevant movements. However, this is not a very time efficient process.
Therefore, I thought it was best to check whether the VGA controller draws over the player box with the colour of the walls. If this happens then disable a certain button. For example, if the red, green and blue values of the walls held in a 12 bit register called "walls" and if the current pixel on the screen is the middle left pixel of the player sprite, then stop moving. This is shown in the following code:
So what I am trying to say is: if the player is at the wall set the left collision flag to 1 and if the player is not at the wall the flag should be 0. However, the if statement is never met, and the flag remains at 0 and I am not sure why this is the case. The logic of the statement makes sense to me, so I am thoroughly confused. I understand that this is a debugging problem and I should figure this out on my own, but I am running out of options after being stuck on this for 2 days!
I am happy to provide any code files if needed.
Any help would be greatly appreciated!
Thank you!
Therefore, I thought it was best to check whether the VGA controller draws over the player box with the colour of the walls. If this happens then disable a certain button. For example, if the red, green and blue values of the walls held in a 12 bit register called "walls" and if the current pixel on the screen is the middle left pixel of the player sprite, then stop moving. This is shown in the following code:
Code:
if((walls) && (currentX == playerX ) && (currentY == playerY + 20)) begin // The player box is 40x40 pixels, //therefore, playerX = 0 and playerY = 0 is the top left hand corner of the player box.
coll_left <= 1'b1;
end
else begin
coll_left <= 1'b0;
end
So what I am trying to say is: if the player is at the wall set the left collision flag to 1 and if the player is not at the wall the flag should be 0. However, the if statement is never met, and the flag remains at 0 and I am not sure why this is the case. The logic of the statement makes sense to me, so I am thoroughly confused. I understand that this is a debugging problem and I should figure this out on my own, but I am running out of options after being stuck on this for 2 days!
I am happy to provide any code files if needed.
Any help would be greatly appreciated!
Thank you!
Last edited: