If you've played Grand Theft Auto 4 or 5, you will know that the animations are very synced to eachother. That's due to a thing called the Euphoria Engine. If your unsure of what the Euphoria Engine is, here is a video:
[video=youtube;wKLaMN9dnjQ]https://www.youtube.com/watch?v=wKLaMN9dnjQ[/video]
Now, I want to recreate that for the player, but it will be a simple version for my game. But I can't seem to get a single arm to go back and forth for walking. I'm also using SDL2 to make this.
Here is my code:
[CODE]while (!Close && e->type != SDL_QUIT)
{
SDL_PollEvent(e);
SDL_RenderClear(_renderer);
SDL_RenderCopy(_renderer, _bgimg, NULL, &bg_rect);
SDL_RenderCopy(_renderer, _headimg, NULL, &head_rect);
SDL_RenderCopy(_renderer, _bodyimg, NULL, &body_rect);
if (e->type == SDL_KEYDOWN)
{
if (e->key.keysym.sym == SDLK_a)
{
body_rect.x = body_rect.x - 3;
arm_rect.x = body_rect.x;
head_rect.x = body_rect.x;
leg_rect.x = body_rect.x;
++armangle;
if (armangle >= 90)
{
--armangle;
}
}
if (e->key.keysym.sym == SDLK_d)
{
body_rect.x = body_rect.x + 3;
arm_rect.x = body_rect.x;
head_rect.x = body_rect.x;
leg_rect.x = body_rect.x;
}
}
SDL_RenderCopyEx(_renderer, _armimg, NULL, &arm_rect, armangle, NULL, flip);
SDL_RenderCopyEx(_renderer, _legimg, NULL, &leg_rect, legangle, NULL, flip);
SDL_RenderPresent(_renderer);
Mix_PlayMusic(menumusic, -1);
}[/CODE]
If you can paste in a edited version or just giving me an idea to make it work that would be great.
Sorry, you need to Log In to post a reply to this thread.