{"id":1049,"date":"2015-04-05T20:34:13","date_gmt":"2015-04-05T08:34:13","guid":{"rendered":"http:\/\/www.davidbrebner.com\/?p=1049"},"modified":"2015-04-06T14:01:18","modified_gmt":"2015-04-06T02:01:18","slug":"umajin-lua-games","status":"publish","type":"post","link":"https:\/\/www.davidbrebner.com\/?p=1049","title":{"rendered":"Umajin Lua Games"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/www.davidbrebner.com\/wp-content\/uploads\/2015\/04\/games.jpg\" alt=\"games\" width=\"900\" height=\"250\" class=\"alignnone size-full wp-image-1050\" srcset=\"https:\/\/www.davidbrebner.com\/wp-content\/uploads\/2015\/04\/games.jpg 900w, https:\/\/www.davidbrebner.com\/wp-content\/uploads\/2015\/04\/games-150x42.jpg 150w, https:\/\/www.davidbrebner.com\/wp-content\/uploads\/2015\/04\/games-300x83.jpg 300w\" sizes=\"(max-width: 900px) 100vw, 900px\" \/><\/p>\n<p><iframe width=\"460\" height=\"520\" src=\"https:\/\/www.youtube.com\/embed\/HHcI0ilPvA4\" frameborder=\"0\" allowfullscreen align = left><\/iframe><\/p>\n<p><iframe width=\"460\" height=\"520\" src=\"https:\/\/www.youtube.com\/embed\/CCBjq3EU3DM\" frameborder=\"0\" allowfullscreen align = right><\/iframe><br \/>\n.<br \/>\nHere are some simple games created with a small amount of Lua script in Umajin.  These are built on top of the gamekit component which manages all the sprites for you.  It can render quite a few million sprites at 60fps so there is plenty of opportunity to go wild graphically.<\/p>\n<p>These examples are just graphical tests for my nephews &#8211; the graphics are all the ownership of the original artists.  We will be releasing worked examples with public domain images for anyone to download and experiment with.<\/p>\n<p>Once you assign a sprite sheet to the Gamekit component you can start adding the custom actions. (I recommend using <a href=\"https:\/\/www.codeandweb.com\/texturepacker\">texturepacker<\/a> or a tool which makes an atlas in the LibGDX format)<\/p>\n<p>These two functions are where the fun starts;<\/p>\n<pre>\r\nsprite_id = gamekit_sprite_create(gamekit, sprite_index, sprite_name, x, y, scale, angle, alpha)\r\n<\/pre>\n<pre>\r\ngamekit_sprite_update(gamekit, sprite_id, sprite_index, sprite_name, x, y, scale, angle, alpha)\r\n<\/pre>\n<p>Now we can write a simple function which you can attach to the on_tick event of your GameKit component.<\/p>\n<pre>\r\n--variables\r\ng_smoke_x = {}\r\ng_smoke_y = {}\r\ng_smoke_a = {}\r\ng_smoke_s = {}\r\n\r\n--main smoke heartbeat\r\nregister(\"smoke_tick\",\"smoke tick\",\"\")\r\nfunction smoke_tick()\r\n  for i=1,10 do\r\n    g_smoke_y[i] = g_smoke_y[i] + 10 --gravity\r\n    g_smoke_a[i] = g_smoke_a[i] + 1 --angle\r\n    g_smoke_s[i] = g_smoke_s[i] + 0.01 --scale\r\n    gamekit_sprite_update(gamekit, i, -1, 'shield', g_smoke_x[i], g_smoke_y[i], g_smoke_s[i], 0, 180)\r\n  end\r\nend\r\n<\/pre>\n<p>We will have these games and many more up on the Umajin SDK community site in May!<\/p>\n<p>Cheers<br \/>\n  David<\/p>\n","protected":false},"excerpt":{"rendered":"<p>. Here are some simple games created with a small amount of Lua script in Umajin. These are built on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"image","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-1049","post","type-post","status-publish","format-image","hentry","category-umaijn","post_format-post-format-image"],"_links":{"self":[{"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/posts\/1049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1049"}],"version-history":[{"count":19,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/posts\/1049\/revisions"}],"predecessor-version":[{"id":1069,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/posts\/1049\/revisions\/1069"}],"wp:attachment":[{"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}