├── LICENSE ├── Examples ├── Figure.sk └── Hand.sk ├── README.md └── sk.gml /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Nik Sudan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Examples/Figure.sk: -------------------------------------------------------------------------------- 1 | [Skeleton] 2 | id=Figure 3 | joints=17 4 | 5 | [1] 6 | parent=0 7 | xoffset=0 8 | yoffset=-64 9 | clampmin=-14.0362434679265 10 | clampmax=14.0362434679265 11 | 12 | [2] 13 | parent=1 14 | xoffset=0 15 | yoffset=-64 16 | clampmin=-14.0362434679265 17 | clampmax=14.0362434679265 18 | 19 | [3] 20 | parent=2 21 | xoffset=32 22 | yoffset=0 23 | clampmin=0 24 | clampmax=0 25 | 26 | [4] 27 | parent=2 28 | xoffset=-32 29 | yoffset=0 30 | clampmin=0 31 | clampmax=0 32 | 33 | [5] 34 | parent=4 35 | xoffset=-64 36 | yoffset=0 37 | clampmin=-63.434948822922 38 | clampmax=56.3099324740202 39 | 40 | [6] 41 | parent=3 42 | xoffset=64 43 | yoffset=0 44 | clampmin=-75.9637565320735 45 | clampmax=63.434948822922 46 | 47 | [7] 48 | parent=6 49 | xoffset=64 50 | yoffset=0 51 | clampmin=0 52 | clampmax=104.036243467926 53 | 54 | [8] 55 | parent=5 56 | xoffset=-64 57 | yoffset=0 58 | clampmin=-135 59 | clampmax=0 60 | 61 | [9] 62 | parent=0 63 | xoffset=-16 64 | yoffset=0 65 | clampmin=0 66 | clampmax=0 67 | 68 | [10] 69 | parent=0 70 | xoffset=16 71 | yoffset=0 72 | clampmin=0 73 | clampmax=0 74 | 75 | [11] 76 | parent=10 77 | xoffset=0 78 | yoffset=64 79 | clampmin=0 80 | clampmax=45 81 | 82 | [12] 83 | parent=9 84 | xoffset=0 85 | yoffset=64 86 | clampmin=-53.1301023541559 87 | clampmax=0 88 | 89 | [13] 90 | parent=12 91 | xoffset=0 92 | yoffset=64 93 | clampmin=0 94 | clampmax=90 95 | 96 | [14] 97 | parent=11 98 | xoffset=0 99 | yoffset=64 100 | clampmin=-90 101 | clampmax=0 102 | 103 | [15] 104 | parent=2 105 | xoffset=0 106 | yoffset=-16 107 | clampmin=-26.565051177078 108 | clampmax=26.565051177078 109 | 110 | [16] 111 | parent=15 112 | xoffset=0 113 | yoffset=-16 114 | clampmin=0 115 | clampmax=0 116 | 117 | -------------------------------------------------------------------------------- /Examples/Hand.sk: -------------------------------------------------------------------------------- 1 | [Skeleton] 2 | id=Hand 3 | joints=22 4 | 5 | [1] 6 | parent=0 7 | xoffset=2 8 | yoffset=-50 9 | clampmin=-42.7093899573615 10 | clampmax=47.2906100426385 11 | 12 | [2] 13 | parent=1 14 | xoffset=-44 15 | yoffset=-39 16 | clampmin=0 17 | clampmax=0 18 | 19 | [3] 20 | parent=1 21 | xoffset=-14 22 | yoffset=-33 23 | clampmin=0 24 | clampmax=0 25 | 26 | [4] 27 | parent=1 28 | xoffset=6 29 | yoffset=-32 30 | clampmin=0 31 | clampmax=0 32 | 33 | [5] 34 | parent=1 35 | xoffset=31 36 | yoffset=-28 37 | clampmin=0 38 | clampmax=0 39 | 40 | [6] 41 | parent=1 42 | xoffset=45 43 | yoffset=-17 44 | clampmin=0 45 | clampmax=0 46 | 47 | [7] 48 | parent=2 49 | xoffset=-15 50 | yoffset=-38 51 | clampmin=0 52 | clampmax=0 53 | 54 | [8] 55 | parent=7 56 | xoffset=-1 57 | yoffset=-40 58 | clampmin=0 59 | clampmax=0 60 | 61 | [9] 62 | parent=3 63 | xoffset=16 64 | yoffset=-63 65 | clampmin=0 66 | clampmax=0 67 | 68 | [10] 69 | parent=9 70 | xoffset=-2 71 | yoffset=-46 72 | clampmin=0 73 | clampmax=0 74 | 75 | [11] 76 | parent=10 77 | xoffset=-12 78 | yoffset=-48 79 | clampmin=0 80 | clampmax=0 81 | 82 | [12] 83 | parent=4 84 | xoffset=22 85 | yoffset=-53 86 | clampmin=0 87 | clampmax=0 88 | 89 | [13] 90 | parent=12 91 | xoffset=-2 92 | yoffset=-54 93 | clampmin=0 94 | clampmax=0 95 | 96 | [14] 97 | parent=13 98 | xoffset=-11 99 | yoffset=-50 100 | clampmin=0 101 | clampmax=0 102 | 103 | [15] 104 | parent=5 105 | xoffset=20 106 | yoffset=-51 107 | clampmin=0 108 | clampmax=0 109 | 110 | [16] 111 | parent=15 112 | xoffset=2 113 | yoffset=-53 114 | clampmin=0 115 | clampmax=0 116 | 117 | [17] 118 | parent=16 119 | xoffset=-10 120 | yoffset=-40 121 | clampmin=0 122 | clampmax=0 123 | 124 | [18] 125 | parent=6 126 | xoffset=29 127 | yoffset=-53 128 | clampmin=0 129 | clampmax=0 130 | 131 | [19] 132 | parent=18 133 | xoffset=11 134 | yoffset=-49 135 | clampmin=0 136 | clampmax=0 137 | 138 | [20] 139 | parent=19 140 | xoffset=-3 141 | yoffset=-31 142 | clampmin=0 143 | clampmax=0 144 | 145 | [21] 146 | parent=8 147 | xoffset=10 148 | yoffset=-20 149 | clampmin=0 150 | clampmax=0 151 | 152 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
sk_import and return the skeleton's data for use with skeleton systems. This way you can load one skeleton that'll be used by loads of entities. Calling this in the **Game Start** or **Room Start** events are recommended. Use this function:
24 |
25 | data = sk_import('pathToFile');
26 |
27 | Once you've initialised the skeleton, you can now use with objects. You can set an object to become a skeleton by using the following function in it's **Create** event:
28 |
29 | sk_create( data );
30 |
31 | Now you've set it up, but the skeleton won't move. You need to update it, and this can be done with the **Begin Step** event. You can use an **Alarm** event if you want to call it less often, but it's a lot smoother when you don't do that. Simply call this function:
32 |
33 | sk_update();
34 |
35 | And that's it!
36 |
37 | ## Making Joints Move
38 |
39 | I take it you want to manipulate the joints and give it a cool, smooth animation. You can move a joint by calling the following function:
40 |
41 | sk_setTargetAngle( jointID, angle );
42 |
43 | The angle the skeleton is imported in at will be the zero value for angle. You can find out the jointID from your sk file or the creator.
44 |
45 | **Note:** There is a function called sk_setAngle() in the library - this will immediately change the angle of the joint. The joint will move back to the target angle after you call this, so don't use it for animation.
46 |
47 | You can then set the rotation speed of the joint with the following function:
48 |
49 | sk_setRotationSpeed( jointID, speed );
50 |
51 | The bigger the speed is, the faster it'll move (duh).
52 |
53 | ## Drawing Stuff
54 |
55 | Ok, you'll want to see your skeleton, right? You can call a little debugging function to see the skeleton in action:
56 |
57 | sk_draw();
58 |
59 | I wouldn't recommend using that for your final product. You can get the position and angle of each joint by calling these respective functions:
60 |
61 | jointX = sk_getX( jointID );
62 | jointY = sk_gety( jointID );
63 | jointAngle = sk_getAngle( jointID );
64 |
65 | Draw whatever you want on these, I won't hold you back.
66 |
67 | ## Examples Of Use
68 |
69 | 
70 |
71 | 
72 |
73 | 
74 |
75 | 
76 |
--------------------------------------------------------------------------------
/sk.gml:
--------------------------------------------------------------------------------
1 | #define nearestPoint
2 | ///nearestPoint(x, y)
3 | //x,y
4 | near = 0;
5 | for (i=0; i