- This wiki is out of date, use the continuation of this wiki instead
Process
From FenixWiki
Revision as of 13:00, 23 March 2007 (edit) 130.89.160.132 (Talk) ← Previous diff |
Revision as of 13:04, 23 March 2007 (edit) (undo) 130.89.160.132 (Talk) Next diff → |
||
Line 18: | Line 18: | ||
Loop | Loop | ||
speed+=key(_up)*(speed<maxspeed)-key(_down)*(speed>-maxspeed); | speed+=key(_up)*(speed<maxspeed)-key(_down)*(speed>-maxspeed); | ||
- | angle+=(key( | + | angle+=(key(_left)-key(_right))*maxturnspeed; |
advance(speed); | advance(speed); | ||
frame; | frame; | ||
Line 24: | Line 24: | ||
End | End | ||
</pre> | </pre> | ||
- | Now one can call this process for example by doing | + | Now one can call this process for example by doing the following. |
<pre> | <pre> | ||
Private | Private | ||
int map; | int map; | ||
Begin | Begin | ||
- | map = new_map(20,20, | + | map = new_map(20,20,8); |
map_clear(0,map,rgb(0,255,255)); | map_clear(0,map,rgb(0,255,255)); | ||
SpaceShip(0,map,100,100,0,20,5000); | SpaceShip(0,map,100,100,0,20,5000); | ||
End | End | ||
</pre> | </pre> | ||
+ | This will make a SpaceShip with a cyan coloured block, able to move around the screen. |
Revision as of 13:04, 23 March 2007
A process is a subroutine to which one or more of the following apply:
- it received parameters
- it acts on the parameters
- it processes data located elsewhere
- it returns a value
In addition to these possibilities, a process always has a frame; statement. The difference between a function and a process is a process is treated as a seperate thread. This means one can't let a process return a value, as the father process continues its code as well. When a process comes to its first frame; statement, the process 'returns' its ProcessID and continues the code (in the next frame).
In earlier Fenix versions (2005 and earlier) there is no difference in syntax, however, a process is treated like a function when there is no frame; statement in the code.
Example
Process SpaceShip( int file , int graph , int x , int y , int angle , int maxspeed , int maxturnspeed ) Private int speed; Begin Loop speed+=key(_up)*(speed<maxspeed)-key(_down)*(speed>-maxspeed); angle+=(key(_left)-key(_right))*maxturnspeed; advance(speed); frame; End End
Now one can call this process for example by doing the following.
Private int map; Begin map = new_map(20,20,8); map_clear(0,map,rgb(0,255,255)); SpaceShip(0,map,100,100,0,20,5000); End
This will make a SpaceShip with a cyan coloured block, able to move around the screen.