Stratos: Punto de Encuentro de Desarrolladores

¡Bienvenido a Stratos!

Acceder

Foros





Sprite Animation...

Iniciado por TheAzazel, 27 de Septiembre de 2005, 11:44:29 PM

« anterior - próximo »

TheAzazel

 Mike,
you have to be careful, you dont get movement when you press UP or LEFT because after:
if(keystate[SDLK_UP]) {s->ym=-1; } else s->ym=0;

your code do this other instruction:
if(keystate[SDLK_DOWN]) {s->ym=1; } else s->ym=0;

and if you dont press SDLK_DOWN too, you will lost s->ym previous value...or your UP movement...

a quick fix of this could be:

void inputsprite( sprite *s)
{
bool t = false;

/* Sprite Movement from keyboard */
if(keystate[SDLK_UP]) s->ym=-1;
else if(keystate[SDLK_DOWN]) s->ym=1;
else s->ym=0;

if(keystate[SDLK_LEFT])   s->xm=-1;
else if(keystate[SDLK_RIGHT]) s->xm=1;
else s->xm=0;

s->y+=s->ym;
s->x+=s->xm;
.....
}

I hope this clarify you :)

Cheers

void inputsprite( sprite *s)
{
bool t = false;

/* Sprite Movement from keyboard */
if(keystate[SDLK_UP]) {s->ym=-1; } else s->ym=0;
if(keystate[SDLK_DOWN]) {s->ym=1; } else s->ym=0;
if(keystate[SDLK_LEFT]) {s->xm=-1; } else s->xm=0;
if(keystate[SDLK_RIGHT]) {s->xm=1; } else s->xm=0;
s->y+=s->ym;
s->x+=s->xm;
.....
}

do you know what might be wrong with that? I can't get the sprite to accept UP movement or LEFT movement. ??? ym & xm are shorts.  



Previous and complete post

Citar

Heh.

I'm coding a quick game that would be best described as a "run-n-jump-n-squish-bunnies" game.

The only problem is I have no bunny sprites, and my player sprite has no jump animation hahaha. So it's gonna be more along the lines of "kill as many chickens as brutally as possible that you can."

I just switched from 8 years of pascal to cpp, so I'm also learning the language as I go.

>Ok, point for you.... I have in development a new version of CRM32Pro and CSprite doesnt depend on ITimeSystem... hahaha.
>
>Well, now that the problems have finished... what are you coding?
>
>Thanks you!
>Roberto
>> I just realized:
>>
>> // Timer Update
>> TimeSystem->Update();
>>
>> That's what I forgot about. Then when I put it in, I didn't remember I put it in like the stoner I am, making it seem like I didn't change anything to fix the problem, but I did. hehe. Sorry for all the trouble.
>>
>>>Sprite animations works if below points are done:
>>>-Include SDL_INIT_TIMER when you initialize CRM32Pro.
>>>(for example: CRM32Pro_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER)
>>>-Create/Load a sprite with a valid animations/frames information.
>>>-Set AutoRestore ON/OFF depends on your application.
>>>-Call each frame update to Update() member.
>>>-When you want to draw the sprite..call before SDL_Flip(screen) to Draw() member.
>>>
>>>I think you forgot to include SDL_INIT_TIMER or you dont assign offsetx and/or offsetx of the sprite on your DPF.
>>>
>>>Anyway, if you have any other problem... I am here!!
>>>
>>>happy coding Mike!
>>>
>>>Cheers
>>>
>>>>Yeh, so it's working now - but I don't know why it's working - It just started working.
>>>>
>>>>>Hi again,
>>>>>
>>>>>with Update(), the sprite change its frame and after that...with Draw() it is drawn to a surface.
>>>>>
>>>>>If you could not see a sprite animation(frame by frame), the problem could be on the DPF, the code of Sprite Collision is ready to get a sprite with animation and draw it successfully.
>>>>>
>>>>>Have you setup the offset X and Y of the sprite on your DPF?
>>>>>If you want, you can send me your dpf and your code and I will fix it for you, no problem at all .
>>>>>
>>>>>cheers
>>>>>
>>>>>>Example 6: Sprite Collision does hav a sprite, but the sprite doesn't use any animation.
>>>>>>
>>>>>>I want to animate an animation set (of frames) so it looks like my sprite is walking when it moves in a certain direction.
>>>>>>
>>>>>>As far as I've seen, crm32pro_csprite's Move and Update isn't handling this.
>>>>>>
>>>>>>I have used the example to setup my sprite, but again that example (i checked the dpf file) Doesn't use animation.
>>>>>>
>>>>>>The dpf editor has animation support for sprites, but I'm guessing it may have been left out in the library???
>>>>>>
>>>>>>Right now I force it to animate by setting the animation set and frame myself.
>>>>>>
>>>>>>>Hi Mike,
>>>>>>>
>>>>>>>you have information about this task on "Example 6: Sprite Collision", I imagine you have already downloaded the library documentation... otherwise, you can download it or go to:
>>>>>>>http://www.megastormsystems.com/download/CRM32ProDoc/_sprite_collision_8cpp-example.html
>>>>>>>
>>>>>>>Basically, you have to load/create the sprite, set its position, change AutoRestore feature(if depends on your application) and... on your main loop, call to Update() and Draw() members of that sprite...
>>>>>>>
>>>>>>>Let me know if you have any other problems
>>>>>>>
>>>>>>>What are you trying to do? I would like to know and if you need any other support... contact with me.
>>>>>>>
>>>>>>>Cheers and happy coding!
>>>>>>>>
>>>>>>>> I do not understand how to start playing a sprite animation.
>>>>>>>>
>>>>>>>> The animation type is PING-PONG, theres 8 frames, blahblahblahblah, but nothing says how exactly to get a sprite animating.
>>>>>>>>
>>>>>>>> Any help would be appreciated, thanks.                                                                                                                                                                                                                                                       

 Heh, I cant read spanish. Anywho..

 Thanks for the help! I didn't realize what was going on, but now I understand control flow in cpp a little more.

 

TheAzazel

 Yeah! I imagine that!  :P

but no problem at all, the main buttons are on english language.
I will try to speak with forum admins to see the possibility to use the english on the whole forum stuff but I think that it is not possible... we will see.

Anyway, you can ask here whatever you want. A lot of people can reply you on english.

I'm longing for your game demo, I would like to see it :)

cheers






Stratos es un servicio gratuito, cuyos costes se cubren en parte con la publicidad.
Por favor, desactiva el bloqueador de anuncios en esta web para ayudar a que siga adelante.
Muchísimas gracias.