Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************
- Bart Olsthoorn 2008
- This code is licenced with the WTFPL.
- ****************/
- #include <allegro.h>
- //#include <semaphore.h>
- #include <winalleg.h>
- #include <stddef.h>
- #include <windows.h>
- #include <stdio.h>
- #include <sstream>
- #include <stdlib.h>
- #include <time.h>
- // Get Screen size:
- const int scrx = GetSystemMetrics(SM_CXSCREEN);
- const int scry = GetSystemMetrics(SM_CYSCREEN);
- // Music config:
- const char *cfg_path;
- PACKFILE *packfile;
- SAMPLE *musicsample;
- // Timer Set:
- int sticks=0;
- int SecondTick=0;
- void changePosImage();
- void Seconds_Tick(void)
- {
- sticks++;
- changePosImage();
- }
- END_OF_FUNCTION(Seconds_Tick);
- // Init random seed:
- int randomNumx;
- int randomNumy;
- // Set default mouse positions:
- int mx = 0;
- int my = 0;
- // Global BITMAPS
- BITMAP *buffer;
- BITMAP *logo;
- // Foreground bool set:
- static int foreground = TRUE;
- static void dispsw_callback(void)
- {
- foreground = FALSE;
- }
- // Announce Functions:
- void init();
- void deinit();
- int main() {
- init();
- srand (time(NULL)); // Random Seed
- mx = mouse_x; // Mouse Pos
- my = mouse_y; // Mouse Pos
- changePosImage(); // Show image on startup, avoid boring black screens
- while (!keypressed() && foreground && (!mouse_b) && (mouse_x == mx) && (mouse_y == my)) {
- //while (!key[KEY_ESC]) { //DEBUG MODE
- // Show buffer:
- blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
- //clear_
- rest(1);
- }
- deinit();
- return 0;
- }
- END_OF_MAIN()
- void init() {
- int depth, res;
- allegro_init();
- depth = desktop_color_depth();
- if (depth == 0) depth = 32;
- set_color_depth(depth);
- res = set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, scrx, scry, 0, 0);
- if (res != 0) {
- allegro_message(allegro_error);
- exit(-1);
- }
- SetPriorityClass(GetCurrentProcess() ,IDLE_PRIORITY_CLASS); // IDLE_PRIORITY_CLASS
- set_display_switch_mode(SWITCH_BACKAMNESIA); /* not SWITCH_AMNESIA */
- set_display_switch_callback(SWITCH_OUT, dispsw_callback);
- install_timer();
- install_keyboard();
- install_mouse();
- install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, cfg_path);
- /* add other initializations here */
- buffer = create_bitmap(scrx, scry); // Create buffer
- logo = load_bitmap("logo.bmp", NULL);
- if (logo == NULL) {
- set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
- allegro_message("Kon Logo.bmp niet vinden");
- allegro_exit();
- }
- install_timer();
- LOCK_VARIABLE(sticks);
- LOCK_FUNCTION(Seconds_Tick);
- install_int_ex(&Seconds_Tick, SECS_TO_TIMER(5));
- }
- void deinit() {
- clear_bitmap(logo);
- destroy_bitmap(logo);
- clear_bitmap(buffer);
- destroy_bitmap(buffer);
- clear_keybuf();
- allegro_exit();
- /* add other deinitializations here */
- }
- void changePosImage() {
- randomNumx = rand() % (SCREEN_W-(logo->w));
- randomNumy = rand() % (SCREEN_H-(logo->h));
- clear_bitmap(buffer);
- blit(logo, buffer, 0, 0, randomNumx, randomNumy, logo->w, logo->h);
- }
Add Comment
Please, Sign In to add comment