Fundamental coding question: loop, restrications..
Hi.
The more code lines the event editor has the more work the computer has to do. Is this correct? I think more lines need more HD space or RAM. Anyway, it is important for coding that the events are well-structured and do what they are supposed to do, using the easiest, less complicated way.
My question concerns some fundamental coding.
An example:
A game can be played alone or with two players. In the menu I have an event something like this: if mouse clicks on picture "one player" then set variable "#ofplayers?" to 1. If mouse clicks on picture "two players" then set variable "#ofplayers" to 2. Alright.
In a level the events have to look at the actual number of players. If only one player is in the game then...if two players are in the game then...
I use:
if "#ofplayers" = 1 then...
and
if ... = 2 then...
BUT...now my question. LOL
How should such "game facts" (1 or 2 players?) be handled?
Do I have to use
"start of the game" and "#ofplayers" = 1 then...
or just
"if "#ofplayers" = 1 then...
or
"if "#ofplayers" = 1 AND only one action if event loops then..
=====
How does this work? Do I have to use "start of game" for such events? Does it loop and consume unneeded memory with just one line (if #ofplayers 1 then...)?
Do I have to restrict such events?
I am not sure what events should be restricted and what don't have to be.
Of course a line "if number of points > 50 then play sound..." is wrong as this sound is repeated over and over when the player scores 51 points or more. So I have to restrict this event. But what about my example?
Please help me and tell me what events should be restricted.
Re: Fundamental coding question: loop, restrications..
Thank you very much for your long and helpful comment. :)
Re: Fundamental coding question: loop, restrications..
"Start of frame" : executed before fadein and called once
>> Fastest
standard condition (like always) : executed after fadein at each loop of the frame
>> Slowest
conditions with "only one action when event loops" : executed after fadein only one time if the state of the condition has not changed since the previous frame
>> Slower than "Start of frame"