Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Brastin

83
Posts
1
Topics
150
Followers
25
Following
A member registered Jul 06, 2017 · View creator page →

Recent community posts

I caught my files nefariously drinking mustard in my documents folder - Thanks Electric File Monitor!

I havent bought the game yet but I love the LEGO LOCO style menu thing and everything, and I don't think ive seen anyone point that out yet

(1 edit)

Oh yeah that was so annoying. The way I fixed it was instead of checking if a key was pressed using keyPressed and checking hat key was being held at the time, I had up, left, down, and right variables. In the keyPressed() function I check what key is pressed and change the variable to true, and in the keyReleased() function I check which key gets released and change the variable to false. This way you can check if multiple keys are pressed at a time, and it doesn't do that weird thing where it can't decide what key is being pressed. Sorry if that was confusing but I hope it helped :)

Heres an example with two buttons (left and right)

boolean left;
boolean right;
int x;
void keyPressed(){
  if(keyCode==LEFT||key=='a'){
    left=true;
  }
  if(keyCode==RIGHT||key=='d'){
    right=true;
  }
}
void keyReleased(){
  if(keyCode==LEFT||key=='a'){
    left=false;
  }
  if(keyCode==RIGHT||key=='d'){
    right=false;
  }
}
void move(){
  if(left){
    x--;
  }
  if(right){
    x++;
  }
}

Thanks! :)

Thank you!

What do you mean by smooth controls? Like just the physics or the key inputs?