SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2010
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript game character speed

    im moving the character with on key press x+=10;

    trouble is if i hold the key to long the character zoooms of the screen since x is having ten added constantly so the amount it jumps in each interval is increased, how can i limit this? i tried just x+10 which didnt move it atall.

    maybe im being stupid and missing something

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    limit x to 200

    Code:
    x=Math.min(x+10,200);


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •