Hot answers tagged

42 votes
Accepted

Is it normal for a game to use 100% CPU?

Yes, this is normal for a real-time game to try to use 100% CPU to perform as fast and good as it can. So that player sees as much frames per second or as good physics simulation or anything else as ...
user avatar
  • 10.1k
37 votes
Accepted

Should I develop with mouse in mind if I plan on targetting more than PC?

Yes, when you want your game to run on PC, you should think from an early design stage on how to best utilize the mouse. The same applies to the input features of all other platforms you consider ...
user avatar
  • 112k
34 votes

Can I (safely) assume that people playing my game have a middle mouse button?

Although you are targeting desktops, there will be players on (gaming) laptops and for some of them, it will be an inconvenience to get a mouse before being able to play your game. It would sound like ...
user avatar
  • 900
32 votes
Accepted

How to avoid ghosting when pressing multiple keys?

You can't. At least, not as a game developer. As a gamer, you can purchase more expensive keyboards with "anti-ghosting" features, but otherwise the limitation is part of the hardware itself, so ...
user avatar
  • 14.6k
31 votes

How to make a delayed mouse input?

To simulate a time lag, use a circular buffer to store the last N frames' mouse positions. Store the current mouse position each frame. In your control calculations, use the oldest mouse position from ...
user avatar
  • 401
27 votes

Ways to draw tracks on 4-connected grid

This is Matt, the creator of Trainyard. @DMGregory summoned me here! :) It sounds like you're working through the same issues I had to deal with. It's a tricky problem where there isn't necessarily a ...
user avatar
  • 371
22 votes

Can I (safely) assume that people playing my game have a middle mouse button?

It really depends what you mean by "assume". Are you making this assumption at the point of designing your gameplay mechanics? Or at the point of deciding whether or not to implement fully ...
user avatar
19 votes

Unity 3d 4 players Only 4 buttons can be pressed at a time

Keyboards have hardware limitations on how many keys can be pressed and recognized at the same time. Your code is not the problem here, it's most likely the design of the keyboard.
user avatar
  • 6,399
11 votes
Accepted

Act on Right Mouse Button click on Button

This is actually really simple. All you have to do is add another ClickListener which listens for Right Clicks (the default only listens to left clicks). To do this ...
user avatar
11 votes

Unity 3d 4 players Only 4 buttons can be pressed at a time

Keyboards have a key matrix, where the buttons have been arranged into something roughly square, with the keyswitches each being tied to one row and one column. The keyboard activates each row and ...
user avatar
10 votes

Can I (safely) assume that people playing my game have a middle mouse button?

Many laptops lack a middle button, especially those with a trackpad, and you need special software to emulate it. Mac laptops have only one button. Right-click is pretty easy (two finger click) and ...
user avatar
  • 201
9 votes

Is it normal for a game to use 100% CPU?

A game with a constant active window refresh will mostly be ran in full-screen mode and be the only (big) program of the machine managed by the OS. So it is totally acceptable to use 100% of CPU, ...
user avatar
  • 999
9 votes

Is it normal for a game to use 100% CPU?

There are a few drawbacks of aiming to use all available CPU time in a PC or mobile game. System requirements: Even if a game is playable on the PC where you develop your game, it might not be ...
user avatar
8 votes

How do I accept only one directional input per update?

Firstly, you need to use a switch case statement and decide which direction overrides the others, for example, if they press all four buttons, which button should be listened to for input? This gets ...
user avatar
6 votes

Act on Right Mouse Button click on Button

There are three main ways (that I know of) to obtaining input in LibGDX. The first is as you said, changing the ClickListener, the second will be setting the ...
user avatar
6 votes
Accepted

How to handle complex inputs in 2D platform game?

This is an excellent question because you are experiencing a problem that's quite commonplace with less experienced programmers: attempting to solve your problem with a purely imperative approach. ...
user avatar
  • 1,637
6 votes

Should I develop with mouse in mind if I plan on targetting more than PC?

Yes you should. PC users expect that they'll have a mouse to play your game. If you don't use it, your game risks to be labeled as a "poor mobile port", specially if some actions in the game should ...
user avatar
  • 15.5k
6 votes

Simple message box in gdscript / godot

You can use the OS / platform's alert system: OS.alert('This is your message', 'Message Title') You can use ...
user avatar
  • 251
6 votes
Accepted

Comparing analog stick movements to predefined flick shapes

It looks like all these gestures only care about which points you hit around the outside of the stick's range, and the order you hit them in, so we can take a very simplified approach. Let's label ...
user avatar
  • 113k
6 votes

Ways to draw tracks on 4-connected grid

I think you can solve the two pain points you indicated with a few heuristics. One is a little hysteresis: once the player is drawing in a particular row/column, keep their drawing cursor locked in ...
user avatar
  • 113k
6 votes
Accepted

Visual Studio not recognizing Unity's new Input system

I found the answer online! I had to go to the editor preferences (Edit -> Preferences) and under External Tools, there's a section with checkboxes under "Generate .csproj files for:." ...
user avatar
  • 490
5 votes

Can I (safely) assume that people playing my game have a middle mouse button?

Some people use a trackball (some trackballs have no middle mouse button), trackballs generally are just as good pointing devices for players as ordinary mouses. The trackball I linked has no middle ...
user avatar
  • 151
5 votes

LibGDX : Textfield input type

I found out a solution to your other problem. To allow the typing of a dot you should create your own implementation of TextFieldFilter like this. ...
user avatar
  • 73
5 votes
Accepted

How do I accept only one directional input per update?

Your issues does not seems to be "How do I accept only one directional input per update?" but rather "How do I prevent my snake to go backward?" From the many comments and discussion, you seem to be ...
user avatar
  • 15.5k
5 votes
Accepted

How to know when user has stopped dragging

Check if Touch TouchPhase is Stationary, which even says will be set only if: A finger is ...
user avatar
  • 3,318
5 votes
Accepted

What keys should I use for a four-player game with one keyboard?

Just as a heads up, most keyboards have a finite limit of keys that can be pressed. For example, I have an Asus Transformer Book and you can only press around ~5 keys at a time. Some keyboards also ...
user avatar
5 votes

How does input work when exporting to Android?

With Unity, the mouse input will work like a touch input on android, automatically. Alternatively, you can look at the Input.touches class to handle multiple touches.
user avatar
  • 8,279
5 votes

Calculate 8 different directional input based on arrow keys combinations

Given 4 variables up left down right with values zero or ...
user avatar
  • 113k
5 votes
Accepted

Entity Component System - Handling Input

Input is usually more abstracted from character behaviour than that. Usually by some kind of "character controller" that translates requested state into movement/actions. Ideally you don't want to ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible