diff --git a/bin/Debug/blockBreaker b/bin/Debug/blockBreaker index 7937d54..2d12b1a 100755 Binary files a/bin/Debug/blockBreaker and b/bin/Debug/blockBreaker differ diff --git a/blockBreaker.depend b/blockBreaker.depend index 80c0ecd..2f0e6c0 100644 --- a/blockBreaker.depend +++ b/blockBreaker.depend @@ -1,5 +1,5 @@ # depslib dependency file v1.0 -1729487645 source:/home/fluffy/codeBlocks/blockBreaker/main.c +1729498522 source:/home/fluffy/codeBlocks/blockBreaker/main.c diff --git a/main.c b/main.c index 34a7d94..d91a53e 100644 --- a/main.c +++ b/main.c @@ -4,15 +4,16 @@ #include #include #include -#define SCREEN_WIDTH 11 //set the width of the game screen -#define SCREEN_HEIGHT 20 //set the height of the game screen -#define PADDLE_SIZE 2 //set the paddle size. the blocks are added this amount either size of a central block. -#define SLEEP_TIME_MS 100 * 1000 //set the time to sleep between frames -#define PADDLE_HEIGHT SCREEN_HEIGHT-4 //the negative number is distance from the bottom -#define Y_BLOCK_LAYERS 10 //add the amount of layers of blocks from the top of the screen +#define SCREEN_WIDTH 11 //set the width of the game screen +#define SCREEN_HEIGHT 20 //set the height of the game screen +#define PADDLE_SIZE 2 //set the paddle size. the blocks are added this amount either size of a central block. +#define SLEEP_TIME_MS 100 * 1000 //set the time to sleep between frames +#define PADDLE_HEIGHT SCREEN_HEIGHT-4 //the negative number is distance from the bottom +#define Y_BLOCK_LAYERS 10 //add the amount of layers of blocks from the top of the screen #define X_BLOCK_LAYERS SCREEN_WIDTH uint8_t screen[SCREEN_WIDTH][SCREEN_HEIGHT]; //this is the array the game lives in +int moveArr[] = {-2,-1,0,1,2}; enum PIXEL_TYPE { //used to set what kind of pixel is shown on the screen array PIXEL_EMPTY=0u, @@ -41,10 +42,10 @@ typedef struct ballStruct { int8_t yVEL; } Ball_t; -struct Paddle { +typedef struct Paddle { uint8_t location; - uint8_t paddleSize; -} paddle= {.location=(SCREEN_WIDTH/2),.paddleSize=PADDLE_SIZE}; + int paddleSize; +} Paddle_t; typedef struct block { uint8_t xLocation; @@ -58,8 +59,22 @@ bool ballOnXEdge(Ball_t ball){ //work around to determine if the ball is on the return false; } +bool movePaddle(Paddle_t* Paddle, int dir){ //negitave dir to move left positive to move right + if (dir==0) return false; + if (dir<=0){ + if (Paddle ->location-Paddle->paddleSize+dir<=0) return false; + Paddle->location = Paddle->location+dir; + return true; + } else if (dir>=0) { + if (Paddle->location+Paddle->paddleSize+dir>= SCREEN_WIDTH-1) return false; + Paddle->location= Paddle->location+dir; + return true; + } +} + int main() { Ball_t ball = {.xPOS=0,.yPOS=0,.xVEL=0,.yVEL=0}; //setup game ball + Paddle_t paddle= {.location=(SCREEN_WIDTH/2),.paddleSize=PADDLE_SIZE}; time_t UNIXTIME = time(NULL); //create UNIXTIME struct srand(UNIXTIME); //seed random number with time at run time Block_t blockArr[X_BLOCK_LAYERS][Y_BLOCK_LAYERS]; @@ -201,5 +216,9 @@ int main() { ball.xPOS=ball.xPOS+ball.xVEL; ball.yPOS= ball.yPOS+ball.yVEL; + + //move paddle + movePaddle(&paddle,moveArr[rand()%6]); + } } diff --git a/obj/Debug/main.o b/obj/Debug/main.o index 7d1f922..7b82947 100644 Binary files a/obj/Debug/main.o and b/obj/Debug/main.o differ