├── raylib ├── tags.txt ├── authors.txt ├── demo │ ├── tags.txt │ └── demo.factor ├── gui-demo │ ├── tags.txt │ └── gui-demo.factor ├── summary.txt ├── modules │ ├── ricons │ │ └── ricons.factor │ └── gui │ │ └── gui.factor └── ffi │ └── ffi.factor ├── hello-factor.png ├── examples ├── fof-poet │ ├── end.png │ ├── door.png │ ├── ground.png │ ├── left.png │ ├── right.png │ ├── deploy.factor │ ├── fof-poet.factor~ │ ├── #fof-poet.factor# │ └── fof-poet.factor ├── fof-thames │ ├── fof-thames.factor~ │ └── fof-thames.factor ├── piggy │ ├── deploy.factor │ ├── README.md │ └── piggy.factor └── fof-clever │ ├── fof-clever.factor~ │ └── fof-clever.factor ├── raylib-factor_256x256.png ├── LICENSE └── README.md /raylib/tags.txt: -------------------------------------------------------------------------------- 1 | bindings 2 | -------------------------------------------------------------------------------- /raylib/authors.txt: -------------------------------------------------------------------------------- 1 | Jack Lucas 2 | -------------------------------------------------------------------------------- /raylib/demo/tags.txt: -------------------------------------------------------------------------------- 1 | demos 2 | -------------------------------------------------------------------------------- /raylib/gui-demo/tags.txt: -------------------------------------------------------------------------------- 1 | demos 2 | -------------------------------------------------------------------------------- /raylib/summary.txt: -------------------------------------------------------------------------------- 1 | Complete bindings for the Raylib video game library. 2 | -------------------------------------------------------------------------------- /hello-factor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnautDaniel/raylib-factor/HEAD/hello-factor.png -------------------------------------------------------------------------------- /examples/fof-poet/end.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnautDaniel/raylib-factor/HEAD/examples/fof-poet/end.png -------------------------------------------------------------------------------- /raylib-factor_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnautDaniel/raylib-factor/HEAD/raylib-factor_256x256.png -------------------------------------------------------------------------------- /examples/fof-poet/door.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnautDaniel/raylib-factor/HEAD/examples/fof-poet/door.png -------------------------------------------------------------------------------- /examples/fof-poet/ground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnautDaniel/raylib-factor/HEAD/examples/fof-poet/ground.png -------------------------------------------------------------------------------- /examples/fof-poet/left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnautDaniel/raylib-factor/HEAD/examples/fof-poet/left.png -------------------------------------------------------------------------------- /examples/fof-poet/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnautDaniel/raylib-factor/HEAD/examples/fof-poet/right.png -------------------------------------------------------------------------------- /examples/fof-thames/fof-thames.factor~: -------------------------------------------------------------------------------- 1 | ! Copyright (C) 2019 Your name. 2 | ! See http://factorcode.org/license.txt for BSD license. 3 | USING: ; 4 | IN: fof-thames 5 | 6 | -------------------------------------------------------------------------------- /examples/piggy/deploy.factor: -------------------------------------------------------------------------------- 1 | USING: tools.deploy.config ; 2 | H{ 3 | { deploy-console? f } 4 | { deploy-io 3 } 5 | { deploy-reflection 1 } 6 | { deploy-ui? f } 7 | { deploy-word-defs? f } 8 | { deploy-threads? t } 9 | { "stop-after-last-window?" t } 10 | { deploy-math? t } 11 | { deploy-word-props? f } 12 | { deploy-c-types? f } 13 | { deploy-help? f } 14 | { deploy-name "piggy" } 15 | { deploy-unicode? f } 16 | } 17 | -------------------------------------------------------------------------------- /examples/fof-poet/deploy.factor: -------------------------------------------------------------------------------- 1 | USING: tools.deploy.config ; 2 | H{ 3 | { deploy-console? t } 4 | { deploy-io 3 } 5 | { deploy-reflection 1 } 6 | { deploy-ui? f } 7 | { deploy-word-defs? f } 8 | { deploy-threads? t } 9 | { "stop-after-last-window?" t } 10 | { deploy-math? t } 11 | { deploy-word-props? f } 12 | { deploy-c-types? f } 13 | { deploy-help? f } 14 | { deploy-name "fof-poet" } 15 | { deploy-unicode? f } 16 | } 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Jack Lucas 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 | -------------------------------------------------------------------------------- /raylib/gui-demo/gui-demo.factor: -------------------------------------------------------------------------------- 1 | ! Copyright (C) 2019 Jack Lucas 2 | ! See http://factorcode.org/license.txt for BSD license. 3 | USING: raylib.ffi kernel math.ranges sequences locals random combinators.random math threads calendar namespaces accessors classes.struct combinators alien.enums raylib.modules.gui ; 4 | IN: raylib.gui-demo 5 | 6 | : make-window ( -- ) 7 | 800 600 "Hello, Factor!" init-window 8 | 60 set-target-fps ; 9 | 10 | : button-rec ( -- button ) 11 | 50 50 100 100 Rectangle ; 12 | 13 | : white-background ( -- ) 14 | RAYWHITE clear-background ; 15 | 16 | : say-hello ( -- ) 17 | "Hello Factor!" 4 4 30 RED draw-text ; 18 | 19 | : set-button-style ( -- ) 20 | BUTTON enum>number 21 | TEXT_ALIGNMENT enum>number 22 | GUI_TEXT_ALIGN_LEFT enum>number 23 | rl-gui-set-style ; 24 | 25 | : draw-button ( -- ) 26 | set-button-style 27 | button-rec "Button" 28 | rl-gui-button drop ; 29 | 30 | : render-gui ( -- ) 31 | rl-gui-lock 32 | draw-button 33 | rl-gui-unlock ; 34 | 35 | : render-loop ( -- ) 36 | begin-drawing white-background 37 | say-hello render-gui end-drawing ; 38 | 39 | : main ( -- ) 40 | make-window 41 | [ render-loop 42 | window-should-close not ] loop 43 | close-window ; 44 | 45 | -------------------------------------------------------------------------------- /examples/fof-thames/fof-thames.factor: -------------------------------------------------------------------------------- 1 | ! Copyright (C) 2019 Your name. 2 | ! See http://factorcode.org/license.txt for BSD license. 3 | USING: raylib.ffi kernel sequences locals alien.enums 4 | namespaces math classes.struct accessors combinators ; 5 | IN: fof-thames 6 | 7 | : make-window ( -- ) 8 | 640 480 "Irrigation" init-window 9 | 60 set-target-fps ; 10 | 11 | : clear-window ( -- ) 12 | RAYWHITE clear-background ; 13 | 14 | SYMBOL: player 15 | 16 | : show-player-circle ( -- ) 17 | player get 25.0 RED draw-circle-v ; 18 | 19 | : setup-player ( -- ) 20 | get-screen-width 2 / 21 | get-screen-height 2 / 22 | Vector2 23 | player set ; 24 | 25 | : render ( -- ) 26 | begin-drawing 27 | clear-window 28 | show-player-circle 29 | end-drawing ; 30 | 31 | : move-x ( increment -- ) 32 | player get x>> + player get x<< ; 33 | 34 | : move-y ( increment -- ) 35 | player get y>> + player get y<< ; 36 | 37 | : check-individual-action ( keypair -- ) 38 | dup first ! Get the key 39 | enum>number is-key-down 40 | [ second call( -- ) ] [ drop ] if ; 41 | 42 | : check-input ( -- ) 43 | { 44 | { KEY_W [ -2.0 move-y ] } 45 | { KEY_S [ 2.0 move-y ] } 46 | { KEY_A [ -2.0 move-x ] } 47 | { KEY_D [ 2.0 move-x ] } 48 | } 49 | ! We could also put this in a symbol if we wanted. 50 | 51 | [ check-individual-action ] each ; 52 | 53 | : main ( -- ) 54 | make-window setup-player 55 | [ check-input render 56 | window-should-close not ] loop 57 | close-window ; 58 | 59 | MAIN: main 60 | -------------------------------------------------------------------------------- /examples/piggy/README.md: -------------------------------------------------------------------------------- 1 | Recreation of an example from the raylib page. Using 3d! 2 | 3 | This deploys to a size of 3.7mb...Amazing. 4 | 5 | I figure I'll reimplement examples and try to figure out the best way to write a factor-y wrapper for these bindings. 6 | 7 | # Lessons from Piggy 8 | 9 | I think two components that would be incredibly helpful would be some sort of entity system and a proper gameloop. 10 | 11 | For the entity system I'm considering using part of my idea from 12Labors in making the world a single variable/symbol based off of the set SFG. 12 | 13 | S would include the state of all game objects 14 | F defines functions that can used to modify those objects (would need a rudimentary type system) 15 | G is supposed to be the GOAL set but I'm not sure what use I'd have for this. 16 | 17 | Such that we could define 18 | 19 | : main ( -- ) 20 | SFG decide execute ; 21 | 22 | As our main loop where execute is 23 | 24 | : execute ( SFG -- SFG2 ) 25 | [ren2d 26 | ren2d] ! render loop 27 | [update 28 | entities 29 | update] ! update entities 30 | [input 31 | input] ! handle input 32 | execute ; 33 | 34 | A recursive function that takes in a game world and returns a new game world. 35 | 36 | Essentially we need a tidy concept of holding onto objects/structs that can then be passed around into meta functions that handle the looping constructs. [ren2d | [update | [input would have to be macros that translate our game structure into the required form needed to be used by raylib functions. 37 | 38 | -------------------------------------------------------------------------------- /raylib/demo/demo.factor: -------------------------------------------------------------------------------- 1 | ! Copyright (C) 2019 Jack Lucas 2 | ! See http://factorcode.org/license.txt for BSD license. 3 | USING: raylib.ffi kernel math.ranges sequences locals random combinators.random math threads calendar namespaces accessors classes.struct combinators alien.enums ; 4 | IN: raylib.demo 5 | 6 | : say-hello ( -- ) 7 | "Hello, Factor!" 200 400 60 MAGENTA draw-text ; 8 | 9 | : make-window ( -- ) 10 | 640 480 "Hello, Factor!" init-window 11 | 60 set-target-fps ; 12 | 13 | : clear-window ( -- ) 14 | RAYWHITE clear-background ; 15 | 16 | ! Save our players position in a dynamic var 17 | SYMBOL: player 18 | 19 | : show-player-circle ( -- ) 20 | player get 21 | 25.0 RED draw-circle-v ; 22 | 23 | : setup-game-vars ( -- ) 24 | get-screen-width 2 / 25 | get-screen-height 2 / 26 | Vector2 player set ; 27 | 28 | ! Make this cleaner 29 | : change-player-position ( -- ) 30 | { 31 | { [ KEY_RIGHT enum>number is-key-down ] [ player get x>> 2.0 + player get x<< ] } 32 | { [ KEY_LEFT enum>number is-key-down ] [ player get x>> -2.0 + player get x<< ] } 33 | { [ KEY_DOWN enum>number is-key-down ] [ player get y>> 2.0 + player get y<< ] } 34 | { [ KEY_UP enum>number is-key-down ] [ player get y>> -2.0 + player get y<< ] } 35 | [ ] } cond ; 36 | 37 | : render-loop ( -- ) 38 | begin-drawing 39 | clear-window show-player-circle say-hello 40 | end-drawing ; 41 | 42 | : main ( -- ) 43 | make-window clear-window setup-game-vars 44 | [ change-player-position 45 | render-loop 46 | window-should-close not ] loop 47 | close-window 48 | ; 49 | 50 | MAIN: main 51 | 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Raylib-factor Logo](https://github.com/arnautdaniel/raylib-factor/blob/master/raylib-factor_256x256.png "Raylib-factor Logo") 2 | 3 | # raylib-factor 4 | bindings for the raylib library in 5 | [Factor](https://factorcode.org "Factor") 6 | 7 | 8 | # How to use it 9 | 10 | raylib-factor has been merged into the factor source tree! (raylib-factor 3.5) If you have Factor then you're already good to go. 11 | 12 | **A Raylib/Factor** book is in the works. 135 pages so far! 13 | 14 | [Fait Idees](https://faitidees.org/) holds draft copies. And when I mean draft, I mean read at your own peril right now. It'll be done someday. 15 | 16 | Simply **USE: raylib.ffi** and pretty soon you'll be saying... 17 | ![Hello Factor](https://github.com/silverbeard00/raylib-factor/blob/master/hello-factor.png "Hello Factor") 18 | 19 | # What is it 20 | 21 | This is complete (one exception) bindings for the Raylib library (3.5). It also includes **raygui** and **rayicon** support which will load automatically if the dll/so you are using has those modules compiled in. 22 | 23 | The exception is that android related structs are not included because Factor doesn't run on it. 24 | 25 | # How to program it 26 | 27 | A small demo or two is included to help you get an idea of how to use it. In reality the next step of this project will be adding utility functions to make the experience more "Factor-y". 28 | 29 | All "functions" are named according to the Factorish style. This means something like **InitWindow** in C becomes **init-window** in factor. Every function is renamed this way with the exception of the raygui module which is the same except you have to prepend **rl-** to the function name. 30 | 31 | 32 | Have fun! 33 | -------------------------------------------------------------------------------- /examples/piggy/piggy.factor: -------------------------------------------------------------------------------- 1 | ! Copyright (C) 2019 Jack Lucas 2 | ! See http://factorcode.org/license.txt for BSD license. 3 | USING: raylib.ffi kernel math.ranges sequences locals random combinators.random math threads calendar namespaces accessors alien.c-types classes.struct combinators alien.enums ; 4 | IN: piggy 5 | 6 | : make-window ( -- ) 7 | 800 450 "Hello, Piggy!" init-window 8 | 60 set-target-fps ; 9 | 10 | : clear-window ( -- ) 11 | RAYWHITE clear-background ; 12 | 13 | SYMBOL: camera 14 | DEFER: draw-enemies 15 | DEFER: draw-player 16 | : draw-moveable ( moveable -- ) 17 | dup [ position>> ] dip 18 | dup [ size>> ] dip 19 | color>> 20 | draw-cube-v ; 21 | 22 | : render-loop ( -- ) 23 | begin-drawing 24 | clear-window 25 | camera get 26 | begin-mode-3d 27 | draw-enemies 28 | draw-player 29 | 10 1.0 draw-grid 30 | end-mode-3d 31 | end-drawing ; inline 32 | 33 | : make-vector3 ( x y z -- vector3 ) 34 | Vector3 ; 35 | 36 | : setup-camera ( -- ) 37 | 0.0 10.0 10.0 make-vector3 38 | 0.0 0.0 0.0 make-vector3 39 | 0.0 1.0 0.0 make-vector3 40 | 45.0 CAMERA_PERSPECTIVE enum>number 41 | Camera3D 42 | camera set ; 43 | 44 | TUPLE: player-t position size color ; 45 | 46 | SYMBOL: player 47 | 48 | : draw-player ( -- ) 49 | player get draw-moveable ; 50 | 51 | SYMBOL: collision 52 | 53 | : setup-moveable ( position size color -- moveable ) 54 | player-t boa ; 55 | 56 | 57 | : change-player-position ( -- ) 58 | { 59 | { [ KEY_RIGHT enum>number is-key-down ] 60 | [ player get position>> x>> 0.2 + player get position>> x<< ] } 61 | { [ KEY_LEFT enum>number is-key-down ] 62 | [ player get position>> x>> -0.2 + player get position>> x<< ] } 63 | { [ KEY_DOWN enum>number is-key-down ] 64 | [ player get position>> z>> 0.2 + player get position>> z<< ] } 65 | { [ KEY_UP enum>number is-key-down ] 66 | [ player get position>> z>> -0.2 + player get position>> z<< ] } 67 | [ ] } cond ; 68 | 69 | :: make-bounding-box ( position size -- item ) 70 | position x>> size x>> 2 / - 71 | position y>> size y>> 2 / - 72 | position z>> size z>> 2 / - make-vector3 73 | position x>> size x>> 2 / + 74 | position y>> size y>> 2 / + 75 | position z>> size y>> 2 / + make-vector3 76 | BoundingBox ; 77 | 78 | : player-bounding-box ( -- box ) 79 | player get position>> player get size>> make-bounding-box ; 80 | 81 | DEFER: get-enemies 82 | : check-collisions ( -- ) 83 | get-enemies [ dup position>> swap size>> make-bounding-box ] map 84 | [ player-bounding-box check-collision-boxes ] filter 85 | empty? not [ RED player get color<< ] 86 | [ GREEN player get color<< ] if ; 87 | 88 | : setup-player ( -- ) 89 | 0.0 1.0 2.0 make-vector3 90 | 1.0 2.0 1.0 make-vector3 91 | GREEN setup-moveable player set ; 92 | 93 | : setup-enemy ( positon size -- enemy ) 94 | GRAY setup-moveable ; 95 | 96 | : get-enemies ( -- enemy-list ) 97 | { } 98 | -4.0 1.0 0.0 make-vector3 99 | 2.0 2.0 2.0 make-vector3 setup-enemy suffix 100 | 4.0 0.0 0.0 make-vector3 101 | 2.0 2.0 2.0 make-vector3 setup-enemy suffix ; 102 | 103 | : draw-enemies ( -- ) 104 | get-enemies [ draw-moveable ] each ; 105 | 106 | : main ( -- ) 107 | make-window 108 | setup-camera 109 | setup-player 110 | f collision set 111 | [ render-loop change-player-position 112 | check-collisions window-should-close not ] loop 113 | close-window ; 114 | 115 | MAIN: main 116 | -------------------------------------------------------------------------------- /raylib/modules/ricons/ricons.factor: -------------------------------------------------------------------------------- 1 | ! Copyright (C) 2019 Jack Lucas 2 | ! See http://factorcode.org/license.txt for BSD license. 3 | ! These should be complete bindings to the Raylib Icons module 4 | USING: alien alien.c-types alien.enums alien.libraries 5 | alien.libraries.finder alien.syntax classes.struct combinators 6 | kernel quotations system vocabs raylib.ffi ; 7 | IN: raylib.modules.ricons 8 | 9 | FUNCTION-ALIAS: rl-draw-icon void DrawIcon ( int iconId, Vector2 position, int pixelSize, Color color ) 10 | 11 | ENUM: rIconDescription 12 | RICON_NONE 13 | RICON_FOLDER_FILE_OPEN 14 | RICON_FILE_SAVE_CLASSIC 15 | RICON_FOLDER_OPEN 16 | RICON_FOLDER_SAVE 17 | RICON_FILE_OPEN 18 | RICON_FILE_SAVE 19 | RICON_FILE_EXPORT 20 | RICON_FILE_NEW 21 | RICON_FILE_DELETE 22 | RICON_FILETYPE_TEXT 23 | RICON_FILETYPE_AUDIO 24 | RICON_FILETYPE_IMAGE 25 | RICON_FILETYPE_PLAY 26 | RICON_FILETYPE_VIDEO 27 | RICON_FILETYPE_INFO 28 | RICON_FILE_COPY 29 | RICON_FILE_CUT 30 | RICON_FILE_PASTE 31 | RICON_CURSOR_HAND 32 | RICON_CURSOR_POINTER 33 | RICON_CURSOR_CLASSIC 34 | RICON_PENCIL 35 | RICON_PENCIL_BIG 36 | RICON_BRUSH_CLASSIC 37 | RICON_BRUSH_PAINTER 38 | RICON_WATER_DROP 39 | RICON_COLOR_PICKER 40 | RICON_RUBBER 41 | RICON_COLOR_BUCKET 42 | RICON_TEXT_T 43 | RICON_TEXT_A 44 | RICON_SCALE 45 | RICON_RESIZE 46 | RICON_FILTER_POINT 47 | RICON_FILTER_BILINEAR 48 | RICON_CROP 49 | RICON_CROP_ALPHA 50 | RICON_SQUARE_TOGGLE 51 | RICON_SIMMETRY 52 | RICON_SIMMETRY_HORIZONTAL 53 | RICON_SIMMETRY_VERTICAL 54 | RICON_LENS 55 | RICON_LENS_BIG 56 | RICON_EYE_ON 57 | RICON_EYE_OFF 58 | RICON_FILTER_TOP 59 | RICON_FILTER 60 | RICON_TARGET_POINT 61 | RICON_TARGET_SMALL 62 | RICON_TARGET_BIG 63 | RICON_TARGET_MOVE 64 | RICON_CURSOR_MOVE 65 | RICON_CURSOR_SCALE 66 | RICON_CURSOR_SCALE_RIGHT 67 | RICON_CURSOR_SCALE_LEFT 68 | RICON_UNDO 69 | RICON_REDO 70 | RICON_REREDO 71 | RICON_MUTATE 72 | RICON_ROTATE 73 | RICON_REPEAT 74 | RICON_SHUFFLE 75 | RICON_EMPTYBOX 76 | RICON_TARGET 77 | RICON_TARGET_SMALL_FILL 78 | RICON_TARGET_BIG_FILL 79 | RICON_TARGET_MOVE_FILL 80 | RICON_CURSOR_MOVE_FILL 81 | RICON_CURSOR_SCALE_FILL 82 | RICON_CURSOR_SCALE_RIGHT_FILL 83 | RICON_CURSOR_SCALE_LEFT_FILL 84 | RICON_UNDO_FILL 85 | RICON_REDO_FILL 86 | RICON_REREDO_FILL 87 | RICON_MUTATE_FILL 88 | RICON_ROTATE_FILL 89 | RICON_REPEAT_FILL 90 | RICON_SHUFFLE_FILL 91 | RICON_EMPTYBOX_SMALL 92 | RICON_BOX 93 | RICON_BOX_TOP 94 | RICON_BOX_TOP_RIGHT 95 | RICON_BOX_RIGHT 96 | RICON_BOX_BOTTOM_RIGHT 97 | RICON_BOX_BOTTOM 98 | RICON_BOX_BOTTOM_LEFT 99 | RICON_BOX_LEFT 100 | RICON_BOX_TOP_LEFT 101 | RICON_BOX_CENTER 102 | RICON_BOX_CIRCLE_MASK 103 | RICON_POT 104 | RICON_ALPHA_MULTIPLY 105 | RICON_ALPHA_CLEAR 106 | RICON_DITHERING 107 | RICON_MIPMAPS 108 | RICON_BOX_GRID 109 | RICON_GRID 110 | RICON_BOX_CORNERS_SMALL 111 | RICON_BOX_CORNERS_BIG 112 | RICON_FOUR_BOXES 113 | RICON_GRID_FILL 114 | RICON_BOX_MULTISIZE 115 | RICON_ZOOM_SMALL 116 | RICON_ZOOM_MEDIUM 117 | RICON_ZOOM_BIG 118 | RICON_ZOOM_ALL 119 | RICON_ZOOM_CENTER 120 | RICON_BOX_DOTS_SMALL 121 | RICON_BOX_DOTS_BIG 122 | RICON_BOX_CONCENTRIC 123 | RICON_BOX_GRID_BIG 124 | RICON_OK_TICK 125 | RICON_CROSS 126 | RICON_ARROW_LEFT 127 | RICON_ARROW_RIGHT 128 | RICON_ARROW_BOTTOM 129 | RICON_ARROW_TOP 130 | RICON_ARROW_LEFT_FILL 131 | RICON_ARROW_RIGHT_FILL 132 | RICON_ARROW_BOTTOM_FILL 133 | RICON_ARROW_TOP_FILL 134 | RICON_AUDIO 135 | RICON_FX 136 | RICON_WAVE 137 | RICON_WAVE_SINUS 138 | RICON_WAVE_SQUARE 139 | RICON_WAVE_TRIANGULAR 140 | RICON_CROSS_SMALL 141 | RICON_PLAYER_PREVIOUS 142 | RICON_PLAYER_PLAY_BACK 143 | RICON_PLAYER_PLAY 144 | RICON_PLAYER_PAUSE 145 | RICON_PLAYER_STOP 146 | RICON_PLAYER_NEXT 147 | RICON_PLAYER_RECORD 148 | RICON_MAGNET 149 | RICON_LOCK_CLOSE 150 | RICON_LOCK_OPEN 151 | RICON_CLOCK 152 | RICON_TOOLS 153 | RICON_GEAR 154 | RICON_GEAR_BIG 155 | RICON_BIN 156 | RICON_HAND_POINTER 157 | RICON_LASER 158 | RICON_COIN 159 | RICON_EXPLOSION 160 | RICON_1UP 161 | RICON_PLAYER 162 | RICON_PLAYER_JUMP 163 | RICON_KEY 164 | RICON_DEMON 165 | RICON_TEXT_POPUP 166 | RICON_GEAR_EX 167 | RICON_CRACK 168 | RICON_CRACK_POINTS 169 | RICON_STAR 170 | RICON_DOOR 171 | RICON_EXIT 172 | RICON_MODE_2D 173 | RICON_MODE_3D 174 | RICON_CUBE 175 | RICON_CUBE_FACE_TOP 176 | RICON_CUBE_FACE_LEFT 177 | RICON_CUBE_FACE_FRONT 178 | RICON_CUBE_FACE_BOTTOM 179 | RICON_CUBE_FACE_RIGHT 180 | RICON_CUBE_FACE_BACK 181 | RICON_CAMERA 182 | RICON_SPECIAL 183 | RICON_LINK_NET 184 | RICON_LINK_BOXES 185 | RICON_LINK_MULTI 186 | RICON_LINK 187 | RICON_LINK_BROKE 188 | RICON_TEXT_NOTES 189 | RICON_NOTEBOOK 190 | RICON_SUITCASE 191 | RICON_SUITCASE_ZIP 192 | RICON_MAILBOX 193 | RICON_MONITOR 194 | RICON_PRINTER 195 | RICON_PHOTO_CAMERA 196 | RICON_PHOTO_CAMERA_FLASH 197 | RICON_HOUSE 198 | RICON_HEART 199 | RICON_CORNER 200 | RICON_VERTICAL_BARS 201 | RICON_VERTICAL_BARS_FILL 202 | RICON_LIFE_BARS 203 | RICON_INFO 204 | RICON_CROSSLINE 205 | RICON_HELP 206 | RICON_FILETYPE_ALPHA 207 | RICON_FILETYPE_HOME 208 | RICON_LAYERS_VISIBLE 209 | RICON_LAYERS 210 | RICON_WINDOW ; 211 | 212 | -------------------------------------------------------------------------------- /examples/fof-clever/fof-clever.factor~: -------------------------------------------------------------------------------- 1 | ! Copyright (C) 2019 Your name. 2 | ! See http://factorcode.org/license.txt for BSD license. 3 | USING: raylib.ffi kernel sequences locals alien.enums namespaces math classes.struct accessors combinators math.ranges sequences.deep continuations assocs classes.tuple math.functions random math.parser io.directories.hierarchy io.pathnames io.directories splitting unicode make fry ; 4 | IN: fof-clever 5 | 6 | ! Basic Grid for background textures 7 | TUPLE: square posx posy size container ; 8 | SYMBOL: grid-size 9 | SYMBOL: grid 10 | 11 | : game-height ( -- height ) 12 | get-screen-height grid-size get - ; 13 | 14 | : game-width ( -- width ) 15 | get-screen-width grid-size get - ; 16 | 17 | : make-grid-line ( x range -- list ) 18 | [ length ] keep 19 | [ swap ] dip 20 | zip 21 | [ [ grid-size get H{ } clone square boa ] with-datastack ] map ; 22 | 23 | : setup-grid-squares ( -- ) 24 | 0 game-width grid-size get 25 | [ 0 game-height grid-size get make-grid-line ] 26 | map flatten grid set ; 27 | 28 | : center-square ( -- x ) 29 | grid-size get 2 / ; 30 | 31 | : offset ( vector2 -- vector2' ) 32 | [ x>> center-square + ] keep 33 | y>> center-square + 34 | Vector2 ; 35 | 36 | : find-square-by-coordinate ( n -- squares ) 37 | grid get swap filter ; inline 38 | 39 | ! Find all squares that have a certain x or y 40 | : find-square-by-y ( y -- squares ) 41 | [ swap posy>> = ] curry 42 | find-square-by-coordinate ; 43 | 44 | : find-square-by-x ( x -- squares ) 45 | [ swap posx>> = ] curry 46 | find-square-by-coordinate ; 47 | 48 | ! Extract the square coordinates 49 | : with-square-coordinates ( square -- x y square ) 50 | [ posx>> ] keep 51 | [ posy>> ] keep ; 52 | 53 | : square-coordinates ( square -- x y ) 54 | with-square-coordinates drop ; 55 | 56 | : draw-square ( grid-square -- ) 57 | tuple-slots 58 | [ drop dup BLACK draw-rectangle-lines ] 59 | with-datastack drop ; 60 | 61 | : draw-grid ( -- ) 62 | grid get [ draw-square ] each ; 63 | 64 | : setup-grid ( -- ) 65 | 40 grid-size set ; 66 | 67 | : coordinates=? ( square x y -- bool ) 68 | [ square-coordinates ] 2dip 69 | swap [ = ] dip 70 | swap [ = ] dip and ; 71 | 72 | : find-square ( x y -- square ) 73 | [ coordinates=? ] 2curry grid get 74 | swap 75 | filter ; 76 | 77 | ! Windowing 78 | 79 | : make-window ( -- ) 80 | 800 400 "Clever Bean" init-window 81 | 30 set-target-fps ; 82 | 83 | : clear-window ( -- ) 84 | RAYWHITE clear-background ; 85 | 86 | ! Texture bank 87 | 88 | : texture-names ( name -- name' ) 89 | "/" split last 90 | "." split first 91 | >lower ; 92 | 93 | SYMBOL: textures 94 | 95 | : clever-load-image ( image -- texture ) 96 | load-image dup grid-size get dup 97 | image-resize load-texture-from-image ; 98 | 99 | : setup-textures ( -- ) 100 | current-directory get directory-tree-files 101 | [ absolute-path ] map 102 | [ dup clever-load-image 103 | [ { } swap texture-names suffix ] dip suffix ] 104 | map 105 | textures set ; 106 | 107 | : get-textures ( key -- texture ) 108 | textures get at ; 109 | 110 | ! Environment 111 | 112 | :: draw-generic ( seq texture -- ) 113 | seq 114 | [ square-coordinates [ texture get-textures ] 2dip 115 | RAYWHITE draw-texture ] each ; 116 | 117 | SYMBOL: background 118 | : draw-background ( -- ) 119 | background get 120 | 0 0 RAYWHITE draw-texture ; 121 | 122 | : load-background ( -- ) 123 | "kitchen.png" load-texture 124 | background set ; 125 | 126 | ! Player 127 | SYMBOL: player-sym 128 | TUPLE: player posx posy speed direction item ; 129 | SYMBOL: player-texture 130 | 131 | : load-player-textures ( -- ) 132 | { } "player.png" load-texture suffix 133 | "player.png" load-image dup 134 | image-flip-horizontal load-texture-from-image suffix 135 | { "left" "right" } swap zip 136 | player-texture set ; 137 | 138 | : load-player ( -- ) 139 | load-player-textures 140 | get-screen-width 2 / 141 | get-screen-height "right" 142 | player-texture get at height>> - 143 | 15 "right" f player boa 144 | player-sym set ; 145 | 146 | : get-player-texture ( -- texture ) 147 | player-sym get direction>> 148 | player-texture get at ; 149 | 150 | : draw-player ( -- ) 151 | get-player-texture 152 | player-sym get square-coordinates 153 | RAYWHITE draw-texture ; 154 | 155 | : player-right ( -- ) 156 | player-sym get 157 | [ speed>> ] keep 158 | [ posx>> ] keep 159 | [ + ] dip 160 | [ posx<< ] keep 161 | "right" swap direction<< ; 162 | 163 | : player-left ( -- ) 164 | player-sym get 165 | [ speed>> ] keep 166 | [ posx>> ] keep 167 | [ swap - ] dip 168 | [ posx<< ] keep 169 | "left" swap direction<< ; 170 | 171 | : player-below-bounds ( x -- ) 172 | neg? [ player-right player-right ] when ; 173 | 174 | : player-above-bounds ( x -- ) 175 | get-screen-width > [ player-left player-left ] when ; 176 | 177 | : player-within-bounds ( -- ) 178 | player-sym get 179 | posx>> dup 180 | player-below-bounds 181 | player-above-bounds ; 182 | 183 | : attempt-to-move ( direction -- ) 184 | player-within-bounds 185 | { 186 | { "left" [ player-left ] } 187 | { "right" [ player-right ] } 188 | } case ; 189 | 190 | 191 | : process-input ( keypair -- result/bool ) 192 | dup first ! Get the key 193 | enum>number is-key-down 194 | [ second ] [ drop "" ] if ; 195 | 196 | : player-inputs ( -- inputs ) 197 | { 198 | { KEY_A "left" } 199 | { KEY_D "right" } 200 | } ; 201 | 202 | : player-input ( -- ) 203 | player-inputs 204 | [ process-input dup 205 | "" equal? 206 | [ drop ] 207 | [ attempt-to-move ] if ] each ; 208 | 209 | :: adjacent ( x y ex ex2 -- quot ) 210 | [ x grid-size get ex execute , 211 | y grid-size get ex2 execute , ] { } make ; inline 212 | 213 | ! Player grabbing 214 | : upper-left ( x y -- seq ) 215 | \ - \ drop adjacent 216 | [ first ] keep second 217 | \ - \ - adjacent ; 218 | 219 | : upper-right ( x y -- seq ) 220 | \ + \ drop adjacent 221 | [ first ] keep second 222 | \ + \ - adjacent ; 223 | 224 | : bottom-left ( x y -- seq ) 225 | \ - \ + adjacent 226 | [ first ] keep second 227 | \ - \ + adjacent ; 228 | 229 | : bottom-right ( x y -- seq ) 230 | \ + \ + adjacent 231 | [ first ] keep second 232 | \ + \ + adjacent ; 233 | 234 | : adjacent-squares ( square -- list ) 235 | square-coordinates [ rot execute( x y -- seq ) ] 2curry 236 | { bottom-left bottom-right upper-left upper-right } 237 | swap map ; inline 238 | 239 | : adjacent-map ( seq -- seq ) 240 | [ [ find-square ] with-datastack ] map ; 241 | 242 | : player-middle-coordinates ( -- x y ) 243 | player-sym get square-coordinates 244 | get-player-texture 245 | [ width>> 2 / ] keep height>> 2 / 246 | [ swap ] dip + 247 | [ + ] dip ; 248 | 249 | : generate-grid-rectangles ( -- seq ) 250 | grid get 251 | [ square-coordinates 252 | grid-size get dup 253 | Rectangle ] 254 | map ; 255 | 256 | : within-rectangle ( x y -- seq ) 257 | Vector2 258 | [ swap check-collision-point-rec ] curry 259 | generate-grid-rectangles 260 | swap filter ; 261 | 262 | : player-center-square ( -- square ) 263 | player-middle-coordinates 264 | within-rectangle first 265 | [ x>> >integer ] keep 266 | y>> >integer find-square first ; 267 | 268 | : draw-adjacent ( -- ) 269 | player-center-square 270 | adjacent-squares 271 | adjacent-map flatten 272 | [ square-coordinates grid-size get dup 273 | GREEN draw-rectangle ] each ; 274 | 275 | : draw-player-center ( -- ) 276 | player-middle-coordinates 277 | within-rectangle first 278 | [ x>> >integer ] keep 279 | y>> >integer 280 | grid-size get dup RED draw-rectangle ; 281 | 282 | SYMBOL: hack 283 | : setup ( -- ) 284 | make-window 285 | setup-grid 286 | setup-grid-squares 287 | current-directory get hack set 288 | "~/assets" set-current-directory 289 | setup-textures 290 | hack get set-current-directory 291 | load-background 292 | load-player 293 | ; 294 | 295 | : render ( -- ) 296 | begin-drawing 297 | clear-window 298 | draw-background 299 | draw-grid 300 | draw-player 301 | draw-player-center 302 | draw-adjacent 303 | end-drawing ; 304 | 305 | : game-loop ( -- ) 306 | [ render player-input window-should-close not ] loop ; 307 | 308 | : main ( -- ) 309 | setup 310 | game-loop 311 | close-window ; 312 | -------------------------------------------------------------------------------- /examples/fof-clever/fof-clever.factor: -------------------------------------------------------------------------------- 1 | ! Copyright (C) 2019 Your name. 2 | ! See http://factorcode.org/license.txt for BSD license. 3 | USING: raylib.ffi kernel sequences locals alien.enums namespaces math classes.struct accessors combinators math.ranges sequences.deep continuations assocs classes.tuple math.functions random math.parser io.directories.hierarchy io.pathnames io.directories splitting unicode make fry ; 4 | IN: fof-clever 5 | 6 | ! Basic Grid for background textures 7 | TUPLE: square posx posy size container ; 8 | SYMBOL: grid-size 9 | SYMBOL: grid 10 | 11 | : game-height ( -- height ) 12 | get-screen-height grid-size get - ; 13 | 14 | : game-width ( -- width ) 15 | get-screen-width grid-size get - ; 16 | 17 | : make-grid-line ( x range -- list ) 18 | [ length ] keep 19 | [ swap ] dip 20 | zip 21 | [ [ grid-size get H{ } clone square boa ] with-datastack ] map ; 22 | 23 | : setup-grid-squares ( -- ) 24 | 0 game-width grid-size get 25 | [ 0 game-height grid-size get make-grid-line ] 26 | map flatten grid set ; 27 | 28 | : center-square ( -- x ) 29 | grid-size get 2 / ; 30 | 31 | : offset ( vector2 -- vector2' ) 32 | [ x>> center-square + ] keep 33 | y>> center-square + 34 | Vector2 ; 35 | 36 | : find-square-by-coordinate ( n -- squares ) 37 | grid get swap filter ; inline 38 | 39 | ! Find all squares that have a certain x or y 40 | : find-square-by-y ( y -- squares ) 41 | [ swap posy>> = ] curry 42 | find-square-by-coordinate ; 43 | 44 | : find-square-by-x ( x -- squares ) 45 | [ swap posx>> = ] curry 46 | find-square-by-coordinate ; 47 | 48 | ! Extract the square coordinates 49 | : with-square-coordinates ( square -- x y square ) 50 | [ posx>> ] keep 51 | [ posy>> ] keep ; 52 | 53 | : square-coordinates ( square -- x y ) 54 | with-square-coordinates drop ; 55 | 56 | : draw-square ( grid-square -- ) 57 | tuple-slots 58 | [ drop dup BLACK draw-rectangle-lines ] 59 | with-datastack drop ; 60 | 61 | : draw-grid ( -- ) 62 | grid get [ draw-square ] each ; 63 | 64 | : setup-grid ( -- ) 65 | 40 grid-size set ; 66 | 67 | : coordinates=? ( square x y -- bool ) 68 | [ square-coordinates ] 2dip 69 | swap [ = ] dip 70 | swap [ = ] dip and ; 71 | 72 | : find-square ( x y -- square ) 73 | [ coordinates=? ] 2curry grid get 74 | swap 75 | filter ; 76 | 77 | : set-square-key ( square val key -- ) 78 | pick container>> set-at drop ; 79 | 80 | : remove-square-key ( square key -- ) 81 | swap container>> delete-at ; 82 | 83 | : get-square-key ( square key -- val ) 84 | swap container>> at* drop ; 85 | 86 | : container=? ( square name -- bool ) 87 | swap container>> at* nip ; 88 | 89 | : find-square-by-container ( name -- square ) 90 | [ container=? ] curry 91 | grid get swap 92 | filter ; 93 | 94 | ! Windowing 95 | 96 | : make-window ( -- ) 97 | 800 400 "Clever Bean" init-window 98 | 30 set-target-fps ; 99 | 100 | : clear-window ( -- ) 101 | RAYWHITE clear-background ; 102 | 103 | ! Texture bank 104 | 105 | : texture-names ( name -- name' ) 106 | "/" split last 107 | "." split first 108 | >lower ; 109 | 110 | SYMBOL: textures 111 | 112 | : clever-load-image ( image -- texture ) 113 | load-image dup grid-size get dup 114 | image-resize load-texture-from-image ; 115 | 116 | : setup-textures ( -- ) 117 | current-directory get directory-tree-files 118 | [ absolute-path ] map 119 | [ dup clever-load-image 120 | [ { } swap texture-names suffix ] dip suffix ] 121 | map 122 | textures set ; 123 | 124 | : get-textures ( key -- texture ) 125 | textures get at ; 126 | 127 | ! Environment 128 | 129 | :: draw-generic ( seq texture -- ) 130 | seq 131 | [ square-coordinates [ texture get-textures ] 2dip 132 | RAYWHITE draw-texture ] each ; 133 | 134 | SYMBOL: background 135 | : draw-background ( -- ) 136 | background get 137 | 0 0 RAYWHITE draw-texture ; 138 | 139 | : load-background ( -- ) 140 | "kitchen.png" load-texture 141 | background set ; 142 | 143 | ! Player 144 | SYMBOL: player-sym 145 | TUPLE: player posx posy speed direction item ; 146 | SYMBOL: player-texture 147 | DEFER: player-grab 148 | 149 | : load-player-textures ( -- ) 150 | { } "player.png" load-texture suffix 151 | "player.png" load-image dup 152 | image-flip-horizontal load-texture-from-image suffix 153 | { "left" "right" } swap zip 154 | player-texture set ; 155 | 156 | : load-player ( -- ) 157 | load-player-textures 158 | get-screen-width 2 / 159 | get-screen-height "right" 160 | player-texture get at height>> - 161 | 15 "right" f player boa 162 | player-sym set ; 163 | 164 | : get-player-texture ( -- texture ) 165 | player-sym get direction>> 166 | player-texture get at ; 167 | 168 | : draw-player ( -- ) 169 | get-player-texture 170 | player-sym get square-coordinates 171 | RAYWHITE draw-texture ; 172 | 173 | : player-right ( -- ) 174 | player-sym get 175 | [ speed>> ] keep 176 | [ posx>> ] keep 177 | [ + ] dip 178 | [ posx<< ] keep 179 | "right" swap direction<< ; 180 | 181 | : player-left ( -- ) 182 | player-sym get 183 | [ speed>> ] keep 184 | [ posx>> ] keep 185 | [ swap - ] dip 186 | [ posx<< ] keep 187 | "left" swap direction<< ; 188 | 189 | : player-below-bounds ( x -- ) 190 | neg? [ player-right ] when ; 191 | 192 | : player-above-bounds ( x -- ) 193 | get-screen-width grid-size get - > [ player-left ] when ; 194 | 195 | : player-within-bounds ( -- ) 196 | player-sym get 197 | posx>> dup 198 | player-below-bounds 199 | player-above-bounds ; 200 | 201 | : attempt-to-move ( direction -- ) 202 | player-within-bounds 203 | { 204 | { "left" [ player-left ] } 205 | { "right" [ player-right ] } 206 | { "use" [ "use" player-grab ] } 207 | { "lowuse" [ "lowuse" player-grab ] } 208 | } case ; 209 | 210 | 211 | : process-input ( keypair -- result/bool ) 212 | dup first ! Get the key 213 | enum>number is-key-down 214 | [ second ] [ drop "" ] if ; 215 | 216 | : player-inputs ( -- inputs ) 217 | { 218 | { KEY_A "left" } 219 | { KEY_D "right" } 220 | } ; 221 | 222 | : player-actions ( -- inputs ) 223 | { { KEY_S "use" } 224 | { KEY_W "lowuse" } } ; 225 | 226 | : process-actions ( keypair -- result/bool ) 227 | dup first 228 | enum>number is-key-pressed 229 | [ second ] [ drop "" ] if ; 230 | 231 | : player-action ( -- ) 232 | player-actions 233 | [ process-actions dup 234 | "" equal? 235 | [ drop ] 236 | [ attempt-to-move ] if ] each ; 237 | 238 | : player-input ( -- ) 239 | player-action 240 | player-inputs 241 | [ process-input dup 242 | "" equal? 243 | [ drop ] 244 | [ attempt-to-move ] if ] each ; 245 | 246 | :: adjacent ( x y ex ex2 -- quot ) 247 | [ x grid-size get ex execute , 248 | y grid-size get ex2 execute , ] { } make ; inline 249 | 250 | ! Player grabbing 251 | : upper-left ( x y -- seq ) 252 | \ - \ drop adjacent 253 | [ first ] keep second 254 | \ - \ - adjacent ; 255 | 256 | : upper-right ( x y -- seq ) 257 | \ + \ drop adjacent 258 | [ first ] keep second 259 | \ + \ - adjacent ; 260 | 261 | : bottom-left ( x y -- seq ) 262 | \ - \ + adjacent 263 | [ first ] keep second 264 | \ - \ + adjacent ; 265 | 266 | : bottom-right ( x y -- seq ) 267 | \ + \ + adjacent 268 | [ first ] keep second 269 | \ + \ + adjacent ; 270 | 271 | : player-direction-squares ( -- squares ) 272 | player-sym get direction>> 273 | { 274 | { "left" [ { bottom-left upper-left } ] } 275 | { "right" [ { bottom-right upper-right } ] } 276 | } case ; 277 | 278 | : adjacent-squares ( square -- list ) 279 | square-coordinates [ rot execute( x y -- seq ) ] 2curry 280 | player-direction-squares 281 | swap map ; inline 282 | 283 | : adjacent-map ( seq -- seq ) 284 | [ [ find-square ] with-datastack ] map ; 285 | 286 | : player-middle-coordinates ( -- x y ) 287 | player-sym get square-coordinates 288 | get-player-texture 289 | [ width>> 2 / ] keep height>> 2 / 290 | [ swap ] dip + 291 | [ + ] dip 292 | [ dup get-screen-width > 293 | [ drop 800 ] 294 | [ ] if ] dip ; 295 | 296 | : generate-grid-rectangles ( -- seq ) 297 | grid get 298 | [ square-coordinates 299 | grid-size get dup 300 | Rectangle ] 301 | map ; 302 | 303 | : within-rectangle ( x y -- seq ) 304 | Vector2 305 | [ swap check-collision-point-rec ] curry 306 | generate-grid-rectangles 307 | swap filter ; 308 | 309 | : player-center-square ( -- square ) 310 | player-middle-coordinates 311 | within-rectangle first 312 | [ x>> >integer ] keep 313 | y>> >integer find-square first ; 314 | 315 | : draw-adjacent ( -- ) 316 | player-center-square 317 | adjacent-squares 318 | adjacent-map flatten 319 | [ dup square? [ square-coordinates grid-size get dup 320 | GREEN draw-rectangle ] [ drop ] if ] each ; 321 | 322 | : counter-items ( -- items ) 323 | { "apple" "knife" "spatula" "wine" "wheat" } ; 324 | 325 | : get-counter-sequence ( n -- seq ) 326 | 200 find-square-by-y 327 | [ posx>> 159 > ] filter 328 | [ 0 ] 2dip subseq ; 329 | 330 | : add-counter-items-to-grid ( -- ) 331 | counter-items dup length 332 | get-counter-sequence 333 | [ swap "item" set-square-key ] 2each ; 334 | 335 | : draw-items ( -- ) 336 | "item" find-square-by-container 337 | [ dup [ "item" get-square-key get-textures ] dip 338 | [ posx>> ] keep 339 | posy>> RAYWHITE draw-texture ] each ; 340 | 341 | : player-swap ( square -- ) 342 | dup "item" get-square-key 343 | [ player-sym get item>> "item" set-square-key ] dip 344 | player-sym get item<< ; 345 | 346 | : player-remove ( square -- ) 347 | dup "item" get-square-key 348 | [ "item" remove-square-key ] dip 349 | player-sym get item<< ; 350 | 351 | : player-grab ( vert -- ) 352 | player-center-square adjacent-squares 353 | adjacent-map flatten 354 | swap 355 | { { "use" [ first ] } 356 | { "lowuse" [ second ] } } 357 | case 358 | player-sym get item>> 359 | [ player-swap ] 360 | [ player-remove ] if ; 361 | 362 | : draw-hands ( -- ) 363 | player-sym get item>> get-textures 364 | player-center-square square-coordinates RAYWHITE 365 | draw-texture ; 366 | 367 | SYMBOL: hack 368 | : setup ( -- ) 369 | make-window 370 | setup-grid 371 | setup-grid-squares 372 | current-directory get hack set 373 | "~/assets" set-current-directory 374 | setup-textures 375 | hack get set-current-directory 376 | load-background 377 | load-player 378 | add-counter-items-to-grid 379 | ; 380 | 381 | : render ( -- ) 382 | begin-drawing 383 | clear-window 384 | draw-background 385 | draw-grid 386 | draw-player 387 | draw-adjacent 388 | draw-items 389 | end-drawing ; 390 | 391 | : game-loop ( -- ) 392 | [ render player-input window-should-close not ] loop ; 393 | 394 | : main ( -- ) 395 | setup 396 | game-loop 397 | close-window ; 398 | -------------------------------------------------------------------------------- /raylib/modules/gui/gui.factor: -------------------------------------------------------------------------------- 1 | ! Copyright (C) 2019 Jack Lucas 2 | ! See http://factorcode.org/license.txt for BSD license. 3 | ! These should be complete bindings to the Raygui library 2.0 4 | ! Most of the comments are included from the original header 5 | ! for your convenience. 6 | USING: alien alien.c-types alien.enums alien.libraries 7 | alien.libraries.finder alien.syntax classes.struct combinators 8 | kernel quotations system vocabs raylib.ffi ; 9 | IN: raylib.modules.gui 10 | 11 | ! Enumerations ---------------------------------------------------------- 12 | 13 | ! Gui global state enum 14 | ENUM: GuiControlState 15 | GUI_STATE_NORMAL 16 | GUI_STATE_FOCUSED 17 | GUI_STATE_PRESSED 18 | GUI_STATE_DISABLED ; 19 | 20 | ! Gui global text alignment 21 | ENUM: GuiTextAlignment 22 | GUI_TEXT_ALIGN_LEFT 23 | GUI_TEXT_ALIGN_CENTER 24 | GUI_TEXT_ALIGN_RIGHT ; 25 | 26 | ! Gui standard controls 27 | ENUM: GuiControlStandard 28 | DEFAULT 29 | LABEL ! LABELBUTTON 30 | BUTTON ! IMAGEBUTTON 31 | TOGGLE ! TOGGLEGROUP 32 | SLIDER ! SLIDERBAR 33 | PROGRESSBAR 34 | CHECKBOX 35 | COMBOBOX 36 | DROPDOWNBOX 37 | TEXTBOX ! VALUEBOX SPINNER 38 | LISTVIEW 39 | COLORPICKER 40 | SCROLLBAR ; 41 | 42 | ! Gui default properties for every control 43 | ENUM: GuiControlProperty 44 | BORDER_COLOR_NORMAL 45 | BASE_COLOR_NORMAL 46 | TEXT_COLOR_NORMAL 47 | BORDER_COLOR_FOCUSED 48 | BASE_COLOR_FOCUSED 49 | TEXT_COLOR_FOCUSED 50 | BORDER_COLOR_PRESSED 51 | BASE_COLOR_PRESSED 52 | TEXT_COLOR_PRESSED 53 | BORDER_COLOR_DISABLED 54 | BASE_COLOR_DISABLED 55 | TEXT_COLOR_DISABLED 56 | BORDER_WIDTH 57 | INNER_PADDING 58 | TEXT_ALIGNMENT 59 | RESERVED02 ; 60 | 61 | ! Gui extended properties depending on control type 62 | ! NOTE: We reserve a fixed size of additional properties per control (8) 63 | 64 | ! Default properties 65 | ENUM: GuiDefaultProperty 66 | { TEXT_SIZE 16 } 67 | { TEXT_SPACING 17 } 68 | { TEXT_COLOR 18 } 69 | { BACKGROUND_COLOR 19 } ; 70 | 71 | ! Toggle / ToggleGroup 72 | ENUM: GuiToggleProperty 73 | { GROUP_PADDING 16 } ; 74 | 75 | ! Slider / SliderBar 76 | ENUM: GuiSliderProperty 77 | { SLIDER_WIDTH 16 } 78 | { TEXT_PADDING 17 } ; 79 | 80 | ! TextBox / ValueBox / Spinner 81 | ENUM: GuiTextBoxProperty 82 | { MULTILINE_PADDING 16 } 83 | { SPINNER_BUTTON_WIDTH 17 } 84 | { SPINNER_BUTTON_PADDING 18 } 85 | { SPINNER_BUTTON_BORDER_WIDTH 19 } ; 86 | 87 | ! CheckBox 88 | ENUM: GuiCheckBoxProperty 89 | { CHECK_TEXT_PADDING 16 } ; 90 | 91 | ! ComboBox 92 | ENUM: GuiComboBoxProperty 93 | { SELECTOR_WIDTH 16 } 94 | { SELECTOR_PADDING 17 } ; 95 | 96 | ! DropdownBox 97 | ENUM: GuiDropdownBoxProperty 98 | { ARROW_RIGHT_PADDING 16 } ; 99 | 100 | ! ColorPicker 101 | ENUM: GuiColorPickerProperty 102 | { COLOR_SELECTOR_SIZE 16 } 103 | { BAR_WIDTH 17 } ! Lateral bar width 104 | { BAR_PADDING 18 } ! Later bar separation from panel 105 | { BAR_SELECTOR_HEIGHT 19 } ! Lateral bar selector height 106 | { BAR_SELECTOR_PADDING 20 } ; ! Later bar selector outer padding 107 | 108 | ! ListView 109 | ENUM: GuiListViewProperty 110 | { ELEMENTS_HEIGHT 16 } 111 | { ELEMENTS_PADDING 17 } 112 | { SCROLLBAR_WIDTH 18 } 113 | { SCROLLBAR_SIDE 19 } ; ! This property defines vertical scrollbar side 114 | 115 | ! ScrollBar 116 | ENUM: GuiScrollBarProperty 117 | { SCROLLBAR_BORDER 16 } 118 | { SCROLLBAR_SHOW_SPINNER_BUTTONS 17 } 119 | { SCROLLBAR_ARROWS_SIZE 18 } 120 | { SCROLLBAR_PADDING 19 } 121 | { SCROLLBAR_SLIDER_PADDING 20 } 122 | { SCROLLBAR_SLIDER_SIZE 21 } 123 | { SCROLLBAR_SCROLL_SPEED 22 } ; 124 | 125 | ! ScrollBar side 126 | ENUM: GuiScrollBarSide 127 | SCROLLBAR_LEFT_SIDE 128 | SCROLLBAR_RIGHT_SIDE ; 129 | 130 | ! Functions --------------------------------------------------------- 131 | 132 | 133 | ! Global gui modification functions 134 | FUNCTION-ALIAS: rl-gui-enable void GuiEnable ( ) ! Enable gui controls ( global state ) 135 | FUNCTION-ALIAS: rl-gui-disable void GuiDisable ( ) ! Disable gui controls ( global state ) 136 | FUNCTION-ALIAS: rl-gui-lock void GuiLock ( ) ! Lock gui controls ( global state ) 137 | FUNCTION-ALIAS: rl-gui-unlock void GuiUnlock ( ) ! Unlock gui controls ( global state ) 138 | FUNCTION-ALIAS: rl-gui-state void GuiState ( int state ) ! Set gui state ( global state ) 139 | FUNCTION-ALIAS: rl-gui-font void GuiFont ( Font font ) ! Set gui custom font ( global state ) 140 | FUNCTION-ALIAS: rl-gui-fade void GuiFade ( float alpha ) ! Set gui controls alpha ( global state ) , alpha goes from 0.0f to 1.0f 141 | 142 | ! Style set/get functions 143 | FUNCTION-ALIAS: rl-gui-set-style void GuiSetStyle ( int control, int property, int value ) ! Set one style property 144 | FUNCTION-ALIAS: rl-gui-get-style int GuiGetStyle ( int control, int property ) ! Get one style property 145 | 146 | ! Container/separator controls, useful for controls organization 147 | FUNCTION-ALIAS: rl-gui-window-box bool GuiWindowBox ( Rectangle bounds, c-string text ) ! Window Box control, shows a window that can be closed 148 | FUNCTION-ALIAS: rl-gui-group-box void GuiGroupBox ( Rectangle bounds, c-string text ) ! Group Box control with title name 149 | FUNCTION-ALIAS: rl-gui-line void GuiLine ( Rectangle bounds, c-string text ) ! Line separator control, could contain text 150 | FUNCTION-ALIAS: rl-gui-panel void GuiPanel ( Rectangle bounds ) ! Panel control, useful to group controls 151 | FUNCTION-ALIAS: rl-gui-scrollpanel Rectangle GuiScrollPanel ( Rectangle bounds, Rectangle content, Vector2 *scroll ) ! Scroll Panel control 152 | 153 | ! Basic controls set 154 | FUNCTION-ALIAS: rl-gui-label void GuiLabel ( Rectangle bounds, c-string text ) ! Label control, shows text 155 | FUNCTION-ALIAS: rl-gui-button bool GuiButton ( Rectangle bounds, c-string text ) ! Button control, returns true when clicked 156 | FUNCTION-ALIAS: rl-gui-label-button bool GuiLabelButton ( Rectangle bounds, c-string text ) ! Label button control, show true when clicked 157 | FUNCTION-ALIAS: rl-gui-image-button bool GuiImageButton ( Rectangle bounds, Texture2D texture ) ! Image button control, returns true when clicked 158 | FUNCTION-ALIAS: rl-gui-image-button-ex bool GuiImageButtonEx ( Rectangle bounds, Texture2D texture, Rectangle texSource, c-string text ) ! Image button extended control, returns true when clicked 159 | FUNCTION-ALIAS: rl-gui-toggle bool GuiToggle ( Rectangle bounds, c-string text, bool active ) ! Toggle Button control, returns true when active 160 | FUNCTION-ALIAS: rl-gui-toggle-group int GuiToggleGroup ( Rectangle bounds, c-string text, int active ) ! Toggle Group control, returns active toggle index 161 | FUNCTION-ALIAS: rl-gui-check-box bool GuiCheckBox ( Rectangle bounds, c-string text, bool checked ) ! Check Box control, returns true when active 162 | FUNCTION-ALIAS: rl-gui-combo-box int GuiComboBox ( Rectangle bounds, c-string text, int active ) ! Combo Box control, returns selected item index 163 | FUNCTION-ALIAS: rl-gui-dropdown-box bool GuiDropdownBox ( Rectangle bounds, c-string text, int* active, bool editMode ) ! Dropdown Box control, returns selected item 164 | FUNCTION-ALIAS: rl-gui-spinner bool GuiSpinner ( Rectangle bounds, int* value, int minValue, int maxValue, bool editMode ) ! Spinner control, returns selected value 165 | FUNCTION-ALIAS: rl-gui-value-box bool GuiValueBox ( Rectangle bounds, int* value, int minValue, int maxValue, bool editMode ) ! Value Box control, updates input text with numbers 166 | FUNCTION-ALIAS: rl-gui-text-box bool GuiTextBox ( Rectangle bounds, char *text, int textSize, bool editMode ) ! Text Box control, updates input text 167 | FUNCTION-ALIAS: rl-gui-text-box-multi bool GuiTextBoxMulti ( Rectangle bounds, char *text, int textSize, bool editMode ) ! Text Box control with multiple lines 168 | FUNCTION-ALIAS: rl-gui-slider float GuiSlider ( Rectangle bounds, c-string text, float value, float minValue, float maxValue, bool showValue ) ! Slider control, returns selected value 169 | FUNCTION-ALIAS: rl-gui-slider-bar float GuiSliderBar ( Rectangle bounds, c-string text, float value, float minValue, float maxValue, bool showValue ) ! Slider Bar control, returns selected value 170 | FUNCTION-ALIAS: rl-gui-progress-bar float GuiProgressBar ( Rectangle bounds, c-string text, float value, float minValue, float maxValue, bool showValue ) ! Progress Bar control, shows current progress value 171 | FUNCTION-ALIAS: rl-gui-status-bar void GuiStatusBar ( Rectangle bounds, c-string text ) ! Status Bar control, shows info text 172 | FUNCTION-ALIAS: rl-gui-dummy-rec void GuiDummyRec ( Rectangle bounds, c-string text ) ! Dummy control for placeholders 173 | FUNCTION-ALIAS: rl-gui-scroll-bar int GuiScrollBar ( Rectangle bounds, int value, int minValue, int maxValue ) ! Scroll Bar control 174 | 175 | ! Advance controls set 176 | FUNCTION-ALIAS: rl-gui-list-view bool GuiListView ( Rectangle bounds, c-string text, int* active, int* scrollIndex, bool editMode ) ! List View control, returns selected list element index 177 | FUNCTION-ALIAS: rl-gui-list-view-ex bool GuiListViewEx ( Rectangle bounds, c-string *text, int count, int* enabled, int* active, int* focus, int* scrollIndex, bool editMode ) ! List View with extended parameters 178 | FUNCTION-ALIAS: rl-gui-message-box int GuiMessageBox ( Rectangle bounds, c-string windowTitle, c-string message, c-string buttons ) ! Message Box control, displays a message 179 | FUNCTION-ALIAS: rl-gui-color-picker Color GuiColorPicker ( Rectangle bounds, Color color ) ! Color Picker control 180 | FUNCTION-ALIAS: rl-gui-grid Vector2 GuiGrid ( Rectangle bounds, float spacing, int subdivs ) ! Grid 181 | 182 | ! Styles loading functions 183 | FUNCTION-ALIAS: rl-gui-load-style void GuiLoadStyle ( c-string fileName ) ! Load style file ( .rgs ) 184 | FUNCTION-ALIAS: rl-gui-load-style-props void GuiLoadStyleProps ( int* props, int count ) ! Load style properties from array 185 | FUNCTION-ALIAS: rl-gui-load-style-default void GuiLoadStyleDefault ( ) ! Load style default over global style 186 | FUNCTION-ALIAS: rl-gui-update-style-complete void GuiUpdateStyleComplete ( ) ! Updates full style properties set with default values 187 | 188 | 189 | FUNCTION-ALIAS: rl-gui-icon-text c-string GuiIconText ( int iconId, c-string text ) ! Get text with icon id prepended 190 | -------------------------------------------------------------------------------- /examples/fof-poet/fof-poet.factor~: -------------------------------------------------------------------------------- 1 | ! Copyright (C) 2019J Jack Lucas 2 | ! See http://factorcode.org/license.txt for BSD license. 3 | USING: raylib.ffi kernel sequences locals alien.enums 4 | namespaces math classes.struct accessors combinators math.ranges 5 | sequences.deep continuations assocs classes.tuple math.functions random 6 | math.parser ; 7 | IN: fof-poet 8 | 9 | TUPLE: square posx posy size container ; 10 | 11 | SYMBOL: grid-size 12 | SYMBOL: grid 13 | 14 | : make-window ( -- ) 15 | 800 600 "Mad Dash til Balderdash" init-window 16 | 10 set-target-fps ; 17 | 18 | : clear-window ( -- ) 19 | RAYWHITE clear-background ; 20 | 21 | ! The Grid 22 | : setup-grid ( -- ) 23 | 40 grid-size set ; 24 | 25 | : game-height ( -- height ) 26 | get-screen-height grid-size get - ; 27 | 28 | : game-width ( -- width ) 29 | get-screen-width grid-size get - ; 30 | 31 | : make-grid-line ( x range -- list ) 32 | [ length ] keep 33 | [ swap ] dip 34 | zip 35 | [ [ 40 H{ } clone square boa ] with-datastack ] map ; 36 | 37 | : setup-grid-squares ( -- ) 38 | 0 game-width grid-size get 39 | [ 0 game-height grid-size get make-grid-line ] 40 | map flatten grid set ; 41 | 42 | : draw-square ( grid-square -- ) 43 | tuple-slots 44 | [ drop dup BLACK draw-rectangle-lines ] 45 | with-datastack drop ; 46 | 47 | : draw-grid ( -- ) 48 | grid get [ draw-square ] each ; 49 | 50 | ! Grid Utilities 51 | 52 | : with-square-coordinates ( square -- x y square ) 53 | [ posx>> ] keep 54 | [ posy>> ] keep ; 55 | 56 | : square-coordinates ( square -- x y ) 57 | with-square-coordinates drop ; 58 | 59 | : coordinates=? ( square x y -- bool ) 60 | [ square-coordinates ] 2dip 61 | swap [ = ] dip 62 | swap [ = ] dip and ; 63 | 64 | : find-square ( x y -- square ) 65 | [ coordinates=? ] 2curry grid get 66 | swap 67 | filter ; 68 | 69 | : container=? ( square name -- bool ) 70 | swap container>> at* nip ; 71 | 72 | : find-square-by-container ( name -- square ) 73 | [ container=? ] curry 74 | grid get swap 75 | filter ; 76 | 77 | 78 | : find-square-by-coordinate ( x -- squares ) 79 | grid get swap filter ; inline 80 | 81 | : find-square-by-y ( y -- squares ) 82 | [ swap posy>> = ] curry 83 | find-square-by-coordinate ; 84 | 85 | : find-square-by-x ( x -- squares ) 86 | [ swap posx>> = ] curry 87 | find-square-by-coordinate ; 88 | 89 | : find-container ( name -- container ) 90 | find-square-by-container 91 | first container>> ; 92 | 93 | : set-square-key ( square val key -- ) 94 | pick container>> set-at drop ; 95 | 96 | : set-square-flag ( square key -- ) 97 | t swap set-square-key ; 98 | 99 | : remove-square-key ( square key -- ) 100 | swap container>> delete-at* 2drop ; 101 | 102 | : center-square ( -- x ) 103 | grid-size get 2 / ; 104 | 105 | : offset ( vector2 -- vector2' ) 106 | [ x>> center-square + ] keep 107 | y>> center-square + 108 | Vector2 ; 109 | 110 | : middle-square ( n -- n' ) 111 | grid-size get / 2 / floor 112 | grid-size get * ; 113 | 114 | ! Player 115 | : find-player-square ( -- square ) 116 | "player" find-square-by-container first ; 117 | 118 | : player-vector ( -- vector ) 119 | find-player-square 120 | [ posx>> ] keep 121 | posy>> Vector2 ; 122 | 123 | : draw-player ( -- ) 124 | player-vector offset 125 | 20.0 RED draw-circle-v ; 126 | 127 | : setup-player ( -- ) 128 | t "player" 129 | game-width middle-square 130 | game-height find-square first container>> 131 | set-at ; 132 | 133 | ! Movement Words 134 | 135 | : process-input ( keypair -- result/bool ) 136 | dup first ! Get the key 137 | enum>number is-key-down 138 | [ second ] [ drop "" ] if ; 139 | 140 | : set-player-square ( square -- ) 141 | t "player" set-square-key ; 142 | 143 | : remove-player-square ( square -- ) 144 | "player" remove-square-key ; 145 | 146 | : get-square-key ( square key -- val ) 147 | swap container>> at* drop ; 148 | 149 | : check-occupied ( square tag -- bool ) 150 | swap container>> at* nip ; 151 | 152 | ! Square2 Doesnt exist stay 153 | ! Square2 occupied with same tag Stay 154 | ! Else move to square2 155 | DEFER: opposite-direction 156 | :: ?change-direction ( square square2 tag -- ) 157 | square2 tag first get-square-key 158 | tag second opposite-direction equal? 159 | [ square tag second opposite-direction tag first 160 | set-square-key 161 | square2 dup tag first get-square-key opposite-direction 162 | tag first set-square-key ] when ; 163 | 164 | :: square-decision ( tag square square2 -- ) 165 | square2 tag first check-occupied 166 | [ square square2 tag ?change-direction ] 167 | [ square2 tag second tag first set-square-key 168 | square tag first remove-square-key ] if ; 169 | 170 | : pick-square ( tag square square2 -- ) 171 | dup empty? 172 | [ 3drop ] 173 | [ first square-decision ] if ; 174 | 175 | : up-square ( x y -- square ) 176 | grid-size get - find-square ; 177 | 178 | : down-square ( x y -- square ) 179 | grid-size get + find-square ; 180 | 181 | : left-square ( x y -- square ) 182 | [ grid-size get - ] dip find-square ; 183 | 184 | : right-square ( x y -- square ) 185 | [ grid-size get + ] dip find-square ; 186 | 187 | : which-square ( x y direction -- square' ) 188 | { 189 | { "up" [ up-square ] } 190 | { "down" [ down-square ] } 191 | { "left" [ left-square ] } 192 | { "right" [ right-square ] } 193 | } case ; 194 | 195 | : move-square ( tag square direction -- ) 196 | [ dup square-coordinates ] dip 197 | which-square 198 | pick-square ; 199 | 200 | : check-input ( -- ) 201 | { 202 | { KEY_W "up" } 203 | { KEY_S "down" } 204 | { KEY_A "left" } 205 | { KEY_D "right" } 206 | } 207 | [ process-input dup 208 | "" equal? 209 | [ drop ] 210 | [ { "player" t } find-player-square rot move-square ] if 211 | ] each ; 212 | 213 | ! AI Entities 214 | : enemy-vector ( square -- vector ) 215 | [ posx>> ] keep 216 | posy>> Vector2 ; 217 | 218 | : draw-enemy ( vector -- ) 219 | offset 20.0 BLUE draw-circle-v ; 220 | 221 | : enemies ( -- squarelst ) 222 | "enemy" find-square-by-container ; 223 | 224 | : draw-enemies ( -- ) 225 | enemies 226 | [ enemy-vector draw-enemy ] each ; 227 | 228 | : enemy-direction ( square -- direction ) 229 | container>> "enemy" swap at ; 230 | 231 | : opposite-direction ( direction -- direction ) 232 | { 233 | { "up" [ "down" ] } 234 | { "down" [ "up" ] } 235 | { "left" [ "right" ] } 236 | { "right" [ "left" ] } 237 | [ drop f ] 238 | } case ; 239 | 240 | : flip-direction ( square direction -- ) 241 | opposite-direction "enemy" set-square-key ; 242 | 243 | : check-enemy-direction ( square -- ) 244 | dup enemy-direction 245 | [ dup square-coordinates ] dip 246 | which-square { } equal? 247 | [ dup enemy-direction flip-direction ] 248 | [ drop ] if ; 249 | 250 | : move-enemy ( square -- ) 251 | [ check-enemy-direction ] keep 252 | [ enemy-direction ] keep 253 | [ { "enemy" } swap suffix ] dip 254 | dup enemy-direction move-square ; 255 | 256 | : move-enemies ( -- ) 257 | enemies 258 | [ move-enemy ] each ; 259 | 260 | : directions ( -- directions ) 261 | { "up" "down" "left" "right" } ; 262 | 263 | : grid-enemy-map ( n -- n' ) 264 | grid-size get / 1 - random 265 | grid-size get * ; 266 | 267 | : grid-height ( -- height ) 268 | game-height grid-enemy-map ; 269 | 270 | : grid-width ( -- width ) 271 | game-width grid-enemy-map ; 272 | SYMBOL: difficulty 273 | : set-difficulty ( n -- ) 274 | difficulty set ; 275 | 276 | : setup-enemy ( n -- n' ) 277 | grid-width grid-height find-square first 278 | directions random "enemy" set-square-key 279 | dup 0 = 280 | [ ] [ 1 - setup-enemy ] if ; recursive 281 | 282 | : setup-enemies ( -- ) 283 | difficulty get setup-enemy drop ; 284 | 285 | ! States (End, Restart, Start) 286 | : draw-game-over ( -- ) 287 | begin-drawing 288 | clear-window 289 | "Press Space to Continue \nEscape to Exit" 290 | 40 get-screen-height 2 / 291 | 30 BLACK draw-text 292 | end-drawing ; 293 | 294 | DEFER: game-loop 295 | DEFER: setup 296 | DEFER: reset-difficulty 297 | : game-over-input ( -- ) 298 | { 299 | { KEY_SPACE "space" } 300 | } 301 | [ process-input 302 | "space" equal? 303 | [ reset-difficulty setup game-loop ] when ] each ; 304 | 305 | : game-over-screen ( -- ) 306 | [ draw-game-over 307 | game-over-input window-should-close not ] loop ; 308 | 309 | ! Collisions 310 | 311 | : detect-collision ( -- ) 312 | find-player-square 313 | enemies 314 | member? 315 | [ game-over-screen ] when ; 316 | 317 | SYMBOL: textures 318 | : setup-textures ( -- ) 319 | { "ground.png" "left.png" "right.png" "end.png" "door.png" } 320 | [ dup load-image load-texture-from-image 321 | [ { } swap suffix ] dip suffix ] 322 | map 323 | textures set ; 324 | 325 | : get-textures ( key -- texture ) 326 | textures get at ; 327 | 328 | : draw-ground ( -- ) 329 | grid get 330 | [ square-coordinates [ "ground.png" get-textures ] 2dip 331 | RAYWHITE draw-texture ] each ; 332 | 333 | : draw-sidewalks ( -- ) 334 | 0 find-square-by-x 335 | [ square-coordinates [ "right.png" get-textures ] 2dip 336 | RAYWHITE draw-texture ] each 337 | game-width find-square-by-x 338 | [ square-coordinates [ "left.png" get-textures ] 2dip 339 | RAYWHITE draw-texture ] each ; 340 | 341 | SYMBOL: max-level 342 | 343 | : draw-winning-end ( -- ) 344 | difficulty get max-level get = 345 | [ 0 find-square-by-y 346 | [ square-coordinates [ "end.png" get-textures ] 2dip 347 | RAYWHITE draw-texture ] each 348 | "door.png" get-textures game-width middle-square 0 349 | RAYWHITE draw-texture ] when ; 350 | 351 | : draw-level-num ( -- ) 352 | difficulty get number>string 353 | 10 10 20 RED draw-text ; 354 | 355 | : draw-game-won ( -- ) 356 | begin-drawing 357 | clear-window 358 | draw-grid 359 | draw-ground 360 | "You reached the\nPoet Society!\nSpace to play again." 361 | 40 get-screen-height 2 / 362 | 30 BLACK draw-text 363 | end-drawing ; 364 | 365 | : game-won ( -- ) 366 | [ draw-game-won game-over-input window-should-close not ] loop ; 367 | 368 | 369 | : render ( -- ) 370 | begin-drawing 371 | clear-window 372 | draw-grid 373 | draw-ground 374 | draw-sidewalks 375 | draw-winning-end 376 | draw-player 377 | draw-enemies 378 | draw-level-num 379 | end-drawing ; 380 | 381 | : setup ( -- ) 382 | setup-grid 383 | setup-grid-squares 384 | setup-player 385 | setup-enemies ; 386 | 387 | : increase-difficulty ( -- ) 388 | difficulty get 389 | 1 + difficulty set ; 390 | 391 | : reset-difficulty ( -- ) 392 | 0 difficulty set ; 393 | 394 | 395 | 396 | : ?next-screen ( -- ) 397 | find-player-square 398 | posy>> 0 = 399 | [ difficulty get max-level get = 400 | [ game-won ] 401 | [ increase-difficulty setup game-loop ] if 402 | ] when ; 403 | 404 | : game-loop ( -- ) 405 | [ check-input render move-enemies 406 | detect-collision ?next-screen 407 | window-should-close not ] loop ; 408 | 409 | : draw-difficulty-box ( -- ) 410 | "Press 1, 2 or 3 to select\n 411 | (1) 3 Levels\n 412 | (2) 5 Levels\n 413 | (3) 10 Levels\n" 414 | 40 40 415 | 30 BLACK draw-text ; 416 | 417 | : render-difficulty-screen ( -- ) 418 | begin-drawing 419 | clear-window 420 | draw-difficulty-box 421 | end-drawing ; 422 | 423 | : difficulties ( -- n ) 424 | { { "one" 3 } { "two" 5 } { "three" 10 } } ; 425 | 426 | : check-difficulty-input ( -- ) 427 | { 428 | { KEY_ONE "one" } 429 | { KEY_TWO "two" } 430 | { KEY_THREE "three" } 431 | } [ process-input dup 432 | "" equal? 433 | [ drop ] 434 | [ difficulties at max-level set ] 435 | if ] each ; 436 | 437 | : choose-difficulty ( -- ) 438 | [ render-difficulty-screen 439 | check-difficulty-input 440 | max-level get number? not ] loop ; 441 | 442 | ! These only need to be initialized once 443 | : pre-setup ( -- ) 444 | setup-textures 445 | choose-difficulty 446 | reset-difficulty ; 447 | 448 | : main ( -- ) 449 | make-window 450 | pre-setup 451 | setup 452 | game-loop 453 | f max-level set 454 | close-window ; 455 | 456 | MAIN: main 457 | -------------------------------------------------------------------------------- /examples/fof-poet/#fof-poet.factor#: -------------------------------------------------------------------------------- 1 | ! Copyright (C) 2019J Jack Lucas 2 | ! See http://factorcode.org/license.txt for BSD license. 3 | USING: raylib.ffi kernel sequences locals alien.enums 4 | namespaces math classes.struct accessors combinators math.ranges 5 | sequences.deep continuations assocs classes.tuple math.functions random 6 | math.parser ; 7 | IN: fof-poet 8 | 9 | TUPLE: square posx posy size container ; 10 | 11 | SYMBOL: grid-size 12 | SYMBOL: grid 13 | 14 | : make-window ( -- ) 15 | 800 600 "Mad Dash til Balderdash" init-window 16 | 10 set-target-fps ; 17 | 18 | : clear-window ( -- ) 19 | RAYWHITE clear-background ; 20 | 21 | ! The Grid 22 | : setup-grid ( -- ) 23 | 40 grid-size set ; 24 | 25 | ! Remove the points that would lie outside the canvas 26 | : game-height ( -- height ) 27 | get-screen-height grid-size get - ; 28 | 29 | : game-width ( -- width ) 30 | get-screen-width grid-size get - ; 31 | 32 | : make-grid-line ( x range -- list ) 33 | [ length ] keep 34 | [ swap ] dip 35 | zip 36 | [ [ grid-size get H{ } clone square boa ] with-datastack ] map ; 37 | 38 | : setup-grid-squares ( -- ) 39 | 0 game-width grid-size get 40 | [ 0 game-height grid-size get make-grid-line ] 41 | map flatten grid set ; 42 | 43 | : draw-square ( grid-square -- ) 44 | tuple-slots 45 | [ drop dup BLACK draw-rectangle-lines ] 46 | with-datastack drop ; 47 | 48 | : draw-grid ( -- ) 49 | grid get [ draw-square ] each ; 50 | 51 | ! Grid Utilities 52 | 53 | ! Extract the square coordinates 54 | : with-square-coordinates ( square -- x y square ) 55 | [ posx>> ] keep 56 | [ posy>> ] keep ; 57 | 58 | : square-coordinates ( square -- x y ) 59 | with-square-coordinates drop ; 60 | 61 | ! Check if a pair (x,y) matches a square 62 | : coordinates=? ( square x y -- bool ) 63 | [ square-coordinates ] 2dip 64 | swap [ = ] dip 65 | swap [ = ] dip and ; 66 | 67 | : find-square ( x y -- square ) 68 | [ coordinates=? ] 2curry grid get 69 | swap 70 | filter ; 71 | 72 | : container=? ( square name -- bool ) 73 | swap container>> at* nip ; 74 | 75 | : find-square-by-container ( name -- square ) 76 | [ container=? ] curry 77 | grid get swap 78 | filter ; 79 | 80 | : find-square-by-coordinate ( n -- squares ) 81 | grid get swap filter ; inline 82 | 83 | ! Find all squares that have a certain x or y 84 | : find-square-by-y ( y -- squares ) 85 | [ swap posy>> = ] curry 86 | find-square-by-coordinate ; 87 | 88 | : find-square-by-x ( x -- squares ) 89 | [ swap posx>> = ] curry 90 | find-square-by-coordinate ; 91 | 92 | : set-square-key ( square val key -- ) 93 | pick container>> set-at drop ; 94 | 95 | : remove-square-key ( square key -- ) 96 | swap container>> delete-at ; 97 | 98 | : get-square-key ( square key -- val ) 99 | swap container>> at* drop ; 100 | 101 | : center-square ( -- x ) 102 | grid-size get 2 / ; 103 | 104 | : offset ( vector2 -- vector2' ) 105 | [ x>> center-square + ] keep 106 | y>> center-square + 107 | Vector2 ; 108 | 109 | : middle-square ( n -- n' ) 110 | grid-size get / 2 / floor 111 | grid-size get * ; 112 | 113 | ! Player 114 | : find-player-square ( -- square ) 115 | "player" find-square-by-container first ; 116 | 117 | : player-vector ( -- vector ) 118 | find-player-square 119 | [ posx>> ] keep 120 | posy>> Vector2 ; 121 | 122 | : draw-player ( -- ) 123 | player-vector offset 124 | 20.0 RED draw-circle-v ; 125 | 126 | : setup-player ( -- ) 127 | t "player" 128 | game-width middle-square 129 | game-height find-square first container>> 130 | set-at ; 131 | 132 | ! Movement Words 133 | 134 | ! Square2 Doesnt exist stay 135 | ! Square2 occupied with same tag Stay 136 | ! Else move to square2 137 | DEFER: opposite-direction 138 | 139 | : change-former ( square tag -- ) 140 | dup first [ second opposite-direction ] dip 141 | set-square-key ; 142 | 143 | : change-later ( square tag -- ) 144 | dup first pick swap get-square-key 145 | opposite-direction [ first ] dip 146 | swap set-square-key ; 147 | 148 | :: ?change-direction ( square square2 tag -- ) 149 | square2 tag first get-square-key 150 | tag second opposite-direction equal? 151 | [ square tag change-former 152 | square2 tag change-later ] when ; 153 | 154 | :: square-decision ( tag square square2 -- ) 155 | square2 tag first container=? 156 | [ square square2 tag ?change-direction ] 157 | [ square2 tag second tag first set-square-key 158 | square tag first remove-square-key ] if ; 159 | 160 | : pick-square ( tag square square2 -- ) 161 | dup empty? 162 | [ 3drop ] 163 | [ first square-decision ] if ; 164 | 165 | : up-square ( x y -- square ) 166 | grid-size get - find-square ; 167 | 168 | : down-square ( x y -- square ) 169 | grid-size get + find-square ; 170 | 171 | : left-square ( x y -- square ) 172 | [ grid-size get - ] dip find-square ; 173 | 174 | : right-square ( x y -- square ) 175 | [ grid-size get + ] dip find-square ; 176 | 177 | : which-square ( x y direction -- square' ) 178 | { 179 | { "up" [ up-square ] } 180 | { "down" [ down-square ] } 181 | { "left" [ left-square ] } 182 | { "right" [ right-square ] } 183 | } case ; 184 | 185 | : move-square ( tag square direction -- ) 186 | [ dup square-coordinates ] dip 187 | which-square 188 | pick-square ; 189 | 190 | : process-input ( keypair -- result/bool ) 191 | dup first ! Get the key 192 | enum>number is-key-down 193 | [ second ] [ drop "" ] if ; 194 | 195 | : player-inputs ( -- inputs ) 196 | { 197 | { KEY_W "up" } 198 | { KEY_S "down" } 199 | { KEY_A "left" } 200 | { KEY_D "right" } 201 | } ; 202 | 203 | : attempt-to-move ( direction -- ) 204 | { "player" t } find-player-square rot move-square ; 205 | 206 | : check-input ( -- ) 207 | player-inputs 208 | [ process-input dup 209 | "" equal? 210 | [ drop ] 211 | [ attempt-to-move ] if 212 | ] each ; 213 | 214 | ! AI Entities 215 | : enemy-vector ( square -- vector ) 216 | [ posx>> ] keep 217 | posy>> Vector2 ; 218 | 219 | : draw-enemy ( vector -- ) 220 | offset 20.0 BLUE draw-circle-v ; 221 | 222 | : enemies ( -- squarelst ) 223 | "enemy" find-square-by-container ; 224 | 225 | : draw-enemies ( -- ) 226 | enemies 227 | [ enemy-vector draw-enemy ] each ; 228 | 229 | : enemy-direction ( square -- direction ) 230 | container>> "enemy" swap at ; 231 | 232 | : opposite-direction ( direction -- direction ) 233 | { 234 | { "up" [ "down" ] } 235 | { "down" [ "up" ] } 236 | { "left" [ "right" ] } 237 | { "right" [ "left" ] } 238 | [ drop f ] 239 | } case ; 240 | 241 | : flip-direction ( square direction -- ) 242 | opposite-direction "enemy" set-square-key ; 243 | 244 | : check-enemy-direction ( square -- ) 245 | dup enemy-direction 246 | [ dup square-coordinates ] dip 247 | which-square { } equal? 248 | [ dup enemy-direction flip-direction ] 249 | [ drop ] if ; 250 | 251 | : move-enemy ( square -- ) 252 | [ check-enemy-direction ] keep 253 | [ enemy-direction ] keep 254 | [ { "enemy" } swap suffix ] dip 255 | over second move-square ; 256 | 257 | : move-enemies ( -- ) 258 | enemies 259 | [ move-enemy ] each ; 260 | 261 | : directions ( -- directions ) 262 | { "up" "down" "left" "right" } ; 263 | 264 | : grid-enemy-map ( n -- n' ) 265 | grid-size get / 1 - random 266 | grid-size get * ; 267 | 268 | : grid-height ( -- height ) 269 | game-height grid-enemy-map ; 270 | 271 | : grid-width ( -- width ) 272 | game-width grid-enemy-map ; 273 | 274 | ! Difficulty 275 | SYMBOL: difficulty 276 | : set-difficulty ( n -- ) 277 | difficulty set ; 278 | 279 | : increase-difficulty ( -- ) 280 | difficulty get 281 | 1 + difficulty set ; 282 | 283 | : reset-difficulty ( -- ) 284 | 0 difficulty set ; 285 | 286 | ! Enemies 287 | : setup-enemy ( n -- n' ) 288 | grid-width grid-height find-square first 289 | directions random "enemy" set-square-key 290 | dup 0 = 291 | [ ] [ 1 - setup-enemy ] if ; recursive 292 | 293 | : setup-enemies ( -- ) 294 | difficulty get setup-enemy drop ; 295 | 296 | : game-over-text ( -- ) 297 | "Press Space to Continue \nEscape to Exit" 298 | 40 get-screen-height 2 / 299 | 30 BLACK draw-text ; 300 | ! States (End, Restart, Start) 301 | : draw-game-over ( -- ) 302 | begin-drawing 303 | clear-window 304 | game-over-text 305 | end-drawing ; 306 | 307 | DEFER: game-loop 308 | DEFER: setup 309 | 310 | : game-over-input ( -- ) 311 | { 312 | { KEY_SPACE "space" } 313 | } 314 | [ process-input 315 | "space" equal? 316 | [ reset-difficulty setup game-loop ] when ] each ; 317 | 318 | : game-over-screen ( -- ) 319 | [ draw-game-over 320 | game-over-input window-should-close not ] loop ; 321 | 322 | ! Collisions 323 | 324 | : detect-collision ( -- ) 325 | find-player-square 326 | enemies 327 | member? 328 | [ game-over-screen ] when ; 329 | 330 | ! Textures and scenery 331 | SYMBOL: textures 332 | : setup-textures ( -- ) 333 | { "ground.png" "sidewalk.png" "end.png" "door.png" } 334 | [ dup load-image load-texture-from-image 335 | [ { } swap suffix ] dip suffix ] 336 | map 337 | textures set ; 338 | 339 | : get-textures ( key -- texture ) 340 | textures get at ; 341 | 342 | : draw-ground ( -- ) 343 | grid get 344 | [ square-coordinates [ "ground.png" get-textures ] 2dip 345 | RAYWHITE draw-texture ] each ; 346 | 347 | : draw-sidewalks ( -- ) 348 | 0 find-square-by-x 349 | game-width find-square-by-x append 350 | [ square-coordinates [ "sidewalk.png" get-textures ] 2dip 351 | RAYWHITE draw-texture ] each ; 352 | 353 | SYMBOL: max-level 354 | 355 | : draw-ending-door ( -- ) 356 | "door.png" get-textures game-width middle-square 0 357 | RAYWHITE draw-texture ; 358 | 359 | : draw-winning-end ( -- ) 360 | difficulty get max-level get = 361 | [ 0 find-square-by-y 362 | [ square-coordinates [ "end.png" get-textures ] 2dip 363 | RAYWHITE draw-texture ] each 364 | draw-ending-door ] when ; 365 | 366 | : draw-level-num ( -- ) 367 | difficulty get number>string 368 | 10 10 20 RED draw-text ; 369 | 370 | : draw-game-won-text ( -- ) 371 | "You reached the\nPoet Society!\nSpace to play again." 372 | 40 get-screen-height 2 / 373 | 30 BLACK draw-text ; 374 | 375 | : draw-game-won ( -- ) 376 | begin-drawing 377 | clear-window 378 | draw-grid 379 | draw-ground 380 | draw-game-won-text 381 | end-drawing ; 382 | 383 | : game-won ( -- ) 384 | [ draw-game-won game-over-input 385 | window-should-close not ] loop ; 386 | 387 | : render ( -- ) 388 | begin-drawing 389 | clear-window 390 | draw-grid 391 | draw-ground 392 | draw-sidewalks 393 | draw-winning-end 394 | draw-player 395 | draw-enemies 396 | draw-level-num 397 | end-drawing ; 398 | 399 | : setup ( -- ) 400 | setup-grid 401 | setup-grid-squares 402 | setup-player 403 | setup-enemies ; 404 | 405 | : ?next-screen ( -- ) 406 | find-player-square 407 | posy>> 0 = 408 | [ difficulty get max-level get = 409 | [ game-won ] 410 | [ increase-difficulty setup game-loop ] if 411 | ] when ; 412 | 413 | : game-loop ( -- ) 414 | [ check-input render move-enemies 415 | detect-collision ?next-screen 416 | window-should-close not ] loop ; 417 | 418 | : draw-difficulty-box ( -- ) 419 | "Press 1, 2 or 3 to select\n 420 | (1) 3 Levels\n 421 | (2) 5 Levels\n 422 | (3) 10 Levels\n" 423 | 40 40 424 | 30 BLACK draw-text ; 425 | 426 | : render-difficulty-screen ( -- ) 427 | begin-drawing 428 | clear-window 429 | draw-difficulty-box 430 | end-drawing ; 431 | 432 | : difficulties ( -- n ) 433 | { { "one" 3 } { "two" 5 } { "three" 10 } } ; 434 | 435 | : check-difficulty-input ( -- ) 436 | { 437 | { KEY_ONE "one" } 438 | { KEY_TWO "two" } 439 | { KEY_THREE "three" } 440 | } [ process-input dup 441 | "" equal? 442 | [ drop ] 443 | [ difficulties at max-level set ] 444 | if ] each ; 445 | 446 | : choose-difficulty ( -- ) 447 | [ render-difficulty-screen 448 | check-difficulty-input 449 | max-level get number? not ] loop ; 450 | 451 | ! These only need to be initialized once 452 | : pre-setup ( -- ) 453 | setup-textures 454 | choose-difficulty 455 | reset-difficulty ; 456 | 457 | : reset-max-level ( -- ) 458 | f max-level set ; 459 | 460 | : main ( -- ) 461 | make-window 462 | pre-setup 463 | setup 464 | game-loop 465 | reset-max-level ! While developing you'll want this 466 | close-window ; 467 | 468 | MAIN: main 469 | -------------------------------------------------------------------------------- /examples/fof-poet/fof-poet.factor: -------------------------------------------------------------------------------- 1 | ! Copyright (C) 2019J Jack Lucas 2 | ! See http://factorcode.org/license.txt for BSD license. 3 | USING: raylib.ffi kernel sequences locals alien.enums 4 | namespaces math classes.struct accessors combinators math.ranges 5 | sequences.deep continuations assocs classes.tuple math.functions random 6 | math.parser ; 7 | IN: fof-poet 8 | 9 | TUPLE: square posx posy size container ; 10 | 11 | SYMBOL: grid-size 12 | SYMBOL: grid 13 | 14 | : make-window ( -- ) 15 | 800 600 "Mad Dash til Balderdash" init-window 16 | 10 set-target-fps ; 17 | 18 | : clear-window ( -- ) 19 | RAYWHITE clear-background ; 20 | 21 | ! The Grid 22 | : setup-grid ( -- ) 23 | 40 grid-size set ; 24 | 25 | ! Remove the points that would lie outside the canvas 26 | : game-height ( -- height ) 27 | get-screen-height grid-size get - ; 28 | 29 | : game-width ( -- width ) 30 | get-screen-width grid-size get - ; 31 | 32 | : make-grid-line ( x range -- list ) 33 | [ length ] keep 34 | [ swap ] dip 35 | zip 36 | [ [ grid-size get H{ } clone square boa ] with-datastack ] map ; 37 | 38 | : setup-grid-squares ( -- ) 39 | 0 game-width grid-size get 40 | [ 0 game-height grid-size get make-grid-line ] 41 | map flatten grid set ; 42 | 43 | : draw-square ( grid-square -- ) 44 | tuple-slots 45 | [ drop dup BLACK draw-rectangle-lines ] 46 | with-datastack drop ; 47 | 48 | : draw-grid ( -- ) 49 | grid get [ draw-square ] each ; 50 | 51 | ! Grid Utilities 52 | 53 | ! Extract the square coordinates 54 | : with-square-coordinates ( square -- x y square ) 55 | [ posx>> ] keep 56 | [ posy>> ] keep ; 57 | 58 | : square-coordinates ( square -- x y ) 59 | with-square-coordinates drop ; 60 | 61 | ! Check if a pair (x,y) matches a square 62 | : coordinates=? ( square x y -- bool ) 63 | [ square-coordinates ] 2dip 64 | swap [ = ] dip 65 | swap [ = ] dip and ; 66 | 67 | : find-square ( x y -- square ) 68 | [ coordinates=? ] 2curry grid get 69 | swap 70 | filter ; 71 | 72 | : container=? ( square name -- bool ) 73 | swap container>> at* nip ; 74 | 75 | : find-square-by-container ( name -- square ) 76 | [ container=? ] curry 77 | grid get swap 78 | filter ; 79 | 80 | : find-square-by-coordinate ( n -- squares ) 81 | grid get swap filter ; inline 82 | 83 | ! Find all squares that have a certain x or y 84 | : find-square-by-y ( y -- squares ) 85 | [ swap posy>> = ] curry 86 | find-square-by-coordinate ; 87 | 88 | : find-square-by-x ( x -- squares ) 89 | [ swap posx>> = ] curry 90 | find-square-by-coordinate ; 91 | 92 | : set-square-key ( square val key -- ) 93 | pick container>> set-at drop ; 94 | 95 | : remove-square-key ( square key -- ) 96 | swap container>> delete-at ; 97 | 98 | : get-square-key ( square key -- val ) 99 | swap container>> at* drop ; 100 | 101 | : center-square ( -- x ) 102 | grid-size get 2 / ; 103 | 104 | : offset ( vector2 -- vector2' ) 105 | [ x>> center-square + ] keep 106 | y>> center-square + 107 | Vector2 ; 108 | 109 | : middle-square ( n -- n' ) 110 | grid-size get / 2 / floor 111 | grid-size get * ; 112 | 113 | ! Player 114 | : find-player-square ( -- square ) 115 | "player" find-square-by-container first ; 116 | 117 | : player-vector ( -- vector ) 118 | find-player-square 119 | [ posx>> ] keep 120 | posy>> Vector2 ; 121 | 122 | : draw-player ( -- ) 123 | player-vector offset 124 | 20.0 RED draw-circle-v ; 125 | 126 | : setup-player ( -- ) 127 | t "player" 128 | game-width middle-square 129 | game-height find-square first container>> 130 | set-at ; 131 | 132 | ! Movement Words 133 | 134 | ! Square2 Doesnt exist stay 135 | ! Square2 occupied with same tag Stay 136 | ! Else move to square2 137 | DEFER: opposite-direction 138 | 139 | : change-former ( square tag -- ) 140 | dup first [ second opposite-direction ] dip 141 | set-square-key ; 142 | 143 | : change-later ( square tag -- ) 144 | dup first pick swap get-square-key 145 | opposite-direction [ first ] dip 146 | swap set-square-key ; 147 | 148 | :: ?change-direction ( square square2 tag -- ) 149 | square2 tag first get-square-key 150 | tag second opposite-direction equal? 151 | [ square tag change-former 152 | square2 tag change-later ] when ; 153 | 154 | :: square-decision ( tag square square2 -- ) 155 | square2 tag first container=? 156 | [ square square2 tag ?change-direction ] 157 | [ square2 tag second tag first set-square-key 158 | square tag first remove-square-key ] if ; 159 | 160 | : pick-square ( tag square square2 -- ) 161 | dup empty? 162 | [ 3drop ] 163 | [ first square-decision ] if ; 164 | 165 | : up-square ( x y -- square ) 166 | grid-size get - find-square ; 167 | 168 | : down-square ( x y -- square ) 169 | grid-size get + find-square ; 170 | 171 | : left-square ( x y -- square ) 172 | [ grid-size get - ] dip find-square ; 173 | 174 | : right-square ( x y -- square ) 175 | [ grid-size get + ] dip find-square ; 176 | 177 | : which-square ( x y direction -- square' ) 178 | { 179 | { "up" [ up-square ] } 180 | { "down" [ down-square ] } 181 | { "left" [ left-square ] } 182 | { "right" [ right-square ] } 183 | } case ; 184 | 185 | : move-square ( tag square direction -- ) 186 | [ dup square-coordinates ] dip 187 | which-square 188 | pick-square ; 189 | 190 | : process-input ( keypair -- result/bool ) 191 | dup first ! Get the key 192 | enum>number is-key-down 193 | [ second ] [ drop "" ] if ; 194 | 195 | : player-inputs ( -- inputs ) 196 | { 197 | { KEY_W "up" } 198 | { KEY_S "down" } 199 | { KEY_A "left" } 200 | { KEY_D "right" } 201 | } ; 202 | 203 | : attempt-to-move ( direction -- ) 204 | { "player" t } find-player-square rot move-square ; 205 | 206 | : check-input ( -- ) 207 | player-inputs 208 | [ process-input dup 209 | "" equal? 210 | [ drop ] 211 | [ attempt-to-move ] if 212 | ] each ; 213 | 214 | ! AI Entities 215 | : enemy-vector ( square -- vector ) 216 | [ posx>> ] keep 217 | posy>> Vector2 ; 218 | 219 | : draw-enemy ( vector -- ) 220 | offset 20.0 BLUE draw-circle-v ; 221 | 222 | : enemies ( -- squarelst ) 223 | "enemy" find-square-by-container ; 224 | 225 | : draw-enemies ( -- ) 226 | enemies 227 | [ enemy-vector draw-enemy ] each ; 228 | 229 | : enemy-direction ( square -- direction ) 230 | container>> "enemy" swap at ; 231 | 232 | : opposite-direction ( direction -- direction ) 233 | { 234 | { "up" [ "down" ] } 235 | { "down" [ "up" ] } 236 | { "left" [ "right" ] } 237 | { "right" [ "left" ] } 238 | [ drop f ] 239 | } case ; 240 | 241 | : flip-direction ( square direction -- ) 242 | opposite-direction "enemy" set-square-key ; 243 | 244 | : check-enemy-direction ( square -- ) 245 | dup enemy-direction 246 | [ dup square-coordinates ] dip 247 | which-square { } equal? 248 | [ dup enemy-direction flip-direction ] 249 | [ drop ] if ; 250 | 251 | : move-enemy ( square -- ) 252 | [ check-enemy-direction ] keep 253 | [ enemy-direction ] keep 254 | [ { "enemy" } swap suffix ] dip 255 | over second move-square ; 256 | 257 | : move-enemies ( -- ) 258 | enemies 259 | [ move-enemy ] each ; 260 | 261 | : directions ( -- directions ) 262 | { "up" "down" "left" "right" } ; 263 | 264 | : grid-enemy-map ( n -- n' ) 265 | grid-size get / 1 - random 266 | grid-size get * ; 267 | 268 | : grid-height ( -- height ) 269 | game-height grid-enemy-map ; 270 | 271 | : grid-width ( -- width ) 272 | game-width grid-enemy-map ; 273 | 274 | ! Difficulty 275 | SYMBOL: difficulty 276 | : set-difficulty ( n -- ) 277 | difficulty set ; 278 | 279 | : increase-difficulty ( -- ) 280 | difficulty get 281 | 1 + difficulty set ; 282 | 283 | : reset-difficulty ( -- ) 284 | 0 difficulty set ; 285 | 286 | ! Enemies 287 | : setup-enemy ( n -- n' ) 288 | grid-width grid-height find-square first 289 | directions random "enemy" set-square-key 290 | dup 0 = 291 | [ ] [ 1 - setup-enemy ] if ; recursive 292 | 293 | : setup-enemies ( -- ) 294 | difficulty get setup-enemy drop ; 295 | 296 | : game-over-text ( -- ) 297 | "Press Space to Continue \nEscape to Exit" 298 | 40 get-screen-height 2 / 299 | 30 BLACK draw-text ; 300 | ! States (End, Restart, Start) 301 | : draw-game-over ( -- ) 302 | begin-drawing 303 | clear-window 304 | game-over-text 305 | end-drawing ; 306 | 307 | DEFER: game-loop 308 | DEFER: setup 309 | 310 | : game-over-input ( -- ) 311 | { 312 | { KEY_SPACE "space" } 313 | } 314 | [ process-input 315 | "space" equal? 316 | [ reset-difficulty setup game-loop ] when ] each ; 317 | 318 | : game-over-screen ( -- ) 319 | [ draw-game-over 320 | game-over-input window-should-close not ] loop ; 321 | 322 | ! Collisions 323 | 324 | : detect-collision ( -- ) 325 | find-player-square 326 | enemies 327 | member? 328 | [ game-over-screen ] when ; 329 | 330 | ! Textures and scenery 331 | SYMBOL: textures 332 | : setup-textures ( -- ) 333 | { "ground.png" "sidewalk.png" "end.png" "door.png" } 334 | [ dup load-image load-texture-from-image 335 | [ { } swap suffix ] dip suffix ] 336 | map 337 | textures set ; 338 | 339 | : get-textures ( key -- texture ) 340 | textures get at ; 341 | 342 | : draw-ground ( -- ) 343 | grid get 344 | [ square-coordinates [ "ground.png" get-textures ] 2dip 345 | RAYWHITE draw-texture ] each ; 346 | 347 | : draw-sidewalks ( -- ) 348 | 0 find-square-by-x 349 | game-width find-square-by-x append 350 | [ square-coordinates [ "sidewalk.png" get-textures ] 2dip 351 | RAYWHITE draw-texture ] each ; 352 | 353 | SYMBOL: max-level 354 | 355 | : draw-ending-door ( -- ) 356 | "door.png" get-textures game-width middle-square 0 357 | RAYWHITE draw-texture ; 358 | 359 | : draw-winning-end ( -- ) 360 | difficulty get max-level get = 361 | [ 0 find-square-by-y 362 | [ square-coordinates [ "end.png" get-textures ] 2dip 363 | RAYWHITE draw-texture ] each 364 | draw-ending-door ] when ; 365 | 366 | : draw-level-num ( -- ) 367 | difficulty get number>string 368 | 10 10 20 RED draw-text ; 369 | 370 | : draw-game-won-text ( -- ) 371 | "You reached the\nPoet Society!\nSpace to play again." 372 | 40 get-screen-height 2 / 373 | 30 BLACK draw-text ; 374 | 375 | : draw-game-won ( -- ) 376 | begin-drawing 377 | clear-window 378 | draw-grid 379 | draw-ground 380 | draw-game-won-text 381 | end-drawing ; 382 | 383 | : game-won ( -- ) 384 | [ draw-game-won game-over-input 385 | window-should-close not ] loop ; 386 | 387 | : render ( -- ) 388 | begin-drawing 389 | clear-window 390 | draw-grid 391 | draw-ground 392 | draw-sidewalks 393 | draw-winning-end 394 | draw-player 395 | draw-enemies 396 | draw-level-num 397 | end-drawing ; 398 | 399 | : setup ( -- ) 400 | setup-grid 401 | setup-grid-squares 402 | setup-player 403 | setup-enemies ; 404 | 405 | : ?next-screen ( -- ) 406 | find-player-square 407 | posy>> 0 = 408 | [ difficulty get max-level get = 409 | [ game-won ] 410 | [ increase-difficulty setup game-loop ] if 411 | ] when ; 412 | 413 | : game-loop ( -- ) 414 | [ check-input render move-enemies 415 | detect-collision ?next-screen 416 | window-should-close not ] loop ; 417 | 418 | : draw-difficulty-box ( -- ) 419 | "Press 1, 2 or 3 to select\n 420 | (1) 3 Levels\n 421 | (2) 5 Levels\n 422 | (3) 10 Levels\n" 423 | 40 40 424 | 30 BLACK draw-text ; 425 | 426 | : render-difficulty-screen ( -- ) 427 | begin-drawing 428 | clear-window 429 | draw-difficulty-box 430 | end-drawing ; 431 | 432 | : difficulties ( -- n ) 433 | { { "one" 3 } { "two" 5 } { "three" 10 } } ; 434 | 435 | : check-difficulty-input ( -- ) 436 | { 437 | { KEY_ONE "one" } 438 | { KEY_TWO "two" } 439 | { KEY_THREE "three" } 440 | } [ process-input dup 441 | "" equal? 442 | [ drop ] 443 | [ difficulties at max-level set ] 444 | if ] each ; 445 | 446 | : choose-difficulty ( -- ) 447 | [ render-difficulty-screen 448 | check-difficulty-input 449 | max-level get number? not ] loop ; 450 | 451 | ! These only need to be initialized once 452 | : pre-setup ( -- ) 453 | setup-textures 454 | choose-difficulty 455 | reset-difficulty ; 456 | 457 | : reset-max-level ( -- ) 458 | f max-level set ; 459 | 460 | : main ( -- ) 461 | make-window 462 | pre-setup 463 | setup 464 | game-loop 465 | reset-max-level ! While developing you'll want this 466 | close-window ; 467 | 468 | MAIN: main 469 | -------------------------------------------------------------------------------- /raylib/ffi/ffi.factor: -------------------------------------------------------------------------------- 1 | ! Copyright (C) 2019 Jack Lucas 2 | ! See http://factorcode.org/license.txt for BSD license. 3 | ! These should be complete bindings to the Raylib library. (v2.5) 4 | ! Most of the comments are included from the original header 5 | ! for your convenience. 6 | USING: accessors alien alien.c-types alien.enums alien.libraries 7 | alien.syntax classes.struct combinators kernel quotations system 8 | vocabs ; 9 | IN: raylib.ffi 10 | << 11 | "raylib" { 12 | { [ os windows? ] [ "raylib.dll" ] } 13 | { [ os macosx? ] [ "libraylib.dylib" ] } 14 | { [ os unix? ] [ "libraylib.so" ] } 15 | } cond cdecl add-library 16 | 17 | "raylib" deploy-library 18 | >> 19 | 20 | LIBRARY: raylib 21 | 22 | ! Structs ---------------------------------------------------------------- 23 | STRUCT: Color 24 | { r uchar } 25 | { g uchar } 26 | { b uchar } 27 | { a uchar } ; 28 | 29 | STRUCT: Vector2 30 | { x float } 31 | { y float } ; 32 | 33 | STRUCT: Vector3 34 | { x float } 35 | { y float } 36 | { z float } ; 37 | 38 | STRUCT: Vector4 39 | { x float } 40 | { y float } 41 | { z float } 42 | { w float } ; 43 | TYPEDEF: Vector4 Quaternion ! Same as Vector4 44 | 45 | STRUCT: Rectangle 46 | { x float } 47 | { y float } 48 | { width float } 49 | { height float } ; 50 | 51 | ! Image type, bpp always RGBA (32bit) 52 | ! NOTE: Data Stored in CPU Memory (RAM) 53 | STRUCT: Image 54 | { data void* } ! Image raw data 55 | { width int } ! Image base width 56 | { height int } ! Image base height 57 | { mipmaps int } ! Mipmap levels, 1 by default 58 | { format int } ; ! Data format (PixelFormat type) 59 | 60 | STRUCT: Texture2D 61 | { id uint } ! OpenGL Texture ID 62 | { width int } ! Texture Base Width 63 | { height int } ! Texture Base Height 64 | { mipmaps int } ! Mipmap Levels, 1 by default 65 | { format int } ; ! Data Format (PixelFormat type) 66 | TYPEDEF: Texture2D Texture ! Texture type same as Texture2D 67 | TYPEDEF: Texture2D TextureCubemap ! Actually same as Texture2D 68 | 69 | STRUCT: RenderTexture2D 70 | { id uint } ! OpenGL Framebuffer Object (FBO) id 71 | { texture Texture2D } ! Color buffer attachment texture 72 | { depth Texture2D } ; ! Depth buffer attachment texture 73 | 74 | TYPEDEF: RenderTexture2D RenderTexture ! Same as RenderTexture2D 75 | 76 | STRUCT: NPatchInfo 77 | { sourceRec Rectangle } 78 | { left int } 79 | { top int } 80 | { right int } 81 | { bottom int } 82 | { type int } ; 83 | 84 | STRUCT: CharInfo 85 | { value int } ! Character value (Unicode) 86 | { offsetX int } ! Character offset X when drawing 87 | { offsetY int } ! Character offset Y when drawing 88 | { advanceX int } ! Character advance position X 89 | { image Image } ; ! Character image data 90 | 91 | STRUCT: Font 92 | { baseSize int } ! Base Size (default chars height) 93 | { charsCount int } ! Number of characters 94 | { texture Texture2D } ! Characters texture atlas 95 | { recs Rectangle* } ! Characters rectangles in texture 96 | { chars CharInfo* } ; ! Characters info data 97 | 98 | STRUCT: Camera3D 99 | { position Vector3 } ! Camera postion 100 | { target Vector3 } ! Camera target it looks-at 101 | { up Vector3 } ! Camera up vector (rotation over its axis) 102 | { fovy float } ! camera field-of-view apperature in Y (degrees) in perspective, used as near plane width in orthographic 103 | { type int } ; ! Camera type, defines projection type: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC 104 | 105 | STRUCT: Camera2D 106 | { offset Vector2 } ! Camera offset (displacement from target) 107 | { target Vector2 } ! Camera target (rotation and zoom origin) 108 | { rotation float } ! Camera rotation in degrees 109 | { zoom float } ; ! Camera zoom (scaling), should be 1.0f by default 110 | TYPEDEF: Camera3D Camera ! Default to 3D Camera 111 | 112 | STRUCT: BoundingBox 113 | { min Vector3 } ! Minimum vertex box-corner 114 | { max Vector3 } ; ! Maximum vertex box-corner 115 | 116 | STRUCT: Mesh 117 | { vertexCount int } ! Number of verticles stored in arrays 118 | { triangleCount int } ! Number of triangles stored (indexed or not ) 119 | { verticles float* } ! Vertex position (XYZ - 3 components per vertex) 120 | { texcoords float* } ! Vertex texture coordinates (UV - 2 components per vertex ) 121 | { texcoords2 float* } ! Vertex second texture coordinates (useful for lightmaps) 122 | { normals float* } ! Vertex normals (XYZ - 3 components per vertex) 123 | { tangents float* } ! Vertex tangents (XYZW - 4 components per vertex ) 124 | { colors uchar* } ! Vertex colors (RGBA - 4 components per vertex) 125 | { indices ushort* } ! Vertex indices (in case vertex data comes indexed) 126 | { animVerticles float* } 127 | { animNormals float* } 128 | { boneIds int* } 129 | { boneWeights float* } 130 | { vaoId uint } ! OpenGL Vertex Array Object id 131 | { vboId uint* } ; ! OpenGL Vertex Buffer Objects id (7 types of vertex data) 132 | 133 | 134 | STRUCT: Shader 135 | { id uint } ! Shader program id 136 | { locs int* } ; ! Shader locations array 137 | ! This is dependant on MAX_SHADER_LOCATIONS. Default is 32 138 | 139 | STRUCT: MaterialMap 140 | { texture Texture2D } ! Material map Texture 141 | { color Color } ! Material map color 142 | { value float } ; ! Material map value 143 | 144 | STRUCT: Material 145 | { shader Shader } ! Material shader 146 | { maps MaterialMap* } ! Material maps. Uses MAX_MATERIAL_MAPS. 147 | { params float* } ; ! Material generic parameters (if required) 148 | 149 | STRUCT: Transform 150 | { translation Vector3 } 151 | { rotation Quaternion } 152 | { scale Vector3 } ; 153 | 154 | STRUCT: BoneInfo 155 | { name char[32] } ! Bone Name 156 | { parent int } ; ! Bone parent 157 | 158 | ! Matrix type (OpenGL style 4x4 - right handed, column major) 159 | STRUCT: Matrix 160 | { m0 float } { m4 float } { m8 float } { m12 float } 161 | { m1 float } { m5 float } { m9 float } { m13 float } 162 | { m2 float } { m6 float } { m10 float } { m14 float } 163 | { m3 float } { m7 float } { m11 float } { m15 float } ; 164 | 165 | STRUCT: Model 166 | { transform Matrix } 167 | { meshCount int } 168 | { materialCount int } 169 | { meshes Mesh* } 170 | { materials Material* } 171 | { meshMaterial int* } 172 | { boneCount int } 173 | { bones BoneInfo* } 174 | { bindPose Transform* } ; 175 | 176 | STRUCT: ModelAnimation 177 | { boneCount int } 178 | { bones BoneInfo* } 179 | { frameCount int } 180 | { framePoses Transform** } ; 181 | 182 | STRUCT: Ray 183 | { position Vector3 } ! Ray position (origin) 184 | { direction Vector3 } ; ! Ray direction 185 | 186 | STRUCT: RayHitInfo 187 | { hit bool } ! Did the ray hit something? 188 | { distance float } ! Distance to nearest hit 189 | { position Vector3 } ! Position of nearest hit 190 | { normal Vector3 } ; ! Surface normal of hit 191 | 192 | STRUCT: Wave 193 | { sampleCount uint } ! Number of samples 194 | { sampleRate uint } ! Frequency (samples per second) 195 | { sampleSize uint } ! Bit depth (bits per sample): 8,16,32 196 | { channels uint } ! Number of channels (1-mono, 2-stereo) 197 | { data void* } ; ! Buffer data pointer 198 | 199 | STRUCT: AudioStream 200 | { buffer void* } ! Pointer to internal data used by the audio system 201 | { sampleRate uint } ! Frequency (samples per second) 202 | { sampleSize uint } ! Bit depth (bits per sample): 8, 16, 32 (24 not supported) 203 | { channels uint } ; ! Number of channels (1-mono, 2-stereo) 204 | 205 | STRUCT: Sound 206 | { stream AudioStream } ! Audio stream 207 | { sampleCount uint } ; ! Total number of samples 208 | 209 | STRUCT: Music 210 | { stream AudioStream } ! Audio stream 211 | { sampleCount uint } ! Total number of samples 212 | { looping bool } ! Music looping enable 213 | { ctxType int } ! Type of music context (audio filetype) 214 | { ctxData void* } ; ! Audio context data, depends on type 215 | 216 | 217 | STRUCT: VrDeviceInfo 218 | { hResolution int } ! HMD horizontal resolution in pixels 219 | { vResolution int } ! HMD verticle resolution in pixels 220 | { hScreenSize float } ! HMD horizontal size in meters 221 | { vScreenSize float } ! HMD verticle size in meters 222 | { vScreenCenter float } ! HMD screen center in meters 223 | { eyeToScreenDistance float } ! HMD distance between eye and display in meters 224 | { lensSeparationDistance float } ! HMD lens separation distance in meters 225 | { interpupillaryDistance float } ! HMD IPD in meters 226 | { lensDistortionValues float[4] } ! HMD lens distortion constant parameters 227 | { chromaAbCorrection float[4] } ; ! HMD chromatic abberation correction parameters 228 | 229 | ! Enumerations --------------------------------------------------------- 230 | 231 | ! Putting some of the #define's as enums. 232 | ENUM: raylibConfigFlags 233 | { FLAG_SHOW_LOGO 1 } ! Set to show raylib logo at startup 234 | { FLAG_FULLSCREEN_MODE 2 } ! Set to run program in fullscreen 235 | { FLAG_WINDOW_RESIZABLE 4 } ! Set to allow resizable window 236 | { FLAG_WINDOW_UNDECORATED 8 } ! Set to disable window decoration (frame and buttons) 237 | { FLAG_WINDOW_TRANSPARENT 16 } ! Set to allow transparent window 238 | { FLAG_WINDOW_HIDDEN 128 } 239 | { FLAG_MSAA_4X_HINT 32 } ! Set to try enabling MSAA 4X 240 | { FLAG_VSYNC_HINT 64 } ; ! Set to try enabling V-Sync on GPU 241 | 242 | ENUM: KeyboardFunctionKeys 243 | { KEY_SPACE 32 } 244 | { KEY_ESCAPE 256 } 245 | { KEY_ENTER 257 } 246 | { KEY_TAB 258 } 247 | { KEY_BACKSPACE 259 } 248 | { KEY_INSERT 260 } 249 | { KEY_DELETE 261 } 250 | { KEY_RIGHT 262 } 251 | { KEY_LEFT 263 } 252 | { KEY_DOWN 264 } 253 | { KEY_UP 265 } 254 | { KEY_PAGE_UP 266 } 255 | { KEY_PAGE_DOWN 267 } 256 | { KEY_HOME 268 } 257 | { KEY_END 269 } 258 | { KEY_CAPS_LOCK 280 } 259 | { KEY_SCROLL_LOCK 281 } 260 | { KEY_NUM_LOCK 282 } 261 | { KEY_PRINT_SCREEN 283 } 262 | { KEY_PAUSE 284 } 263 | { KEY_F1 290 } 264 | { KEY_F2 291 } 265 | { KEY_F3 292 } 266 | { KEY_F4 293 } 267 | { KEY_F5 294 } 268 | { KEY_F6 295 } 269 | { KEY_F7 296 } 270 | { KEY_F8 297 } 271 | { KEY_F9 298 } 272 | { KEY_F10 299 } 273 | { KEY_F11 300 } 274 | { KEY_F12 301 } 275 | { KEY_LEFT_SHIFT 340 } 276 | { KEY_LEFT_CONTROL 341 } 277 | { KEY_LEFT_ALT 342 } 278 | { KEY_RIGHT_SHIFT 344 } 279 | { KEY_RIGHT_CONTROL 345 } 280 | { KEY_RIGHT_ALT 346 } 281 | { KEY_GRAVE 96 } 282 | { KEY_SLASH 47 } 283 | { KEY_BACKSLASH 92 } ; 284 | 285 | ENUM: KeyboardAlphaNumericKeys 286 | { KEY_ZERO 48 } 287 | { KEY_ONE 49 } 288 | { KEY_TWO 50 } 289 | { KEY_THREE 51 } 290 | { KEY_FOUR 52 } 291 | { KEY_FIVE 53 } 292 | { KEY_SIX 54 } 293 | { KEY_SEVEN 55 } 294 | { KEY_EIGHT 56 } 295 | { KEY_NINE 57 } 296 | { KEY_A 65 } 297 | { KEY_B 66 } 298 | { KEY_C 67 } 299 | { KEY_D 68 } 300 | { KEY_E 69 } 301 | { KEY_F 70 } 302 | { KEY_G 71 } 303 | { KEY_H 72 } 304 | { KEY_I 73 } 305 | { KEY_J 74 } 306 | { KEY_K 75 } 307 | { KEY_L 76 } 308 | { KEY_M 77 } 309 | { KEY_N 78 } 310 | { KEY_O 79 } 311 | { KEY_P 80 } 312 | { KEY_Q 81 } 313 | { KEY_R 82 } 314 | { KEY_S 83 } 315 | { KEY_T 84 } 316 | { KEY_U 85 } 317 | { KEY_V 86 } 318 | { KEY_W 87 } 319 | { KEY_X 88 } 320 | { KEY_Y 89 } 321 | { KEY_Z 90 } ; 322 | 323 | : LIGHTGRAY ( -- Color ) 200 200 200 255 Color ; ! Light Gray 324 | : GRAY ( -- Color ) 130 130 130 255 Color ; ! Gray 325 | : DARKGRAY ( -- Color ) 80 80 80 255 Color ; ! Dark Gray 326 | : YELLOW ( -- Color ) 253 249 0 255 Color ; ! Yellow 327 | : GOLD ( -- Color ) 255 203 0 255 Color ; ! Gold 328 | : ORANGE ( -- Color ) 255 161 0 255 Color ; ! Orange 329 | : PINK ( -- Color ) 255 109 194 255 Color ; ! Pink 330 | : RED ( -- Color ) 230 41 55 255 Color ; ! Red 331 | : MAROON ( -- Color ) 190 33 55 255 Color ; ! Maroon 332 | : GREEN ( -- Color ) 0 228 48 255 Color ; ! Green 333 | : LIME ( -- Color ) 0 158 47 255 Color ; ! Lime 334 | : DARKGREEN ( -- Color ) 0 117 44 255 Color ; ! Dark Green 335 | : SKYBLUE ( -- Color ) 102 191 255 255 Color ; ! Sky Blue 336 | : BLUE ( -- Color ) 0 121 241 255 Color ; ! Blue 337 | : DARKBLUE ( -- Color ) 0 82 172 255 Color ; ! Dark Blue 338 | : PURPLE ( -- Color ) 200 122 255 255 Color ; ! Purple 339 | : VIOLET ( -- Color ) 135 60 190 255 Color ; ! Violet 340 | : DARKPURPLE ( -- Color ) 112 31 126 255 Color ; ! Dark Purple 341 | : BEIGE ( -- Color ) 211 176 131 255 Color ; ! Beige 342 | : BROWN ( -- Color ) 127 106 79 255 Color ; ! Brown 343 | : DARKBROWN ( -- Color ) 76 63 47 255 Color ; ! Dark Brown 344 | 345 | : WHITE ( -- Color ) 255 255 255 255 Color ; ! White 346 | : BLACK ( -- Color ) 0 0 0 255 Color ; ! Black 347 | : BLANK ( -- Color ) 0 0 0 0 Color ; ! Blank (Transparent) 348 | : MAGENTA ( -- Color ) 255 0 255 255 Color ; ! Magenta 349 | : RAYWHITE ( -- Color ) 245 245 245 255 Color ; ! My own White (raylib logo) 350 | 351 | ! Leaving Android Enum out because Factor doesn't run on it 352 | ENUM: MouseButtons 353 | MOUSE_LEFT_BUTTON 354 | MOUSE_RIGHT_BUTTON 355 | MOUSE_MIDDLE_BUTTON ; 356 | 357 | ENUM: GamepadNumber 358 | GAMEPAD_PLAYER1 359 | GAMEPAD_PLAYER2 360 | GAMEPAD_PLAYER3 361 | GAMEPAD_PLAYER4 ; 362 | 363 | ! Trace log type 364 | ENUM: LogType 365 | { LOG_INFO 1 } 366 | { LOG_WARNING 2 } 367 | { LOG_ERROR 4 } 368 | { LOG_DEBUG 8 } 369 | { LOG_OTHER 16 } ; 370 | 371 | ! Shader location point type 372 | ENUM: ShaderLocationIndex 373 | LOC_VERTEX_POSITION 374 | LOC_VERTEX_TEXCOORD01 375 | LOC_VERTEX_TEXCOORD02 376 | LOC_VERTEX_NORMAL 377 | LOC_VERTEX_TANGENT 378 | LOC_VERTEX_COLOR 379 | LOC_MATRIX_MVP 380 | LOC_MATRIX_MODEL 381 | LOC_MATRIX_VIEW 382 | LOC_MATRIX_PROJECTION 383 | LOC_VECTOR_VIEW 384 | LOC_COLOR_DIFFUSE 385 | LOC_COLOR_SPECULAR 386 | LOC_COLOR_AMBIENT 387 | LOC_MAP_ALBEDO 388 | LOC_MAP_METALNESS 389 | LOC_MAP_NORMAL 390 | LOC_MAP_ROUGHNESS 391 | LOC_MAP_OCCLUSION 392 | LOC_MAP_EMISSION 393 | LOC_MAP_HEIGHT 394 | LOC_MAP_CUBEMAP 395 | LOC_MAP_IRRADIANCE 396 | LOC_MAP_PREFILTER 397 | LOC_MAP_BRDF ; 398 | 399 | ENUM: ShaderUniformDataType 400 | UNIFORM_FLOAT 401 | UNIFORM_VEC2 402 | UNIFORM_VEC3 403 | UNIFORM_VEC4 404 | UNIFORM_INT 405 | UNIFORM_IVEC2 406 | UNIFORM_IVEC3 407 | UNIFORM_IVEC4 408 | UNIFORM_SAMPLER2D ; 409 | 410 | ! Material map type 411 | ENUM: TexmapIndex 412 | MAP_ALBEDO 413 | MAP_METALNESS 414 | MAP_NORMAL 415 | MAP_ROUGHNESS 416 | MAP_OCCLUSION 417 | MAP_EMISSION 418 | MAP_HEIGHT 419 | MAP_CUBEMAP 420 | MAP_IRRADIANCE 421 | MAP_PREFILTER 422 | MAP_BRDF ; 423 | 424 | ! Pixel formats 425 | ! NOTE: Support depends on OpenGL version and platform 426 | ENUM: PixelFormat 427 | { UNCOMPRESSED_GRAYSCALE 1 } ! 8 bit per pixel (no alpha) 428 | UNCOMPRESSED_GRAY_ALPHA ! 8*2 bpp (2 channels) 429 | UNCOMPRESSED_R5G6B5 ! 16 bpp 430 | UNCOMPRESSED_R8G8B8 ! 24 bpp 431 | UNCOMPRESSED_R5G5B5A1 ! 16 bpp (1 bit alpha) 432 | UNCOMPRESSED_R4G4B4A4 ! 16 bpp (4 bit alpha) 433 | UNCOMPRESSED_R8G8B8A8 ! 32 bpp 434 | UNCOMPRESSED_R32 ! 32 bpp (1 channel - float) 435 | UNCOMPRESSED_R32G32B32 ! 32*3 bpp (3 channels - float) 436 | UNCOMPRESSED_R32G32B32A32 ! 32*4 bpp (4 channels - float) 437 | COMPRESSED_DXT1_RGB ! 4 bpp (no alpha) 438 | COMPRESSED_DXT1_RGBA ! 4 bpp (1 bit alpha) 439 | COMPRESSED_DXT3_RGBA ! 8 bpp 440 | COMPRESSED_DXT5_RGBA ! 8 bpp 441 | COMPRESSED_ETC1_RGB ! 4 bpp 442 | COMPRESSED_ETC2_RGB ! 4 bpp 443 | COMPRESSED_ETC2_EAC_RGBA ! 8 bpp 444 | COMPRESSED_PVRT_RGB ! 4 bpp 445 | COMPRESSED_PVRT_RGBA ! 4 bpp 446 | COMPRESSED_ASTC_4x4_RGBA ! 8 bpp 447 | COMPRESSED_ASTC_8x8_RGBA ; ! 2 bpp 448 | 449 | ! Texture parameters: filter mode 450 | ! NOTE 1: Filtering considers mipmaps if available in the texture 451 | ! NOTE 2: Filter is accordingly set for minification and magnification 452 | ENUM: TextureFilterMode 453 | FILTER_POINT ! No filter just pixel aproximation 454 | FILTER_BILINEAR ! Linear filtering 455 | FILTER_TRILINEAR ! Trilinear filtering (linear with mipmaps) 456 | FILTER_ANISOTROPIC_4X ! Anisotropic filtering 4x 457 | FILTER_ANISOTROPIC_8X ! Anisotropic filtering 8x 458 | FILTER_ANISOTROPIC_16X ; ! Anisotropic filtering 16x 459 | 460 | ! Texture parameters: wrap mode 461 | ENUM: TextureWrapMode 462 | WRAP_REPEAT 463 | WRAP_CLAMP 464 | WRAP_MIRROR_REPEAT 465 | WRAP_MIRROR_CLAMP ; 466 | 467 | ! Color blending modes (pre-defined) 468 | ENUM: BlendMode 469 | BLEND_ALPHA 470 | BLEND_ADDITIVE 471 | BLEND_MULTIPLIED ; 472 | 473 | ! Gestures type 474 | ! NOTE: IT could be used as flags to enable only some gestures 475 | ENUM: Gestures 476 | { GESTURE_NONE 0 } 477 | { GESTURE_TAP 1 } 478 | { GESTURE_DOUBLETAP 2 } 479 | { GESTURE_HOLD 4 } 480 | { GESTURE_DRAG 8 } 481 | { GESTURE_SWIPE_RIGHT 16 } 482 | { GESTURE_SWIPE_LEFT 32 } 483 | { GESTURE_SWIPE_UP 64 } 484 | { GESTURE_SWIPE_DOWN 128 } 485 | { GESTURE_PINCH_IN 256 } 486 | { GESTURE_PINCH_OUT 512 } ; 487 | 488 | ! Camera system modes 489 | ENUM: CameraMode 490 | CAMERA_CUSTOM 491 | CAMERA_FREE 492 | CAMERA_ORBITAL 493 | CAMERA_FIRST_PERSON 494 | CAMERA_THIRD_PERSON ; 495 | 496 | ! Camera projection modes 497 | ENUM: CameraType 498 | CAMERA_PERSPECTIVE 499 | CAMERA_ORTHOGRAPHIC ; 500 | 501 | ENUM: NPatchType 502 | NPT_9PATCH 503 | NPT_3PATCH_VERTICAL 504 | NPT_3PATCH_HORIZONTAL ; 505 | 506 | ! Head Mounted Display devices 507 | ENUM: VrDeviceType 508 | HMD_DEFAULT_DEVICE 509 | HMD_OCULUS_RIFT_DK2 510 | HMD_OCULUS_RIFT_CV1 511 | HMD_OCULUS_GO 512 | HMD_VALVE_HTC_VIVE 513 | HMD_SONY_PSVR ; 514 | 515 | ! Functions --------------------------------------------------------------- 516 | 517 | ! Windowing Functions 518 | FUNCTION-ALIAS: init-window void InitWindow ( int width, int height, c-string title ) ! Initialize window and OpenGL context 519 | FUNCTION-ALIAS: close-window void CloseWindow ( ) ! Close window and unload OpenGL context 520 | FUNCTION-ALIAS: is-window-ready bool IsWindowReady ( ) ! Check if window has been initialized successfully 521 | FUNCTION-ALIAS: window-should-close bool WindowShouldClose ( ) ! Check if KEY_ESCAPE pressed or Close icon pressed 522 | FUNCTION-ALIAS: is-window-minimized bool IsWindowMinimized ( ) ! Check if window has been minimized ( or lost focus ) 523 | FUNCTION-ALIAS: is-window-resized bool IsWindowResized ( ) ! Check if window has been resized 524 | FUNCTION-ALIAS: is-window-hidden bool IsWindowHidden ( ) ! Check if window is currently hidden 525 | FUNCTION-ALIAS: unhide-window void UnhideWindow ( ) ! Show the window 526 | FUNCTION-ALIAS: hide-window void HideWindow ( ) ! Hide the window 527 | FUNCTION-ALIAS: toggle-fullscreen void ToggleFullscreen ( ) ! Toggle fullscreen mode ( only PLATFORM_DESKTOP ) 528 | FUNCTION-ALIAS: set-window-icon void SetWindowIcon ( Image image ) ! Set icon for window ( only PLATFORM_DESKTOP ) 529 | FUNCTION-ALIAS: set-window-title void SetWindowTitle ( c-string title ) ! Set title for window ( only PLATFORM_DESKTOP ) 530 | FUNCTION-ALIAS: set-window-position void SetWindowPosition ( int x, int y ) ! Set window position on screen ( only PLATFORM_DESKTOP ) 531 | FUNCTION-ALIAS: set-window-monitor void SetWindowMonitor ( int monitor ) ! Set monitor for the current window ( fullscreen mode ) 532 | FUNCTION-ALIAS: set-window-min-size void SetWindowMinSize ( int width, int height ) ! Set window minimum dimensions ( for FLAG_WINDOW_RESIZABLE ) 533 | FUNCTION-ALIAS: set-window-size void SetWindowSize ( int width, int height ) ! Set window dimensions 534 | FUNCTION-ALIAS: get-screen-width int GetScreenWidth ( ) ! Get current screen width 535 | FUNCTION-ALIAS: get-screen-height int GetScreenHeight ( ) ! Get current screen height 536 | FUNCTION-ALIAS: get-window-handle void* GetWindowHandle ( ) ! Get native window handle 537 | FUNCTION-ALIAS: get-monitor-count int GetMonitorCount ( ) ! Get number of connected monitors 538 | FUNCTION-ALIAS: get-monitor-width int GetMonitorWidth ( int monitor ) ! Get primary monitor width 539 | FUNCTION-ALIAS: get-monitor-height int GetMonitorHeight ( int monitor ) ! Get primary monitor height 540 | FUNCTION-ALIAS: get-monitor-physical-width int GetMonitorPhysicalWidth ( int monitor ) ! Get primary monitor physical width in millimetres 541 | FUNCTION-ALIAS: get-monitor-physical-height int GetMonitorPhysicalHeight ( int monitor ) ! Get primary monitor physical height in millimetres 542 | FUNCTION-ALIAS: get-monitor-name c-string GetMonitorName ( int monitor ) ! Get the human-readable, UTF-8 encoded name of the primary monitor 543 | FUNCTION-ALIAS: get-clipboard-text c-string GetClipboardText ( ) ! Get clipboard text content 544 | FUNCTION-ALIAS: set-clipboard-text void SetClipboardText ( c-string text ) ! Set clipboard text content 545 | 546 | ! 2.5 -> 3.5 Additions 547 | FUNCTION-ALIAS: get-window-scale-dpi Vector2 GetWindowScaleDPI ( ) ! Get window scale DPI factor 548 | FUNCTION-ALIAS: is-window-maximized bool IsWindowMaximized ( ) ! Check if window is currently maximized ( only PLATFORM_DESKTOP) 549 | FUNCTION-ALIAS: is-window-focused bool IsWindowFocused ( ) ! Check if window is currently focused ( only PLATFORM_DESKTOP) 550 | FUNCTION-ALIAS: is-window-state bool IsWindowState ( uint flag ) ! Check if one specific window flag is enabled 551 | FUNCTION-ALIAS: set-window-state void SetWindowState ( uint flags ) ! Set window configuration state using flags 552 | FUNCTION-ALIAS: clear-window-state void ClearWindowState ( uint flags ) ! Clear window configuration state flags 553 | FUNCTION-ALIAS: maximized-window void MaximizeWindow ( ) ! Set window state: maximized, if resizable ( only PLATFORM_DESKTOP) 554 | FUNCTION-ALIAS: minimize-window void MinimizeWindow ( ) ! Set window state: minimized, if resizable ( only PLATFORM_DESKTOP) 555 | FUNCTION-ALIAS: restore-window void RestoreWindow ( ) ! Set window state: not minimized/maximized ( only PLATFORM_DESKTOP) 556 | FUNCTION-ALIAS: get-current-monitor int GetCurrentMonitor ( ) ! Get current connected monitor 557 | FUNCTION-ALIAS: get-monitor-position Vector2 GetMonitorPosition ( int monitor ) ! Get specified monitor position 558 | FUNCTION-ALIAS: get-monitor-refresh-rate int GetMonitorRefreshRate ( int monitor ) ! Get specified monitor refresh rate 559 | FUNCTION-ALIAS: get-window-position Vector2 GetWindowPosition ( ) ! Get window position XY on monitor 560 | 561 | 562 | ! Cursor-related functions 563 | FUNCTION-ALIAS: show-cursor void ShowCursor ( ) ! Shows cursor 564 | FUNCTION-ALIAS: hide-cursor void HideCursor ( ) ! Hides cursor 565 | FUNCTION-ALIAS: is-cursor-hidden bool IsCursorHidden ( ) ! Check if cursor is not visible 566 | FUNCTION-ALIAS: enable-cursor void EnableCursor ( ) ! Enables cursor ( unlock cursor ) 567 | FUNCTION-ALIAS: disable-cursor void DisableCursor ( ) ! Disables cursor ( lock cursor ) 568 | FUNCTION-ALIAS: is-cursor-on-screen bool IsCursorOnScreen ( ) ! Check if cursor is on the current screen. 569 | 570 | ! Drawing-related functions 571 | FUNCTION-ALIAS: clear-background void ClearBackground ( Color color ) ! Set background color ( framebuffer clear color ) 572 | FUNCTION-ALIAS: begin-drawing void BeginDrawing ( ) ! Setup canvas ( framebuffer ) to start drawing 573 | FUNCTION-ALIAS: end-drawing void EndDrawing ( ) ! End canvas drawing and swap buffers ( double buffering ) 574 | FUNCTION-ALIAS: begin-mode-2d void BeginMode2D ( Camera2D camera ) ! Initialize 2D mode with custom camera ( 2D ) 575 | FUNCTION-ALIAS: end-mode-2d void EndMode2D ( ) ! Ends 2D mode with custom camera 576 | FUNCTION-ALIAS: begin-mode-3d void BeginMode3D ( Camera3D camera ) ! Initializes 3D mode with custom camera ( 3D ) 577 | FUNCTION-ALIAS: end-mode-3d void EndMode3D ( ) ! Ends 3D mode and returns to default 2D orthographic mode 578 | FUNCTION-ALIAS: begin-texture-mode void BeginTextureMode ( RenderTexture2D target ) ! Initializes render texture for drawing 579 | FUNCTION-ALIAS: end-texture-mode void EndTextureMode ( ) ! Ends drawing to render texture 580 | FUNCTION-ALIAS: begin-scissor-mode void BeginScissorMode ( int x, int y, int width, int height ) ! Begin scissor mode ( define screen area for following drawing) 581 | FUNCTION-ALIAS: end-scissor-mode void EndScissorMode ( ) ! End scissor mode 582 | 583 | ! Screen-space-related functions 584 | FUNCTION-ALIAS: get-mouse-ray Ray GetMouseRay ( Vector2 mousePosition, Camera camera ) ! Returns a ray trace from mouse position 585 | FUNCTION-ALIAS: get-world-to-screen Vector2 GetWorldToScreen ( Vector3 position, Camera camera ) ! Returns the screen space position for a 3d world space position 586 | FUNCTION-ALIAS: get-camera-matrix Matrix GetCameraMatrix ( Camera camera ) ! Returns camera transform matrix ( view matrix ) 587 | 588 | ! Timing-related functions 589 | FUNCTION-ALIAS: set-target-fps void SetTargetFPS ( int fps ) ! Set target FPS ( maximum ) 590 | FUNCTION-ALIAS: get-fps int GetFPS ( ) ! Returns current FPS 591 | FUNCTION-ALIAS: get-frame-time float GetFrameTime ( ) ! Returns time in seconds for last frame drawn 592 | FUNCTION-ALIAS: get-time double GetTime ( ) ! Returns elapsed time in seconds since InitWindow () 593 | 594 | ! Misc. functions 595 | FUNCTION-ALIAS: set-config-flags void SetConfigFlags ( uchar flags ) ! Setup window configuration flags (view FLAGS) 596 | FUNCTION-ALIAS: set-trace-log-level void SetTraceLogLevel ( int logType ) ! Set the current threshold (minimum) log level 597 | FUNCTION-ALIAS: set-trace-log-exit void SetTraceLogExit ( int logType ) ! Set the exit threshold (minimum) log level 598 | FUNCTION-ALIAS: take-screenshot void TakeScreenshot ( c-string fileName ) ! Takes a screenshot of current screen ( saved a .png ) 599 | FUNCTION-ALIAS: get-random-value int GetRandomValue ( int min, int max ) ! Returns a random value between min and max ( both included ) 600 | 601 | ! Files management functions 602 | FUNCTION-ALIAS: load-file-data c-string LoadFileData ( c-string fileName, uint* bytesRead ) ! Load file data as byte array ( read) 603 | FUNCTION-ALIAS: unload-file-data void UnloadFileData ( c-string data ) ! Unload file data allocated by LoadFileData ( ) 604 | FUNCTION-ALIAS: save-file-data bool SaveFileData ( c-string fileName, void *data, uint bytesToWrite ) ! Save data to file from byte array ( write), returns true on success 605 | FUNCTION-ALIAS: load-file-text c-string LoadFileText ( c-string fileName ) ! Load text data from file ( read), returns a '\0' terminated string 606 | FUNCTION-ALIAS: unload-file-text void UnloadFileText ( c-string text ) ! Unload file text data allocated by LoadFileText ( ) 607 | FUNCTION-ALIAS: save-file-text bool SaveFileText ( c-string fileName, c-string text ) ! Save text data to file ( write), string must be '\0' terminated, returns true on success 608 | FUNCTION-ALIAS: file-exists bool FileExists ( c-string fileName ) ! Check if file exists 609 | FUNCTION-ALIAS: directory-exists bool DirectoryExists ( c-string dirPath ) ! Check if a directory path exists 610 | FUNCTION-ALIAS: is-file-extension bool IsFileExtension ( c-string fileName, c-string ext ) ! Check file extension ( including point: .png, .wav) 611 | FUNCTION-ALIAS: get-file-extension c-string GetFileExtension ( c-string fileName ) ! Get pointer to extension for a filename string ( including point: ".png") 612 | FUNCTION-ALIAS: get-file-name c-string GetFileName ( c-string filePath ) ! Get pointer to filename for a path string 613 | FUNCTION-ALIAS: get-file-name-without-ext c-string GetFileNameWithoutExt ( c-string filePath ) ! Get filename string without extension ( uses static string) 614 | FUNCTION-ALIAS: get-directory-path c-string GetDirectoryPath ( c-string filePath ) ! Get full path for a given fileName with path ( uses static string) 615 | FUNCTION-ALIAS: get-prev-directory-path c-string GetPrevDirectoryPath ( c-string dirPath ) ! Get previous directory path for a given path ( uses static string) 616 | FUNCTION-ALIAS: get-working-directory c-string GetWorkingDirectory ( ) ! Get current working directory ( uses static string) 617 | FUNCTION-ALIAS: get-directory-files char** GetDirectoryFiles ( c-string dirPath, int *count ) ! Get filenames in a directory path ( memory should be freed) 618 | FUNCTION-ALIAS: clear-directory-files void ClearDirectoryFiles ( ) ! Clear directory files paths buffers ( free memory) 619 | FUNCTION-ALIAS: change-directory bool ChangeDirectory ( c-string dir ) ! Change working directory, return true on success 620 | FUNCTION-ALIAS: is-file-dropped bool IsFileDropped ( ) ! Check if a file has been dropped into window 621 | FUNCTION-ALIAS: get-dropped-files char** GetDroppedFiles ( int *count ) ! Get dropped files names ( memory should be freed) 622 | FUNCTION-ALIAS: clear-dropped-files void ClearDroppedFiles ( ) ! Clear dropped files paths buffer ( free memory) 623 | FUNCTION-ALIAS: get-file-mod-time long GetFileModTime ( c-string fileName ) ! Get file modification time ( last write time) 624 | 625 | ! Persistent storage management 626 | FUNCTION-ALIAS: storage-save-value void StorageSaveValue ( int position, int value ) ! Save integer value to storage file ( to defined position ) 627 | FUNCTION-ALIAS: storage-load-value int StorageLoadValue ( int position ) ! Load integer value from storage file ( from defined position ) 628 | FUNCTION-ALIAS: open-url void OpenURL ( c-string url ) ! Open URL with default system browser ( if available ) 629 | ! ------------------------------------------------------------------------------------ 630 | ! Input Handling Functions ( Module: core ) 631 | ! ------------------------------------------------------------------------------------ 632 | 633 | ! Input-related functions: keyboard 634 | FUNCTION-ALIAS: is-key-pressed bool IsKeyPressed ( int key ) ! Detect if a key has been pressed once 635 | FUNCTION-ALIAS: is-key-down bool IsKeyDown ( int key ) ! Detect if a key is being pressed 636 | FUNCTION-ALIAS: is-key-released bool IsKeyReleased ( int key ) ! Detect if a key has been released once 637 | FUNCTION-ALIAS: is-key-up bool IsKeyUp ( int key ) ! Detect if a key is NOT being pressed 638 | FUNCTION-ALIAS: get-key-pressed int GetKeyPressed ( ) ! Get latest key pressed 639 | FUNCTION-ALIAS: set-exit-key void SetExitKey ( int key ) ! Set a custom key to exit program ( default is ESC ) 640 | 641 | ! Input-related functions: gamepads 642 | FUNCTION-ALIAS: is-gamepad-available bool IsGamepadAvailable ( int gamepad ) ! Detect if a gamepad is available 643 | FUNCTION-ALIAS: is-gamepad-name bool IsGamepadName ( int gamepad, c-string name ) ! Check gamepad name ( if available ) 644 | FUNCTION-ALIAS: get-gamepad-name c-string GetGamepadName ( int gamepad ) ! Return gamepad internal name id 645 | FUNCTION-ALIAS: is-gamepad-button-pressed bool IsGamepadButtonPressed ( int gamepad, int button ) ! Detect if a gamepad button has been pressed once 646 | FUNCTION-ALIAS: is-gamepad-button-down bool IsGamepadButtonDown ( int gamepad, int button ) ! Detect if a gamepad button is being pressed 647 | FUNCTION-ALIAS: is-gamepad-button-released bool IsGamepadButtonReleased ( int gamepad, int button ) ! Detect if a gamepad button has been released once 648 | FUNCTION-ALIAS: is-gamepad-button-up bool IsGamepadButtonUp ( int gamepad, int button ) ! Detect if a gamepad button is NOT being pressed 649 | FUNCTION-ALIAS: get-gamepad-button-pressed int GetGamepadButtonPressed ( ) ! Get the last gamepad button pressed 650 | FUNCTION-ALIAS: get-gamepad-axis-count int GetGamepadAxisCount ( int gamepad ) ! Return gamepad axis count for a gamepad 651 | FUNCTION-ALIAS: get-gamepad-axis-movement float GetGamepadAxisMovement ( int gamepad, int axis ) ! Return axis movement value for a gamepad axis 652 | 653 | ! Input-related functions: mouse 654 | FUNCTION-ALIAS: is-mouse-button-pressed bool IsMouseButtonPressed ( int button ) ! Detect if a mouse button has been pressed once 655 | FUNCTION-ALIAS: is-mouse-button-down bool IsMouseButtonDown ( int button ) ! Detect if a mouse button is being pressed 656 | FUNCTION-ALIAS: is-mouse-button-released bool IsMouseButtonReleased ( int button ) ! Detect if a mouse button has been released once 657 | FUNCTION-ALIAS: is-mouse-button-up bool IsMouseButtonUp ( int button ) ! Detect if a mouse button is NOT being pressed 658 | FUNCTION-ALIAS: get-mouse-x int GetMouseX ( ) ! Returns mouse position X 659 | FUNCTION-ALIAS: get-mouse-y int GetMouseY ( ) ! Returns mouse position Y 660 | FUNCTION-ALIAS: get-mouse-position Vector2 GetMousePosition ( ) ! Returns mouse position XY 661 | FUNCTION-ALIAS: set-mouse-position void SetMousePosition ( int x, int y ) ! Set mouse position XY 662 | FUNCTION-ALIAS: set-mouse-offset void SetMouseOffset ( int offsetX, int offsetY ) ! Set mouse offset 663 | FUNCTION-ALIAS: set-mouse-scale void SetMouseScale ( float scale ) ! Set mouse scaling 664 | FUNCTION-ALIAS: get-mouse-wheel-move int GetMouseWheelMove ( ) ! Returns mouse wheel movement Y 665 | 666 | ! Input-related functions: touch 667 | FUNCTION-ALIAS: get-touch-x int GetTouchX ( ) ! Returns touch position X for touch point 0 ( relative to screen size ) 668 | FUNCTION-ALIAS: get-touch-y int GetTouchY ( ) ! Returns touch position Y for touch point 0 ( relative to screen size ) 669 | FUNCTION-ALIAS: get-touch-position Vector2 GetTouchPosition ( int index ) ! Returns touch position XY for a touch point index ( relative to screen size ) 670 | 671 | ! ------------------------------------------------------------------------------------ 672 | ! Gestures and Touch Handling Functions ( Module: gestures ) 673 | ! ------------------------------------------------------------------------------------ 674 | FUNCTION-ALIAS: set-gestures-enabled void SetGesturesEnabled ( uint gestureFlags ) ! Enable a set of gestures using flags 675 | FUNCTION-ALIAS: is-gesture-detected bool IsGestureDetected ( int gesture ) ! Check if a gesture have been detected 676 | FUNCTION-ALIAS: get-gesture-detected int GetGestureDetected ( ) ! Get latest detected gesture 677 | FUNCTION-ALIAS: get-touch-points-count int GetTouchPointsCount ( ) ! Get touch points count 678 | FUNCTION-ALIAS: get-gesture-hold-duration float GetGestureHoldDuration ( ) ! Get gesture hold time in milliseconds 679 | FUNCTION-ALIAS: get-gesture-drag-vector Vector2 GetGestureDragVector ( ) ! Get gesture drag vector 680 | FUNCTION-ALIAS: get-gesture-drag-angle float GetGestureDragAngle ( ) ! Get gesture drag angle 681 | FUNCTION-ALIAS: get-gesture-pinch-vector Vector2 GetGesturePinchVector ( ) ! Get gesture pinch delta 682 | FUNCTION-ALIAS: get-gesture-pinch-angle float GetGesturePinchAngle ( ) ! Get gesture pinch angle 683 | 684 | ! ------------------------------------------------------------------------------------ 685 | ! Camera System Functions ( Module: camera ) 686 | ! ------------------------------------------------------------------------------------ 687 | FUNCTION-ALIAS: set-camera-mode void SetCameraMode ( Camera camera, int mode ) ! Set camera mode ( multiple camera modes available ) 688 | FUNCTION-ALIAS: update-camera void UpdateCamera ( Camera* camera ) ! Update camera position for selected mode 689 | FUNCTION-ALIAS: set-camera-pan-control void SetCameraPanControl ( int panKey ) ! Set camera pan key to combine with mouse movement ( free camera ) 690 | FUNCTION-ALIAS: set-camera-alt-control void SetCameraAltControl ( int altKey ) ! Set camera alt key to combine with mouse movement ( free camera ) 691 | FUNCTION-ALIAS: set-camera-smooth-zoom-control void SetCameraSmoothZoomControl ( int szKey ) ! Set camera smooth zoom key to combine with mouse ( free camera ) 692 | FUNCTION-ALIAS: set-camera-move-controls void SetCameraMoveControls ( int frontKey, int backKey, int rightKey, int leftKey, int upKey, int downKey ) ! Set camera move controls ( 1st person and 3rd person cameras ) 693 | 694 | ! ------------------------------------------------------------------------------------ 695 | ! Basic Shapes Drawing Functions ( Module: shapes ) 696 | ! ------------------------------------------------------------------------------------ 697 | 698 | ! Basic shapes drawing functions 699 | FUNCTION-ALIAS: draw-pixel void DrawPixel ( int posX, int posY, Color color ) ! Draw a pixel 700 | FUNCTION-ALIAS: draw-pixel-lv void DrawPixelV ( Vector2 position, Color color ) ! Draw a pixel ( Vector version ) 701 | FUNCTION-ALIAS: draw-line void DrawLine ( int startPosX, int startPosY, int endPosX, int endPosY, Color color ) ! Draw a line 702 | FUNCTION-ALIAS: draw-line-v void DrawLineV ( Vector2 startPos, Vector2 endPos, Color color ) ! Draw a line ( Vector version ) 703 | FUNCTION-ALIAS: draw-line-ex void DrawLineEx ( Vector2 startPos, Vector2 endPos, float thick, Color color ) ! Draw a line defining thickness 704 | FUNCTION-ALIAS: draw-line-bezier void DrawLineBezier ( Vector2 startPos, Vector2 endPos, float thick, Color color ) ! Draw a line using cubic-bezier curves in-out 705 | FUNCTION-ALIAS: draw-circle void DrawCircle ( int centerX, int centerY, float radius, Color color ) ! Draw a color-filled circle 706 | FUNCTION-ALIAS: draw-circle-sector void DrawCircleSector ( Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color ) ! Draw a piece of a circle 707 | FUNCTION-ALIAS: draw-circle-sector-lines void DrawCircleSectorLines ( Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color ) ! Draw circle sector outline 708 | FUNCTION-ALIAS: draw-circle-gradient void DrawCircleGradient ( int centerX, int centerY, float radius, Color color1, Color color2 ) ! Draw a gradient-filled circle 709 | FUNCTION-ALIAS: draw-circle-v void DrawCircleV ( Vector2 center, float radius, Color color ) ! Draw a color-filled circle ( Vector version ) 710 | FUNCTION-ALIAS: draw-circle-lines void DrawCircleLines ( int centerX, int centerY, float radius, Color color ) ! Draw circle outline 711 | FUNCTION-ALIAS: draw-ring void DrawRing ( Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color ) ! Draw ring 712 | FUNCTION-ALIAS: draw-ring-lines void DrawRingLines ( Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color ) ! Draw ring outline 713 | FUNCTION-ALIAS: draw-rectangle void DrawRectangle ( int posX, int posY, int width, int height, Color color ) ! Draw a color-filled rectangle 714 | FUNCTION-ALIAS: draw-rectangle-v void DrawRectangleV ( Vector2 position, Vector2 size, Color color ) ! Draw a color-filled rectangle ( Vector version ) 715 | FUNCTION-ALIAS: draw-rectangle-rec void DrawRectangleRec ( Rectangle rec, Color color ) ! Draw a color-filled rectangle 716 | FUNCTION-ALIAS: draw-rectangle-pro void DrawRectanglePro ( Rectangle rec, Vector2 origin, float rotation, Color color ) ! Draw a color-filled rectangle with pro parameters 717 | FUNCTION-ALIAS: draw-rectangle-gradient-v void DrawRectangleGradientV ( int posX, int posY, int width, int height, Color color1, Color color2 ) ! Draw a vertical-gradient-filled rectangle 718 | FUNCTION-ALIAS: draw-rectangle-graident-h void DrawRectangleGradientH ( int posX, int posY, int width, int height, Color color1, Color color2 ) ! Draw a horizontal-gradient-filled rectangle 719 | FUNCTION-ALIAS: draw-rectangle-gradient-ex void DrawRectangleGradientEx ( Rectangle rec, Color col1, Color col2, Color col3, Color col4 ) ! Draw a gradient-filled rectangle with custom vertex colors 720 | FUNCTION-ALIAS: draw-rectangle-lines void DrawRectangleLines ( int posX, int posY, int width, int height, Color color ) ! Draw rectangle outline 721 | FUNCTION-ALIAS: draw-rectangle-lines-ex void DrawRectangleLinesEx ( Rectangle rec, int lineThick, Color color ) ! Draw rectangle outline with extended parameters 722 | FUNCTION-ALIAS: draw-rectangle-rounded void DrawRectangleRounded ( Rectangle rec, float roundness, int segments, Color color ) ! Draw rectangle with rounded edges 723 | FUNCTION-ALIAS: draw-rectangle-rounded-lines void DrawRectangleRoundedLines ( Rectangle rec, float roundness, int segments, int lineThick, Color color ) ! Draw rectangle with rounded edges outline 724 | FUNCTION-ALIAS: draw-triangle void DrawTriangle ( Vector2 v1, Vector2 v2, Vector2 v3, Color color ) ! Draw a color-filled triangle 725 | FUNCTION-ALIAS: draw-triangle-lines void DrawTriangleLines ( Vector2 v1, Vector2 v2, Vector2 v3, Color color ) ! Draw triangle outline 726 | FUNCTION-ALIAS: draw-poly void DrawPoly ( Vector2 center, int sides, float radius, float rotation, Color color ) ! Draw a regular polygon ( Vector version ) 727 | FUNCTION-ALIAS: draw-poly-ex void DrawPolyEx ( Vector2* points, int numPoints, Color color ) ! Draw a closed polygon defined by points 728 | FUNCTION-ALIAS: draw-poly-ex-lines void DrawPolyExLines ( Vector2* points, int numPoints, Color color ) ! Draw polygon lines 729 | FUNCTION-ALIAS: set-shapes-texture void SetShapesTexture ( Texture2D texture, Rectangle source ) ! Define default texture used to draw shapes 730 | 731 | ! Basic shapes collision detection functions 732 | FUNCTION-ALIAS: check-collision-recs bool CheckCollisionRecs ( Rectangle rec1, Rectangle rec2 ) ! Check collision between two rectangles 733 | FUNCTION-ALIAS: check-collision-circles bool CheckCollisionCircles ( Vector2 center1, float radius1, Vector2 center2, float radius2 ) ! Check collision between two circles 734 | FUNCTION-ALIAS: check-collision-circle-rec bool CheckCollisionCircleRec ( Vector2 center, float radius, Rectangle rec ) ! Check collision between circle and rectangle 735 | FUNCTION-ALIAS: get-collision-rec Rectangle GetCollisionRec ( Rectangle rec1, Rectangle rec2 ) ! Get collision rectangle for two rectangles collision 736 | FUNCTION-ALIAS: check-collision-point-rec bool CheckCollisionPointRec ( Vector2 point, Rectangle rec ) ! Check if point is inside rectangle 737 | FUNCTION-ALIAS: check-collision-point-circle bool CheckCollisionPointCircle ( Vector2 point, Vector2 center, float radius ) ! Check if point is inside circle 738 | FUNCTION-ALIAS: check-collision-point-triangle bool CheckCollisionPointTriangle ( Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3 ) ! Check if point is inside a triangle 739 | 740 | ! ------------------------------------------------------------------------------------ 741 | ! Texture Loading and Drawing Functions ( Module: textures ) 742 | ! ------------------------------------------------------------------------------------ 743 | 744 | ! Image/Texture2D data loading/unloading/saving functions 745 | FUNCTION-ALIAS: load-image Image LoadImage ( c-string fileName ) ! Load image from file into CPU memory ( RAM ) 746 | FUNCTION-ALIAS: load-image-raw Image LoadImageRaw ( c-string fileName, int width, int height, int format, int headerSize ) ! Load image from RAW file data 747 | FUNCTION-ALIAS: export-image void ExportImage ( c-string fileName, Image image ) ! Export image as a PNG file 748 | FUNCTION-ALIAS: export-image-as-code void ExportImageAsCode ( Image image, c-string fileName ) ! Export image as code file defining an array of bytes 749 | FUNCTION-ALIAS: load-texture Texture2D LoadTexture ( c-string fileName ) ! Load texture from file into GPU memory ( VRAM ) 750 | FUNCTION-ALIAS: load-texture-from-image Texture2D LoadTextureFromImage ( Image image ) ! Load texture from image data 751 | FUNCTION-ALIAS: load-render-texture RenderTexture2D LoadRenderTexture ( int width, int height ) ! Load texture for rendering ( framebuffer ) 752 | FUNCTION-ALIAS: unload-image void UnloadImage ( Image image ) ! Unload image from CPU memory ( RAM ) 753 | FUNCTION-ALIAS: unload-texture void UnloadTexture ( Texture2D texture ) ! Unload texture from GPU memory ( VRAM ) 754 | FUNCTION-ALIAS: unload-render-texture void UnloadRenderTexture ( RenderTexture2D target ) ! Unload render texture from GPU memory ( VRAM ) 755 | FUNCTION-ALIAS: get-image-data Color* GetImageData ( Image image ) ! Get pixel data from image as a Color struct array 756 | FUNCTION-ALIAS: get-image-data-normalized Vector4* GetImageDataNormalized ( Image image ) ! Get pixel data from image as Vector4 array ( float normalized ) 757 | FUNCTION-ALIAS: get-pixel-datasize int GetPixelDataSize ( int width, int height, int format ) ! Get pixel data size in bytes ( image or texture ) 758 | FUNCTION-ALIAS: get-texture-data Image GetTextureData ( Texture2D texture ) ! Get pixel data from GPU texture and return an Image 759 | FUNCTION-ALIAS: get-screen-data Image GetScreenData ( ) ! Get pixel data from screen buffer and return an Image ( screenshot ) 760 | FUNCTION-ALIAS: update-texture void UpdateTexture ( Texture2D texture, void* pixels ) ! Update GPU texture with new data 761 | ! FIX: Const Void * 762 | 763 | ! Image manipulation functions 764 | FUNCTION-ALIAS: image-copy Image ImageCopy ( Image image ) ! Create an image duplicate ( useful for transformations ) 765 | FUNCTION-ALIAS: image-to-pot void ImageToPOT ( Image* image, Color fillColor ) ! Convert image to POT ( power-of-two ) 766 | FUNCTION-ALIAS: image-format void ImageFormat ( Image* image, int newFormat ) ! Convert image data to desired format 767 | FUNCTION-ALIAS: image-alpha-mask void ImageAlphaMask ( Image* image, Image alphaMask ) ! Apply alpha mask to image 768 | FUNCTION-ALIAS: image-alpha-clear void ImageAlphaClear ( Image* image, Color color, float threshold ) ! Clear alpha channel to desired color 769 | FUNCTION-ALIAS: image-alpha-crop void ImageAlphaCrop ( Image* image, float threshold ) ! Crop image depending on alpha value 770 | FUNCTION-ALIAS: image-alpha-premultiply void ImageAlphaPremultiply ( Image* image ) ! Premultiply alpha channel 771 | FUNCTION-ALIAS: image-crop void ImageCrop ( Image* image, Rectangle crop ) ! Crop an image to a defined rectangle 772 | FUNCTION-ALIAS: image-resize void ImageResize ( Image* image, int newWidth, int newHeight ) ! Resize image ( bilinear filtering ) 773 | FUNCTION-ALIAS: image-resize-nn void ImageResizeNN ( Image* image, int newWidth, int newHeight ) ! Resize image ( Nearest-Neighbor scaling algorithm ) 774 | FUNCTION-ALIAS: image-resize-canvas void ImageResizeCanvas ( Image* image, int newWidth, int newHeight, int offsetX, int offsetY, Color color ) ! Resize canvas and fill with color 775 | FUNCTION-ALIAS: image-mipmaps void ImageMipmaps ( Image* image ) ! Generate all mipmap levels for a provided image 776 | FUNCTION-ALIAS: image-dither void ImageDither ( Image* image, int rBpp, int gBpp, int bBpp, int aBpp ) ! Dither image data to 16bpp or lower ( Floyd-Steinberg dithering ) 777 | FUNCTION-ALIAS: image-text Image ImageText ( c-string text, int fontSize, Color color ) ! Create an image from text ( default font ) 778 | FUNCTION-ALIAS: image-text-ex Image ImageTextEx ( Font font, c-string text, float fontSize, float spacing, Color tint ) ! Create an image from text ( custom sprite font ) 779 | FUNCTION-ALIAS: image-draw-rectangle void ImageDrawRectangle ( Image* dst, Vector2 position, Rectangle rec, Color color ) ! Draw rectangle within an image 780 | FUNCTION-ALIAS: image-draw-rectangle-lines void ImageDrawRectangleLines ( Image *dst, Rectangle rec, int thick, Color color ) ! Draw rectangle lines within an image 781 | FUNCTION-ALIAS: image-flip-vertical void ImageFlipVertical ( Image* image ) ! Flip image vertically 782 | FUNCTION-ALIAS: image-flip-horizontal void ImageFlipHorizontal ( Image* image ) ! Flip image horizontally 783 | FUNCTION-ALIAS: image-rotate-cw void ImageRotateCW ( Image* image ) ! Rotate image clockwise 90deg 784 | FUNCTION-ALIAS: image-rotate-ccw void ImageRotateCCW ( Image* image ) ! Rotate image counter-clockwise 90deg 785 | FUNCTION-ALIAS: image-color-tint void ImageColorTint ( Image* image, Color color ) ! Modify image color: tint 786 | FUNCTION-ALIAS: image-color-invert void ImageColorInvert ( Image* image ) ! Modify image color: invert 787 | FUNCTION-ALIAS: image-color-grayscale void ImageColorGrayscale ( Image* image ) ! Modify image color: grayscale 788 | FUNCTION-ALIAS: image-color-contrast void ImageColorContrast ( Image* image, float contrast ) ! Modify image color: contrast ( -100 to 100 ) 789 | FUNCTION-ALIAS: image-color-brightness void ImageColorBrightness ( Image* image, int brightness ) ! Modify image color: brightness ( -255 to 255 ) 790 | FUNCTION-ALIAS: image-color-replace void ImageColorReplace ( Image* image, Color color, Color replace ) ! Modify image color: replace color 791 | 792 | ! Image generation functions 793 | FUNCTION-ALIAS: gen-image-color Image GenImageColor ( int width, int height, Color color ) ! Generate image: plain color 794 | FUNCTION-ALIAS: gen-image-gradient-v Image GenImageGradientV ( int width, int height, Color top, Color bottom ) ! Generate image: vertical gradient 795 | FUNCTION-ALIAS: get-image-gradient-h Image GenImageGradientH ( int width, int height, Color left, Color right ) ! Generate image: horizontal gradient 796 | FUNCTION-ALIAS: gen-image-gradient-radial Image GenImageGradientRadial ( int width, int height, float density, Color inner, Color outer ) ! Generate image: radial gradient 797 | FUNCTION-ALIAS: get-image-checked Image GenImageChecked ( int width, int height, int checksX, int checksY, Color col1, Color col2 ) ! Generate image: checked 798 | FUNCTION-ALIAS: get-image-white-noise Image GenImageWhiteNoise ( int width, int height, float factor ) ! Generate image: white noise 799 | FUNCTION-ALIAS: get-image-perlin-noise Image GenImagePerlinNoise ( int width, int height, int offsetX, int offsetY, float scale ) ! Generate image: perlin noise 800 | FUNCTION-ALIAS: get-image-cellular Image GenImageCellular ( int width, int height, int tileSize ) ! Generate image: cellular algorithm. Bigger tileSize means bigger cells 801 | 802 | ! Texture2D configuration functions 803 | FUNCTION-ALIAS: gen-texture-mipmaps void GenTextureMipmaps ( Texture2D* texture ) ! Generate GPU mipmaps for a texture 804 | FUNCTION-ALIAS: set-texture-filter void SetTextureFilter ( Texture2D texture, int filterMode ) ! Set texture scaling filter mode 805 | FUNCTION-ALIAS: set-texture-wrap void SetTextureWrap ( Texture2D texture, int wrapMode ) ! Set texture wrapping mode 806 | 807 | ! Texture2D drawing functions 808 | FUNCTION-ALIAS: draw-texture void DrawTexture ( Texture2D texture, int posX, int posY, Color tint ) ! Draw a Texture2D 809 | FUNCTION-ALIAS: draw-texture-v void DrawTextureV ( Texture2D texture, Vector2 position, Color tint ) ! Draw a Texture2D with position defined as Vector2 810 | FUNCTION-ALIAS: draw-texture-ex void DrawTextureEx ( Texture2D texture, Vector2 position, float rotation, float scale, Color tint ) ! Draw a Texture2D with extended parameters 811 | FUNCTION-ALIAS: draw-texture-rec void DrawTextureRec ( Texture2D texture, Rectangle sourceRec, Vector2 position, Color tint ) ! Draw a part of a texture defined by a rectangle 812 | FUNCTION-ALIAS: draw-texture-quad void DrawTextureQuad ( Texture2D texture, Vector2 tiling, Vector2 offset, Rectangle quad, Color tint ) ! Draw texture quad with tiling and offset parameters 813 | FUNCTION-ALIAS: draw-texture-pro void DrawTexturePro ( Texture2D texture, Rectangle sourceRec, Rectangle destRec, Vector2 origin, float rotation, Color tint ) ! Draw a part of a texture defined by a rectangle with 'pro' parameters 814 | FUNCTION-ALIAS: draw-texture-n-patch void DrawTextureNPatch ( Texture2D texture, NPatchInfo nPatchInfo, Rectangle destRec, Vector2 origin, float rotation, Color tint ) ! Draws a texture ( or part of it ) that stretches or shrinks nicely 815 | ! ------------------------------------------------------------------------------------ 816 | ! Font Loading and Text Drawing Functions ( Module: text ) 817 | ! ------------------------------------------------------------------------------------ 818 | 819 | ! Font loading/unloading functions 820 | FUNCTION-ALIAS: get-font-default Font GetFontDefault ( ) ! Get the default Font 821 | FUNCTION-ALIAS: load-font Font LoadFont ( c-string fileName ) ! Load font from file into GPU memory ( VRAM ) 822 | FUNCTION-ALIAS: load-font-ex Font LoadFontEx ( c-string fileName, int fontSize, int charsCount, int* fontChars ) ! Load font from file with extended parameters 823 | FUNCTION-ALIAS: load-font-data CharInfo* LoadFontData ( c-string fileName, int fontSize, int* fontChars, int charsCount, bool sdf ) ! Load font data for further use 824 | FUNCTION-ALIAS: gen-image-font-atlas Image GenImageFontAtlas ( CharInfo* chars, int fontSize, int charsCount, int padding, int packMethod ) ! Generate image font atlas using chars info 825 | FUNCTION-ALIAS: unload-font void UnloadFont ( Font font ) ! Unload Font from GPU memory ( VRAM ) 826 | 827 | ! Text drawing functions 828 | FUNCTION-ALIAS: draw-fps void DrawFPS ( int posX, int posY ) ! Shows current FPS 829 | FUNCTION-ALIAS: draw-text void DrawText ( c-string text, int posX, int posY, int fontSize, Color color ) ! Draw text ( using default font ) 830 | FUNCTION-ALIAS: draw-text-ex void DrawTextEx ( Font font, c-string text, Vector2 position, float fontSize, float spacing, Color tint ) ! Draw text using font and additional parameters 831 | FUNCTION-ALIAS: draw-text-rec void DrawTextRec ( Font font, c-string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint ) ! Draw text using font inside rectangle limits 832 | FUNCTION-ALIAS: draw-text-rec-ex void DrawTextRecEx ( Font font, c-string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectText, Color selectBack ) ! Draw text using font inside rectangle limits with support for text selection 833 | 834 | ! Text misc. functions 835 | FUNCTION-ALIAS: measure-text int MeasureText ( c-string text, int fontSize ) ! Measure string width for default font 836 | FUNCTION-ALIAS: measure-text-ex Vector2 MeasureTextEx ( Font font, c-string text, float fontSize, float spacing ) ! Measure string size for Font 837 | FUNCTION-ALIAS: get-glyph-index int GetGlyphIndex ( Font font, int character ) ! Get index position for a unicode character on font 838 | 839 | ! Text strings management functions 840 | ! Some of these aren't included because Factor should be able to handle most of this 841 | FUNCTION-ALIAS: text-is-equal bool TextIsEqual ( c-string text1, c-string text2 ) ! Check if two text string are equal 842 | FUNCTION-ALIAS: text-length uint TextLength ( c-string text ) ! Get text length, checks for '\0' ending 843 | FUNCTION-ALIAS: text-subtext c-string TextSubtext ( c-string text, int position, int length ) ! Get a piece of a text string 844 | FUNCTION-ALIAS: text-replace c-string TextReplace ( c-string text, c-string replace, c-string by ) ! Replace text string 845 | FUNCTION-ALIAS: text-insert c-string TextInsert ( c-string text, c-string insert, int position ) ! Insert text in a position 846 | FUNCTION-ALIAS: text-split c-string* TextSplit ( c-string text, char delimiter, int* count ) ! Split text into multiple strings 847 | FUNCTION-ALIAS: text-append void TextAppend ( c-string text, c-string append, int* position ) ! Append text at specific position and move cursor! 848 | FUNCTION-ALIAS: text-find-index int TextFindIndex ( c-string text, c-string find ) ! Find first text occurrence within a string 849 | FUNCTION-ALIAS: text-to-upper c-string TextToUpper ( c-string text ) ! Get upper case version of provided string 850 | FUNCTION-ALIAS: text-to-lower c-string TextToLower ( c-string text ) ! Get lower case version of provided string 851 | FUNCTION-ALIAS: text-to-pascal c-string TextToPascal ( c-string text ) ! Get Pascal case notation version of provided string 852 | FUNCTION-ALIAS: text-to-integer int TextToInteger ( c-string text ) ! Get integer value from text ( negative values not supported ) 853 | ! ------------------------------------------------------------------------------------ 854 | ! Basic 3d Shapes Drawing Functions ( Module: models ) 855 | ! ------------------------------------------------------------------------------------ 856 | 857 | ! Basic geometric 3D shapes drawing functions 858 | FUNCTION-ALIAS: draw-line-3d void DrawLine3D ( Vector3 startPos, Vector3 endPos, Color color ) ! Draw a line in 3D world space 859 | FUNCTION-ALIAS: draw-circle-3d void DrawCircle3D ( Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color ) ! Draw a circle in 3D world space 860 | FUNCTION-ALIAS: draw-cube void DrawCube ( Vector3 position, float width, float height, float length, Color color ) ! Draw cube 861 | FUNCTION-ALIAS: draw-cube-v void DrawCubeV ( Vector3 position, Vector3 size, Color color ) ! Draw cube ( Vector version ) 862 | FUNCTION-ALIAS: draw-cube-wires void DrawCubeWires ( Vector3 position, float width, float height, float length, Color color ) ! Draw cube wires 863 | FUNCTION-ALIAS: draw-cube-wires-v void DrawCubeWiresV ( Vector3 position, Vector3 size, Color color ) ! Draw cube wires ( Vector version ) 864 | FUNCTION-ALIAS: draw-cube-texture void DrawCubeTexture ( Texture2D texture, Vector3 position, float width, float height, float length, Color color ) ! Draw cube textured 865 | FUNCTION-ALIAS: draw-sphere void DrawSphere ( Vector3 centerPos, float radius, Color color ) ! Draw sphere 866 | FUNCTION-ALIAS: draw-sphere-ex void DrawSphereEx ( Vector3 centerPos, float radius, int rings, int slices, Color color ) ! Draw sphere with extended parameters 867 | FUNCTION-ALIAS: draw-sphere-wires void DrawSphereWires ( Vector3 centerPos, float radius, int rings, int slices, Color color ) ! Draw sphere wires 868 | FUNCTION-ALIAS: draw-cylinder void DrawCylinder ( Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color ) ! Draw a cylinder/cone 869 | FUNCTION-ALIAS: draw-cylinder-wires void DrawCylinderWires ( Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color ) ! Draw a cylinder/cone wires 870 | FUNCTION-ALIAS: draw-plane void DrawPlane ( Vector3 centerPos, Vector2 size, Color color ) ! Draw a plane XZ 871 | FUNCTION-ALIAS: draw-ray void DrawRay ( Ray ray, Color color ) ! Draw a ray line 872 | FUNCTION-ALIAS: draw-grid void DrawGrid ( int slices, float spacing ) ! Draw a grid ( centered at ( 0, 0, 0 ) ) 873 | FUNCTION-ALIAS: draw-gizmo void DrawGizmo ( Vector3 position ) ! Draw simple gizmo 874 | 875 | 876 | ! ------------------------------------------------------------------------------------ 877 | ! Model 3d Loading and Drawing Functions ( Module: models ) 878 | ! ------------------------------------------------------------------------------------ 879 | 880 | ! Model loading/unloading functions 881 | FUNCTION-ALIAS: load-model Model LoadModel ( c-string fileName ) ! Load model from files ( mesh and material ) 882 | FUNCTION-ALIAS: load-model-from-mesh Model LoadModelFromMesh ( Mesh mesh ) ! Load model from generated mesh 883 | FUNCTION-ALIAS: unload-model void UnloadModel ( Model model ) ! Unload model from memory ( RAM and/or VRAM ) 884 | 885 | ! Mesh loading/unloading functions 886 | FUNCTION-ALIAS: load-mesh Mesh* LoadMeshes ( c-string fileName, int* meshCount ) ! Load meshes from model file 887 | FUNCTION-ALIAS: unload-mesh void UnloadMesh ( Mesh* mesh ) ! Unload mesh from memory ( RAM and/or VRAM ) 888 | FUNCTION-ALIAS: export-mesh void ExportMesh ( c-string fileName, Mesh mesh ) ! Export mesh as an OBJ file 889 | 890 | ! Mesh manipulation functions 891 | FUNCTION-ALIAS: mesh-bounding-box BoundingBox MeshBoundingBox ( Mesh mesh ) ! Compute mesh bounding box limits 892 | FUNCTION-ALIAS: mesh-tangents void MeshTangents ( Mesh* mesh ) ! Compute mesh tangents 893 | FUNCTION-ALIAS: mesh-binormals void MeshBinormals ( Mesh* mesh ) ! Compute mesh binormals 894 | 895 | ! Mesh generation functions 896 | FUNCTION-ALIAS: gen-mesh-poly Mesh GenMeshPoly ( int sides, float radius ) ! Generate polygonal mesh 897 | FUNCTION-ALIAS: gen-mesh-plane Mesh GenMeshPlane ( float width, float length, int resX, int resZ ) ! Generate plane mesh ( with subdivisions ) 898 | FUNCTION-ALIAS: gen-mesh-cube Mesh GenMeshCube ( float width, float height, float length ) ! Generate cuboid mesh 899 | FUNCTION-ALIAS: gen-mesh-sphere Mesh GenMeshSphere ( float radius, int rings, int slices ) ! Generate sphere mesh ( standard sphere ) 900 | FUNCTION-ALIAS: gen-mesh-hemisphere Mesh GenMeshHemiSphere ( float radius, int rings, int slices ) ! Generate half-sphere mesh ( no bottom cap ) 901 | FUNCTION-ALIAS: gen-mesh-cylinder Mesh GenMeshCylinder ( float radius, float height, int slices ) ! Generate cylinder mesh 902 | FUNCTION-ALIAS: gen-mesh-torus Mesh GenMeshTorus ( float radius, float size, int radSeg, int sides ) ! Generate torus mesh 903 | FUNCTION-ALIAS: gen-mesh-knot Mesh GenMeshKnot ( float radius, float size, int radSeg, int sides ) ! Generate trefoil knot mesh 904 | FUNCTION-ALIAS: gen-mesh-heightmap Mesh GenMeshHeightmap ( Image heightmap, Vector3 size ) ! Generate heightmap mesh from image data 905 | FUNCTION-ALIAS: gen-mesh-cubicmap Mesh GenMeshCubicmap ( Image cubicmap, Vector3 cubeSize ) ! Generate cubes-based map mesh from image data 906 | 907 | ! Material loading/unloading functions 908 | FUNCTION-ALIAS: load-material Material LoadMaterial ( c-string fileName ) ! Load material from file 909 | FUNCTION-ALIAS: load-material-default Material LoadMaterialDefault ( ) ! Load default material ( Supports: DIFFUSE, SPECULAR, NORMAL maps ) 910 | FUNCTION-ALIAS: unload-material void UnloadMaterial ( Material material ) ! Unload material from GPU memory ( VRAM ) 911 | FUNCTION-ALIAS: set-material-texture void SetMaterialTexture ( Material *material, int mapType, Texture2D texture ) ! Set texture for a material map type ( MAP_DIFFUSE, MAP_SPECULAR... ) 912 | FUNCTION-ALIAS: set-model-mesh-material void SetModelMeshMaterial ( Model *model, int meshId, int materialId ) ! Set material for a mesh 913 | 914 | ! Model animations loading/unloading functions 915 | FUNCTION-ALIAS: load-model-animations ModelAnimation* LoadModelAnimations ( c-string fileName, int* animsCount ) ! Load model animations from file 916 | FUNCTION-ALIAS: update-model-animation void UpdateModelAnimation ( Model model, ModelAnimation anim, int frame ) ! Update model animation pose 917 | FUNCTION-ALIAS: unload-model-animation void UnloadModelAnimation ( ModelAnimation anim ) ! Unload animation data 918 | FUNCTION-ALIAS: is-model-animation-valid bool IsModelAnimationValid ( Model model, ModelAnimation anim ) ! Check model animation skeleton match 919 | 920 | ! Model drawing functions 921 | FUNCTION-ALIAS: draw-model void DrawModel ( Model model, Vector3 position, float scale, Color tint ) ! Draw a model ( with texture if set ) 922 | FUNCTION-ALIAS: draw-model-ex void DrawModelEx ( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint ) ! Draw a model with extended parameters 923 | FUNCTION-ALIAS: draw-model-wires void DrawModelWires ( Model model, Vector3 position, float scale, Color tint ) ! Draw a model wires ( with texture if set ) 924 | FUNCTION-ALIAS: draw-model-wires-ex void DrawModelWiresEx ( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint ) ! Draw a model wires ( with texture if set ) with extended parameters 925 | FUNCTION-ALIAS: draw-bounding-box void DrawBoundingBox ( BoundingBox box, Color color ) ! Draw bounding box ( wires ) 926 | FUNCTION-ALIAS: draw-billboard void DrawBillboard ( Camera camera, Texture2D texture, Vector3 center, float size, Color tint ) ! Draw a billboard texture 927 | FUNCTION-ALIAS: draw-billboard-rec void DrawBillboardRec ( Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint ) ! Draw a billboard texture defined by sourceRec 928 | 929 | ! Collision detection functions 930 | FUNCTION-ALIAS: check-collision-spheres bool CheckCollisionSpheres ( Vector3 centerA, float radiusA, Vector3 centerB, float radiusB ) ! Detect collision between two spheres 931 | FUNCTION-ALIAS: check-collision-boxes bool CheckCollisionBoxes ( BoundingBox box1, BoundingBox box2 ) ! Detect collision between two bounding boxes 932 | FUNCTION-ALIAS: check-collision-box-sphere bool CheckCollisionBoxSphere ( BoundingBox box, Vector3 centerSphere, float radiusSphere ) ! Detect collision between box and sphere 933 | FUNCTION-ALIAS: check-collision-ray-sphere bool CheckCollisionRaySphere ( Ray ray, Vector3 spherePosition, float sphereRadius ) ! Detect collision between ray and sphere 934 | FUNCTION-ALIAS: check-collision-ray-sphere-ex bool CheckCollisionRaySphereEx ( Ray ray, Vector3 spherePosition, float sphereRadius, Vector3* collisionPoint ) ! Detect collision between ray and sphere, returns collision point 935 | FUNCTION-ALIAS: check-collision-ray-box bool CheckCollisionRayBox ( Ray ray, BoundingBox box ) ! Detect collision between ray and box 936 | FUNCTION-ALIAS: get-collision-ray-model RayHitInfo GetCollisionRayModel ( Ray ray, Model* model ) ! Get collision info between ray and model 937 | FUNCTION-ALIAS: get-collision-ray-triangle RayHitInfo GetCollisionRayTriangle ( Ray ray, Vector3 p1, Vector3 p2, Vector3 p3 ) ! Get collision info between ray and triangle 938 | FUNCTION-ALIAS: get-collision-ray-ground RayHitInfo GetCollisionRayGround ( Ray ray, float groundHeight ) ! Get collision info between ray and ground plane ( Y-normal plane ) 939 | 940 | ! ------------------------------------------------------------------------------------ 941 | ! Shaders System Functions ( Module: rlgl ) 942 | ! NOTE: This functions are useless when using OpenGL 1.1 943 | ! ------------------------------------------------------------------------------------ 944 | 945 | ! Shader loading/unloading functions 946 | FUNCTION-ALIAS: load-text c-string LoadText ( c-string fileName ) ! Load chars array from text file 947 | FUNCTION-ALIAS: load-shader Shader LoadShader ( c-string vsFileName, c-string fsFileName ) ! Load shader from files and bind default locations 948 | FUNCTION-ALIAS: load-shader-code Shader LoadShaderCode ( c-string vsCode, c-string fsCode ) ! Load shader from code strings and bind default locations 949 | FUNCTION-ALIAS: unload-shader void UnloadShader ( Shader shader ) ! Unload shader from GPU memory ( VRAM ) 950 | FUNCTION-ALIAS: get-shader-default Shader GetShaderDefault ( ) ! Get default shader 951 | FUNCTION-ALIAS: get-texture-default Texture2D GetTextureDefault ( ) ! Get default texture 952 | 953 | ! Shader configuration functions 954 | FUNCTION-ALIAS: get-shader-location int GetShaderLocation ( Shader shader, c-string uniformName ) ! Get shader uniform location 955 | FUNCTION-ALIAS: set-shader-value void SetShaderValue ( Shader shader, int uniformLoc, void* value, int uniformType ) ! Set shader uniform value 956 | FUNCTION-ALIAS: set-shader-value-v void SetShaderValueV ( Shader shader, int uniformLoc, void* value, int uniformType, int count ) ! Set shader uniform value vector 957 | FUNCTION-ALIAS: set-shader-value-matrix void SetShaderValueMatrix ( Shader shader, int uniformLoc, Matrix mat ) ! Set shader uniform value ( matrix 4x4 ) 958 | FUNCTION-ALIAS: set-shader-value-texture void SetShaderValueTexture ( Shader shader, int uniformLoc, Texture2D texture ) ! Set shader uniform value for texture 959 | FUNCTION-ALIAS: set-matrix-projection void SetMatrixProjection ( Matrix proj ) ! Set a custom projection matrix ( replaces internal projection matrix ) 960 | FUNCTION-ALIAS: set-matrix-model-view void SetMatrixModelview ( Matrix view ) ! Set a custom modelview matrix ( replaces internal modelview matrix ) 961 | FUNCTION-ALIAS: get-matrix-model-view Matrix GetMatrixModelview ( ) ! Get internal modelview matrix 962 | 963 | ! Texture maps generation ( PBR ) 964 | ! NOTE: Required shaders should be provided 965 | FUNCTION-ALIAS: gen-texture-cubemap Texture2D GenTextureCubemap ( Shader shader, Texture2D skyHDR, int size ) ! Generate cubemap texture from HDR texture 966 | FUNCTION-ALIAS: gen-texture-irradiance Texture2D GenTextureIrradiance ( Shader shader, Texture2D cubemap, int size ) ! Generate irradiance texture using cubemap data 967 | FUNCTION-ALIAS: gen-texture-prefilter Texture2D GenTexturePrefilter ( Shader shader, Texture2D cubemap, int size ) ! Generate prefilter texture using cubemap data 968 | FUNCTION-ALIAS: gen-texture-brdf Texture2D GenTextureBRDF ( Shader shader, Texture2D cubemap, int size ) ! Generate BRDF texture using cubemap data 969 | 970 | ! Shading begin/end functions 971 | FUNCTION-ALIAS: begin-shader-mode void BeginShaderMode ( Shader shader ) ! Begin custom shader drawing 972 | FUNCTION-ALIAS: end-shader-mode void EndShaderMode ( ) ! End custom shader drawing ( use default shader ) 973 | FUNCTION-ALIAS: begin-blend-mode void BeginBlendMode ( int mode ) ! Begin blending mode ( alpha, additive, multiplied ) 974 | FUNCTION-ALIAS: end-blend-mode void EndBlendMode ( ) ! End blending mode ( reset to default: alpha blending ) 975 | 976 | ! VR control functions 977 | FUNCTION-ALIAS: init-vr-simulator void InitVrSimulator ( ) ! Init VR simulator for selected device parameters 978 | FUNCTION-ALIAS: close-vr-simulator void CloseVrSimulator ( ) ! Close VR simulator for current device 979 | FUNCTION-ALIAS: update-vr-tracking void UpdateVrTracking ( Camera *camera ) ! Update VR tracking ( position and orientation ) and camera 980 | FUNCTION-ALIAS: set-vr-configuration void SetVrConfiguration ( VrDeviceInfo info, Shader distortion ) ! Set stereo rendering configuration parameters 981 | FUNCTION-ALIAS: is-vr-simulator-ready bool IsVrSimulatorReady ( ) ! Detect if VR simulator is ready 982 | FUNCTION-ALIAS: toggle-vr-mode void ToggleVrMode ( ) ! Enable/Disable VR experience 983 | FUNCTION-ALIAS: begin-vr-drawing void BeginVrDrawing ( ) ! Begin VR simulator stereo rendering 984 | FUNCTION-ALIAS: end-vr-drawing void EndVrDrawing ( ) ! End VR simulator stereo rendering 985 | 986 | ! ------------------------------------------------------------------------------------ 987 | ! Audio Loading and Playing Functions ( Module: audio ) 988 | ! ------------------------------------------------------------------------------------ 989 | 990 | ! Audio device management functions 991 | FUNCTION-ALIAS: init-audio-device void InitAudioDevice ( ) ! Initialize audio device and context 992 | FUNCTION-ALIAS: close-audio-device void CloseAudioDevice ( ) ! Close the audio device and context 993 | FUNCTION-ALIAS: is-audio-device-ready bool IsAudioDeviceReady ( ) ! Check if audio device has been initialized successfully 994 | FUNCTION-ALIAS: set-master-volume void SetMasterVolume ( float volume ) ! Set master volume ( listener ) 995 | 996 | ! Wave/Sound loading/unloading functions 997 | FUNCTION-ALIAS: load-wave Wave LoadWave ( c-string fileName ) ! Load wave data from file 998 | FUNCTION-ALIAS: load-wave-ex Wave LoadWaveEx ( void* data, int sampleCount, int sampleRate, int sampleSize, int channels ) ! Load wave data from raw array data 999 | FUNCTION-ALIAS: load-sound Sound LoadSound ( c-string fileName ) ! Load sound from file 1000 | FUNCTION-ALIAS: load-sound-from-wave Sound LoadSoundFromWave ( Wave wave ) ! Load sound from wave data 1001 | FUNCTION-ALIAS: update-sound void UpdateSound ( Sound sound, void* data, int samplesCount ) ! Update sound buffer with new data 1002 | FUNCTION-ALIAS: unload-wave void UnloadWave ( Wave wave ) ! Unload wave data 1003 | FUNCTION-ALIAS: unload-sound void UnloadSound ( Sound sound ) ! Unload sound 1004 | FUNCTION-ALIAS: export-wave void ExportWave ( Wave wave, c-string fileName ) ! Export wave data to file 1005 | FUNCTION-ALIAS: export-wave-as-code void ExportWaveAsCode ( Wave wave, c-string fileName ) ! Export wave sample data to code ( .h ) 1006 | 1007 | ! Wave/Sound management functions 1008 | FUNCTION-ALIAS: play-sound void PlaySound ( Sound sound ) ! Play a sound 1009 | FUNCTION-ALIAS: pause-sound void PauseSound ( Sound sound ) ! Pause a sound 1010 | FUNCTION-ALIAS: resume-sound void ResumeSound ( Sound sound ) ! Resume a paused sound 1011 | FUNCTION-ALIAS: stop-sound void StopSound ( Sound sound ) ! Stop playing a sound 1012 | FUNCTION-ALIAS: is-sound-playing bool IsSoundPlaying ( Sound sound ) ! Check if a sound is currently playing 1013 | FUNCTION-ALIAS: set-sound-volume void SetSoundVolume ( Sound sound, float volume ) ! Set volume for a sound ( 1.0 is max level ) 1014 | FUNCTION-ALIAS: set-sound-pitch void SetSoundPitch ( Sound sound, float pitch ) ! Set pitch for a sound ( 1.0 is base level ) 1015 | FUNCTION-ALIAS: wave-format void WaveFormat ( Wave* wave, int sampleRate, int sampleSize, int channels ) ! Convert wave data to desired format 1016 | FUNCTION-ALIAS: wave-copy Wave WaveCopy ( Wave wave ) ! Copy a wave to a new wave 1017 | FUNCTION-ALIAS: wave-crop void WaveCrop ( Wave* wave, int initSample, int finalSample ) ! Crop a wave to defined samples range 1018 | FUNCTION-ALIAS: get-wave-data float* GetWaveData ( Wave wave ) ! Get samples data from wave as a floats array 1019 | 1020 | ! Music management functions 1021 | FUNCTION-ALIAS: load-music-stream Music LoadMusicStream ( c-string fileName ) ! Load music stream from file 1022 | FUNCTION-ALIAS: unload-music-stream void UnloadMusicStream ( Music music ) ! Unload music stream 1023 | FUNCTION-ALIAS: play-music-stream void PlayMusicStream ( Music music ) ! Start music playing 1024 | FUNCTION-ALIAS: update-music-stream void UpdateMusicStream ( Music music ) ! Updates buffers for music streaming 1025 | FUNCTION-ALIAS: stop-music-stream void StopMusicStream ( Music music ) ! Stop music playing 1026 | FUNCTION-ALIAS: pause-music-stream void PauseMusicStream ( Music music ) ! Pause music playing 1027 | FUNCTION-ALIAS: resume-music-stream void ResumeMusicStream ( Music music ) ! Resume playing paused music 1028 | FUNCTION-ALIAS: is-music-playing bool IsMusicPlaying ( Music music ) ! Check if music is playing 1029 | FUNCTION-ALIAS: set-music-volume void SetMusicVolume ( Music music, float volume ) ! Set volume for music ( 1.0 is max level ) 1030 | FUNCTION-ALIAS: set-music-pitch void SetMusicPitch ( Music music, float pitch ) ! Set pitch for a music ( 1.0 is base level ) 1031 | FUNCTION-ALIAS: set-music-loop-count void SetMusicLoopCount ( Music music, int count ) ! Set music loop count ( loop repeats ) 1032 | FUNCTION-ALIAS: get-music-time-length float GetMusicTimeLength ( Music music ) ! Get music time length ( in seconds ) 1033 | FUNCTION-ALIAS: get-music-time-played float GetMusicTimePlayed ( Music music ) ! Get current music time played ( in seconds ) 1034 | 1035 | ! AudioStream management functions 1036 | FUNCTION-ALIAS: init-audio-stream AudioStream InitAudioStream ( uint sampleRate, uint sampleSize, uint channels ) ! Init audio stream ( to stream raw audio pcm data ) 1037 | FUNCTION-ALIAS: update-audio-stream void UpdateAudioStream ( AudioStream stream, void* data, int samplesCount ) ! Update audio stream buffers with data 1038 | FUNCTION-ALIAS: close-audio-stream void CloseAudioStream ( AudioStream stream ) ! Close audio stream and free memory 1039 | FUNCTION-ALIAS: is-audio-buffer-processed bool IsAudioBufferProcessed ( AudioStream stream ) ! Check if any audio stream buffers requires refill 1040 | FUNCTION-ALIAS: play-audio-stream void PlayAudioStream ( AudioStream stream ) ! Play audio stream 1041 | FUNCTION-ALIAS: pause-audio-stream void PauseAudioStream ( AudioStream stream ) ! Pause audio stream 1042 | FUNCTION-ALIAS: resume-audio-stream void ResumeAudioStream ( AudioStream stream ) ! Resume audio stream 1043 | FUNCTION-ALIAS: is-audio-stream-playing bool IsAudioStreamPlaying ( AudioStream stream ) ! Check if audio stream is playing 1044 | FUNCTION-ALIAS: stop-audio-stream void StopAudioStream ( AudioStream stream ) ! Stop audio stream 1045 | FUNCTION-ALIAS: set-audio-stream-volume void SetAudioStreamVolume ( AudioStream stream, float volume ) ! Set volume for audio stream ( 1.0 is max level ) 1046 | FUNCTION-ALIAS: set-audio-stream-pitch void SetAudioStreamPitch ( AudioStream stream, float pitch ) ! Set pitch for audio stream ( 1.0 is base level ) 1047 | 1048 | 1049 | 1050 | ! ------------------------------ 1051 | ! New or updated from 2.5 -> 3.5 1052 | ! ------------------------------ 1053 | 1054 | FUNCTION-ALIAS: get-world-to-screen-ex Vector2 GetWorldToScreenEx ( Vector3 position, Camera camera, int width, int height ) ! Returns size position for a 3d world space position 1055 | FUNCTION-ALIAS: get-world-to-screen-2d Vector2 GetWorldToScreen2D ( Vector2 position, Camera2D camera ) ! Returns the screen space position for a 2d camera world space position 1056 | FUNCTION-ALIAS: get-screen-to-world2d Vector2 GetScreenToWorld2D ( Vector2 position, Camera2D camera ) ! Returns the world space position for a 2d camera screen space position 1057 | FUNCTION-ALIAS: compress-data uchar* CompressData ( uchar* data, int dataLength, int* compDataLength ) ! Compress data ( DEFLATE algorithm) 1058 | FUNCTION-ALIAS: decompress-data uchar* DecompressData ( uchar* compData, int compDataLength, int* dataLength ) ! Decompress data ( DEFLATE algorithm) 1059 | FUNCTION-ALIAS: get-char-pressed int GetCharPressed ( ) ! Get char pressed ( unicode), call it multiple times for chars queued 1060 | FUNCTION-ALIAS: get-mouse-cursor int GetMouseCursor ( ) ! Returns mouse cursor if ( MouseCursor enum) 1061 | FUNCTION-ALIAS: set-mouse-cursor void SetMouseCursor ( int cursor ) ! Set mouse cursor 1062 | FUNCTION-ALIAS: check-collision-lines bool CheckCollisionLines ( Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2, Vector2 *collisionPoint ) ! Check the collision between two lines defined by two points each, returns collision point by reference 1063 | FUNCTION-ALIAS: load-image-anim Image LoadImageAnim ( char* fileName, int* frames ) ! Load image sequence from file ( frames appended to image.data) 1064 | FUNCTION-ALIAS: load-image-from-memory Image LoadImageFromMemory ( char* fileType, uchar* fileData, int dataSize ) ! Load image from memory buffer, fileType refers to extension: i.e. "png" 1065 | FUNCTION-ALIAS: load-image-colors Color* LoadImageColors ( Image image ) ! Load color data from image as a Color array ( RGBA - 32bit) 1066 | FUNCTION-ALIAS: load-image-palette Color* LoadImagePalette ( Image image, int maxPaletteSize, int* colorsCount ) ! Load colors palette from image as a Color array ( RGBA - 32bit) 1067 | FUNCTION-ALIAS: unload-image-colors void UnloadImageColors ( Color* colors ) ! Unload color data loaded with LoadImageColors ( ) 1068 | FUNCTION-ALIAS: unload-image-palette void UnloadImagePalette ( Color* colors ) ! Unload colors palette loaded with LoadImagePalette ( ) 1069 | FUNCTION-ALIAS: get-image-alpha-border Rectangle GetImageAlphaBorder ( Image image, float threshold ) ! Get image alpha border rectangle 1070 | 1071 | 1072 | ! Image drawing functions 1073 | ! NOTE: Image software-rendering functions (CPU) 1074 | FUNCTION-ALIAS: image-clear-background void ImageClearBackground ( Image* dst, Color color ) ! Clear image background with given color 1075 | FUNCTION-ALIAS: image-draw-pixel void ImageDrawPixel ( Image* dst, int posX, int posY, Color color ) ! Draw pixel within an image 1076 | FUNCTION-ALIAS: image-draw-pixel-v void ImageDrawPixelV ( Image* dst, Vector2 position, Color color ) ! Draw pixel within an image ( Vector version) 1077 | FUNCTION-ALIAS: image-draw-line void ImageDrawLine ( Image* dst, int startPosX, int startPosY, int endPosX, int endPosY, Color color ) ! Draw line within an image 1078 | FUNCTION-ALIAS: image-draw-line-v void ImageDrawLineV ( Image* dst, Vector2 start, Vector2 end, Color color ) ! Draw line within an image ( Vector version) 1079 | FUNCTION-ALIAS: image-draw-circle void ImageDrawCircle ( Image* dst, int centerX, int centerY, int radius, Color color ) ! Draw circle within an image 1080 | FUNCTION-ALIAS: image-draw-circle-v void ImageDrawCircleV ( Image* dst, Vector2 center, int radius, Color color ) ! Draw circle within an image ( Vector version) 1081 | FUNCTION-ALIAS: image-draw-rectangle-v void ImageDrawRectangleV ( Image* dst, Vector2 position, Vector2 size, Color color ) ! Draw rectangle within an image ( Vector version) 1082 | FUNCTION-ALIAS: image-draw-rectangle-rec void ImageDrawRectangleRec ( Image* dst, Rectangle rec, Color color ) ! Draw rectangle within an image 1083 | FUNCTION-ALIAS: image-draw void ImageDraw ( Image* dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint ) ! Draw a source image within a destination image ( tint applied to source) 1084 | FUNCTION-ALIAS: image-draw-text void ImageDrawText ( Image* dst, char* text, int posX, int posY, int fontSize, Color color ) ! Draw text ( using default font) within an image ( destination) 1085 | FUNCTION-ALIAS: image-draw-text-ex void ImageDrawTextEx ( Image* dst, Font font, char* text, Vector2 position, float fontSize, float spacing, Color tint ) ! Draw text ( custom sprite font) within an image ( destination) 1086 | ! ---- 1087 | 1088 | FUNCTION-ALIAS: update-texture-rec void UpdateTextureRec ( Texture2D texture, Rectangle rec, void* pixels ) ! Update GPU texture rectangle with new data 1089 | 1090 | ! Color/pixel related functions 1091 | FUNCTION-ALIAS: fade Color Fade ( Color color, float alpha ) ! Returns color with alpha applied, alpha goes from 0.0f to 1.0f 1092 | FUNCTION-ALIAS: color-to-int int ColorToInt ( Color color ) ! Returns hexadecimal value for a Color 1093 | FUNCTION-ALIAS: color-normalize Vector4 ColorNormalize ( Color color ) ! Returns Color normalized as float [0..1] 1094 | FUNCTION-ALIAS: color-from-normalized Color ColorFromNormalized ( Vector4 normalized ) ! Returns Color from normalized values [0..1] 1095 | FUNCTION-ALIAS: color-to-hsv Vector3 ColorToHSV ( Color color ) ! Returns HSV values for a Color 1096 | FUNCTION-ALIAS: color-from-hsv Color ColorFromHSV ( float hue, float saturation, float value ) ! Returns a Color from HSV values 1097 | FUNCTION-ALIAS: color-alpha Color ColorAlpha ( Color color, float alpha ) ! Returns color with alpha applied, alpha goes from 0.0f to 1.0f 1098 | FUNCTION-ALIAS: color-alpha-blend Color ColorAlphaBlend ( Color dst, Color src, Color tint ) ! Returns src alpha-blended into dst color with tint 1099 | FUNCTION-ALIAS: get-color Color GetColor ( int hexValue ) ! Get Color structure from hexadecimal value 1100 | FUNCTION-ALIAS: get-pixel-color Color GetPixelColor ( void* srcPtr, int format ) ! Get Color from a source pixel pointer of certain format 1101 | FUNCTION-ALIAS: set-pixel-color void SetPixelColor ( void* dstPtr, Color color, int format ) ! Set color formatted into destination pixel pointer 1102 | 1103 | ! --------- 1104 | 1105 | FUNCTION-ALIAS: get-codepoints int* GetCodepoints ( char* text, int* count ) ! Get all codepoints in a string, codepoints count returned by parameters 1106 | FUNCTION-ALIAS: get-codepoints-count int GetCodepointsCount ( char* text ) ! Get total number of characters ( codepoints) in a UTF8 encoded string 1107 | FUNCTION-ALIAS: get-next-codepoint int GetNextCodepoint ( char* text, int* bytesProcessed ) ! Returns next codepoint in a UTF8 encoded string; 0x3f ( '?') is returned on failure 1108 | FUNCTION-ALIAS: codepoint-to-utf8 char* CodepointToUtf8 ( int codepoint, int* byteLength ) ! Encode codepoint into utf8 text ( char array length returned as parameter) 1109 | FUNCTION-ALIAS: mesh-normals-smooth void MeshNormalsSmooth ( Mesh *mesh ) ! Smooth ( average) vertex normals 1110 | FUNCTION-ALIAS: get-shapes-texture Texture2D GetShapesTexture ( ) ! Get texture to draw shapes 1111 | FUNCTION-ALIAS: get-shapes-texture-rec Rectangle GetShapesTextureRec ( ) ! Get texture rectangle to draw shapes 1112 | FUNCTION-ALIAS: get-matrix-projection Matrix GetMatrixProjection ( ) ! Get internal projection matrix 1113 | FUNCTION-ALIAS: load-wave-samples float* LoadWaveSamples ( Wave wave ) ! Load samples data from wave as a floats array 1114 | FUNCTION-ALIAS: unload-wave-samples void UnloadWaveSamples ( float* samples ) ! Unload samples data loaded with LoadWaveSamples ( ) 1115 | FUNCTION-ALIAS: set-audiostream-buffersize-default void SetAudioStreamBufferSizeDefault ( int size ) ! Default size for new audio streams 1116 | 1117 | 1118 | ! ------------------------------------------------------------ 1119 | ! Load modules depending on what the installed dll/so supports 1120 | ! ----------------------------------------------------------- 1121 | "raylib" lookup-library dll>> dup 1122 | ! Check for ricons symbols 1123 | "DrawIcon" swap dlsym [ "raylib.modules.ricons" require ] when 1124 | ! Check for gui symbols 1125 | "GuiEnable" swap dlsym [ "raylib.modules.gui" require ] when 1126 | 1127 | 1128 | --------------------------------------------------------------------------------