Jump to content
  • Advertisement
Sign in to follow this  
walle

Trouble with SDL_gfx(rotozoomer)

This topic is 4406 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. Long time I've posted here, and long time since I've done any c++ programming. But now I've in the race again and directly I ran into trouble =) I want to rotate a surface in the end I want to rotate it with the mouse, but for now I just want to rotate it with the arrows. So here comes my problem. When I rotate a surface with rotozoomer it moves down to the right corner and gets blurry...I have done something wrong, how should I do this correctly? Here is my code I use, just some test code I threw together...
#include <iostream>
#include <SDL/SDL.h>
#include <SDL/SDL_Image.h>

#include "SDL_rotozoom.h"

SDL_Surface *screen;
SDL_Event event;
bool done = false;

SDL_Surface *player;
SDL_Rect rect;

int main( int argc, char *arcv[])
{
    if( SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO) < 0 )
    { 
        std::cout<<"ERROR INITILASING SDL!" <<std::endl<<"Reason: "<<SDL_GetError();
        exit(1);
    }
    atexit(SDL_Quit);
    
    screen=SDL_SetVideoMode(800,600,32,SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_HWPALETTE);
    if(screen == NULL)
    {
        std::cout<<"ERROR SETTING 800x600x32 VIDEO!"<<std::endl<<"Reason: "<<SDL_GetError();
        exit(1);
    } 

	player = IMG_Load("player.png");

	rect.x = 380;
	rect.y = 280;

	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);

    while(!done)
    {   
		SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255));
		SDL_BlitSurface(player, NULL, screen, &rect);
		SDL_Flip(screen);
          while( SDL_PollEvent(&event) )
          {
              switch(event.type)
            {
                case SDL_QUIT:
                    done = true;
                    break;
                case SDL_KEYDOWN:
                    switch(event.key.keysym.sym)
                    {
                        case SDLK_ESCAPE:
							done = true;
                            break;			
			case SDLK_LEFT:
			    player = rotozoomSurface(player, 45, 1, 1);
		            break;
			case SDLK_RIGHT:
			    player = rotozoomSurface(player, -45, 1, 1);
			    break;
                    }
                default: 
                    break;
            }        
          }
      }            
               
      SDL_FreeSurface(player);

return 0;
}
               






EDIT: Sry, some probs with the tabs. Pasted from vc++ 8 :EDIT [Edited by - walle on May 28, 2006 5:56:16 PM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!