Dev C++

This is a discussion on Dev C++ within the Game Programming forums, part of the General Programming Boards category; I am quite frustrated. For sum reason I cannot get any bitmap loading programs to work with Dev C++. It ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    208

    Dev C++

    I am quite frustrated. For sum reason I cannot get any bitmap loading programs to work with Dev C++. It compiles fine but everytime the program runs it just gives me a "this program has preformed a illegal operation" and closes. I have located the bitmaps in the same folder as the program. I dunno here is my source

    Code:
    #include <allegro.h> // You must include the Allegro Header file
    
    
    ///////////
    // TIMER //
    ///////////
    volatile long speed_counter = 0;//A long integer which will store the value of the
    								//speed counter.
    
    void increment_speed_counter() //A function to increment the speed counter
    {
    	speed_counter++; // This will just increment the speed counter by one.
    }
    END_OF_FUNCTION(increment_speed_counter);
    										 //function
    
    
    ///////////////////////
    // The Main function //
    ///////////////////////
    int main(int argc, char *argv[])
    {
    
    	
    	
    	allegro_init(); // Initialize Allegro
    	install_keyboard(); // Initialize keyboard routines
    	install_timer(); // Initialize the timer routines
    
    	LOCK_VARIABLE(speed_counter);		   //Used to set the timer - which regulates the game's
    	LOCK_FUNCTION(increment_speed_counter);//speed.
    	install_int_ex(increment_speed_counter, BPS_TO_TIMER(60));//Set our BPS
    	
    	set_color_depth(16); // Set the color depth
    							
    	set_gfx_mode(GFX_AUTODETECT, 640,480,0,0); // Change our graphics mode to 640x480
    
    
    	BITMAP *frame1 = load_bitmap("frame1.bmp", NULL); // Declare a bitmap and Load our picture in one statement
    	BITMAP *frame2 = load_bitmap("frame2.bmp", NULL); 
    	BITMAP *frame3 = load_bitmap("frame3.bmp", NULL);
    
    
    
    	BITMAP *buffer; //Declare a BITMAP called buffer.
    
    	buffer = create_bitmap(640,480); //Create an empty bitmap.
    
    	int my_pic_x = 0;// Holds our pictures X coorinate
    	int my_pic_y = 0;// Holds our picture's Y coordinate
    	
    					 
    	int frame_counter = 0;// A counter for which frame to draw
    	
    	
    	while(!key[KEY_ESC])//If the user hits escape, quit the program
    	{
    	
    		while(speed_counter > 0)
    		{
    			if(key[KEY_RIGHT])// If the user hits the right key, change the picture's X coordinate
    			{
    				my_pic_x ++;// Moving right so up the X coordinate by 1
    			}
    			else if(key[KEY_LEFT])// Ditto' - only for left key
    			{
    				my_pic_x --;// Moving left, so lower the X coordinate by 1
    			}
    			else if(key[KEY_UP])// If the user hits the up key, change the picture's Y coordinate
    			{
    				my_pic_y --;// Moving up, so lower the Y coordinate by 1
    			}
    			else if(key[KEY_DOWN])// Ditto' - only for down
    			{
    				my_pic_y ++;// Moving down, so up the Y coordinate by 1
    			}
    
    			speed_counter --;
    
    			frame_counter ++; //Increment our frame counter at the same speed of the 
    							  //speed counter
    
    						if(frame_counter > 240)
    			{
    				frame_counter = 0;
    			}
    		}
    	
    		acquire_screen();// Get the screen
    
    	
    
    		//In the first second, draw the first frame
    		if(frame_counter < 60)//Less than a full second
    		{
    			draw_sprite(buffer, frame1, my_pic_x, my_pic_y);//Draw the first frame
    		}
    		else if(frame_counter >= 60 && frame_counter < 120)//Between 1 and 2 seconds
    		{
    			draw_sprite(buffer, frame2, my_pic_x, my_pic_y);//Draw the second frame
    		}
    		else if(frame_counter >= 120 && frame_counter < 180)//If we are between 2 and 3 seconds
    		{
    			draw_sprite(buffer, frame1, my_pic_x, my_pic_y);//Draw the first frame again,
    															//to acheive better effect
    		}
    		else// If we are over 3 seconds
    		{
    			draw_sprite(buffer, frame3, my_pic_x, my_pic_y);//Draw the last frame,											
    		}
    
      blit(buffer, screen, 0,0,0,0,640,480);//Draw the buffer to the screen
    		clear_bitmap(buffer);
    		release_screen();// Release it
    	}
    
    	destroy_bitmap(frame1);//Release the bitmap data
    	destroy_bitmap(frame2);//Release the bitmap data
    	destroy_bitmap(frame3);//Release the bitmap data
    	
    	destroy_bitmap(buffer);//Release the bitmap data
    
    
    	return(0);// Exit with no errors
    }
    END_OF_MAIN();

  2. #2
    Registered User red_baron's Avatar
    Join Date
    May 2002
    Posts
    274
    where do you ask for user input for key?
    ¿Red Baron?

    "Imagination is more important than knowledge"
    -Albert Einstein (1879-1955)

    Check out my games!

    [code] /* dont forget code tags! */ [/code]

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    208

    n/m

    never mind I found th problem
    Jeff Paddon
    Undergraduate Research Assistant
    Physics Department
    St. Francis Xavier University

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New to Dev C++/<windows.h>...
    By Cilius in forum C++ Programming
    Replies: 3
    Last Post: 02-23-2005, 01:05 AM
  2. Glut and Dev C++, Programs not Quitting?
    By Zeusbwr in forum Game Programming
    Replies: 13
    Last Post: 11-29-2004, 08:43 PM
  3. openGL programming - From MSVC++ to Dev C++
    By WDT in forum Game Programming
    Replies: 3
    Last Post: 03-08-2004, 08:47 PM
  4. openGL programming - From MSVC++ to Dev C++
    By WDT in forum Game Programming
    Replies: 1
    Last Post: 03-08-2004, 05:19 PM
  5. DEV C++ Limitations?
    By Kirdra in forum Game Programming
    Replies: 3
    Last Post: 09-09-2002, 10:40 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21