- This wiki is out of date, use the continuation of this wiki instead
Frame
From FenixWiki
Revision as of 21:04, 25 June 2007 (edit) 87.177.23.239 (Talk) ← Previous diff |
Revision as of 21:00, 19 August 2007 (edit) (undo) Sandman (Talk | contribs) Next diff → |
||
Line 1: | Line 1: | ||
[[Category:language]] | [[Category:language]] | ||
- | + | ||
- | + | == Definition == | |
The '''frame;''' command tells the interpreter when a [[process]] is done for one game cycle. | The '''frame;''' command tells the interpreter when a [[process]] is done for one game cycle. | ||
When the '''frame;''' is reached, the screen is updated. | When the '''frame;''' is reached, the screen is updated. | ||
- | If there are several [[process]]es running, the screen is updated once every [[process]] has reached | + | If there are several [[process]]es running, the screen is updated once every [[process]] has reached its '''frame;''' statement. |
- | '''frame;''' statement. | + | |
- | It is commonly used in [[loop]]s of [[process]]es that should do something like moving around by a certain | + | It is commonly used in [[loop]]s of [[process]]es that should do something like moving around by a certain amount of pixels per game cycle (or per frame). |
- | amount of pixels per game cycle (or per frame). | + | |
- | + | A possibility is to adjust the amount of cycles to wait. '''frame(100);''' would wait one cycle (100%), same as '''frame;'''. However '''frame(200);''' will wait two cycles (200% means the frame statement provides for 200% frame). So '''frame(50);''' will wait a half cycle or otherwise said, it will make a loop run twice per frame. | |
- | + | ||
+ | == Example == | ||
<pre> | <pre> | ||
- | + | Begin | |
- | + | square(); | |
- | + | Loop | |
- | + | frame; | |
+ | End | ||
+ | End | ||
+ | |||
+ | Process square() | ||
+ | Begin | ||
+ | |||
+ | graph = new_map(5,5,16); | ||
+ | map_clear(0,graph,rgb(255,255,255)); | ||
- | + | Loop | |
- | + | x += 2 * (key(_right)-key(_left)); | |
- | + | frame; //<-vital part | |
+ | End | ||
- | + | End | |
- | + | ||
- | + | ||
</pre> | </pre> | ||
This example [[process]] would give you a square you can move around the screen by 2 pixel before it | This example [[process]] would give you a square you can move around the screen by 2 pixel before it | ||
gets showed again, before the game cycle is over, before the '''frame;''' happens. | gets showed again, before the game cycle is over, before the '''frame;''' happens. | ||
- | If there would be no '''frame;''' in the [[loop]], it would just run | + | If there would be no '''frame;''' in the [[loop]], it would just run forever and the interpreter would wait forever and wait for the '''frame;''' which would result in freezing. |
- | + |
Revision as of 21:00, 19 August 2007
Definition
The frame; command tells the interpreter when a process is done for one game cycle. When the frame; is reached, the screen is updated. If there are several processes running, the screen is updated once every process has reached its frame; statement.
It is commonly used in loops of processes that should do something like moving around by a certain amount of pixels per game cycle (or per frame).
A possibility is to adjust the amount of cycles to wait. frame(100); would wait one cycle (100%), same as frame;. However frame(200); will wait two cycles (200% means the frame statement provides for 200% frame). So frame(50); will wait a half cycle or otherwise said, it will make a loop run twice per frame.
Example
Begin square(); Loop frame; End End Process square() Begin graph = new_map(5,5,16); map_clear(0,graph,rgb(255,255,255)); Loop x += 2 * (key(_right)-key(_left)); frame; //<-vital part End End
This example process would give you a square you can move around the screen by 2 pixel before it gets showed again, before the game cycle is over, before the frame; happens. If there would be no frame; in the loop, it would just run forever and the interpreter would wait forever and wait for the frame; which would result in freezing.