Ok, here's my situation: I am making a top-down, grid-based sand castle game. The game terrain is comprised of a few hundred "sandTerrain" objects, each one of which is a tile on the grid. Each tile has a "height" value of 1 to 4, which is represented by the coloration of the tile.
I'm giving players the ability to either add height to the sand, or lower the height. They can hold down and drag the mouse button across the terrain to edit a line of sand. I am running into two problems with this:
1. If the player moves the mouse really fast, some squares on the grid are skipped, and instead of a full line of edited squares I have a dotted line. Which makes sense; the mouse is moving faster than the code is checking. I suspect that I'll need to learn about fast loops and use those to do this, but any other thoughts or techniques would be very appreciated.
2. Second, if the player is moving the mouse anywhere below max speed, the mouse hovers over an individual square long enough for the code to check at least twice, usually three or four times. This means that a piece of terrain at height 4 can be lowered down to height 1 faster than the eye can follow. Ideally, each single piece of terrain can only be raised or lowered once per mouse click. In order to make another change, the player would need to let go of the button they're holding, and then click again.
I am unsure of a good way to fix the second problem, so any advice would definitely be appreciated.
You can download a stripped-down version of my .cap file here:
I am using Construct version 0.99.42
Develop games in your browser. Powerful, performant & highly capable.
You can't rely on mouse. Instead, record mouse coordinates each frame and "draw" a line to the previous mouse location and so on. Mark the points the line overlaps.
Too tired to give more concrete example, I'm sure someone can give you a simpler solution.
yeah it's not that the code is not going fast enough. Computer mice only output discrete variations. It's up to the software to interpret that as needed.
Once an object has been clicked once set a private variable to 1 and add a condition to check the variable in the raise and lower code. then make a new event for on mouse released terrain object set variable to 0 that should take care of the once per mouse click problem.