Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.10 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <math.h>
  3. #include <cab202_graphics.h>
  4. #include <cab202_sprites.h>
  5. #include <cab202_timers.h>
  6. //#include <string.h>
  7. #define DELAY (20)//when it compiles it it replaces all if the instances of the the define with the number rather then using a variable which takes more memory
  8.  
  9. int h;
  10. int w;
  11. bool paused = true;
  12.  
  13. void helpScreen() {
  14.   draw_string(screen_width()/2 - 6.5, screen_height()/2+1, "Jainesh Kumar");//13
  15.   draw_string(screen_width()/2 - 10, screen_height()/2, "Student No: n9686789");//20
  16.   draw_string(screen_width()/2 - 19, screen_height()/2-5, "Move the paddel with the W and S keys!");//38;
  17.   draw_string(screen_width()/2 - 22, screen_height()/2-4, "Press the L key to advance to the next level");//44
  18.   draw_string(screen_width()/2 - 12.5, screen_height()/4*3, "Press any key to continue");//25
  19.   show_screen();
  20.  
  21. }
  22. void helpScreenKeyPress(){
  23.   wait_char();
  24.   paused = false;
  25. }
  26.  
  27. void border(){
  28.  
  29.   h = screen_height();//setting up a variable called h to be the height of the screen
  30.   w = screen_width();//setting up a variable called w to be the width of the screeb
  31.  
  32.   draw_line(0, 0, w-1, 0, '+');//top-1 from left and right
  33.   draw_line(w-1, 0, w-1, h-1, '+');//right
  34.   draw_line(0, h-1, 0, 0, '+');//left
  35.   draw_line(w-1, h-1, 0, h-1, '+');//bottom
  36.   draw_line(0, 2, w-1, 2, '+');//2ndLineTop
  37.  
  38.   show_screen();
  39. }
  40.  
  41. void playerPaddle(){
  42.   if (h >= 21) {
  43.     draw_line(w-10, 0, w-10, 7, '|');
  44.   }
  45.   else {
  46.     draw_line(w-10,0,w-10,(h-3-1)/2, '|');
  47.   }
  48. }
  49.  
  50. void levelOne(){
  51.   border();
  52.   playerPaddle();
  53. }
  54.  
  55.  
  56. int main() {
  57.   bool isRunning = true; // Main Game Loop - Continues to loop until a value is turned to false and reaches the end and ends the game
  58.                          //It is it also used because otherwise it would do everything in a procedural order therefor making the game not playable
  59.   while (isRunning) {
  60.  
  61.     setup_screen();
  62.     if (paused == true){
  63.       helpScreen();
  64.       helpScreenKeyPress();
  65.     }
  66.     else{
  67.       levelOne();
  68.     }
  69.     timer_pause(DELAY);
  70.  
  71.     //cleanup();
  72.   }
  73.   cleanup_screen();
  74.   return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement