Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Includes----------------------------------------------
- #include <allegro.h>
- #include "Sys.h"
- #include "Player.h"
- #include "Stick.h"
- //Includes----------------------------------------------
- //Creating Class Objects--------------------------------
- Sys System;
- Player Player;
- Stick Stick;
- //Creating Class Objects--------------------------------
- //Misc Functions----------------------------------------
- bool CheckCollision (int b1_x, int b1_y, int b1_w, int b1_h, int b2_x, int b2_y, int b2_w, int b2_h) {
- if ( ( b1_x > b2_x + b2_w - 1 ) ||
- ( b1_y > b2_y + b2_h - 1 ) ||
- ( b2_x > b1_x + b1_w - 1 ) ||
- ( b2_y > b1_y + b1_h - 1 ) )
- {return false;}
- else {return true;}
- }
- //Misc Functions----------------------------------------
- int main()
- {
- System.Initilize(); //Initilizes Allegro.
- //Creating & loading bitmaps & samples here, as they are a pain to pass from other functions.
- BITMAP *buffer = create_bitmap(640, 480);
- BITMAP *bmpTitleScreen = load_bitmap("resources/TitleScreen.bmp", NULL);
- BITMAP *bmpPlayer = load_bitmap("resources/PlayerSprite.bmp", NULL);
- BITMAP *bmpGameBG = load_bitmap("resources/GameBG.bmp", NULL);
- BITMAP *bmpStick = load_bitmap("resources/Stick.bmp", NULL);
- SAMPLE *wavBackingMusic = load_sample("resources/AfterTheRain_Moosader.wav");
- //Game Loop-----------------------------------------
- while (!key[KEY_ESC]) {
- while (System.getTitleScreen() == true) {
- System.Draw(buffer, bmpTitleScreen);
- if (key[KEY_ENTER]) {
- System.toggleTitleScreen();
- }
- }
- play_sample(wavBackingMusic, 255, 128, 1000, true);
- Player.CheckMovement();
- if (CheckCollision(Player.ReturnX(), Player.ReturnY(), Player.ReturnBBw(), Player.ReturnBBh(), Stick.ReturnX(), Stick.ReturnY(), Stick.ReturnBBw(), Stick.ReturnBBh()) == true) {Stick.GenerateNewCoords();}
- System.Draw(buffer, bmpGameBG);
- Stick.Draw(buffer, bmpStick);
- Player.Draw(buffer, bmpPlayer);
- blit(buffer, screen, 0, 0, 0, 0, 640, 480);
- clear_bitmap(buffer);
- }
- //Game Loop-----------------------------------------
- //Destroying Bitmaps & Samples--------------------------------
- destroy_bitmap(buffer);
- destroy_bitmap(bmpPlayer);
- destroy_bitmap(bmpTitleScreen);
- destroy_bitmap(bmpGameBG);
- destroy_bitmap(bmpStick);
- destroy_sample(wavBackingMusic);
- //Destroying Bitmaps & Samples--------------------------------
- }
- END_OF_MAIN()
Advertisement
Add Comment
Please, Sign In to add comment