GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 07-Jun-2009, 14:48
AwesDess AwesDess is offline
New Member
 
Join Date: May 2009
Posts: 10
AwesDess is on a distinguished road

Allegro BITMAP convert error


I compiled my game and it's saying it can't convert the bitmaps. I have both of them in the same folder and they are definitely .bmp files so I don't know what's wrong

CPP / C++ / C Code:
#include <allegro.h>

BITMAP xSprite;
BITMAP oSprite;

int board[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };//keep track of x's and o's

int curSquare = 0; //this will keep track of the current square


int turn = 1;


int x = 0;
int y = 0;

int tempX = 0;
int tempY = 0;

void setupBoard(){ //this will draw the grid

   acquire_screen();
   
   line( screen, 200, 0, 200, 480, makecol( 255, 255, 255 ) );
   line( screen, 400, 0, 400, 480, makecol( 255, 255, 255 ) );
   line( screen, 0, 150, 680, 150, makecol( 255, 255, 255 ) );
   line( screen, 0, 300, 680, 300, makecol( 255, 255, 255 ) );
   
   rect( screen, x + 1, y + 1, x + 199, y + 149, makecol( 255, 255, 0 ) );
   
   release_screen();
   
}


void updateBoard(){//draws in selector
  
   rect( screen, tempX + 1, tempY + 1, tempX + 199, tempY + 149, makecol( 0, 0, 0 ) ); 
   rect( screen, x + 1, y + 1, x + 199, y + 149, makecol( 255, 255, 0 ) );
   rest( 100 );
   
}

void announceWinner(){ //announces winner

   if ( turn == 1 ){
       textout_ex( screen, font, "X Wins!", 300, 240, makecol( 255, 255, 255 ), makecol( 0, 0, 0 ) );
   } else{
       textout_ex( screen, font, "O Wins!", 300, 240, makecol( 255, 255, 255 ), makecol( 0, 0, 0 ) );   
   } 


}   


void checkWin(){ //checks for a winner
    
    if( board[0] == turn && board[1] == turn &&  board[2] == turn){
        announceWinner();
    } else if( board[0] == turn &&  board[3] == turn  && board[6] == turn){
        announceWinner();
    } else if( board[0] == turn &&  board[4] == turn  && board[8] == turn){
        announceWinner();
    } else if( board[1] == turn &&  board[4] == turn  && board[7] == turn){
        announceWinner();
    } else if( board[2] == turn &&  board[4] == turn  && board[6] == turn){
        announceWinner();
    } else if( board[2] == turn &&  board[5] == turn  && board[8] == turn){
        announceWinner();
    } else if( board[3] == turn &&  board[4] == turn  && board[5] == turn){
        announceWinner();
    } else if( board[6] == turn &&  board[7] == turn  && board[8] == turn){
        announceWinner();
    }
    
}   




void drawXO(){ //draws in the X and O
   
   acquire_screen();
   
   if(turn == 1){
    draw_sprite( screen, xSprite, x, y);
    board[curSquare] = 1;
    checkWin();
    ++turn;   
  } else if( turn == 2){
    draw_sprite( screen, oSprite, x, y);
    board[curSquare] = 2;
    checkWin();
    --turn;
  }
  
  release_screen();
  
  rest(100);
  
  }
   
void moveBox(){ // takes input
   
   clear_keybuf();
   tempX = x;
   tempY = y;
   
   if( key[KEY_UP] && y != 0 )
   {
      y -= 150;
      curSquare -= 3;
      updateBoard();    
   }
   else if( key[KEY_DOWN] && y != 300 )
   {
      y += 150;
      curSquare += 3;
      updateBoard();    
   }
   else if( key[KEY_RIGHT] && x != 400 )
   {
      x += 200;
      ++curSquare;
      updateBoard();    
   }
   else if( key[KEY_LEFT] && x != 0 )
   {
      x -= 200;
      --curSquare;
      updateBoard();    
   }
   else if( key[KEY_ENTER] && board[curSquare] = 0 )
   {
      drawXO();    
   }
}

int main()
{
    allegro_init();
    install_keyboard();
    set_color_depth( 16 );
    set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0 );
    
    xSprite = load_bitmap( "x.bmp", NULL );
    
    oSprite = load_bitmap( "o.bmp", NULL );
    
    setupBoard();
    
    while( !key[KEY_ESC] )
    {
       moveBox();    
           
    }
    
    destroy_bitmap( xSprite );
    destroy_bitmap( oSprite );  
    
}
END_OF_MAIN();





Errors

C:\Dev\Dev-Cpp\Allegro\Test\tic tac toe\main.cpp In function `void drawXO()':

86 C:\Dev\Dev-Cpp\Allegro\Test\tic tac toe\main.cpp cannot convert `BITMAP' to `BITMAP*' for argument `2' to `void draw_sprite(BITMAP*, BITMAP*, int, int)'

91 C:\Dev\Dev-Cpp\Allegro\Test\tic tac toe\main.cpp cannot convert `BITMAP' to `BITMAP*' for argument `2' to `void draw_sprite(BITMAP*, BITMAP*, int, int)'

C:\Dev\Dev-Cpp\Allegro\Test\tic tac toe\main.cpp In function `void moveBox()':

133 C:\Dev\Dev-Cpp\Allegro\Test\tic tac toe\main.cpp non-lvalue in assignment

C:\Dev\Dev-Cpp\Allegro\Test\tic tac toe\main.cpp In function `int _mangled_main()':

146 C:\Dev\Dev-Cpp\Allegro\Test\tic tac toe\main.cpp no match for 'operator=' in 'xSprite = load_bitmap(((const char*)"x.bmp"), 0u)'

note C:\Dev\Dev-Cpp\include\allegro\gfx.h:262 candidates are: BITMAP& BITMAP::operator=(const BITMAP&)

148 C:\Dev\Dev-Cpp\Allegro\Test\tic tac toe\main.cpp no match for 'operator=' in 'oSprite = load_bitmap(((const char*)"o.bmp"), 0u)'

note C:\Dev\Dev-Cpp\include\allegro\gfx.h:262 candidates are: BITMAP& BITMAP::operator=(const BITMAP&)

158 C:\Dev\Dev-Cpp\Allegro\Test\tic tac toe\main.cpp cannot convert `BITMAP' to `BITMAP*' for argument `1' to `void destroy_bitmap(BITMAP*)'

159 C:\Dev\Dev-Cpp\Allegro\Test\tic tac toe\main.cpp cannot convert `BITMAP' to `BITMAP*' for argument `1' to `void destroy_bitmap(BITMAP*)'

159 C:\Dev\Dev-Cpp\Allegro\Test\tic tac toe\main.cpp *** [main.o] Error 1
  #2  
Old 07-Jun-2009, 14:50
AwesDess AwesDess is offline
New Member
 
Join Date: May 2009
Posts: 10
AwesDess is on a distinguished road

Re: Allegro BITMAP convert error


UGH the problem with the bitmaps was the BITMAP variables weren't pointers, the Ivalue was a mistake with = and ==. Sorry guys!
 
 

Recent GIDBlogVista ?Widgets? on Windows XP by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Two-Tier data dissemination code installation problem nidhibansal1984 Computer Software Forum - Linux 6 16-Sep-2007 10:13
Linked Lists advice request promsan C Programming Language 74 23-May-2007 08:29
Major newbie problem cynack MS Visual C++ / MFC Forum 1 08-Apr-2007 11:25
Winsock error when compiling FLTK 2.0 Projects mauriciorossi FLTK Forum 3 16-Aug-2005 10:18
Help with syntax errors PeteGallo C Programming Language 7 08-Aug-2005 20:30

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 07:48.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.