{"id":16085463,"url":"https://github.com/Dragosha/cards-fx-kit","last_synced_at":"2025-10-23T02:30:33.865Z","repository":{"id":240226167,"uuid":"802022263","full_name":"Dragosha/cards-fx-kit","owner":"Dragosha","description":"A small kit of scripts and shaders for card games made with Defold.","archived":false,"fork":false,"pushed_at":"2024-05-17T11:48:10.000Z","size":1020,"stargazers_count":32,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T07:11:25.174Z","etag":null,"topics":["defold-module","defold-shaders"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dragosha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-17T11:16:20.000Z","updated_at":"2025-01-15T22:52:51.000Z","dependencies_parsed_at":"2024-05-17T13:02:02.496Z","dependency_job_id":null,"html_url":"https://github.com/Dragosha/cards-fx-kit","commit_stats":null,"previous_names":["dragosha/cards-fx-kit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dragosha%2Fcards-fx-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dragosha%2Fcards-fx-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dragosha%2Fcards-fx-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dragosha%2Fcards-fx-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dragosha","download_url":"https://codeload.github.com/Dragosha/cards-fx-kit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237763855,"owners_count":19362310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["defold-module","defold-shaders"],"created_at":"2024-10-09T13:01:58.474Z","updated_at":"2025-10-23T02:30:33.393Z","avatar_url":"https://github.com/Dragosha.png","language":"Lua","funding_links":[],"categories":["Libraries"],"sub_categories":["Programming Language"],"readme":"# Defold Cards FX Kit\n\n![Example](/example.png)\n\nThis is a small kit of scripts and shaders for card games and similar games. Made for the GUI interface, does not use the camera or Game objects. Includes:\n\n- Click and dragging card detection module. Does not depend on the aspect ratio of the screen. See `main\\m\\rnodes.lua`.\n- A module for detecting clicks on interface buttons. See `main\\m\\si.lua`\n- GUI material and shader for the effect of perspective distortion, so-called fake 3D.\n- Dissolve effect shader adapted for GUI material.\n- Freeze effect shader.\n- Material and background texture repeat shader. (Uses a separate atlas with a texture that is a multiple of a square of two). \n- Example Usage. See `main\\gui\\ui.gui_script`.\n- A slightly modified render script.\n- Mouse click/single touch is bound to action \"touch\"\n\nCheck out [HTML5 demo ](https://dragosha.com/defold/cards-fx-kit/)\n\nFor correct work it is also necessary to make noise texture passing in render script. For this purpose `textures.script` and slightly modified render script are used. Also note, by default gui camera is used for pure 2D and works in the range Z from -1 to 1. For the effect of distortions in render script changed the projection matrix for GUI, instead of -1..1 near and far planes are set to -300..300.\n\n```lua\n-- projection for gui\n--\nlocal function get_gui_projection(camera, state)\n    return vmath.matrix4_orthographic(0, state.window_width, 0, state.window_height, -300, 300)\nend\n```\n\nThe `rnodes.lua` and `si.lua` modules are very similar in functionality and code inside. Both of them use the node table lookup and trigger callbacks when specific events occur for a found node. I separated them mainly by semantic content, so as not to mix tables with cards and tables with buttons. But if you want, you can combine them and use a more suitable variant.\n\n## How to use\n\nSet material `/assets/material/gui/gui.material` for whole your gui. Also add other materials to the GUI material list if you want to use some effects for the card. Each effect has its own material for each effect.\n\nInclude the module `rnodes.lua` in the script.\n\n```lua\nlocal rnodes = require \"main.m.rnodes\"\n```\n\nCreate the cards and register them in the rnodes module. Note that in addition to the main node, to which the interaction with the cursor or touch is defined, you can pass the card value and a node with the card shadow to the registrator, it will change its position depending on the interaction with the card.\n\n```lua\n rnodes.register(self, {\n\t\tnode = node,\n\t\tvalue = uid,\n\t\tposition = position,\n\t\tshadow = \"shadow\",\n\t\trelease_cb = release_cb,\n\t\tpress_cb = press_cb,\n\t\tdrag_cb = drag_cb,\n\t\tover_cb = over_cb\n\t})\n```\n\n### Press callback\n\n`function press_cb(self, instance, action)` where\nInstance is the table of the registered node, contains the node itself `instance.node`, the value `instance.value`, the starting position `instance.position`, the starting scale `instance.scale`.\n`Action` is a table received from the on_input event.\nIn this callback you can return ‘true’ to accept the following steps (drag and release) or ‘false’ to prevent it.\n\n\n### Release callback\n\n`function release_cb(self, instance, action)`\n\nSame as press, but only release :-). Click happened you can do something with the node.\n\n\n### Drag callback\n\nInvoked every time a node changes its position and is in a dragged state.\n\n`function drag_cb(self, instance, action, action_pos)`\n\n`action_pos` a vmath.vector3 it's modified position of the node considering the screen aspect ratio.\nTo visual dragging a node do following code in this callback function:\n\n```lua\n\tlocal position = action_pos - instance.offset\n\tlocal node = instance.node\n\tgui.set_position(node, position)\n```\n\n### Over callback\n\nInvoked every time the cursor hovers over a node.\n\n`function over_cb(self, instance, action, enter)`\n\nHere we have additional argument `enter` it takes one of three values: it takes one of three values:\n\n- `rnodes.ENTER` the cursor appears above the node\n- `rnodes.OUT` the cursor has moved outside the node\n- `rnodes.REPEAT` the cursor moves over the node. \n\n\n### On input\n\nForward on_input calls to `rnodes.on_input` function to detect input:\n\n```lua\nfunction on_input(self, action_id, action)\n\tif rnodes.on_input(self, action_id, action) then\n\t\treturn true\n\tend\nend\n```\n\n---\n\nLearn, modify, adapt and use in your games!\n\nHappy Defolding!\n\n---\n\n## Credits\n\nThis project and included assets are licensed under the terms of the CC0 1.0 Universal license. It's developed and supported by [@Dragosha](https://github.com/Dragosha).\n\nFont `Troika.otf` (c) JOEL CARROUCHE used under the FREE FONT LICENSE version 1.2, February 2019\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDragosha%2Fcards-fx-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDragosha%2Fcards-fx-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDragosha%2Fcards-fx-kit/lists"}