Home | Rules and Guide | Sign In/Create Account | Write a Post | Donate | #ludumdare on irc.afternet.org (Info)

Ludum Dare 24 — Coming August 2012

Ludum Dare 23 — April 20th-23rd, 2012 — 10 Year Anniversary
[ Results: Top 50 Compo, Jam | Top 25 Categories | View My Entry ]
[ View All 1402 Games (Compo Only, Jam Only) | Warmup ]


Hooray for keystates!

Posted by (twitter: @atkinssj)
August 30th, 2009 6:15 am

Shows how much of a noob I am really, but I just discovered that SDL lets you check keystates at any time, not just when a keypress event is raised. This makes the movement code much, much simpler. Currently attempting to let you jump, which currently conflicts horribly with the code that stops you falling through the floor… Wait a minute! I think I’ve cracked it! I just need to do a check if the vertical velocity is negative! Yay! :D

Tags:

4 Responses to “Hooray for keystates!”

  1. Jonny D says:

    I mentioned this elsewhere already, but you might get some use out of StickyInput:
    http://code.bluedinosaurs.com/SDL.html

  2. LunarCrisis says:

    If you just check for negative velocity you’ll be able to keep jumping as long as you’re moving upwards XD

    • AtkinsSJ says:

      Yeah, it checks for solid ground before jumping. It’s just that I have a second piece of code which was basically

      If there is no square beneath you, fall
      Else, snap to the ground.

      Which stopped you being able to leave the ground. Using a grid system with a smooth-movement system is complicated. *_*

Leave a Reply

You must be logged in to post a comment.


All posts, images, and comments are owned by their creators.

[fcache: storing page]