Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // I WANT TO PLAY WITH YOU
- // YOUR FRIEND, AI
- #include <stdio.h>
- #include <unistd.h>
- #include <curses.h>
- void draw();
- void keypressed(char keyboard);
- int player_one_y = 13, player_two_y = 13;
- int ball_x = 4, ball_y = 13;
- int score_one = 0, score_two=0;
- int main() {
- initscr();
- curs_set(0);
- noecho();
- nodelay(stdscr, TRUE);
- // while(score_one !=21 || score_two !=21){
- // char c = getch();
- // keypressed(c);
- //
- // draw();
- //
- // usleep(500000);
- // }
- }
- void draw(){
- // move(0,0);
- system("@cls||clear");
- for (int y = 0; y < 25; y++) {
- for (int x = 0; x < 80; x++) {
- if (y == 0 || y == 24)
- printf("%c", '-');
- else if (x == 0 || x == 79)
- printf("%c", '|');
- else if ((y <= (player_one_y + 1) && y >= player_one_y - 1) && x == 3)
- printf("%c", ']');
- else if (y == ball_y && x == ball_x)
- printf("%c", '*');
- else if (x == 39 || x == 40)
- printf("%c", '-');
- else if ((y <= (player_two_y + 1) && y >= player_two_y- 1) && x == 77)
- printf("%c", '[');
- else
- printf("%c", ' ');
- }
- printf("\n");
- }
- printf("player 1 %d - %d player 2\n", score_one, score_two);
- }
- void keypressed(char keyboard){
- if (keyboard == 'z' && player_one_y < 24) {
- player_one_y++;
- } else if (keyboard == 'a' && player_one_y > 3) {
- player_one_y--;
- } else if (keyboard == 'm' && player_two_y < 24) {
- player_two_y++;
- } else if (keyboard == 'k' && player_two_y > 3) {
- player_two_y--;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement