How do I make it go backwards once it reaches the fourth icon?
Presently it jumps back to the first.
That gets a little more complicated, but
select = ((select >> 25) + 1 * ((select & 0x7F) - 1) << 25) | ((select >> 25) > 2 ? 0 : (select >> 25) < 3 ? 2 : (select & 0x7F))
should do the trick.
Alternatively, store a variable called
select_direction or something and set that to 1 if
select is 1, -1 if
select is 4, or don't change it if
select is 2 or 3. Then simply increment
select by
select_direction.
Radnen's right that you probably want two keys for this though. I think I use D and F for this in my game. Something like:
var min = Math.min, max = Math.max;
while (AreKeysLeft()) {
var key = GetKey();
select = max(1, min(4, select + (key == KEY_D ? -1 : key == KEY_F ? 1 : 0)));
}
is how I'd do it, although Radnen's version is perfectly reasonable as well.
It's not a bad idea, not at all. I was just concerned of pacing that's all: newbies can lose interest if too much info is headed their way.
You mean, he might... learn something? Crazy, we can't have noobs learning.
And yes, it's a bad idea. The render script doesn't run at a fixed framerate, which will mess up input a lot. The engine attempts to run the update script at
GetMapEngineFramerate() frames per second, which is much better for handling input.
Good call on the selection rolling, but now I must explain ternary operators.
I assumed he knows JavaScript syntax, but maybe not.
EDIT: Sorry for double posting.