Thread: simple SDL question

  1. #1
    ---
    Join Date
    May 2004
    Posts
    1,379

    simple SDL question

    in SDL can a simple sprite just be a bmp loaded onto a surface? or is there a function for loading sprites?

  2. #2
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743
    The Free Online Dictionary of Computing States:

    sprite - A small bitmap image, often used in
    animated games.

    Therefore, what do you think a sprite is? It is a simple BMP loaded onto a surface.

    Now, some sprites consist of more than one frame of animation. Most of the time those sprites will have all of their animation frames in one BMP file. In that case you simply load the entire BMP onto a surface, and you use a source rect to specify what frame gets blitted.

    The destination rect specifies where the sprite gets blitted onto the screen (or other surface).
    My Website

    "Circular logic is good because it is."

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    ah ofcourse.
    thanks a lot

  4. #4
    ---
    Join Date
    May 2004
    Posts
    1,379
    ok ive got my .bmp which hold two different images. 2 x (128x29)
    ive got this
    Code:
    //updates background
        DrawIMG(back, xpos-speed, ypos-speed, 128+(speed*2), 29+(speed*2), xpos-2, ypos-2);
    
        // draws block blurred
        DrawIMG(image, xpos, ypos, 128, 29, 0, 0);
    
        // draws block normal
        DrawIMG(image, xpos, ypos, 128, 29, 129, 0);
    
        SDL_Flip(screen);
    but im not sure how i go about alternating between the two blocks at a reasonable speed.

    [edit] now i got this but it doesnt wor the way i hoped.
    Code:
    if (blur = true)
        {
            // draws block blurred
            DrawIMG(image, xpos, ypos, 128, 29, 0, 0);
            blur = false;
        }
        else
        {
            // draws block normal
            DrawIMG(image, xpos, ypos, 128, 29, 129, 0);
        }
        SDL_Flip(screen);
    i know its prbably going so fast that you cant tell its doing anything but what is a good way around it?[/edit]
    Last edited by sand_man; 07-02-2004 at 12:11 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  2. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  3. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. simple fgets question
    By theweirdo in forum C Programming
    Replies: 7
    Last Post: 01-27-2002, 06:58 PM