Advertisement
Guest User

Circle oval thing

a guest
Jul 17th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void drawScreen();
  4.  
  5. void main(){
  6. drawScreen();
  7. }
  8. void drawScreen() {
  9. //This function draws display screen with map boundary, snake and mouse
  10. int x; // loop counter for x axis
  11. int y; // loop counter for y axis
  12. int k; // loop counter to count length of snake tail
  13. int drawTail=0; //draw is set to TRUE when a tail is drawn at the coordinates
  14. int mapHeight=20;
  15. int mapWidth=20;
  16. int snakeHeadX=9;
  17. int snakeHeadY=8;
  18. system("cls"); // clears the entire screen
  19. printf("\n");
  20.  
  21. //draw left and right boundary, top and bottom boundary, snake and mouse
  22.  
  23. // Part 3: Complete the nested for loops
  24. for (y = 0; y < mapHeight; y++) { //loop from top to bottom, y=0 to y=mapHeight-1
  25. for (x = 0; x < mapWidth; x++){ //loop from left to right, x=0 to x=mapWidth-1
  26. if(x==0&&y>=5&&y<=14){
  27. printf("#");
  28. } else if(y==0&&x>=5&&x<=14){
  29. printf("#");
  30. }else if(x==19&&y>=5&&y<=14){
  31. printf("#");
  32. }else if(y==19&&x>=5&&x<=14){
  33. printf("#");
  34. }else if((y==4||y==15)&&(x==1||x==18)){
  35. printf("#");
  36. }else if((y==1||y==18)&&(x==4||x==15)){
  37. printf("#");
  38. }else if((y==3||y==16)&&(x==2||x==17)){
  39. printf("#");
  40. }else if((y==2||y==17)&&(x==3||x==16)){
  41. printf("#");
  42.  
  43.  
  44. } else if((x==snakeHeadX)&&(y==snakeHeadY)){
  45. printf("O");
  46. }else{
  47. drawTail=0;
  48.  
  49. if(drawTail==0){
  50. printf(" ");
  51. }
  52. }
  53. }//end of inner for loop
  54. printf("\n");
  55.  
  56. }//end of outer for loop
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement