Tian Gao
Published

Ahhhh...BIU!

I built a video game controlled by people’s voice. The game is about jet fighters.

Full instructions provided941
Ahhhh...BIU!

Things used in this project

Hardware components

Solder Board
×1
Power Supply
×1
Mega1284
×1
LCD TV
×1
DIP socket
×2
Microphone
×2
3.5mm Phone Plug
×3

Story

Read more

Code

function.c

C/C++
function.c
int GetRand(int MIN,int MAX)
{
int dis=MAX-MIN+1;
int incr=pgm_read_word(RAND+RandomNumIndex);
RandomNumIndex=(RandomNumIndex+1)&0x03FF;
return MIN+incr%dis;
}

/* There are four structs built in the project, each represents an object in the game. */

struct S_Player
{
unsigned char Num;
unsigned char Plane_X;
unsigned char Plane_Y;
signed char HP;
signed char b_speed;
signed char b_size;
unsigned char b_num;
};

struct S_Bullet
{
unsigned char x;
unsigned char y;
unsigned char size;
signed char x_speed;
signed char y_speed;
char en;
};

struct S_Obstacle
{
unsigned char x_left;
unsigned char x_right;
unsigned char y_up;
unsigned char y_down;
signed char x_speed;
signed char y_speed;
unsigned char en;
};

struct S_Buff
{
unsigned char x;
unsigned char y;
signed char x_speed;
signed char y_speed;
unsigned char Type;
signed char Value;
unsigned char en;
};

/* Objects' characters are defined in the struct. For bullet/obstacle/buff, variable en means whether it's enabled. If en=1, the object is valid, otherwise it's invisible. There are six types of buff, defined as */

#define BUFF_SIZEPLUS 1
#define BUFF_SIZEMINUS 2
#define BUFF_SPEEDPLUS 3
#define BUFF_SPEEDMINUS 4
#define BUFF_DOUBLE 5
#define BUFF_LIFE 6

/* Also, there are minimum intervals for every two bullets/obstacles/buffs defined. */

Credits

Tian Gao

Tian Gao

1 project • 0 followers

Comments