SNAKE GAME VHDL

OP (Company: enseirb) #5264211
Rate this post
• ▲ useful
▼ not useful
Hi
I am trying to develop a snake game using a Nexys 4 board and oled rgb 
screen.
I can't generate automaticaly an other point on the screen when the 
snake's head meets the food and while the head is moving . My random 
generator(control_pomme) seems to work .  I didn't base my project on 
the use of a RAM , do you think it is necessary because  almost all the 
snake-like  vga projects on the web seem to use this approach .
Moderator (Company: Titel) #5264384
Rate this post
• ▲ useful
▼ not useful
Ya Y. wrote:
> Thanks for your reply
1
           b_up       : in STD_LOGIC;
2
           b_down     : in STD_LOGIC;
3
           b_left     : in STD_LOGIC;
4
           b_right    : in STD_LOGIC;
If those are asynchronous real world buttons, then you must sync them 
to your clock. Otherwise you will encouter curious problems.
1
    type etat is (init, snake_right, snake_left, snake_up, snake_down, snake_pause);
2
:
3
:
4
        case etat_present is
5
:
6
:
7
        when others => go_up <= '0';     --others = snake_down
Instead of "others" you better should have written "snake_down", because 
then there would remain no "others" and the obfuscating "others" clause 
would be not needed.
1
signal sspixcol : unsigned( 6 downto 0 ):="0110000";
2
signal sspixrow : unsigned( 5 downto 0 ):="100000";
3
signal noir : STD_LOGIC_VECTOR (15 downto 0) :="0000000000000000";
4
signal vert : STD_LOGIC_VECTOR (15 downto 0) :="0000001111100000";
5
:
6
:
7
        sspixrow <= sspixrow - "000001";
Why don't you work with integers throughout? Then you could use "real 
world numbers" instead of unreadable binary codes. And the arithmetic 
operations would be much easier to understand...
1
signal sspixcol : integer range 0 to 127 := 96;
2
signal sspixrow : integer range 0 to 63  := 32;
3
:
4
:
5
        sspixrow <= sspixrow - 1;

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.