Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <math.h>
- #include <cab202_graphics.h>
- #include <cab202_sprites.h>
- #include <cab202_timers.h>
- //#include <string.h>
- #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
- int h;
- int w;
- bool paused = true;
- void helpScreen() {
- draw_string(screen_width()/2 - 6.5, screen_height()/2+1, "Jainesh Kumar");//13
- draw_string(screen_width()/2 - 10, screen_height()/2, "Student No: n9686789");//20
- draw_string(screen_width()/2 - 19, screen_height()/2-5, "Move the paddel with the W and S keys!");//38;
- draw_string(screen_width()/2 - 22, screen_height()/2-4, "Press the L key to advance to the next level");//44
- draw_string(screen_width()/2 - 12.5, screen_height()/4*3, "Press any key to continue");//25
- show_screen();
- }
- void helpScreenKeyPress(){
- wait_char();
- paused = false;
- }
- void border(){
- h = screen_height();//setting up a variable called h to be the height of the screen
- w = screen_width();//setting up a variable called w to be the width of the screeb
- draw_line(0, 0, w-1, 0, '+');//top-1 from left and right
- draw_line(w-1, 0, w-1, h-1, '+');//right
- draw_line(0, h-1, 0, 0, '+');//left
- draw_line(w-1, h-1, 0, h-1, '+');//bottom
- draw_line(0, 2, w-1, 2, '+');//2ndLineTop
- show_screen();
- }
- void playerPaddle(){
- if (h >= 21) {
- draw_line(w-10, 0, w-10, 7, '|');
- }
- else {
- draw_line(w-10,0,w-10,(h-3-1)/2, '|');
- }
- }
- void levelOne(){
- border();
- playerPaddle();
- }
- int main() {
- bool isRunning = true; // Main Game Loop - Continues to loop until a value is turned to false and reaches the end and ends the game
- //It is it also used because otherwise it would do everything in a procedural order therefor making the game not playable
- while (isRunning) {
- setup_screen();
- if (paused == true){
- helpScreen();
- helpScreenKeyPress();
- }
- else{
- levelOne();
- }
- timer_pause(DELAY);
- //cleanup();
- }
- cleanup_screen();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement