Problem whith timer

First fo j_post i’ve scan my system with AVG, there isn’t any virus and i check and mail i send and recive.

Here is my SDL problem:
I want to make a timer but it seems that the syntax isn’t good

anime = SDL_AddTimer(500, anime_perso, NULL);

my callback function is :

void anime_perso(void)
{
if(new_x < rond_x)
{
rond_x = rond_x - 1;
}

if(new_x > rond_x)
{
     rond_x = rond_x + 1;
}

if(new_y < rond_y)
{
     rond_y = rond_y - 1;
}

if(new_y > rond_y)
{
     rond_y = rond_y + 1;
}

}

But i don’t understand how to set up the timer. The error is :
passing void (*)(char *)' as argument 2 ofSDL_AddTimer(unsigned int, Unit32 ()(unsigned int, void), void *)’

If someone can help me please

Thomas LAURO
-------------- next part --------------
Ce message Envoi est certifi? sans virus connu.
Analyse effectu?e par Anti-virus AVG (http://www.grisoft.com).
Version: 7.0.211 / Base de donn?es virus: 261.9.2 - Date: 12/02/2004

First fo j_post i’ve scan my system with AVG, there isn’t any virus and i
check and mail i send and recive.

Ok, thanks for checking.

Here is my SDL problem:
I want to make a timer but it seems that the syntax isn’t good

anime = SDL_AddTimer(500, anime_perso, NULL);

my callback function is :

void anime_perso(void)

Uint32 anime_perso(Uint32 interval, void *param)
{
// do stuff
return interval;
}On Friday 13 February 2004 07:59 am, tocx wrote:

But i don’t understand how to set up the timer. The error is :
passing void (*)(char *)' as argument 2 ofSDL_AddTimer(unsigned int,
Unit32 ()(unsigned int, void), void *)’

Your callback function must be compatible with the timer callback
function prototype, which means it must look something like this:

Uint32 anime_perso(unsigned interval, void *param)

Either way, I’d recommend not using timers at all for this kind of
stuff. It’s not totally portable, as the granularity (“accuracy”) is
platform dependent.

I’m not sure what platforms without thread support do, but I suspect
some don’t implement timers at all, and others may run your callbacks
in interrupt context or similar.

Anyway, you’re generally better off doing everything in a single
thread, together with the rendering. Make the game logic somehow
adapt to the rendering frame rate you get, on a frame-by-frame basis,
or possibly with some filtering. (Rendering frame rates tend to
fluctuate, so the best bet - and easiest way - is usually to just
rely on frame delta times directly.)

I’m just about to release another SDL example, demonstrating my
favorite way of decoupling game logic from rendering; fixed logic
frame rate + interpolation. (It grew quite a bit bigger than I
originally intended, but hopefully that just means there’s more
interesting stuff to look at. :slight_smile: Stay tuned…

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Friday 13 February 2004 16.59, tocx wrote:

First fo j_post i’ve scan my system with AVG, there isn’t any virus
and i check and mail i send and recive.

Here is my SDL problem:
I want to make a timer but it seems that the syntax isn’t good

anime = SDL_AddTimer(500, anime_perso, NULL);

my callback function is :

void anime_perso(void)
{
if(new_x < rond_x)
{
rond_x = rond_x - 1;
}

if(new_x > rond_x)
{
     rond_x = rond_x + 1;
}

if(new_y < rond_y)
{
     rond_y = rond_y - 1;
}

if(new_y > rond_y)
{
     rond_y = rond_y + 1;
}

}

But i don’t understand how to set up the timer. The error is :
passing void (*)(char *)' as argument 2 ofSDL_AddTimer(unsigned
int, Unit32 ()(unsigned int, void), void *)’

Thx for the answer j_post but now i’ve got a new problem.

bool anime;

anime = SDL_AddTimer(500, anime_perso, NULL);

Uint32 anime_perso(Uint32 interval, void *param)

for the moment that’s ok but when i try to use SDL_RemoveTimer(anime);
i have this error :
passing bool' to argument 1 ofSDL_RemoveTimer(_SDL_TimerID *)’ lacks a
cast
i don’t understand when i’ve made a mistake

Thomas LAURO–
Ce message Envoi est certifi? sans virus connu.
Analyse effectu?e par Anti-virus AVG (http://www.grisoft.com).
Version: 7.0.211 / Base de donn?es virus: 261.9.2 - Date: 12/02/2004

Thx for the answer j_post but now i’ve got a new problem.

bool anime;

SDL_TimerID anime; // not bool

anime = SDL_AddTimer(500, anime_perso, NULL);

Uint32 anime_perso(Uint32 interval, void *param)

for the moment that’s ok but when i try to use SDL_RemoveTimer(anime);
i have this error :
passing bool' to argument 1 ofSDL_RemoveTimer(_SDL_TimerID *)’ lacks a
cast

This information is in SDL_timer.h

JPOn Friday 13 February 2004 09:05 am, tocx wrote:

I just read the sdl_timer.h and i found this :
typedef struct _SDL_TimerID *SDL_TimerID;
but i don’t know how to set up my SDL_TimerID
sorry for my lack of prog but i just started programing few days ago
so there are many thing i don’t know
Please someone can explain me how to set up this timer and the meaning of
typedef struct

Thomas LAURO–
Ce message Envoi est certifi? sans virus connu.
Analyse effectu?e par Anti-virus AVG (http://www.grisoft.com).
Version: 7.0.211 / Base de donn?es virus: 261.9.2 - Date: 12/02/2004

— tocx wrote:

I just read the sdl_timer.h and i found this :
typedef struct _SDL_TimerID *SDL_TimerID;
but i don’t know how to set up my SDL_TimerID
sorry for my lack of prog but i just started
programing few days ago
so there are many thing i don’t know
Please someone can explain me how to set up this
timer and the meaning of
typedef struct

Thomas LAURO

typedef int example_t; //creates a new type name which
is really an int.

Thus, these two statements would be equivilant:

int variable;
example_t variable;

You can define structures by using:

struct example_struct
{
int example_member_a;
int example_member_b;
//…members…
};

but then to use the variable type, at least in the
past you had to type:

struct example_struct my_structure;
//(then you could do:)
my_structure.example_member_a = 3;
cout << my_structure.example_member_b << endl;

Now, because typing struct example_struct is
repetative, many times people will create a typedef to
make it less repetitive. Thus:

typedef struct _example_struct * example_struct;

creates a new type, ‘example_struct’, that’s really
just a pointer to a _example_struct structure.

For this SDL specific instance, if you didn’t have
that typedef line, you would have to type:

_SDL_TimerID * MyTimerID;

instead of the nicer and friendlier:

SDL_TimerID MyTimerID;

As for learning how to use SDL in general, I must
refer you to the wonderfull Documentation designed to
explain this:

http://sdldoc.csn.ul.ie/

Which is linked on the libsdl.org main page.

Check out the links:

I. SDL Guide | 4. Examples | Time Examples

and:

II. SDL Reference | 13. Time

Clicking on the link with the name of the function
will explain how to use that function.

Welcome aboard :).
-Mike__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.