Mercurial > molko
comparison man/mlk-action.3 @ 441:31c1bbc33813
man: document mlk-action
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 24 Oct 2022 21:29:39 +0200 |
parents | |
children | c1f64d451230 |
comparison
equal
deleted
inserted
replaced
440:c9bd1ff1ebe1 | 441:31c1bbc33813 |
---|---|
1 .Dd $Mdocdate$ | |
2 .Dt MLK-ACTION 3 | |
3 .Os | |
4 .Sh NAME | |
5 .Nm mlk-action | |
6 .Nd generic in game actions | |
7 .Sh LIBRARY | |
8 libmlk-core (-lmlk-core) | |
9 .Sh SYNOPSIS | |
10 .In mlk/core/action.h | |
11 .Sh DESCRIPTION | |
12 Generic updatable and drawable actions. | |
13 .Pp | |
14 This module help creating user interaction within the gameplay by adding | |
15 actions. They have the following properties: | |
16 .Pp | |
17 .Bl -dash -compact | |
18 .It | |
19 Can handle user input and events, | |
20 .It | |
21 Can be updated through the game loop, | |
22 .It | |
23 Can be drawn. | |
24 .El | |
25 .Pp | |
26 Most more high level objects can handle actions to add flexibility (like in | |
27 battles, maps, etc). | |
28 .Pp | |
29 This header defines the | |
30 .Vt "struct mlk_action" : | |
31 .Bd -literal | |
32 struct mlk_action { | |
33 void *data; | |
34 void (*handle)(struct mlk_action *self, const union mlk_event *ev); | |
35 int (*update)(struct mlk_action *self, unsigned int ticks); | |
36 void (*draw)(struct mlk_action *self); | |
37 void (*end)(struct mlk_action *self); | |
38 void (*finish)(struct mlk_action *self); | |
39 }; | |
40 .Ed | |
41 .Pp | |
42 Each member function takes the original action as first argument and other | |
43 arguments after. Its fields are: | |
44 .Bl -tag | |
45 .It Va data | |
46 Optional user data. | |
47 .It Va handle | |
48 Handle the event | |
49 .Fa ev . | |
50 .It Va update | |
51 Update the action with the | |
52 .Fa ticks | |
53 since last frame expressed as milliseconds. The callback should return non-zero | |
54 if it is considered complete. | |
55 .It Va draw | |
56 Draw the action. | |
57 .It Va end | |
58 Called when the action was completed. | |
59 .Pp | |
60 This callback is mostly provided to allow the user doing something else once an | |
61 action is complete. Predefined actions from the framework should not use this | |
62 callback by themselves. | |
63 .It Va finish | |
64 Destroy internal resources for this action. | |
65 .Pp | |
66 Close the action before removal. This function should be used to deallocate | |
67 memory if necessary. | |
68 .El | |
69 .Sh SEE ALSO | |
70 .Xr mlk_action_draw 3 , | |
71 .Xr mlk_action_end 3 , | |
72 .Xr mlk_action_finish 3 , | |
73 .Xr mlk_action_handle 3 , | |
74 .Xr mlk_action_update 3 | |
75 .Sh AUTHORS | |
76 The | |
77 .Nm | |
78 library was written by | |
79 .An David Demelier Aq Mt markand@malikania.fr . |