Moving Images

32 views
Skip to first unread message

Andres Orellana

unread,
Aug 19, 2013, 12:52:08 AM8/19/13
to lispb...@googlegroups.com
How do I move a Image using the arrow keys on the keyboard?

Elliott Slaughter

unread,
Aug 22, 2013, 10:27:29 PM8/22/13
to lispb...@googlegroups.com
You'll want to create an event loop similar to the one described in the user guide here:

http://code.google.com/p/lispbuilder/wiki/UsingLispbuilderSDL#The_Game_Loop

You can add a clause for :key-down-event and :key-up-event in the loop, and add some code that updates the position of the image. SDL will fire the :key-down-event when the key is pressed, and then the :key-up-event when the key is lifted again. In between, assuming you want the image to move at a constant rate, you can add code to the :idle event, which runs once each frame (default 30 fps), to move the image a little each frame.

See also:

http://lispbuilder.googlecode.com/svn/trunk/documentation/lispbuilder-sdl.html#frame-rate
http://lispbuilder.googlecode.com/svn/trunk/documentation/lispbuilder-sdl.html#enable-key-repeat

Hope that helps.


On Sun, Aug 18, 2013 at 10:52 PM, Andres Orellana <andyo...@gmail.com> wrote:
How do I move a Image using the arrow keys on the keyboard?

--
You received this message because you are subscribed to the Google Groups "Lispbuilder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lispbuilder...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Elliott Slaughter

"Don't worry about what anybody else is going to do. The best way to predict the future is to invent it." - Alan Kay

Andres Orellana

unread,
Sep 10, 2013, 5:01:52 PM9/10/13
to lispb...@googlegroups.com
Thank you the links helped me out a lot
Reply all
Reply to author
Forward
0 new messages