c++ - Continuous keyboard movements -
now making game there 2 plates on both sides of screen (i.e. left , right). , ball bounces in screen. when touches either of plates bounces back. if touches left or right edge of screen it's game over. have control plates arrow keys or standard (w, a, s, d) keys. problem when press w or movement keys moves once stops.
i have press many times make move. want continuous movement when press , hold of movement keys. using allegro 5 dev c++ on windows 7 pc.
the event processing logic should respond keypresses , update velocity of plate, , update logic should move plate according velocity. here's pseudocode:
while running: # event processing event in queue: if event keypress: if key w: velocityy -= 10 if key s: velocityy += 10 if event keyrelease: if key w: velocityy += 10 if key s: velocityy -= 10 # update posy += velocityy * elapsedtime
Comments
Post a Comment