{"id":46255,"date":"2017-12-26T08:59:22","date_gmt":"2017-12-26T08:59:22","guid":{"rendered":"https:\/\/www.libretro.com\/?p=46255"},"modified":"2018-02-11T21:17:22","modified_gmt":"2018-02-11T21:17:22","slug":"chailove","status":"publish","type":"post","link":"https:\/\/www.libretro.com\/index.php\/chailove\/","title":{"rendered":"ChaiLove &#8211; Another Take on 2D Game Development"},"content":{"rendered":"<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.libretro.com\/wp-content\/uploads\/2017\/12\/love2dwhale.png\" alt=\"Whale from the Love2D logo\" width=\"174\" height=\"174\" class=\"alignright size-full wp-image-46211\" srcset=\"https:\/\/www.libretro.com\/wp-content\/uploads\/2017\/12\/love2dwhale.png 174w, https:\/\/www.libretro.com\/wp-content\/uploads\/2017\/12\/love2dwhale-150x150.png 150w\" sizes=\"(max-width: 174px) 100vw, 174px\" \/>When it comes to 2D game development frameworks, there are many options out there for indie game developers. Every framework has its own pros and cons, and its own use cases. Today, <em>let&#8217;s talk about <a href=\"https:\/\/love2d.org\/\">L\u00d6VE<\/a>, baby.<\/em><\/p>\n<p>L\u00d6VE is an awesome framework to make 2D games in <a href=\"http:\/\/www.lua.org\/\">Lua<\/a>. With some modification, these games can be brought to <a href=\"https:\/\/www.libretro.com\/\">libretro<\/a> though <a href=\"https:\/\/github.com\/libretro\/libretro-lutro\">Lutro<\/a>. With the advent of <a href=\"https:\/\/en.wikipedia.org\/wiki\/C%2B%2B14\">C++14<\/a>, are there tools and features we can bring in to improve the scripting experience behind developing 2D games?<\/p>\n<p><center><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.libretro.com\/wp-content\/uploads\/2017\/12\/love2dlogo.png\" alt=\"Love2D\" width=\"116\" height=\"116\" class=\"img-responsive\" title=\"Love2D + ChaiScript = ChaiLove\" \/> <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.libretro.com\/wp-content\/uploads\/2017\/12\/chaiscript.png\"  title=\"Love2D + ChaiScript = ChaiLove\" alt=\"ChaiScript\" width=\"116\" height=\"116\" class=\"img-responsive\" \/>  <img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.libretro.com\/wp-content\/uploads\/2017\/12\/chailovelogo.png\" title=\"Love2D + ChaiScript = ChaiLove\" alt=\"ChaiLove\" width=\"116\" height=\"116\" class=\"img-responsive\" \/><\/center><\/p>\n<p><!--more--><\/p>\n<p>Meet <a href=\"https:\/\/github.com\/RobLoach\/ChaiLove\">ChaiLove<\/a>, an experiment in porting L\u00d6VE to <a href=\"http:\/\/chaiscript.com\/\">ChaiScript<\/a>. Some of the goals behind this endevour include:<\/p>\n<ul>\n<li><a href=\"http:\/\/chaiscript.com\/\">ChaiScript<\/a>: The Lua scripting language is amazing, and is widely adopted. Having ChaiScript natively implemented directly in C++ means it&#8217;s easily embeddable, and has out-of-the-box support for many of the standard libraries already available.<\/li>\n<li>Cross-Platform: Currently available on Windows, Mac OS X, Linux, and ARM. More platforms to come.<\/li>\n<li><a href=\"https:\/\/en.wikipedia.org\/wiki\/Not_invented_here\">Proudly Found Elsewhere<\/a>: Adopt third-party libraries whenever possible to reduce development times and improve maintainability<\/li>\n<li><a href=\"https:\/\/love2d.org\/wiki\/Main_Page\">L\u00d6VE API<\/a>-inspired framework: Much of what you already know from L\u00d6VE will look familiar in the <a href=\"https:\/\/robloach.github.io\/ChaiLove\/\">ChaiLove API<\/a>.<\/li>\n<\/ul>\n<h2>Examples<\/h2>\n<p>It&#8217;s pretty easy to get started with ChaiLove, just check out these code snippets.<\/p>\n<h4>Drawing text<\/h4>\n<pre>\r\ndef draw() {\r\n    love.graphics.print(\"Hello World!\", 400, 300)\r\n}\r\n<\/pre>\n<h4>Drawing an image<\/p>\n<h4>\n<pre>\r\nglobal whale\r\n\r\ndef love.load() {\r\n    whale = love.graphics.newImage(\"whale.png\")\r\n}\r\n\r\ndef draw() {\r\n    love.graphics.draw(whale, 300, 200)\r\n}\r\n<\/pre>\n<h4>Playing a sound<\/h4>\n<pre>\r\nglobal music\r\n\r\ndef load() {\r\n    music = love.audio.newSource(\"music.wav\")\r\n    love.audio.play(music)\r\n}\r\n<\/pre>\n<p>For more information on <a href=\"http:\/\/chaiscript.com\/\">ChaiScript<\/a>, see the <a href=\"https:\/\/github.com\/ChaiScript\/ChaiScript\/blob\/develop\/cheatsheet.md#language-reference\">ChaiScript language reference<\/a>.<\/p>\n<h2>Case Study: Floppy Bird<\/h2>\n<p><a href=\"https:\/\/github.com\/RobLoach\/ChaiLove-FloppyBird\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.libretro.com\/wp-content\/uploads\/2017\/12\/floppybird-150x150.png\" alt=\"Floppy Bird Screenshot\" width=\"150\" height=\"150\" class=\"alignright size-thumbnail wp-image-46233\" \/><\/a><a href=\"https:\/\/github.com\/RobLoach\/ChaiLove-FloppyBird\">Floppy Bird<\/a> is an example of what a ChaiLove game could look like. The game is a re-imagining of Flappy Bird using ChaiLove. It features rotating sprite graphics, music, sounds, a high score, save state support, and more. It&#8217;s available to download <a href=\"https:\/\/github.com\/RobLoach\/ChaiLove-FloppyBird\/releases\">from the project releases<\/a>, or directly through <a href=\"http:\/\/retroarch.com\/\">RetroArch<\/a>:<\/p>\n<ol>\n<li>Online Updater \u2192 Core Updater \u2192 ChaiLove<\/li>\n<li>Online Updater \u2192 Content Downloader \u2192 ChaiLove \u2192 Floppy Bird.chailove<\/li>\n<li>Load Content \u2192 Downloads \u2192 Floppy Bird.chailove<\/li>\n<\/ol>\n<p>The following video shows not only how to download the ChaiLove core and Floppy Bird, but also some gameplay:<\/p>\n<p><center><iframe loading=\"lazy\" class=\"embed-responsive-item\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/RLVwTh6qDFI?rel=0\" frameborder=\"0\" gesture=\"media\" allow=\"encrypted-media\" allowfullscreen><\/iframe><\/center><\/p>\n<h2>What&#8217;s Next?<\/h2>\n<p><a href=\"https:\/\/github.com\/RobLoach\/ChaiLove\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.libretro.com\/wp-content\/uploads\/2017\/12\/chailovelogo.png\" title=\"Love2D + ChaiScript = ChaiLove\" alt=\"ChaiLove\" width=\"116\" height=\"116\" class=\"img-responsive alignright\" \/><\/a><a href=\"https:\/\/github.com\/RobLoach\/ChaiLove\">ChaiLove<\/a> has a few places where it could grow, and we&#8217;ll need your help for it to get there. Some ideas include:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/RobLoach\/ChaiLove\/issues\/132\">Additional platform support<\/a>. Since ChaiLove targets the libretro API, we could port it to platforms such as Android, iOS, Playstation 3, Wii, and more.<\/li>\n<li><a href=\"https:\/\/github.com\/RobLoach\/ChaiLove\/issues\/23\">Examples Browser<\/a> to have a large library of running examples of ChaiLove code.<\/li>\n<li><a href=\"https:\/\/github.com\/RobLoach\/ChaiLove\/issues\/171\">Update to SDL2<\/a> through <a href=\"https:\/\/github.com\/r-type\/\">@r-type<\/a>&#8216;s work on <a href=\"https:\/\/github.com\/r-type\/sdl2-libretro\">sdl2-libretro<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/RobLoach\/ChaiLove\/issues\/93\">Improve the audio system<\/a>. Adding OGG and FLAC would be great to have for music files.<\/li>\n<li><a href=\"https:\/\/github.com\/RobLoach\/ChaiLove\/issues\/74\">Lua support<\/a>. Just because it targets ChaiScript, doesn&#8217;t mean we can&#8217;t have Lua in there too. Having Lua support would allow running Love2D games in ChaiLove.<\/li>\n<li><a href=\"https:\/\/github.com\/RobLoach\/ChaiLove\/issues\/172\">More games!<\/a> Port and develop more games with ChaiLove as great examples of its use.<\/li>\n<\/ul>\n<h2>Resources<\/h2>\n<ul>\n<li><a href=\"https:\/\/github.com\/RobLoach\/ChaiLove\">ChaiLove<\/a><\/li>\n<li><a href=\"https:\/\/robloach.github.io\/ChaiLove\/\">ChaiLove API<\/a><\/li>\n<li><a href=\"http:\/\/chaiscript.com\/\">ChaiScript<\/a><\/li>\n<li><a href=\"https:\/\/love2d.org\/\">Love2D<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/RobLoach\/ChaiLove-FloppyBird\">ChaiLove: Floppy Bird<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>When it comes to 2D game development frameworks, there are many options out there for indie game developers. Every framework has its own pros and cons, and its own use cases. Today, let&#8217;s talk about L\u00d6VE, baby. L\u00d6VE is an awesome framework to make 2D games in Lua. With some modification, these games can be [&hellip;]<\/p>\n","protected":false},"author":8684,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[28,2,5],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.libretro.com\/index.php\/wp-json\/wp\/v2\/posts\/46255"}],"collection":[{"href":"https:\/\/www.libretro.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.libretro.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.libretro.com\/index.php\/wp-json\/wp\/v2\/users\/8684"}],"replies":[{"embeddable":true,"href":"https:\/\/www.libretro.com\/index.php\/wp-json\/wp\/v2\/comments?post=46255"}],"version-history":[{"count":4,"href":"https:\/\/www.libretro.com\/index.php\/wp-json\/wp\/v2\/posts\/46255\/revisions"}],"predecessor-version":[{"id":46297,"href":"https:\/\/www.libretro.com\/index.php\/wp-json\/wp\/v2\/posts\/46255\/revisions\/46297"}],"wp:attachment":[{"href":"https:\/\/www.libretro.com\/index.php\/wp-json\/wp\/v2\/media?parent=46255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.libretro.com\/index.php\/wp-json\/wp\/v2\/categories?post=46255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.libretro.com\/index.php\/wp-json\/wp\/v2\/tags?post=46255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}