SDL problem

I'm having some problem on bliting an image on to my buffer in SDL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <SDL/SDL.h>
#include "SDL/SDL_image.h"



int x = 100;
int y = 100;

void MoveBall();

int main (int argc, char *args[])
{
    SDL_Init(SDL_INIT_EVERYTHING); //initialize
    SDL_WM_SetCaption("Yay!", NULL); //set caption
    Uint8 *key;
    SDL_Event event;
    while (event.type != SDL_QUIT)
    {
          SDL_PollEvent(&event);
          MoveBall();
          
          }
          
    
    //SDL_FreeSurface(buffer); - ikke nødvendig
    SDL_Quit();
    return 0;
}


void MoveBall()
{
     Uint8 *key;
     key = SDL_GetKeyState( NULL);
     if  (key[SDLK_UP])
     ++y;
     else if (key[SDLK_DOWN])
     --y;
     if (key[SDLK_RIGHT])
     ++x;
     else if (key[SDLK_LEFT])
     --x;
     SDL_Rect tmp = {x, y, 40, 40};
     SDL_Surface *buffer;
     buffer = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE);
     SDL_Surface *ball;
     ball = IMG_Load("ball.png");
     SDL_BlitSurface(ball, NULL, buffer, tmp);

     SDL_Flip (buffer);
     SDL_FreeSurface(buffer);
     SDL_FreeSurface(ball);
     }
     
     


The error is: cannot convert `SDL_Rect' to `SDL_Rect*' for argument `4' to `int SDL_UpperBlit(SDL_Surface*, SDL_Rect*, SDL_Surface*, SDL_Rect*)'
Put "address of" operator infront "tmp":
 
SDL_BlitSurface(ball, NULL, buffer, &tmp);
Post your message on 1 part of the forum. It is bit annoying seeing 2 same messages :)
It didn't get any replies in the first forum, and I can't delete my own threads... I just hope noone got seriously injured.

PS: Thanks for the tip, savavampir, it fixed it :D now i just have to get rid of that damn screen flickering -.-
Last edited on
There is a possibility to delete a post (why nit entire thread then?). Of course person who started the thread can delete it's first post -> thread gone (??)

Check out. It got answered. Be patient using forums ;)
http://cplusplus.com/forum/beginner/47960/
Topic archived. No new replies allowed.