Is timer a global variable? Or is it a behavior? Same with timestamp.
... you could also use the system expression timer ... timer returns the time passed since start of the game in milliseconds img src="smileys/smiley4.gif" border="0" align="middle">
But I admit, I wasn't very clear on that.
Here is the link to the Wiki, btw: Construct Wiki
Timer: It is a system expression. You access it either by typing "Timer" where needed, or by selecting "Get timer" in the expression wizard of the system object.
Timestamp: The single quotation marks I used were to indicate that it is a variable. Either global or private - I prefer PV where possible.
The principle of that method is to get a pointer to a certain time. This can be compared to another time, and if some predefined period has elapsed, you can trigger any other actions you need at that time.
Calling timer after game ran for 5 seconds:
timer will return 5000
Calling timer after game ran for 7 seconds:
timer will return 7000
If you use a variable 'timestamp' and fill it once with timer after the game ran for 5 seconds:
'timestamp' will be filled with timer, and timer returns 5000, so
'timestamp' = 5000
If you constantly test against 'timestamp':
if timer - 2000 = 'timestamp'
This condition will be true as soon as timer reaches 7000, because 7000 - 2000 = 5000
Instead of the number 2000, you could use another variable, I called it 'maxTime'. It is the period allowed before the condition will become true:
if timer - 'maxTime' = 'timestamp'
Now the problem is, you not just want something to happen after 2 seconds, you also want to inform the player about how many time there is left. That's the third variable 'remaining'. It needs to be set to the difference of 'maxTime' and the current progress within the period. After 0.5s the remaining time is 1.5s, etc:
set 'remaining' to 'maxTime' - (timer - 'timestamp')
Let's fill this with values to see how it works. 'timestamp' = 5000, 'maxTime' = 2000.
We call this action by chance when timer returns 6500, that's 1.5s after we filled 'timestamp':
set 'remaining' to 2000 - (6500 - 5000) => 2000 - 1500 => 500 or 0.5s
But 'remaining' will always be calculated, so it can get negative. Imagine we call the action, when timer will return 10000, that's 5 seconds after we filled 'timestamp':
set 'remaining' to 2000 - (10000 - 5000) => 2000 - 5000 => -3000 or -3s
We surely don't want that to happen, so we need to catch that before it goes negative:
'remaining' <= 0
This condition will be used to trigger any action that makes sense. You could use it to end the game, or you could fill 'timestamp' again with timer, that would reset the timing, so we get a continous loop of a countdown from 2s to 0s, 2s to 0s, ..., or you could switch to another layout. Whatever is needed.
So the way I am understanding arrays, they are like grids with values at each of the grid spaces.
Now, I want a high-score table where people can enter their names, but I don't want something like "type your name here" since that is kind of lame.
I was wondering, that maybe I can set up an array which has in each space the value for a letter, like A, or H, or a number, 0-9. Stuff like that.
Of course, I don't know how I'd get that to work, but is it possible?
I'm sorry but I don't quite understand. Is it the kind of input (name typing, or selecting letters per digit by using up/down/left/right) you are concerned of, or the actual values to store?
3) Tutorials seem to be split on this- to do a score system, and a high-score system, do you go with arrays, or do you go with INI files (perhaps protected by CRC32), or perhaps some mixture of the two? Whatever is easier is good for me!
They both are relatively easy. Using ini-files you have all of the informations stored in 1 file, while arrays may use 2,3 or more files, depending on the informations to save, but are more easily sortable. There are two other possibilities: You could also use a hash table.
Arrays and hash table save their data in a binary format (non human readable), while ini files are simple text files. So you don't really need a crc32 protection for arrays/hashtables.
Last, but not least you could use 's', a fantastic plugin by lucid. Sorting is easy as well as saving/loading. Plus, all data is not only saved in binary format, but encrypted also, without the need for extra code.