| | |
Allegro res change program, crashes occasionally :P
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 29
Reputation:
Solved Threads: 0
I don't know where you sould put resources on this website so i'll just post it here. Also, if anyone can find the reason this program crashes occasionally and reply back, i'd be greatful! Thanks in advance.
*Reminder: I'm not pro
This is a simple(?) program that allows the user to change the resolution of the program to 5 preset options.
640x480
800x600
1024x768
1280x960
1280x1024
I know that there are some includes that are not needed and some code that serves no purpose, (was either trying to fix a problem, or trying to cover my program's ass)
*uses the allegro 4.1.1.1 game programming library
*This post includes all files needed for the program to work
*if anyone has a problem with this post contact a mod and they will deal with it
*all files are contained in a zip
*remember to actually have allegro installed if you want to use the code within the program
*Reminder: I'm not pro
This is a simple(?) program that allows the user to change the resolution of the program to 5 preset options.
640x480
800x600
1024x768
1280x960
1280x1024
C++ Syntax (Toggle Plain Text)
// //made by Brent D. Corr //written in Dev-Cpp 4.9.9.2 //uses the allegro 4.1.1.1 game programming library or whatever // #include <cstdlib> #include <cstdio> #include <iostream> #include <stdlib.h> #include <ctime> #include <conio.h> #include <fstream> #include <allegro.h> #include <time.h> using namespace std; BITMAP *buffer; BITMAP *defaultx; BITMAP *x800x600; BITMAP *x640x480; BITMAP *x1024x768; BITMAP *x1280x960; BITMAP *x1280x1024; int cursor_x = 20; int cursor_y = 20; int grpf; void getMouseInfo(){ if(mouse_b & 1){ cursor_x = mouse_x; cursor_y = mouse_y; } } void updateScreen(){ if (grpf == 1){ draw_sprite( screen, x640x480, 0, 0); } else if (grpf == 0){ draw_sprite( screen, defaultx, 0, 0); } else if (grpf == 2){ draw_sprite ( screen, x800x600, 0, 0); } else if (grpf == 3){ draw_sprite ( screen, x1024x768, 0, 0); } else if (grpf == 4){ draw_sprite ( screen, x1280x960, 0, 0); } else if (grpf == 5){ draw_sprite ( screen, x1280x1024, 0, 0); } } int main(){ int grapic; allegro_init(); install_mouse(); install_keyboard(); set_color_depth(16); int lol; lol = 1; set_gfx_mode( GFX_AUTODETECT, 800, 600, 0, 0); x640x480 = load_bitmap( "x640x480.bmp", NULL); x800x600 = load_bitmap( "x800x600.bmp", NULL); x1024x768 = load_bitmap( "x1024x768.bmp", NULL); x1280x960 = load_bitmap( "x1280x960.bmp", NULL); x1280x1024 = load_bitmap( "x1280x1024.bmp", NULL); defaultx = load_bitmap( "defaultx.bmp", NULL); start: acquire_screen(); while( !key[KEY_ESC]){ if (lol == 1){ grpf = 0; lol = 0; } else { goto next; } next: if( key[KEY_ESC]){ goto end; } if (grpf == 0){ show_mouse(defaultx); } else if (grpf ==1){ show_mouse(x640x480); } else if (grpf == 2){ show_mouse(x800x600); } else if (grpf == 3){ show_mouse (x1024x768); } else if (grpf == 4) { show_mouse (x1280x960); } else if (grpf == 5) { show_mouse (x1280x1024); } getMouseInfo(); updateScreen(); if(mouse_b & 1){ if ( mouse_x >= 1 && mouse_x <= 385 and mouse_y >= 317 && mouse_y <= 400 ){ grapic = 1; goto fail; } else if ( mouse_x >= 1 && mouse_x <= 385 and mouse_y >= 401 && mouse_y <= 480 ) { grapic = 2; goto fail; } else if ( mouse_x >= 1 && mouse_x <= 385 and mouse_y >= 481 && mouse_y <= 578 ) { grapic = 3; goto fail; } else if ( mouse_x >= 386 && mouse_x <= 799 and mouse_y >= 331 && mouse_y <= 406 ) { grapic = 4; goto fail; } else if ( mouse_x >= 386 && mouse_x <= 799 and mouse_y >= 408 && mouse_y <= 496 ){ grapic = 5; goto fail; } else { goto fail; } } fail: if (grapic == 1){ set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0); draw_sprite( screen, x640x480, 0, 0); grpf = 1; grapic = 20; goto start; } else if (grapic == 2){ set_gfx_mode( GFX_AUTODETECT, 800, 600, 0, 0); draw_sprite( screen, x800x600, 0, 0); grpf = 2; grapic = 20; goto start; } else if (grapic == 3){ set_gfx_mode( GFX_AUTODETECT, 1024, 768, 0, 0); draw_sprite( screen, x1024x768, 0, 0); grpf = 3; grapic = 20; goto start; } else if (grapic == 4){ set_gfx_mode( GFX_AUTODETECT, 1280, 960, 0, 0); draw_sprite( screen, x1280x960, 0, 0); grpf = 4; grapic = 20; goto start; } else if (grapic == 5){ set_gfx_mode( GFX_AUTODETECT, 1280, 1024, 0, 0); draw_sprite( screen, x1280x1024, 0, 0); grpf = 5; grapic = 20; goto start; } else{ goto start; } goto start; } end: readkey(); return 0; } END_OF_MAIN();
*uses the allegro 4.1.1.1 game programming library
*This post includes all files needed for the program to work
*if anyone has a problem with this post contact a mod and they will deal with it
*all files are contained in a zip
*remember to actually have allegro installed if you want to use the code within the program
![]() |
Other Threads in the C++ Forum
- Previous Thread: About C++ game programming, engines, etc
- Next Thread: Dynamic Adding of Widgets in GTKMM
| Thread Tools | Search this Thread |
.so api array arrays background based binary bitmap c# c++ calculator char char* class code commentinghelp compile console crashcourse desktop development dialog download email embed embedded encryption engine error evc examples file floatingpoint fstream function functions game gnu graph guess gui int introduction java line linker lnk2019 math matrix method music mysql newbie noob number objects output pause performance position practice prime problem professor program programming python read recursion recursive regqueryvalueex richedit rpg savefile search selection send set snakes space sql store stream string strings studio superclass symbian system temperature template test text timer tree university url visual visualization win32






