|
@@ -17,8 +17,8 @@
|
|
|
*/
|
|
|
#define LEFT_UP_BUTTON 1
|
|
|
#define LEFT_DOWN_BUTTON 0
|
|
|
-#define RIGTH_UP_BUTTON 3
|
|
|
-#define RIGTH_DOWN_BUTTON 2
|
|
|
+#define RIGHT_UP_BUTTON 3
|
|
|
+#define RIGHT_DOWN_BUTTON 2
|
|
|
|
|
|
#define MIN(a,b) (((a)<(b))?(a):(b))
|
|
|
#define MAX(a,b) (((a)>(b))?(a):(b))
|
|
@@ -30,7 +30,7 @@ struct Paddle right_paddle;
|
|
|
/*
|
|
|
* restes everything to default.
|
|
|
* both paddles on highes position, with a length of 3.
|
|
|
- * ball in the middle, start moving up-rigth.
|
|
|
+ * ball in the middle, start moving up-right.
|
|
|
*/
|
|
|
void reset_pos() {
|
|
|
ball.x = COLS/2 - 1;
|
|
@@ -48,7 +48,7 @@ void reset_pos() {
|
|
|
* first read input registers and calculate new paddelpositions depending on the pressed buttons.
|
|
|
*
|
|
|
* second calculate the new position of the ball depending on its current position and velocity.
|
|
|
- * If Ball hits left or rigth border calculate if the ball hits a paddle or strike a goal.
|
|
|
+ * If Ball hits left or right border calculate if the ball hits a paddle or strike a goal.
|
|
|
* Goal -> restart the game
|
|
|
* Paddle -> bounce ball back
|
|
|
*
|
|
@@ -74,10 +74,10 @@ void game() {
|
|
|
printf("%f\n",left_paddle.y);
|
|
|
}
|
|
|
|
|
|
- if (buttons & (1<<RIGTH_UP_BUTTON)){
|
|
|
+ if (buttons & (1<<RIGHT_UP_BUTTON)){
|
|
|
right_paddle.y = MAX(right_paddle.y - (10 * TICK), 0);
|
|
|
}
|
|
|
- if (buttons & (1<<RIGTH_DOWN_BUTTON)){
|
|
|
+ if (buttons & (1<<RIGHT_DOWN_BUTTON)){
|
|
|
right_paddle.y = MIN(right_paddle.y + (10 * TICK), ROWS - (right_paddle.length));
|
|
|
}
|
|
|
|
|
@@ -98,11 +98,11 @@ void game() {
|
|
|
ball.vel_x = - ball.vel_x;
|
|
|
} else {
|
|
|
printf("ballx: %f, ball y: %f\n",ball.x,ball.y);
|
|
|
- printf("rigth player lost\n");
|
|
|
+ printf("right player lost\n");
|
|
|
reset_pos();
|
|
|
}
|
|
|
}
|
|
|
- // check for rigth border
|
|
|
+ // check for right border
|
|
|
if (ball.x >= COLS - 2){
|
|
|
if (round(ball.y) >= round(right_paddle.y) && round(ball.y) <= (round(right_paddle.y) + right_paddle.length -1)){
|
|
|
ball.vel_x = - ball.vel_x;
|
|
@@ -142,7 +142,7 @@ void game() {
|
|
|
|
|
|
/*
|
|
|
* function to output a test picture. used to verify the VHDL implementation.
|
|
|
- * Will turn on one pixel after another starting with row 1 on the rigth side
|
|
|
+ * Will turn on one pixel after another starting with row 1 on the right side
|
|
|
* Will also print on console if one of the game buttons is pressed.
|
|
|
*/
|
|
|
void test_picture() {
|
|
@@ -160,11 +160,11 @@ void test_picture() {
|
|
|
printf("left button down");
|
|
|
}
|
|
|
|
|
|
- if (buttons & (1<<RIGTH_UP_BUTTON)){
|
|
|
- printf("rigth button up");
|
|
|
+ if (buttons & (1<<RIGHT_UP_BUTTON)){
|
|
|
+ printf("right button up");
|
|
|
}
|
|
|
- if (buttons & (1<<RIGTH_DOWN_BUTTON)){
|
|
|
- printf("rigth button down");
|
|
|
+ if (buttons & (1<<RIGHT_DOWN_BUTTON)){
|
|
|
+ printf("right button down");
|
|
|
}
|
|
|
printf("\n");
|
|
|
set_pixel(j,i);
|