<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tom Van den Bon</title>
    <description>The latest articles on DEV Community by Tom Van den Bon (@tomvdb).</description>
    <link>https://dev.to/tomvdb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F292596%2Fa4abbdfa-ec35-41a9-9511-5dfe02f7bab9.jpeg</url>
      <title>DEV Community: Tom Van den Bon</title>
      <link>https://dev.to/tomvdb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tomvdb"/>
    <language>en</language>
    <item>
      <title>CodeSim - A Game controlled by Code - DevLog - Part 2</title>
      <dc:creator>Tom Van den Bon</dc:creator>
      <pubDate>Sun, 26 Jan 2020 18:17:38 +0000</pubDate>
      <link>https://dev.to/tomvdb/codesim-a-game-controlled-by-code-devlog-part-2-1ijo</link>
      <guid>https://dev.to/tomvdb/codesim-a-game-controlled-by-code-devlog-part-2-1ijo</guid>
      <description>&lt;p&gt;Phew, a lot has changed since my &lt;a href="https://dev.to/tomvdb/codesim-a-game-controlled-by-code-devlog-part-1-h6l"&gt;last update&lt;/a&gt; around my CodeSim game. It's been a wonderful learning experience getting to grips with using Unity. My little experimental game has progressed quite a lot. Here are some of the more notable updates:&lt;/p&gt;

&lt;h1&gt;
  
  
  Graphics
&lt;/h1&gt;

&lt;p&gt;I'm not much of a 3d graphic designer so I'm mostly dependent on existing assets for my game (at least for now). I originally used an asset that had models for vehicles and a town environment. The more I worked on the game, the more I realized that it doesn't really fit well for me. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qcq7v-d4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jh0q5954h8iyfzj48wow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qcq7v-d4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jh0q5954h8iyfzj48wow.png" alt="Alt Text" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I did some more searching and came across another set which fits better. I overhauled everything with the new assets and it looks great! Our main programmable vehicle is nou a catapult. It sounds a bit weird, but it has the advantage of turning it into a shooting catapult...but more on that later&lt;/p&gt;

&lt;h1&gt;
  
  
  Actions and Sensors
&lt;/h1&gt;

&lt;p&gt;Obviously just programming our code vehicle to go forward and turn around is a good start, but it really gets old quickly. I've started to add more commands for "Sensors", this essentially is a command that gives data back but doesn't directly do anything to the code vehicle movements. The sensors I've added are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Location&lt;/strong&gt; - Returns our current grid X and Y position&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GoalLocation&lt;/strong&gt; - Returns the goal X and Y Position&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FrontSensor&lt;/strong&gt; - This tells us whether there is an obstacle in front of us&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DirectionSensor&lt;/strong&gt; - This tells us which direction we are pointing to&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All these sensors would not necessarily be available from level 1 as they can be added as the levels increase.&lt;/p&gt;

&lt;p&gt;Another big action that I added, is the ability to shoot! This allows us to put down "Breakable" objects that needs to be destroyed to be able to let our program reach the goal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AGebEZHH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zalxb0l9rc098dq7cran.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AGebEZHH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zalxb0l9rc098dq7cran.gif" alt="Alt Text" width="880" height="569"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The new sensors and shooting action should make the levels a lot more fun and engaging.&lt;/p&gt;

&lt;p&gt;Speaking of levels...&lt;/p&gt;

&lt;h1&gt;
  
  
  Level Editor
&lt;/h1&gt;

&lt;p&gt;On my bigger issues was how annoying it was to setup a level in code. It worked fine for testing and developing, but once I needed more levels it became an essential requirement.&lt;/p&gt;

&lt;p&gt;Originally I went with one of the popular ways that unity developers use (according to a bunch of YouTube videos) is to create a graphic with different colored pixels. When the level loads, it would go through each pixel in the graphic and then build the level. &lt;/p&gt;

&lt;p&gt;For all intents and purposes, this worked, but it wasn't really much less work than actually coding in the level.&lt;/p&gt;

&lt;p&gt;I decided to bite the bullet and figure out a way to make a level editor in the game that allows you to place objects easily. The end result is a simple top down view of the game world and you just click wherever you want to put down a piece. Pressing space-bar allows you to cycle through the pieces. You also use it to place the player position and the goal position (its smart enough to know that if you try to place to player positions, it will just update it)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Su2kcSaa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/p8vrexn8o4fqf796x8d6.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Su2kcSaa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/p8vrexn8o4fqf796x8d6.gif" alt="Alt Text" width="668" height="627"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At the moment there is only 1 level, but with the above changes done I can start focusing on more expanding the levels and doing more game play mechanics. My little tester (8 years) also have lots of ideas to improve it, but I love how quickly he caught on with writing simple python programs to control the game.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VYKzj-tc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/w4286hzaollcq58d2isf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VYKzj-tc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/w4286hzaollcq58d2isf.jpg" alt="Alt Text" width="880" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's been a fun journey considering that I started with Unity for the first time over Xmas holidays. I try to add work on it for an hour here and there in the evenings. Still have lots of ideas so stay tuned for the next update. Also should have a test release with the next update as well so that everyone can play along!&lt;/p&gt;

</description>
      <category>unity3d</category>
      <category>gamedev</category>
      <category>devlog</category>
    </item>
    <item>
      <title>Getting Started with the Odroid-GO and Arduino</title>
      <dc:creator>Tom Van den Bon</dc:creator>
      <pubDate>Sun, 12 Jan 2020 13:47:04 +0000</pubDate>
      <link>https://dev.to/tomvdb/getting-started-with-the-odroid-go-and-arduino-4mp8</link>
      <guid>https://dev.to/tomvdb/getting-started-with-the-odroid-go-and-arduino-4mp8</guid>
      <description>&lt;p&gt;Recently I've started doing more and more projects with the &lt;a href="https://www.espressif.com/en/products/hardware/esp32/overview"&gt;ESP32&lt;/a&gt; module. The ESP32 is a low-cost, low-power system on a chip microcontroller with integrated Wi-Fi and dual-mode Bluetooth. &lt;/p&gt;

&lt;p&gt;You get various development boards with an ESP32 module, but I always find myself hacking on a few buttons and a display every time I prototype something new. I have always considered the idea of creating a custom pcb with the ESP32 module, some buttons, display etc, but never gotten around to it. While looking for something else I came across the &lt;a href="https://www.hardkernel.com/shop/odroid-go/"&gt;ODROID-GO&lt;/a&gt;, a special 10 year anniversary product sold by HardKernel.&lt;/p&gt;

&lt;p&gt;It's essentially a game kit that you assemble (very easy, no soldering required) into your own little portable game console which looks a lot like the old Game Boy. It comes with emulator firmware that allows you to load some ROMS on an SD card to play all those all old retro games we love. &lt;/p&gt;

&lt;p&gt;Where things get interesting is that it all runs on an ESP32 module. This means that we can load our own code on there which turns the game kit into a development board with some nice features. These features include a 2.4 inch screen, a couple of buttons and it's all powered by a rechargeable battery which makes it great for testing portable prototypes. The original designers have also added an expansion port that allows you to connect more peripherals. We now have a nicely packaged portable development board for the ESP32 module. Yay!!&lt;/p&gt;

&lt;h1&gt;
  
  
  Software Setup
&lt;/h1&gt;

&lt;p&gt;To allow us to write some code for the Odroid-Go we need to setup some software.&lt;/p&gt;

&lt;p&gt;The following software is required to be able to develop new firmware using Arduino&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Arduino&lt;/li&gt;
&lt;li&gt;ESP32 Board Support&lt;/li&gt;
&lt;li&gt;ODROID-GO Arduino Library&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Arduino
&lt;/h2&gt;

&lt;p&gt;The Arduino IDE is our base sofware and everything builds on it from here. You can download a installer for your platform from the &lt;a href="https://www.arduino.cc/"&gt;Arduino Website&lt;/a&gt;. This should be a fairly simple install and you will end up with something that looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IoLtgfBj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/8q9okqhy9mphzfdtbb9g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IoLtgfBj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/8q9okqhy9mphzfdtbb9g.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ESP32 Board Support
&lt;/h2&gt;

&lt;p&gt;Once your Arduino is up and running you need to add support for the ESP32 modules. This will install tools to allow you to compile your arduino program for any ESP32 development board/Module&lt;/p&gt;

&lt;p&gt;First we need to add the following url to our Arduino preferences.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://dl.espressif.com/dl/package_esp32_index.json
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Click on &lt;strong&gt;File-&amp;gt;Preferences&lt;/strong&gt; to get the following window:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ftpeAdC6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9fxxde8ybcarwk0so0rw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ftpeAdC6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/9fxxde8ybcarwk0so0rw.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the icon next to the &lt;strong&gt;Additional Board Manager URLs&lt;/strong&gt; to bring up a new window and paste the link above into the textbox&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rtesEX0I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/faz3uozowtm9gn5dv2d0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rtesEX0I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/faz3uozowtm9gn5dv2d0.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can now access the &lt;strong&gt;Boards Manager&lt;/strong&gt; under &lt;strong&gt;Tools-&amp;gt;Board: ...-&amp;gt;Boards Manager&lt;/strong&gt; and search for esp32. Simply select the package and click on &lt;strong&gt;install&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lk4Dw5Gh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/456gtjtkudom93igxn7j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lk4Dw5Gh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/456gtjtkudom93igxn7j.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After this has been installed you will now be able to select from a variety of ESP32 development boards&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Wg5f8DRj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/b33nuy7dx3gyzi26vwhq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Wg5f8DRj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/b33nuy7dx3gyzi26vwhq.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ODROID-GO Arduino Library
&lt;/h2&gt;

&lt;p&gt;The last step is simply to install an arduino library from HardKernel that gives us access to easy functions to use in our Arduino scripts specifically related to the ODROID-GO. This includes options to write to the LCD, detect when buttons have been pressed, etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://github.com/hardkernel/ODROID-GO
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The final download is the github repository at the link above. You can either clone the repo or just download a zip of it. You want to place the contents in your Arduino &lt;strong&gt;libraries&lt;/strong&gt; folder. On a windows installation this would mostly be in your &lt;strong&gt;Documents-&amp;gt;Arduino-&amp;gt;libraries&lt;/strong&gt; folder&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QaVJkS62--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jare7ukk5ffdzfxsb9rd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QaVJkS62--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jare7ukk5ffdzfxsb9rd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your Arduino IDE was open during this process then please restart it now. If all goes well then you should have ODROID-GO examples under you &lt;strong&gt;File-&amp;gt;Examples&lt;/strong&gt; menus in Arduino&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--a7dgk0h8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kh1g8v4oacymrqq83vk9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a7dgk0h8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kh1g8v4oacymrqq83vk9.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing
&lt;/h2&gt;

&lt;p&gt;If all goes well you should now be completely setup to compile code and upload it to the ODROID-GO&lt;/p&gt;

&lt;p&gt;You can now plugin in your ODROID-GO into a usb port. Give it a few seconds to install any drivers it might need to (if using Windows).&lt;/p&gt;

&lt;p&gt;To test load the Hello_World sketch from the ODROID-GO examples and select the ODROID ESP32 board from the boards menu (Under *&lt;em&gt;Tools-&amp;gt;Board..&lt;/em&gt;). Make sure the port is pointing to the new serial port that enumerated when you plugged in your ODROID-GO&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r8yNkZnH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jvhowxq0ef3wposctbs5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r8yNkZnH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/jvhowxq0ef3wposctbs5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the &lt;strong&gt;Compile and Upload&lt;/strong&gt; Button (The arrow next to the checkmark). The can take a few seconds when you compile for the first time, but subsequent times will be faster (depending on the changes you make).&lt;/p&gt;

&lt;p&gt;If all goes well then you should now see the &lt;strong&gt;Hello World&lt;/strong&gt; demo on your ODROID-GO!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--geh7t-eQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/cf2ka1em2v78cpu51q5m.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--geh7t-eQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/cf2ka1em2v78cpu51q5m.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go ahead and try out the various examples and have fun!!&lt;/p&gt;

</description>
      <category>esp32</category>
      <category>arduino</category>
    </item>
    <item>
      <title>CodeSim - A Game controlled by Code - DevLog - Part 1</title>
      <dc:creator>Tom Van den Bon</dc:creator>
      <pubDate>Fri, 03 Jan 2020 11:14:43 +0000</pubDate>
      <link>https://dev.to/tomvdb/codesim-a-game-controlled-by-code-devlog-part-1-h6l</link>
      <guid>https://dev.to/tomvdb/codesim-a-game-controlled-by-code-devlog-part-1-h6l</guid>
      <description>&lt;h1&gt;
  
  
  Game Concept
&lt;/h1&gt;

&lt;p&gt;I love games in which you can code. Be it something simple as a pseudo language or a game that has a lua interpreter embedded into it. A nice example is &lt;a href="https://colobot.info/"&gt;Colobot&lt;/a&gt;. I spent many hours on it.&lt;/p&gt;

&lt;p&gt;Recently I starting playing with Unity with the idea of using it for a couple of work projects. Not so much games, but rather interesting interfaces to production equipment. While learning how to use Unity I got the idea that I can easily make my own game that uses code to control it. Thus the concept of CodeSim (temporary name) started. &lt;/p&gt;

&lt;p&gt;The basic concept is that you control a object, player, etc in the game using an outside program. The program that controls the game needs to be separate from the game/simulation itself. This allows the player to use his preferred programming language and environment. &lt;/p&gt;

&lt;p&gt;I started with this simple example of how you would control the vehicle in CodeSim:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;codevehicle&lt;/span&gt;

&lt;span class="n"&gt;codevehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ConnectVehicle&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;codevehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Reset&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;codevehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TurnLeft&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;codevehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MoveForward&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;codevehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TurnRight&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;codevehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MoveForward&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;codevehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TurnRight&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;codevehicle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MoveForward&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Program Failed, Reason: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Done"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The core concept is basically similar to &lt;a href="https://en.wikipedia.org/wiki/Logo_(programming_language)"&gt;Logo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Very basic of-course, but if the underlying game engine could be controlled this way then you can start creating all kinds of fun things/challenges in the game. &lt;/p&gt;

&lt;h1&gt;
  
  
  Required Game Features
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;A simple game world with a robot/vehicle controlled by the player&lt;/li&gt;
&lt;li&gt;Some kind of api interface that is simple enough that almost every language can talk to it&lt;/li&gt;
&lt;li&gt;Real time update of the world as the program runs with a goal to reach, or indicating failure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm sure there will be many more features in the future, but for the concept to work I had to have atleast those 3 items&lt;/p&gt;

&lt;h1&gt;
  
  
  Game World
&lt;/h1&gt;

&lt;p&gt;Unity makes it pretty easy to create a gameworld, I decided on a 3d game world that is simple and I found some nice &lt;a href="https://assetstore.unity.com/packages/3d/environments/urban/simple-town-cartoon-assets-43500"&gt;3d assets&lt;/a&gt; to use in this proof of concept.&lt;/p&gt;

&lt;p&gt;Our vehicle started out with simple 3d model of a car and some c# scripts that gave us functions to move it in a turtle like fashion, ie (MoveForward, TurnLeft, etc)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2Y3htCoJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/yxvuqi16q2drn41hwlrh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2Y3htCoJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/yxvuqi16q2drn41hwlrh.png" alt="Alt Text" width="880" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the first couple of tests I made a basic "end goal" gameobject and some obstacles it needs to avoid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vcUl6Kuu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/oy5k98c3t35e10374ik3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vcUl6Kuu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/oy5k98c3t35e10374ik3.png" alt="Alt Text" width="880" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Game API
&lt;/h1&gt;

&lt;p&gt;To allow our player to control the vehicle in the game we need to create an api of sorts. I decided that sockets are the way to go. When our game starts up it listens on port 13000 on the localhost and waits for any incoming connections. Our current list of commands are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MoveForward(amount of units to move)

&lt;ul&gt;
&lt;li&gt;move the vehicle forward and specify the amount of units to move&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;TurnLeft 

&lt;ul&gt;
&lt;li&gt;makes a 90 degree turn to the left&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;TurnRight

&lt;ul&gt;
&lt;li&gt;makes a 90 degree turn to the right&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Reset

&lt;ul&gt;
&lt;li&gt;Reset the vehicle to starting point&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These commands are sent in plaintext to the socket server in the game. To move the vehicle forward 50 units we send the following text&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;forward,50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The game will respond with one of the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OK             # command successfully executed
COMPLETED      # goal block reached (ie. end of level)
DISABLED       # vehicle collided against something and is disabled (required reset)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A simple command set, implemented in a simple way, but enough to test the concept&lt;/p&gt;

&lt;h1&gt;
  
  
  Watch your program run!
&lt;/h1&gt;

&lt;p&gt;As a first test I implemented a simple python module that will send the commands to the socket server. Using Visual Studio Code is very simple to run the program and see the results in the game:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xcGqaVdY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/k0nh5zvptrdeoaednwyn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xcGqaVdY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/k0nh5zvptrdeoaednwyn.png" alt="Alt Text" width="880" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When your vehicle hits an obstacle it will go in disabled state and need to be reset again before you can send more commands to it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CPocdmkv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/a9utwqxh2yvz3j2q0kxl.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CPocdmkv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/a9utwqxh2yvz3j2q0kxl.gif" alt="Alt Text" width="621" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Successfully reaching the end goal looks something like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--62eUnyOi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/z1exnj9387nkq84h832s.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--62eUnyOi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/z1exnj9387nkq84h832s.gif" alt="Alt Text" width="621" height="398"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And with that we have a working proof of concept of a game that can be controlled from your own code outside the game. This is nothing group breaking and other similar games exist. But this a fun way for me to learn to use unity :)&lt;/p&gt;

&lt;h1&gt;
  
  
  Next Steps
&lt;/h1&gt;

&lt;p&gt;With the basic core working I'm keen to expand on it further. For the next update I'm planning on creating some proper levels and add some more interactions. Maybe a radar that lets you detect obstacles, or action buttons you can drive over the make things happen.&lt;/p&gt;

&lt;p&gt;Let me know in the comments if you have other ideas that would work nicely with this concept.&lt;/p&gt;

</description>
      <category>unity3d</category>
      <category>gamedev</category>
      <category>devlog</category>
    </item>
  </channel>
</rss>
