物品基本完成,还剩闪电没搞
parent
052972077d
commit
08372573ef
|
|
@ -0,0 +1,402 @@
|
||||||
|
memory_initialization_radix=2;
|
||||||
|
memory_initialization_vector=111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111101111,
|
||||||
|
101110111111,
|
||||||
|
010101101110,
|
||||||
|
000100101101,
|
||||||
|
000100101101,
|
||||||
|
010101101110,
|
||||||
|
101110111111,
|
||||||
|
110111101111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
101010101111,
|
||||||
|
001101001101,
|
||||||
|
000100101101,
|
||||||
|
000000011101,
|
||||||
|
011001111110,
|
||||||
|
110111011111,
|
||||||
|
110111011111,
|
||||||
|
011001111110,
|
||||||
|
000000011101,
|
||||||
|
000100101101,
|
||||||
|
001101001101,
|
||||||
|
101010101111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
010101101110,
|
||||||
|
000100101101,
|
||||||
|
000100111101,
|
||||||
|
011001111110,
|
||||||
|
101010101111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
101010101111,
|
||||||
|
011001111110,
|
||||||
|
000100111101,
|
||||||
|
000100101101,
|
||||||
|
010101101110,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
000000101101,
|
||||||
|
101111001111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111011101111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
101111001111,
|
||||||
|
000000101101,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
000000101101,
|
||||||
|
110111011111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
101110111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111011111,
|
||||||
|
000000101101,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
000000101101,
|
||||||
|
110111011111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
011101111110,
|
||||||
|
101010101111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111011111,
|
||||||
|
000000101101,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
000000101101,
|
||||||
|
110111011111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
101111001111,
|
||||||
|
000000101101,
|
||||||
|
101110111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111011111,
|
||||||
|
000000101101,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
000100101101,
|
||||||
|
110111011111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111011111,
|
||||||
|
000100111101,
|
||||||
|
000000011101,
|
||||||
|
110111011111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111011111,
|
||||||
|
000100101101,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
000100101101,
|
||||||
|
110111011111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
010001011110,
|
||||||
|
000000011101,
|
||||||
|
000000011101,
|
||||||
|
111011101111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111011111,
|
||||||
|
000100101101,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
000100101101,
|
||||||
|
110111011111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
011110001110,
|
||||||
|
000000011101,
|
||||||
|
000000011101,
|
||||||
|
000000011101,
|
||||||
|
001101011110,
|
||||||
|
010001011110,
|
||||||
|
110111011111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111011111,
|
||||||
|
000100101101,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
000100101101,
|
||||||
|
110111011111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111011111,
|
||||||
|
010001011110,
|
||||||
|
001101011110,
|
||||||
|
000000011101,
|
||||||
|
000000011101,
|
||||||
|
000000011101,
|
||||||
|
011110001110,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111011111,
|
||||||
|
000100101101,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
000100111101,
|
||||||
|
110111011111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111011101111,
|
||||||
|
000000011101,
|
||||||
|
000000011101,
|
||||||
|
010001011110,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111011111,
|
||||||
|
000100111101,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
000100111101,
|
||||||
|
110111011111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111011111,
|
||||||
|
000000011101,
|
||||||
|
000100111101,
|
||||||
|
110111011111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111011111,
|
||||||
|
000100111101,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
001101001110,
|
||||||
|
100110011110,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
101111001111,
|
||||||
|
000000101101,
|
||||||
|
101111001111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
100110011110,
|
||||||
|
001101001110,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
100010011110,
|
||||||
|
000100101101,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
101010101111,
|
||||||
|
011101111110,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
000100101101,
|
||||||
|
100010011110,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
010001011110,
|
||||||
|
001000111101,
|
||||||
|
110111011111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
101110111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111011111,
|
||||||
|
001000111101,
|
||||||
|
010001011110,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
001000111101,
|
||||||
|
000100101101,
|
||||||
|
101010111111,
|
||||||
|
111111111111,
|
||||||
|
111011111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
101110111111,
|
||||||
|
000100101101,
|
||||||
|
001101001101,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
100010011110,
|
||||||
|
000100101101,
|
||||||
|
010101101110,
|
||||||
|
110011001111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110111011111,
|
||||||
|
011001111110,
|
||||||
|
001000111101,
|
||||||
|
100110011110,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
110011001111,
|
||||||
|
001000111101,
|
||||||
|
000000101101,
|
||||||
|
011110001110,
|
||||||
|
011110001110,
|
||||||
|
000000101101,
|
||||||
|
001101001110,
|
||||||
|
111011101111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
101110111111,
|
||||||
|
001101001110,
|
||||||
|
001101001110,
|
||||||
|
101010111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
111111111111,
|
||||||
|
;
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
`timescale 1ns / 1ps
|
`timescale 1ns / 1ps
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
// Company:
|
// Company:
|
||||||
|
|
@ -25,9 +27,10 @@ module Random(
|
||||||
input rst_n,
|
input rst_n,
|
||||||
input [ 1: 0 ] flag,
|
input [ 1: 0 ] flag,
|
||||||
output reg [ 1: 0 ] random,
|
output reg [ 1: 0 ] random,
|
||||||
output reg [ 14: 0 ] random_14
|
output [ 14: 0 ] random_14
|
||||||
);
|
);
|
||||||
reg [ 14: 0 ] rand_num;
|
reg [ 14: 0 ] rand_num;
|
||||||
|
assign random_14 = rand_num;
|
||||||
always @( * ) begin
|
always @( * ) begin
|
||||||
case ( flag )
|
case ( flag )
|
||||||
2'b00:
|
2'b00:
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,12 @@ wire [ 9: 0 ] KeyBoard_Output;
|
||||||
wire item_faster;
|
wire item_faster;
|
||||||
wire item_invincible;
|
wire item_invincible;
|
||||||
wire item_addtime;
|
wire item_addtime;
|
||||||
wire item_test;
|
wire item_frozen;
|
||||||
|
wire item_addHP;
|
||||||
|
wire which_player; //0 is player1 get and 1 is player2 get
|
||||||
wire [ 10: 0 ] vgaH, vgaV;
|
wire [ 10: 0 ] vgaH, vgaV;
|
||||||
wire [ 11: 0 ] VGAData;
|
wire [ 11: 0 ] VGAData;
|
||||||
wire [ 11: 0 ] backgroundData, game_information_data, heart_gametips_data;
|
wire [ 11: 0 ] backgroundData, game_information_data, heart_gametips_data, item_data;
|
||||||
wire [ 1 : 0 ] player1_tank_dir, player2_tank_dir;
|
wire [ 1 : 0 ] player1_tank_dir, player2_tank_dir;
|
||||||
wire [ 1: 0 ] enermy1_tank_dir, enermy2_tank_dir, enermy3_tank_dir, enermy4_tank_dir;
|
wire [ 1: 0 ] enermy1_tank_dir, enermy2_tank_dir, enermy3_tank_dir, enermy4_tank_dir;
|
||||||
wire [ 10: 0 ] player1_tank_H, player1_tank_V, player2_tank_H, player2_tank_V;
|
wire [ 10: 0 ] player1_tank_H, player1_tank_V, player2_tank_H, player2_tank_V;
|
||||||
|
|
@ -171,6 +173,8 @@ game_logic_classic u_game_logic_classic(
|
||||||
.scored1( scored1 ),
|
.scored1( scored1 ),
|
||||||
.scored2( scored2 ),
|
.scored2( scored2 ),
|
||||||
.item_invincible( item_invincible ),
|
.item_invincible( item_invincible ),
|
||||||
|
.item_addHP( item_addHP ),
|
||||||
|
.which_player( which_player ),
|
||||||
.HP1_value( player1_HP ),
|
.HP1_value( player1_HP ),
|
||||||
.HP2_value( player2_HP ),
|
.HP2_value( player2_HP ),
|
||||||
.gameover_classic( gameover_classic ),
|
.gameover_classic( gameover_classic ),
|
||||||
|
|
@ -194,8 +198,8 @@ game_logic_infinity u_game_logic_infinity(
|
||||||
.scored1( scored1 ),
|
.scored1( scored1 ),
|
||||||
.scored2( scored2 ),
|
.scored2( scored2 ),
|
||||||
.item_addtime( item_addtime ),
|
.item_addtime( item_addtime ),
|
||||||
.item_test( item_test ),
|
|
||||||
.item_invincible( item_invincible ),
|
.item_invincible( item_invincible ),
|
||||||
|
.which_player( which_player ),
|
||||||
.timer( timer ),
|
.timer( timer ),
|
||||||
.gameover_infinity( gameover_infinity ),
|
.gameover_infinity( gameover_infinity ),
|
||||||
.led_infinity( LED_infinity ),
|
.led_infinity( LED_infinity ),
|
||||||
|
|
@ -247,7 +251,7 @@ vga_data_selector u_vga_data_selector(
|
||||||
.in13( enermy4_bullet_data ),
|
.in13( enermy4_bullet_data ),
|
||||||
.in14( game_information_data ),
|
.in14( game_information_data ),
|
||||||
.in15( heart_gametips_data ),
|
.in15( heart_gametips_data ),
|
||||||
.in16(),
|
.in16( item_data ),
|
||||||
.in17(),
|
.in17(),
|
||||||
.out( VGAData )
|
.out( VGAData )
|
||||||
);
|
);
|
||||||
|
|
@ -259,10 +263,12 @@ tank_display u_tank1_display(
|
||||||
.mode( mode ),
|
.mode( mode ),
|
||||||
.tank_revive( player1_revive ),
|
.tank_revive( player1_revive ),
|
||||||
.player_enermy( 1'b0 ),
|
.player_enermy( 1'b0 ),
|
||||||
|
|
||||||
.vgaH( vgaH ),
|
.vgaH( vgaH ),
|
||||||
.vgaV( vgaV ),
|
.vgaV( vgaV ),
|
||||||
.tankH( player1_tank_H ),
|
.tankH( player1_tank_H ),
|
||||||
.tankV( player1_tank_V ),
|
.tankV( player1_tank_V ),
|
||||||
|
.item_invincible( ( item_invincible ) & ( ~which_player ) ),
|
||||||
.tankData( player1_tank_data )
|
.tankData( player1_tank_data )
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -277,6 +283,7 @@ tank_display u_tank2_display(
|
||||||
.vgaV( vgaV ),
|
.vgaV( vgaV ),
|
||||||
.tankH( player2_tank_H ),
|
.tankH( player2_tank_H ),
|
||||||
.tankV( player2_tank_V ),
|
.tankV( player2_tank_V ),
|
||||||
|
.item_invincible( ( item_invincible ) & ( which_player ) ),
|
||||||
.tankData( player2_tank_data )
|
.tankData( player2_tank_data )
|
||||||
);
|
);
|
||||||
tank_display enermy1_tank_display(
|
tank_display enermy1_tank_display(
|
||||||
|
|
@ -336,41 +343,41 @@ tank_display enermy4_tank_display(
|
||||||
tank_move player1_tank_move(
|
tank_move player1_tank_move(
|
||||||
clk, reset_n, 1,
|
clk, reset_n, 1,
|
||||||
150, 150,
|
150, 150,
|
||||||
player1_tank_dir, player1_tank_en, player1_tank_move_en, 1'b0, player1_moving,
|
player1_tank_dir, player1_tank_en, player1_tank_move_en, 1'b0, player1_moving, item_frozen,
|
||||||
player1_tank_H, player1_tank_V, player1_tank_moving_direction
|
player1_tank_H, player1_tank_V, player1_tank_moving_direction
|
||||||
);
|
);
|
||||||
|
|
||||||
tank_move player2_tank_move(
|
tank_move player2_tank_move(
|
||||||
clk, reset_n, 1,
|
clk, reset_n, 1,
|
||||||
350, 350,
|
350, 350,
|
||||||
player2_tank_dir, player2_tank_en, player2_tank_move_en, 1'b0, player2_moving,
|
player2_tank_dir, player2_tank_en, player2_tank_move_en, 1'b0, player2_moving, item_frozen,
|
||||||
player2_tank_H, player2_tank_V, player2_tank_moving_direction
|
player2_tank_H, player2_tank_V, player2_tank_moving_direction
|
||||||
);
|
);
|
||||||
|
|
||||||
tank_move enermy1_tank_move(
|
tank_move enermy1_tank_move(
|
||||||
clk, reset_n, 1,
|
clk, reset_n, 1,
|
||||||
0, 0,
|
0, 0,
|
||||||
enermy1_tank_dir, enermy1_tank_en, enermy1_tank_move_en, 1'b1, enermy1_moving,
|
enermy1_tank_dir, enermy1_tank_en, enermy1_tank_move_en, 1'b1, enermy1_moving, item_frozen,
|
||||||
enermy1_tank_H, enermy1_tank_V, enermy1_tank_moving_direction
|
enermy1_tank_H, enermy1_tank_V, enermy1_tank_moving_direction
|
||||||
);
|
);
|
||||||
|
|
||||||
tank_move enermy2_tank_move(
|
tank_move enermy2_tank_move(
|
||||||
clk, reset_n, 1,
|
clk, reset_n, 1,
|
||||||
540, 0,
|
540, 0,
|
||||||
enermy2_tank_dir, enermy2_tank_en, enermy2_tank_move_en, 1'b1, enermy2_moving,
|
enermy2_tank_dir, enermy2_tank_en, enermy2_tank_move_en, 1'b1, enermy2_moving, item_frozen,
|
||||||
enermy2_tank_H, enermy2_tank_V, enermy2_tank_moving_direction
|
enermy2_tank_H, enermy2_tank_V, enermy2_tank_moving_direction
|
||||||
);
|
);
|
||||||
tank_move enermy3_tank_move(
|
tank_move enermy3_tank_move(
|
||||||
clk, reset_n, 1,
|
clk, reset_n, 1,
|
||||||
0, 350,
|
0, 350,
|
||||||
enermy3_tank_dir, enermy3_tank_en, enermy3_tank_move_en, 1'b1, enermy3_moving,
|
enermy3_tank_dir, enermy3_tank_en, enermy3_tank_move_en, 1'b1, enermy3_moving, item_frozen,
|
||||||
enermy3_tank_H, enermy3_tank_V, enermy3_tank_moving_direction
|
enermy3_tank_H, enermy3_tank_V, enermy3_tank_moving_direction
|
||||||
);
|
);
|
||||||
|
|
||||||
tank_move enermy4_tank_move(
|
tank_move enermy4_tank_move(
|
||||||
clk, reset_n, 1,
|
clk, reset_n, 1,
|
||||||
540, 350,
|
540, 350,
|
||||||
enermy4_tank_dir, enermy4_tank_en, enermy4_tank_move_en, 1'b1, enermy4_moving,
|
enermy4_tank_dir, enermy4_tank_en, enermy4_tank_move_en, 1'b1, enermy4_moving, item_frozen,
|
||||||
enermy4_tank_H, enermy4_tank_V, enermy4_tank_moving_direction
|
enermy4_tank_H, enermy4_tank_V, enermy4_tank_moving_direction
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -675,11 +682,31 @@ vga_data_heart_gametips u_vga_data_heart_gametips(
|
||||||
.vgaData( heart_gametips_data )
|
.vgaData( heart_gametips_data )
|
||||||
);
|
);
|
||||||
assign item_faster = 0;
|
assign item_faster = 0;
|
||||||
assign item_addtime = 0;
|
|
||||||
assign item_invincible = 0;
|
|
||||||
assign item_test = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
item_logic u_item_logic(
|
||||||
|
.clk( clk ),
|
||||||
|
.clk_4Hz( clk_4Hz ),
|
||||||
|
.enable_reward( enable_reward ),
|
||||||
|
.enable_game_classic( enable_game_classic ),
|
||||||
|
.enable_game_infinity( enable_game_infinity ),
|
||||||
|
.player1_tank_H( player1_tank_H ),
|
||||||
|
.player1_tank_V( player1_tank_V ),
|
||||||
|
.player1_tank_dir( player1_tank_dir ),
|
||||||
|
.player1_tank_en( player1_tank_en ),
|
||||||
|
.player2_tank_H( player2_tank_H ),
|
||||||
|
.player2_tank_V( player2_tank_V ),
|
||||||
|
.player2_tank_dir( player2_tank_dir ),
|
||||||
|
.player2_tank_en( player2_tank_en ),
|
||||||
|
.VGA_h( vgaH ),
|
||||||
|
.VGA_V( vgaV ),
|
||||||
|
.reset_n( reset_n ),
|
||||||
|
.item_invincible( item_invincible ),
|
||||||
|
.item_addHP( item_addHP ),
|
||||||
|
.item_addtime( item_addtime ),
|
||||||
|
.item_frozen( item_frozen ),
|
||||||
|
.which_player( which_player ),
|
||||||
|
.VGA_data_reward( item_data )
|
||||||
|
);
|
||||||
|
|
||||||
wire [ 31: 0 ] num ;
|
wire [ 31: 0 ] num ;
|
||||||
// assign num = { 3'b000, KeyBoard_Output[ 0 ], 3'b000, KeyBoard_Output[ 1 ], 3'b000, KeyBoard_Output[ 2 ], 3'b000, KeyBoard_Output[ 3 ],
|
// assign num = { 3'b000, KeyBoard_Output[ 0 ], 3'b000, KeyBoard_Output[ 1 ], 3'b000, KeyBoard_Output[ 2 ], 3'b000, KeyBoard_Output[ 3 ],
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ assign enermy_moving = enermy_tank_en;
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
enermy_fire <= 1'b0;
|
enermy_fire <= 1'b0;
|
||||||
counter_num <= 0;
|
counter_num <= flag;
|
||||||
rand <= flag[ 0 ];
|
rand <= flag[ 0 ];
|
||||||
Continue <= 0;
|
Continue <= 0;
|
||||||
Continue_num <= 0;
|
Continue_num <= 0;
|
||||||
|
|
@ -197,7 +197,7 @@ always @( posedge clk_2Hz ) begin
|
||||||
endcase
|
endcase
|
||||||
|
|
||||||
end
|
end
|
||||||
if ( Continue ) begin
|
else begin
|
||||||
enermy_fire <= 1'b0;
|
enermy_fire <= 1'b0;
|
||||||
if ( rand ) begin
|
if ( rand ) begin
|
||||||
if ( enermy_V + TANK_HEIGHT / 2 <= chase_tank_V ) begin
|
if ( enermy_V + TANK_HEIGHT / 2 <= chase_tank_V ) begin
|
||||||
|
|
@ -236,22 +236,8 @@ always @( posedge clk_2Hz ) begin
|
||||||
|
|
||||||
end
|
end
|
||||||
if ( counter_num % 4 != flag ) begin
|
if ( counter_num % 4 != flag ) begin
|
||||||
if ( enermy_dir_feedback == 2'b00 && enermy_V == 0 ) begin
|
|
||||||
enermy_dir_feedback <= rand_num[ 1: 0 ];
|
|
||||||
end
|
|
||||||
else if ( enermy_dir_feedback == 2'b01 && tank_DBound >= HEIGHT ) begin
|
|
||||||
enermy_dir_feedback <= rand_num[ 1: 0 ];
|
|
||||||
end
|
|
||||||
else if ( enermy_dir_feedback == 2'b10 && enermy_H == 0 ) begin
|
|
||||||
enermy_dir_feedback <= rand_num[ 1: 0 ];
|
|
||||||
end
|
|
||||||
else if ( enermy_dir_feedback == 2'b11 && tank_RBound >= WIDTH ) begin
|
|
||||||
enermy_dir_feedback <= rand_num[ 1: 0 ];
|
|
||||||
end
|
|
||||||
else begin
|
|
||||||
enermy_dir_feedback <= enermy_dir_feedback_tmp;
|
enermy_dir_feedback <= enermy_dir_feedback_tmp;
|
||||||
end
|
end
|
||||||
end
|
|
||||||
else begin
|
else begin
|
||||||
enermy_dir_feedback <= rand_num[ 1: 0 ];
|
enermy_dir_feedback <= rand_num[ 1: 0 ];
|
||||||
end
|
end
|
||||||
|
|
@ -267,4 +253,6 @@ always @( posedge clk_2Hz ) begin
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ module game_logic_classic(
|
||||||
input [ 3: 0 ] scored1,
|
input [ 3: 0 ] scored1,
|
||||||
input [ 3: 0 ] scored2,
|
input [ 3: 0 ] scored2,
|
||||||
input item_invincible,
|
input item_invincible,
|
||||||
|
input item_addHP,
|
||||||
|
input which_player,
|
||||||
output reg [ 3: 0 ] HP1_value,
|
output reg [ 3: 0 ] HP1_value,
|
||||||
output reg [ 3: 0 ] HP2_value,
|
output reg [ 3: 0 ] HP2_value,
|
||||||
|
|
||||||
|
|
@ -48,9 +50,10 @@ module game_logic_classic(
|
||||||
reg [ 3: 0 ] score1;
|
reg [ 3: 0 ] score1;
|
||||||
reg [ 3: 0 ] score2;
|
reg [ 3: 0 ] score2;
|
||||||
reg mytank1_state_last, mytank2_state_last;
|
reg mytank1_state_last, mytank2_state_last;
|
||||||
|
reg item_addHP_last;
|
||||||
initial begin
|
initial begin
|
||||||
gameover_classic <= 0;
|
gameover_classic <= 0;
|
||||||
|
item_addHP_last <= 0;
|
||||||
score_classic <= 0;
|
score_classic <= 0;
|
||||||
winner <= 0;
|
winner <= 0;
|
||||||
score1 <= 0;
|
score1 <= 0;
|
||||||
|
|
@ -75,8 +78,18 @@ always @( posedge clk ) begin
|
||||||
HP1_value <= 4;
|
HP1_value <= 4;
|
||||||
HP2_value <= 4;
|
HP2_value <= 4;
|
||||||
end
|
end
|
||||||
|
if ( item_addHP && ~item_addHP_last ) begin
|
||||||
|
if ( which_player == 0 ) begin
|
||||||
|
HP1_value <= HP1_value + 1'b1;
|
||||||
|
end
|
||||||
|
|
||||||
|
else begin
|
||||||
|
HP2_value <= HP2_value + 1'b1;
|
||||||
|
end
|
||||||
|
end
|
||||||
mytank1_state_last <= mytank1_state;
|
mytank1_state_last <= mytank1_state;
|
||||||
mytank2_state_last <= mytank2_state;
|
mytank2_state_last <= mytank2_state;
|
||||||
|
item_addHP_last <= item_addHP;
|
||||||
end
|
end
|
||||||
// always@( negedge enable_game_classic or negedge mytank1_state ) begin
|
// always@( negedge enable_game_classic or negedge mytank1_state ) begin
|
||||||
// if ( item_invincible == 0 ) begin
|
// if ( item_invincible == 0 ) begin
|
||||||
|
|
|
||||||
|
|
@ -36,9 +36,8 @@ module game_logic_infinity(
|
||||||
input [ 3: 0 ] scored1,
|
input [ 3: 0 ] scored1,
|
||||||
input [ 3: 0 ] scored2,
|
input [ 3: 0 ] scored2,
|
||||||
input item_addtime,
|
input item_addtime,
|
||||||
input item_test,
|
|
||||||
|
|
||||||
input item_invincible,
|
input item_invincible,
|
||||||
|
input which_player,
|
||||||
output reg [ 3: 0 ] HP1_value,
|
output reg [ 3: 0 ] HP1_value,
|
||||||
output reg [ 3: 0 ] HP2_value,
|
output reg [ 3: 0 ] HP2_value,
|
||||||
output reg [ 4: 0 ] timer,
|
output reg [ 4: 0 ] timer,
|
||||||
|
|
@ -56,9 +55,8 @@ reg [ 3: 0 ] score1;
|
||||||
reg [ 3: 0 ] score2;
|
reg [ 3: 0 ] score2;
|
||||||
reg add_flag;
|
reg add_flag;
|
||||||
reg item_flag;
|
reg item_flag;
|
||||||
reg [ 1: 0 ] HP1_value, HP2_value;
|
|
||||||
reg mytank1_state_last, mytank2_state_last;
|
reg mytank1_state_last, mytank2_state_last;
|
||||||
|
reg item_addtime_last;
|
||||||
initial begin
|
initial begin
|
||||||
gameover_infinity <= 0;
|
gameover_infinity <= 0;
|
||||||
cnt <= 0;
|
cnt <= 0;
|
||||||
|
|
@ -167,7 +165,7 @@ always @( posedge clk ) begin
|
||||||
score1 <= scorea1 + scoreb1 + scorec1 + scored1;
|
score1 <= scorea1 + scoreb1 + scorec1 + scored1;
|
||||||
score2 <= scorea2 + scoreb2 + scorec2 + scored2;
|
score2 <= scorea2 + scoreb2 + scorec2 + scored2;
|
||||||
|
|
||||||
if ( item_addtime == 1 || item_test ) begin
|
if ( item_addtime == 1 ) begin
|
||||||
if ( item_flag == 0 && timer > 0 && timer < 16 ) begin
|
if ( item_flag == 0 && timer > 0 && timer < 16 ) begin
|
||||||
begin
|
begin
|
||||||
if ( timer == 15 ) begin
|
if ( timer == 15 ) begin
|
||||||
|
|
@ -197,6 +195,11 @@ always @( posedge clk ) begin
|
||||||
timer <= timer - 1;
|
timer <= timer - 1;
|
||||||
cnt <= 0;
|
cnt <= 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if ( item_addtime && ~item_addtime_last ) begin
|
||||||
|
timer <= timer + 10;
|
||||||
|
end
|
||||||
|
item_addtime_last <= item_addtime;
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,112 @@
|
||||||
|
`timescale 1ns / 1ps
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Company:
|
||||||
|
// Engineer:
|
||||||
|
//
|
||||||
|
// Create Date: 01/06/2021 08:41:26 AM
|
||||||
|
// Design Name:
|
||||||
|
// Module Name: item_display
|
||||||
|
// Project Name:
|
||||||
|
// Target Devices:
|
||||||
|
// Tool Versions:
|
||||||
|
// Description:
|
||||||
|
//
|
||||||
|
// Dependencies:
|
||||||
|
//
|
||||||
|
// Revision:
|
||||||
|
// Revision 0.01 - File Created
|
||||||
|
// Additional Comments:
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
module item_display(
|
||||||
|
input clk,
|
||||||
|
input set_require,
|
||||||
|
input enable_reward,
|
||||||
|
input [ 10: 0 ] random_xpos,
|
||||||
|
input [ 10: 0 ] random_ypos,
|
||||||
|
input [ 1: 0 ] item_type,
|
||||||
|
input [ 10: 0 ] VGA_h,
|
||||||
|
input [ 10: 0 ] VGA_V,
|
||||||
|
input enable_game_classic,
|
||||||
|
input enable_game_infinity,
|
||||||
|
output reg [ 11: 0 ] VGA_data
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wire [ 5: 0 ] ITEM_WIDTH ;
|
||||||
|
wire [ 5: 0 ] ITEM_HEIGHT;
|
||||||
|
|
||||||
|
assign ITEM_WIDTH = item_type == 2'b11 ? 32 : 20;
|
||||||
|
assign ITEM_HEIGHT = item_type == 2'b11 ? 32 : 20;
|
||||||
|
reg [ 8: 0 ] addra_add_heart, addra_add_timing, addra_frozen;
|
||||||
|
reg [ 9: 0 ] addra_invincible;
|
||||||
|
|
||||||
|
wire[ 11: 0 ] add_heart_pic, add_timing_pic, add_frozen_pic, invincible_pic;
|
||||||
|
// reg [ 11: 0 ] add_heart_reg, add_timing_reg, add_frozen_reg, invincible_reg;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
always @( posedge clk ) begin
|
||||||
|
if ( set_require == 1'b1 && enable_reward == 1'b1 ) begin
|
||||||
|
if ( VGA_h >= random_xpos && VGA_h < random_xpos + ITEM_WIDTH && VGA_V >= random_ypos && VGA_V < random_ypos + ITEM_HEIGHT ) begin
|
||||||
|
addra_add_heart <= ( VGA_h - random_xpos ) + ( VGA_V - random_ypos ) * 20;
|
||||||
|
addra_add_timing <= ( VGA_h - random_xpos ) + ( VGA_V - random_ypos ) * 20;
|
||||||
|
addra_frozen <= ( VGA_h - random_xpos ) + ( VGA_V - random_ypos ) * 20;
|
||||||
|
addra_invincible <= ( VGA_h - random_xpos ) + ( VGA_V - random_ypos ) * 32;
|
||||||
|
case ( item_type )
|
||||||
|
2'b01: begin
|
||||||
|
if ( enable_game_classic == 1 ) begin
|
||||||
|
VGA_data <= add_heart_pic;
|
||||||
|
end
|
||||||
|
else if ( enable_game_infinity ) begin
|
||||||
|
VGA_data <= add_timing_pic;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
2'b10: begin
|
||||||
|
VGA_data <= add_frozen_pic;
|
||||||
|
end
|
||||||
|
2'b11: begin
|
||||||
|
VGA_data <= invincible_pic;
|
||||||
|
end
|
||||||
|
default : begin
|
||||||
|
VGA_data <= 0;
|
||||||
|
end
|
||||||
|
endcase
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
VGA_data <= 0;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
VGA_data <= 0;
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
add_heart_20_20 u_add_heart_20_20(
|
||||||
|
.clka( clk ),
|
||||||
|
.ena( 1'b1 ),
|
||||||
|
.addra( addra_add_heart ),
|
||||||
|
.douta( add_heart_pic )
|
||||||
|
);
|
||||||
|
add_timing_20_20 u_add_timing_20_20(
|
||||||
|
.clka( clk ),
|
||||||
|
.ena( 1'b1 ),
|
||||||
|
.addra( addra_add_timing ),
|
||||||
|
.douta( add_timing_pic )
|
||||||
|
);
|
||||||
|
snowflake_20_20 u_snowflake_20_20(
|
||||||
|
.clka( clk ),
|
||||||
|
.ena( 1'b1 ),
|
||||||
|
.addra( addra_frozen ),
|
||||||
|
.douta( add_frozen_pic )
|
||||||
|
);
|
||||||
|
invincible_star_32_32 u_invincible_star(
|
||||||
|
.clka( clk ),
|
||||||
|
.ena( 1'b1 ),
|
||||||
|
.addra( addra_invincible ),
|
||||||
|
.douta( invincible_pic )
|
||||||
|
);
|
||||||
|
endmodule
|
||||||
|
|
@ -43,12 +43,12 @@ module item_logic(
|
||||||
output reg item_frozen,
|
output reg item_frozen,
|
||||||
output reg item_addHP,
|
output reg item_addHP,
|
||||||
output reg which_player,
|
output reg which_player,
|
||||||
output [ 11: 0 ] VGA_data
|
output [ 11: 0 ] VGA_data_reward
|
||||||
);
|
);
|
||||||
|
|
||||||
wire [ 1: 0 ] item_type;
|
wire [ 1: 0 ] item_type;
|
||||||
wire [ 10: 0 ] random_xpos, random_ypos;
|
wire [ 10: 0 ] random_xpos, random_ypos;
|
||||||
reg [ 31: 0 ] cnt_num;
|
reg [ 31: 0 ] cnt;
|
||||||
|
|
||||||
wire set_require;
|
wire set_require;
|
||||||
reg set_finish;
|
reg set_finish;
|
||||||
|
|
@ -57,7 +57,7 @@ wire [ 11: 0 ] VGA_data_information;
|
||||||
assign VGA_data_reward = VGA_data_information;
|
assign VGA_data_reward = VGA_data_information;
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
cnt_num <= 0;
|
cnt <= 0;
|
||||||
item_invincible <= 0;
|
item_invincible <= 0;
|
||||||
item_addtime <= 0;
|
item_addtime <= 0;
|
||||||
item_frozen <= 0;
|
item_frozen <= 0;
|
||||||
|
|
@ -92,7 +92,7 @@ object_collide_detection tank2_item(
|
||||||
|
|
||||||
always @( posedge clk ) begin
|
always @( posedge clk ) begin
|
||||||
if ( enable_reward ) begin
|
if ( enable_reward ) begin
|
||||||
if ( player1_tank_get || player2_tank_get ) begin
|
if ( set_require == 1'b1 && ( player1_tank_get || player2_tank_get ) ) begin
|
||||||
case ( item_type )
|
case ( item_type )
|
||||||
1: begin
|
1: begin
|
||||||
if ( enable_game_classic ) begin
|
if ( enable_game_classic ) begin
|
||||||
|
|
@ -127,7 +127,7 @@ always @( posedge clk ) begin
|
||||||
end
|
end
|
||||||
if ( item_invincible ) begin
|
if ( item_invincible ) begin
|
||||||
cnt <= cnt + 1;
|
cnt <= cnt + 1;
|
||||||
if ( cnt >= 500000000 ) begin
|
if ( cnt >= 800000000 ) begin
|
||||||
item_invincible <= 1'b0;
|
item_invincible <= 1'b0;
|
||||||
cnt <= 0;
|
cnt <= 0;
|
||||||
end
|
end
|
||||||
|
|
@ -148,15 +148,44 @@ always @( posedge clk ) begin
|
||||||
end
|
end
|
||||||
if ( item_frozen ) begin
|
if ( item_frozen ) begin
|
||||||
cnt <= cnt + 1;
|
cnt <= cnt + 1;
|
||||||
if ( cnt >= 300000000 ) begin
|
if ( cnt >= 400000000 ) begin
|
||||||
item_frozen <= 1'b0;
|
item_frozen <= 1'b0;
|
||||||
cnt <= 0;
|
cnt <= 0;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else begin
|
||||||
|
cnt <= 0;
|
||||||
|
item_invincible <= 0;
|
||||||
|
item_addtime <= 0;
|
||||||
|
item_frozen <= 0;
|
||||||
|
item_addHP <= 0;
|
||||||
|
which_player <= 0;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
item_random_generator u_item_random_generator(
|
item_random_generator u_item_random_generator(
|
||||||
|
.clk( clk ),
|
||||||
|
.clk_4Hz( clk_4Hz ),
|
||||||
|
.set_finish( set_finish ),
|
||||||
|
.enable( enable_reward ),
|
||||||
|
.dout( random_out ),
|
||||||
|
.item_type( item_type ),
|
||||||
|
.set_require( set_require ),
|
||||||
|
.random_xpos( random_xpos ),
|
||||||
|
.random_ypos( random_ypos )
|
||||||
|
);
|
||||||
|
item_display u_item_display(
|
||||||
|
.clk( clk ),
|
||||||
|
.set_require( set_require ),
|
||||||
|
.enable_reward( enable_reward ),
|
||||||
|
.enable_game_classic( enable_game_classic ),
|
||||||
|
.enable_game_infinity( enable_game_infinity ),
|
||||||
|
.random_xpos( random_xpos ),
|
||||||
|
.random_ypos( random_ypos ),
|
||||||
|
.item_type( item_type ),
|
||||||
|
.VGA_h( VGA_h ),
|
||||||
|
.VGA_V( VGA_V ),
|
||||||
|
.VGA_data( VGA_data_information )
|
||||||
);
|
);
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,67 @@ module item_random_generator(
|
||||||
output reg dout,
|
output reg dout,
|
||||||
output reg set_require,
|
output reg set_require,
|
||||||
output reg [ 1: 0 ] item_type,
|
output reg [ 1: 0 ] item_type,
|
||||||
output [ 10: 0 ] random_xpos,
|
output reg [ 10: 0 ] random_xpos,
|
||||||
output [ 10: 0 ] random_ypos
|
output reg [ 10: 0 ] random_ypos
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
parameter ITEM_BASE_TIME = 24;
|
||||||
|
parameter ITEM_STAY_TIME = 32;
|
||||||
|
parameter TANK_WIDTH = 32;
|
||||||
|
parameter TANK_HEIGHT = 32;
|
||||||
|
parameter WIDTH = 640;
|
||||||
|
parameter HEIGHT = 480;
|
||||||
|
|
||||||
|
wire [ 14: 0 ] random_num;
|
||||||
|
reg [ 31: 0 ] cnt;
|
||||||
|
reg lock;
|
||||||
|
initial begin
|
||||||
|
random_xpos <= 0;
|
||||||
|
random_ypos <= 0;
|
||||||
|
item_type <= 0;
|
||||||
|
lock <= 0;
|
||||||
|
end
|
||||||
|
Random u_Random(
|
||||||
|
.clk( clk_4Hz ),
|
||||||
|
.rst_n( 1'b1 ),
|
||||||
|
.flag( 2'b00 ),
|
||||||
|
.random( ),
|
||||||
|
.random_14( random_num )
|
||||||
|
);
|
||||||
|
always @( posedge clk ) begin
|
||||||
|
if ( enable ) begin
|
||||||
|
cnt <= cnt + 1'b1;
|
||||||
|
if ( cnt >= ITEM_BASE_TIME * 25000000 ) begin
|
||||||
|
dout <= 1'b1;
|
||||||
|
set_require <= 1'b1;
|
||||||
|
if ( cnt >= ( ITEM_BASE_TIME + ITEM_STAY_TIME ) * 25000000 || set_finish == 1'b1 ) begin
|
||||||
|
dout <= 1'b0;
|
||||||
|
cnt <= 0;
|
||||||
|
set_require <= 1'b0;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
dout <= 1'b0;
|
||||||
|
set_require <= 1'b0;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
always @( posedge clk ) begin
|
||||||
|
if ( dout ) begin
|
||||||
|
if ( !lock ) begin
|
||||||
|
lock <= 1'b1;
|
||||||
|
random_xpos <= random_num[ 14: 1 ] % ( WIDTH - TANK_WIDTH );
|
||||||
|
random_ypos <= random_num[ 13: 0 ] % ( HEIGHT - TANK_HEIGHT );
|
||||||
|
item_type <= ( random_num[ 14: 0 ] % 3 ) + 1;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
random_xpos <= 0;
|
||||||
|
random_ypos <= 0;
|
||||||
|
lock <= 0;
|
||||||
|
item_type <= 0;
|
||||||
|
end
|
||||||
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ module tank_display(
|
||||||
input [ 10: 0 ] vgaV, // Current VGA position
|
input [ 10: 0 ] vgaV, // Current VGA position
|
||||||
input [ 10: 0 ] tankH,
|
input [ 10: 0 ] tankH,
|
||||||
input [ 10: 0 ] tankV, // Current Y of tank
|
input [ 10: 0 ] tankV, // Current Y of tank
|
||||||
|
input item_invincible,
|
||||||
output [ 11: 0 ] tankData
|
output [ 11: 0 ] tankData
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -81,6 +82,6 @@ tank_data_selector tank_select( .clk( clk ), .UP( tankUpData ), .DOWN( tankDownD
|
||||||
.RIGHT( tankRightData ), .Dir( tankDir ), .tankData( outData ) );
|
.RIGHT( tankRightData ), .Dir( tankDir ), .tankData( outData ) );
|
||||||
tank_data_selector e_tank_select( .clk( clk ), .UP( tankUpData_enermy ), .DOWN( tankDownData_enermy ), .LEFT( tankLeftData_enermy ),
|
tank_data_selector e_tank_select( .clk( clk ), .UP( tankUpData_enermy ), .DOWN( tankDownData_enermy ), .LEFT( tankLeftData_enermy ),
|
||||||
.RIGHT( tankRightData_enermy ), .Dir( tankDir ), .tankData( outData_enermy ) );
|
.RIGHT( tankRightData_enermy ), .Dir( tankDir ), .tankData( outData_enermy ) );
|
||||||
assign tankData = ( ( tank_en & ~tank_destroyed ) ? ( player_enermy ? outData_enermy : outData ) : 0 ) | ( tank_revive ? outData_star : 0 );
|
assign tankData = ( ( tank_en & ~tank_destroyed ) ? ( player_enermy ? outData_enermy : outData ) : 0 ) | ( ( ( tank_revive || item_invincible ) && tank_en ) ? outData_star : 0 );
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,13 @@
|
||||||
module tank_move(
|
module tank_move(
|
||||||
clk, reset_n, start,
|
clk, reset_n, start,
|
||||||
init_H, init_V,
|
init_H, init_V,
|
||||||
tank_dir, tank_en, tank_move_en, player_enermy, moving,
|
tank_dir, tank_en, tank_move_en, player_enermy, moving, item_frozen,
|
||||||
tank_H, tank_V, tank_dir_feedback
|
tank_H, tank_V, tank_dir_feedback
|
||||||
);
|
);
|
||||||
|
|
||||||
input clk;
|
input clk;
|
||||||
input moving;
|
input moving;
|
||||||
|
input item_frozen;
|
||||||
input reset_n;
|
input reset_n;
|
||||||
input start;
|
input start;
|
||||||
input [ 10: 0 ] init_H;
|
input [ 10: 0 ] init_H;
|
||||||
|
|
@ -87,7 +88,7 @@ always @( * ) begin: state_table
|
||||||
INITIAL:
|
INITIAL:
|
||||||
next_state = STAY;
|
next_state = STAY;
|
||||||
STAY, UP, DOWN, LEFT, RIGHT: begin
|
STAY, UP, DOWN, LEFT, RIGHT: begin
|
||||||
if ( !tank_en || !tank_move_en || !moving ) begin
|
if ( ( item_frozen && player_enermy ) || !tank_en || !tank_move_en || !moving ) begin
|
||||||
next_state = STAY;
|
next_state = STAY;
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
|
|
@ -169,7 +170,7 @@ always @( posedge clk ) begin: tank_move_logic
|
||||||
end
|
end
|
||||||
|
|
||||||
reg [ 31: 0 ] counter;
|
reg [ 31: 0 ] counter;
|
||||||
wire [ 31: 0 ] counter_num = player_enermy ? 2_500_000 : 2_500_000;
|
wire [ 31: 0 ] counter_num = player_enermy ? 2_000_000 : 2_000_000;
|
||||||
always @( posedge clk ) begin
|
always @( posedge clk ) begin
|
||||||
if ( !reset_n ) begin
|
if ( !reset_n ) begin
|
||||||
counter <= 0;
|
counter <= 0;
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,11 @@ always @( posedge clk ) begin
|
||||||
heart_reg2 <= 0;
|
heart_reg2 <= 0;
|
||||||
end
|
end
|
||||||
else if ( mode == 1 || mode == 2 ) begin
|
else if ( mode == 1 || mode == 2 ) begin
|
||||||
if ( vgaH >= 5 && vgaH < 25 && vgaV >= 180 && vgaV < 300 && ( vgaV - 180 ) < ( mode == 1 ? HP1_value : HP1_value_infinity ) * 20 ) begin
|
if ( vgaH >= 5 && vgaH < 25 && vgaV >= 180 && vgaV < 340 && ( vgaV - 180 ) < ( mode == 1 ? HP1_value : HP1_value_infinity ) * 20 ) begin
|
||||||
addra_heart_pic1 <= ( vgaH - 5 ) + ( ( vgaV - 180 ) % 20 ) * 20;
|
addra_heart_pic1 <= ( vgaH - 5 ) + ( ( vgaV - 180 ) % 20 ) * 20;
|
||||||
heart_reg1 <= heart_pic1;
|
heart_reg1 <= heart_pic1;
|
||||||
end
|
end
|
||||||
else if ( vgaH >= 615 && vgaH < 635 && vgaV >= 180 && vgaV < 300 && ( vgaV - 180 ) < ( mode == 1 ? HP2_value : HP2_value_infinity ) * 20 ) begin
|
else if ( vgaH >= 615 && vgaH < 635 && vgaV >= 180 && vgaV < 340 && ( vgaV - 180 ) < ( mode == 1 ? HP2_value : HP2_value_infinity ) * 20 ) begin
|
||||||
addra_heart_pic2 <= ( vgaH - 615 ) + ( ( vgaV - 180 ) % 20 ) * 20;
|
addra_heart_pic2 <= ( vgaH - 615 ) + ( ( vgaV - 180 ) % 20 ) * 20;
|
||||||
heart_reg2 <= heart_pic2;
|
heart_reg2 <= heart_pic2;
|
||||||
end
|
end
|
||||||
|
|
|
||||||
42
TankGame.xpr
42
TankGame.xpr
|
|
@ -195,6 +195,27 @@
|
||||||
<Attr Name="UsedIn" Val="simulation"/>
|
<Attr Name="UsedIn" Val="simulation"/>
|
||||||
</FileInfo>
|
</FileInfo>
|
||||||
</File>
|
</File>
|
||||||
|
<File Path="$PSRCDIR/sources_1/new/item_display.v">
|
||||||
|
<FileInfo>
|
||||||
|
<Attr Name="UsedIn" Val="synthesis"/>
|
||||||
|
<Attr Name="UsedIn" Val="implementation"/>
|
||||||
|
<Attr Name="UsedIn" Val="simulation"/>
|
||||||
|
</FileInfo>
|
||||||
|
</File>
|
||||||
|
<File Path="$PSRCDIR/sources_1/new/item_logic.v">
|
||||||
|
<FileInfo>
|
||||||
|
<Attr Name="UsedIn" Val="synthesis"/>
|
||||||
|
<Attr Name="UsedIn" Val="implementation"/>
|
||||||
|
<Attr Name="UsedIn" Val="simulation"/>
|
||||||
|
</FileInfo>
|
||||||
|
</File>
|
||||||
|
<File Path="$PSRCDIR/sources_1/new/item_random_generator.v">
|
||||||
|
<FileInfo>
|
||||||
|
<Attr Name="UsedIn" Val="synthesis"/>
|
||||||
|
<Attr Name="UsedIn" Val="implementation"/>
|
||||||
|
<Attr Name="UsedIn" Val="simulation"/>
|
||||||
|
</FileInfo>
|
||||||
|
</File>
|
||||||
<File Path="$PSRCDIR/sources_1/new/object_collide_detection.v">
|
<File Path="$PSRCDIR/sources_1/new/object_collide_detection.v">
|
||||||
<FileInfo>
|
<FileInfo>
|
||||||
<Attr Name="UsedIn" Val="synthesis"/>
|
<Attr Name="UsedIn" Val="synthesis"/>
|
||||||
|
|
@ -485,22 +506,6 @@
|
||||||
<Attr Name="UsedIn" Val="simulation"/>
|
<Attr Name="UsedIn" Val="simulation"/>
|
||||||
</FileInfo>
|
</FileInfo>
|
||||||
</File>
|
</File>
|
||||||
<File Path="$PSRCDIR/sources_1/new/item_random_generator.v">
|
|
||||||
<FileInfo>
|
|
||||||
<Attr Name="AutoDisabled" Val="1"/>
|
|
||||||
<Attr Name="UsedIn" Val="synthesis"/>
|
|
||||||
<Attr Name="UsedIn" Val="implementation"/>
|
|
||||||
<Attr Name="UsedIn" Val="simulation"/>
|
|
||||||
</FileInfo>
|
|
||||||
</File>
|
|
||||||
<File Path="$PSRCDIR/sources_1/new/item_logic.v">
|
|
||||||
<FileInfo>
|
|
||||||
<Attr Name="AutoDisabled" Val="1"/>
|
|
||||||
<Attr Name="UsedIn" Val="synthesis"/>
|
|
||||||
<Attr Name="UsedIn" Val="implementation"/>
|
|
||||||
<Attr Name="UsedIn" Val="simulation"/>
|
|
||||||
</FileInfo>
|
|
||||||
</File>
|
|
||||||
<Config>
|
<Config>
|
||||||
<Option Name="DesignMode" Val="RTL"/>
|
<Option Name="DesignMode" Val="RTL"/>
|
||||||
<Option Name="TopModule" Val="Top"/>
|
<Option Name="TopModule" Val="Top"/>
|
||||||
|
|
@ -550,7 +555,7 @@
|
||||||
<File Path="$PSRCDIR/utils_1/imports/impl_1/Top_routed.dcp">
|
<File Path="$PSRCDIR/utils_1/imports/impl_1/Top_routed.dcp">
|
||||||
<FileInfo>
|
<FileInfo>
|
||||||
<Attr Name="ImportPath" Val="$PRUNDIR/impl_1/Top_routed.dcp"/>
|
<Attr Name="ImportPath" Val="$PRUNDIR/impl_1/Top_routed.dcp"/>
|
||||||
<Attr Name="ImportTime" Val="1609851846"/>
|
<Attr Name="ImportTime" Val="1609923161"/>
|
||||||
<Attr Name="UsedIn" Val="synthesis"/>
|
<Attr Name="UsedIn" Val="synthesis"/>
|
||||||
<Attr Name="UsedIn" Val="implementation"/>
|
<Attr Name="UsedIn" Val="implementation"/>
|
||||||
<Attr Name="UsedInSteps" Val="impl_1"/>
|
<Attr Name="UsedInSteps" Val="impl_1"/>
|
||||||
|
|
@ -899,7 +904,6 @@
|
||||||
<FileSet Name="add_timing_20_20" Type="BlockSrcs" RelSrcDir="$PSRCDIR/add_timing_20_20">
|
<FileSet Name="add_timing_20_20" Type="BlockSrcs" RelSrcDir="$PSRCDIR/add_timing_20_20">
|
||||||
<File Path="$PSRCDIR/sources_1/ip/add_timing_20_20/add_timing_20_20.xci">
|
<File Path="$PSRCDIR/sources_1/ip/add_timing_20_20/add_timing_20_20.xci">
|
||||||
<FileInfo>
|
<FileInfo>
|
||||||
<Attr Name="AutoDisabled" Val="1"/>
|
|
||||||
<Attr Name="UsedIn" Val="synthesis"/>
|
<Attr Name="UsedIn" Val="synthesis"/>
|
||||||
<Attr Name="UsedIn" Val="implementation"/>
|
<Attr Name="UsedIn" Val="implementation"/>
|
||||||
<Attr Name="UsedIn" Val="simulation"/>
|
<Attr Name="UsedIn" Val="simulation"/>
|
||||||
|
|
@ -913,7 +917,6 @@
|
||||||
<FileSet Name="snowflake_20_20" Type="BlockSrcs" RelSrcDir="$PSRCDIR/snowflake_20_20">
|
<FileSet Name="snowflake_20_20" Type="BlockSrcs" RelSrcDir="$PSRCDIR/snowflake_20_20">
|
||||||
<File Path="$PSRCDIR/sources_1/ip/snowflake_20_20/snowflake_20_20.xci">
|
<File Path="$PSRCDIR/sources_1/ip/snowflake_20_20/snowflake_20_20.xci">
|
||||||
<FileInfo>
|
<FileInfo>
|
||||||
<Attr Name="AutoDisabled" Val="1"/>
|
|
||||||
<Attr Name="UsedIn" Val="synthesis"/>
|
<Attr Name="UsedIn" Val="synthesis"/>
|
||||||
<Attr Name="UsedIn" Val="implementation"/>
|
<Attr Name="UsedIn" Val="implementation"/>
|
||||||
<Attr Name="UsedIn" Val="simulation"/>
|
<Attr Name="UsedIn" Val="simulation"/>
|
||||||
|
|
@ -927,7 +930,6 @@
|
||||||
<FileSet Name="add_heart_20_20" Type="BlockSrcs" RelSrcDir="$PSRCDIR/add_heart_20_20">
|
<FileSet Name="add_heart_20_20" Type="BlockSrcs" RelSrcDir="$PSRCDIR/add_heart_20_20">
|
||||||
<File Path="$PSRCDIR/sources_1/ip/add_heart_20_20/add_heart_20_20.xci">
|
<File Path="$PSRCDIR/sources_1/ip/add_heart_20_20/add_heart_20_20.xci">
|
||||||
<FileInfo>
|
<FileInfo>
|
||||||
<Attr Name="AutoDisabled" Val="1"/>
|
|
||||||
<Attr Name="UsedIn" Val="synthesis"/>
|
<Attr Name="UsedIn" Val="synthesis"/>
|
||||||
<Attr Name="UsedIn" Val="implementation"/>
|
<Attr Name="UsedIn" Val="implementation"/>
|
||||||
<Attr Name="UsedIn" Val="simulation"/>
|
<Attr Name="UsedIn" Val="simulation"/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue