Skip to content

Commit

Permalink
Flytta runt spriten
Browse files Browse the repository at this point in the history
  • Loading branch information
richardwiden committed Apr 24, 2012
1 parent 80366c3 commit e75394b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
16 changes: 12 additions & 4 deletions FirstGraphicTest.vhd
Expand Up @@ -36,7 +36,9 @@ entity FirstGraphicTest is
hsync : OUT std_logic;
vgaRed: OUT std_logic_vector(2 downto 0);
vgaGreen: OUT std_logic_vector(2 downto 0);
vgaBlue: OUT std_logic_vector(2 downto 1)
vgaBlue: OUT std_logic_vector(2 downto 1);
btnd: in std_logic;
btnu: in std_logic
);
end FirstGraphicTest;

Expand All @@ -59,7 +61,7 @@ architecture Behavioral of FirstGraphicTest is
vgaRed: OUT std_logic_vector(2 downto 0);
vgaGreen: OUT std_logic_vector(2 downto 0);
vgaBlue: OUT std_logic_vector(2 downto 1);
spriteDetected : in std_logic
spriteDetected : in std_logic
);
END COMPONENT;

Expand All @@ -83,7 +85,10 @@ architecture Behavioral of FirstGraphicTest is
spriteVgaBlue: out std_logic_vector(2 downto 1);
collision: out std_logic;
rst : in STD_LOGIC;
spriteDetected : out std_logic);
spriteDetected : out std_logic;
btnd: in std_logic;
btnu: in std_logic
);

END COMPONENT;

Expand All @@ -104,6 +109,7 @@ architecture Behavioral of FirstGraphicTest is

signal spriteDetected : std_logic;


--signal clk : std_logic := '0';
signal rst : std_logic := '1';

Expand Down Expand Up @@ -145,7 +151,9 @@ begin
spriteVgaGreen => spriteVgaGreen,
spriteVgaBlue => spriteVgaBlue,
collision => collision,
spriteDetected =>spriteDetected
spriteDetected =>spriteDetected,
btnd => btnd,
btnu => btnu
);
clk_process :process

Expand Down
4 changes: 2 additions & 2 deletions Nexys3_Master.ucf
Expand Up @@ -174,9 +174,9 @@ Net "clk" LOC=V10 | IOSTANDARD=LVCMOS33;

## Buttons
#Net "btns" LOC = B8 | IOSTANDARD = LVCMOS33; #Bank = 0, pin name = IO_L33P, Sch name = BTNS
#Net "btnu" LOC = A8 | IOSTANDARD = LVCMOS33; #Bank = 0, pin name = IO_L33N, Sch name = BTNU
Net "btnu" LOC = A8 | IOSTANDARD = LVCMOS33; #Bank = 0, pin name = IO_L33N, Sch name = BTNU
#Net "btnl" LOC = C4 | IOSTANDARD = LVCMOS33; #Bank = 0, pin name = IO_L1N_VREF, Sch name = BTNL
#Net "btnd" LOC = C9 | IOSTANDARD = LVCMOS33; #Bank = 0, pin name = IO_L34N_GCLK18, Sch name = BTND
Net "btnd" LOC = C9 | IOSTANDARD = LVCMOS33; #Bank = 0, pin name = IO_L34N_GCLK18, Sch name = BTND
#Net "btnr" LOC = D9 | IOSTANDARD = LVCMOS33; # Bank = 0, pin name = IO_L34P_GCLK19, Sch name = BTNR

## VGA Connector
Expand Down
10 changes: 9 additions & 1 deletion SpriteGpu.vhd
Expand Up @@ -40,7 +40,9 @@ entity SpriteGpu is
spriteVgaBlue: out std_logic_vector(2 downto 1);
collision: out std_logic;
spriteDetected: out std_logic;
rst : in STD_LOGIC);
rst : in STD_LOGIC;
btnd: in std_logic;
btnu: in std_logic);
end SpriteGpu;


Expand Down Expand Up @@ -76,6 +78,12 @@ sprite_brick(15) <= "1111111111111111";
process(clk)
begin
if rising_edge(clk) then
if btnu ='1' then
y_pos <= y_pos-1;
elsif btnd='1' then
y_pos <= y_pos+1;
end if;

if y>y_pos and y <= (y_pos+spriteSize) then
if x> x_pos and x <= (x_pos+spriteSize) then
if sprite_brick( y - y_pos )( x - x_pos ) = '1' then
Expand Down

0 comments on commit e75394b

Please sign in to comment.