Thread: Starting Allegro

  1. #1
    Registered User
    Join Date
    May 2005
    Location
    Texas
    Posts
    103

    Starting Allegro

    Hello there! I am starting allegro and am getting familiarized with it... I am trying to device a structure that holds a dynamically sized (BITMAP*) array. However I get a compile error when I try to build it...

    Code:
    #include <allegro.h>
    #include <cstdio>
    
    class Sprite
    {
        public:
        BITMAP **frames[];
        Sprite(){}
        Sprite(BITMAP* addFrame, unsigned int size){
            frames = new BITMAP*[size];
            }
    }temp;

    error is:

    Code:
    ||=== SpriteClass, Debug ===|
    C:\Projects\CodeBlocks\SpriteClass\main.cpp||In constructor `Sprite::Sprite(BITMAP*, unsigned int)':|
    C:\Projects\CodeBlocks\SpriteClass\main.cpp|10|error: incompatible types in assignment of `BITMAP**' to `BITMAP**[0u]'|
    ||=== Build finished: 1 errors, 0 warnings ===|
    MINGW as compiler
    Any help?
    Last edited by toonlover; 09-15-2008 at 06:16 PM.
    Be easy on me...only 14

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    BITMAP **frame[] eh? Did you mean to have the array declaration? I betcha didn't. And just because it drives me crazy... devise*

  3. #3
    Registered User
    Join Date
    May 2005
    Location
    Texas
    Posts
    103
    Well....to load a bitmap you have to declare a BITMAP pointer like this:
    Code:
    BITMAP* my_picture = loadbitmap( file to load here );
    What I want to do is this:
    Code:
    (BITMAP*) *frames[size];
    So that I can have an array that contains the corresponding frames of a sprite...such as
    frames[0] -> 1st Sprite
    frames[1] -> 2nd Sprite
    frames[2] -> 3rd Sprite
    frames[n] -> nth Sprite
    Be easy on me...only 14

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I gotcha. But you are just kind of going to show how I am not wrong by saying you should be dropping the [].

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 05:59 PM
  2. Game Programming FAQ
    By TechWins in forum Game Programming
    Replies: 5
    Last Post: 09-29-2004, 02:00 AM
  3. double buffering for allegro
    By Leeman_s in forum C++ Programming
    Replies: 6
    Last Post: 09-12-2002, 02:45 PM
  4. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-20-2002, 11:35 PM
  5. Allegro programming in a window
    By Person Man in forum Windows Programming
    Replies: 0
    Last Post: 11-16-2001, 03:23 PM