Share your repls and programming experiences

← Back to all posts
RUN!!
r3b0rn (28)

Created by: @r3b0rn
Suggestions:
None yet
Bugs:
Ball glitching out of map-fixed
player occasionally leaving map-fixing

Comments
hotnewtop
tipollae (36)

Great game! You should also use a jquery (jquery is a javascript library) for the player movement, it will make your movement for the player more smooth, I will link the code:

https://playermovement.cheesehasman.repl.co/jquery.js

How to use this library:

copy paste that code you see in it and put it in a new script in your repl/project, link the script to the HTML: " <script src = "yourScript.js"></script> "

now that you have done that copy this code and put it on your script for the game (not the jquery script):

//wasd controller variables----
var keys = {};
var right_pressed = false;
var left_pressed = false;
var up_pressed = false;
var down_pressed = false;

var right_arrow_pressed = false;
var left_arrow_pressed = false;
var up_arrow_pressed = false;
var down_arrow_pressed = false;
//wasd controller variables----





//jquery for player movement---

$(document).keydown(function (e){

    if (e.which == 87){
      //w is pressed
      up_pressed = true;
    }



    if (e.which == 65){
      //a is pressed
      left_pressed = true;
    }



    if (e.which == 83){
      //s is pressed
      down_pressed = true;
    }



    if (e.which == 68){
      //d is pressed
      right_pressed = true;
    }






    if (e.which == 39) {
    //right arrow key is pressed
    right_arrow_pressed = true;
    }

    if (e.which == 37) {
    //left arrow key is pressed
    left_arrow_pressed = true;
    }

    if (e.which == 38) {
    //up arrow key is pressed
    up_arrow_pressed = true;
    }

    if (e.which == 40) {
    //down arrow key is pressed
    down_arrow_pressed = true;
    }



    if (e.which == 32 || e.which == 13){
    space_pressed = true;
    //space is pressed
    }

    
  

});







$(document).keyup(function (e) {
    delete keys[e.which]; 

    if (e.which == 68) {
    //d is NOT pressed
    right_pressed = false;
    }

    if (e.which == 65) {
    //a is NOT pressed
    left_pressed = false;
    }   

    if (e.which == 87) {
    //w is NOT pressed
    up_pressed = false;
    }

    if (e.which == 83) {
    //s is NOT pressed
    down_pressed = false;
    }   




    if (e.which == 39) {
    //right arrow key is NOT pressed
    right_arrow_pressed = false;
    }

    if (e.which == 37) {
    //left arrow key is NOT pressed
    left_arrow_pressed = false;
    }

    if (e.which == 38) {
    //up arrow key is NOT pressed
    up_arrow_pressed = false;
    }

    if (e.which == 40) {
    //down arrow key is NOT pressed
    down_arrow_pressed = false;
    }



    if (e.which == 32 || e.which == 13){
    space_pressed = false;
    //space is NOT pressed
    }



});
//jquery for player movement---

After that copy paste this somewhere in a function (Yeah I know a lot is needed to be copy and pasted :p):

  if (right_pressed || right_arrow_pressed){
  //enter code here
}

  if (left_pressed || left_arrow_pressed){
  //enter code here    
  }

  if (down_pressed || down_arrow_pressed){
    //enter code here
  }

  if (up_pressed || up_arrow_pressed){
    //enter code here
  }

If you still don't understand what I am saying here's a link of the forked version of your game: https://run.cheesehasman.repl.co

but with all that aside, great game! (also you don't have to use the jquery but I'm just saying)

r3b0rn (28)

@Cheesehasman thanks! ill note that for next time

Bunnytoes (116)

I also glitched it but great job :D

tankerguy1917 (178)

Noice. I glitched it out and made the ball disappear, so infinite points.

r3b0rn (28)

@tankerguy1917 im aware of that trying to fix that
sorry

tankerguy1917 (178)

@r3b0rn Its fine, I thought it was pretty neet.

r3b0rn (28)

@tankerguy1917 thanks, do you think you know the cause to the problem btw?

tankerguy1917 (178)

@r3b0rn I moved all the way to the left of the screen, then it moved me to the bottom left and the ball kind of just disappeared.