NO

Author Topic: Scanf in SDL  (Read 3822 times)

potchi

  • Guest
Scanf in SDL
« on: July 05, 2011, 08:18:34 PM »
Hi Im using pelles C and SDL.

I just want to create a rectangle in SDL but with the help of scanf so that the
rectangle height would be user-dependent.

here's the code.

#include "SDL.h"
#include "SDL_gfxPrimitives.h"
#include <stdio.h>

const int WINDOW_WIDTH = 640;
const int WINDOW_HEIGHT = 480;
const char* WINDOW_TITLE = "SDL Start";

int main(int argc, char **argv)
{
/*The printf and scanf here is not working*/
  int y;
 printf("Enter y coordinate: ")
 scanf("%d",&y);   
/*The printf and scanf here is not working*/

   SDL_Init( SDL_INIT_VIDEO );

   SDL_Surface* screen = SDL_SetVideoMode( WINDOW_WIDTH, WINDOW_HEIGHT, 0,
      SDL_HWSURFACE | SDL_DOUBLEBUF );
   SDL_WM_SetCaption( WINDOW_TITLE, 0 );

   SDL_Event event;
   int keypress=1;

   while (keypress==1)
   {
      if (SDL_PollEvent(&event))
      {
         if (event.type == SDL_QUIT)
         {
            keypress = 0;
         }
      }

      SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));

      boxRGBA(screen,
              260, 60,
              385, y,
              255, 0, 0, 150);

      SDL_Flip(screen);
   }

   SDL_Quit();

   
   return 0;
}


Thanks!!!