[SDL] Mouse Input + Delay problem

Leonardo Guilherme leonardo.guilherme at gmail.com
Mon Apr 7 10:31:32 PDT 2008


Have you ever tried "Programming Linux Games", from Loki's games?
It covers well SDL and a simple 2D game is crerated through the book.
If you search "Programming Linux Games" in google you'll eventualy find a
link to it. It's an e-book.

Good Luck!


2008/4/7, Ankush Thakur <ankush.gamedev at gmail.com>:
>
> OK, thanks for the idea. Implementing it will take some time, so I'll tell
> you later.
>
> By the way, I would *REALLY* appreciate a COMPLETE game tutorial for SDL.
> It should be for a simple 2D game and must discuss ALL the aspects involved
> right from start to finish. I'm particularly interested in class design and
> game flow.
>
> As I'm new to game dev. + OOP, I am having lots of troubles. :(
>
> Please help me find some tutorials.
>
> On Mon, Apr 7, 2008 at 10:14 PM, Justin Coleman <jmcoleman at gmail.com>
> wrote:
>
> > Delay is a bad way to do that. What you need is a timer instead. Your
> > game loop should look more like this:
> >
> > set timer for how long to display card
> > while game is playing
> >    if display time not expired
> >        redraw screen
> >        check for mouse clicked
> >             if click is detected
> >                 check for click coordinates in the right place
> >        decrement display time by amount of time passed since last loop
> >
> > Hope that helps you.
> >
> > -J
> >
> > On Mon, Apr 7, 2008 at 12:39 PM, Ankush Thakur <ankush.gamedev at gmail.com>
> > wrote:
> > > Hi,
> > >
> > > I am making a small game.
> > > The requirement is that an image will be displayed for some time (say
> > 1000
> > > ms), and the user has to click on it.
> > > After the click, we must check for click coordinates.
> > >
> > > the general structure I follows goes like this:
> > >
> > > draw();
> > > checkForInput();
> > > delay for 1000 ms();
> > >
> > > The problem is that  mouse clicks are not getting detected. I guess it
> > is
> > > because the mouse clicks happen when the game is waiting through
> > > SDL_Delay(1000), so we miss the input.
> > >
> > > The delay MUST be there because the image has to stay for a certain
> > amount
> > > of time.
> > >
> > > Please help me out.
> > >
> > > _______________________________________________
> > >  SDL mailing list
> > >  SDL at lists.libsdl.org
> > >  http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> > >
> > >
> > _______________________________________________
> > SDL mailing list
> > SDL at lists.libsdl.org
> > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> >
>
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20080407/f015adca/attachment.html 


More information about the SDL mailing list