<?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: Armen</title>
    <description>The latest articles on DEV Community by Armen (@armen138).</description>
    <link>https://dev.to/armen138</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%2F1670956%2Feb3ef04a-37dc-4507-aa48-66fb1dd44104.png</url>
      <title>DEV Community: Armen</title>
      <link>https://dev.to/armen138</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/armen138"/>
    <language>en</language>
    <item>
      <title>MiniJamLab: Building Scenes</title>
      <dc:creator>Armen</dc:creator>
      <pubDate>Wed, 31 Jul 2024 03:08:56 +0000</pubDate>
      <link>https://dev.to/armen138/minijamlab-building-scenes-4jdo</link>
      <guid>https://dev.to/armen138/minijamlab-building-scenes-4jdo</guid>
      <description>&lt;p&gt;It's been a little while since I wrote an update on what's going on with MiniJamLab, so here are a few things I want to share.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where's the editor?
&lt;/h2&gt;

&lt;p&gt;Conceptually, the way the engine works is similar to engines like Godot and Unity. We compose a scene from components/nodes and attach scripts to them to define behaviors. But where, then, is the editor? How do we go about "composing" anything, if we lack a "composer" tool? Well, that's a great question! Currently, I'm afraid you're stuck writing JSON files to define a scene. Luckily, the JSON file isn't overly complex - For example, this is the TypeScript interface that defines a base node component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface NodeData {
  is: string;
  name: string;
  script?: string;
  angle?: number;
  group?: string;
  position?: {
    x: number;
    y: number;
  },
  scale?: {
    x: number;
    y: number;
  },
  size?: {
    width: number;
    height: number;
  },
  opacity?: number;
  fill?: string;
  children?: NodeData[]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have no intention of displaying anything, this is all you need. Create a component, then add child-components, and so on.&lt;/p&gt;

&lt;p&gt;A quick high level overview of the allowed properties:&lt;/p&gt;

&lt;h3&gt;
  
  
  is
&lt;/h3&gt;

&lt;p&gt;"is" defines what kind of node we are serializing. The base component is just "Node", but we also have others like "Sprite", "TileMap", and some UI nodes like "Text" and "Button", as well as non-display nodes like "Audio" and "SimpleCollider".&lt;/p&gt;

&lt;h3&gt;
  
  
  name
&lt;/h3&gt;

&lt;p&gt;For many nodes, you'll want to be able to look them up and manipulate them from a script. In order to find them, we must name them - Note that the engine does not guarantee unique names, so keep that in mind!&lt;/p&gt;

&lt;h3&gt;
  
  
  script (optional)
&lt;/h3&gt;

&lt;p&gt;Well we can't just sit there and do nothing - the "script" property allows us to attach a script file, for which we use the excellent MiniScript language&lt;/p&gt;

&lt;h3&gt;
  
  
  angle (optional)
&lt;/h3&gt;

&lt;p&gt;For nodes that can be displayed (Sprite, TileMap), this allows us to rotate the node. This property may be moved out of the base node in the future.&lt;/p&gt;

&lt;h3&gt;
  
  
  group (optional)
&lt;/h3&gt;

&lt;p&gt;Like name, this helps us identify what node we're dealing with - this is particularly useful when dealing with collisions. If we collide with a node in the "enemies" group, we may want to take damage now. If we are are colliding with a node in the "ladders" group, we could enable vertical movement controls. These group names are user-defined, so don't be afraid to get creative!&lt;/p&gt;

&lt;h3&gt;
  
  
  position, scale, size (optional)
&lt;/h3&gt;

&lt;p&gt;Most nodes, even some that can't be displayed like the base node, will benefit from having at least a position set. That's because its children will be positioned relative to this, which allows things like easy attachments (weapons, tools), or relative movement (like parallax and particle effects)&lt;br&gt;
Scale is useful for example to scale up pixel art, and size will help define a bounding box for collision. Note that for Sprite nodes, the size can be derived from the image, but if it is given, and smaller than the image, it allows us to treat the image as a &lt;em&gt;spritesheet&lt;/em&gt;. Defining animations on a Sprite node is a topic for another day, however.&lt;/p&gt;

&lt;h3&gt;
  
  
  opacity (optional, default=1.0)
&lt;/h3&gt;

&lt;p&gt;Again for nodes that can be displayed, this will allow us to add some transparency - note that here too, the value applies to this node's children as well.&lt;/p&gt;

&lt;h3&gt;
  
  
  fill (optional)
&lt;/h3&gt;

&lt;p&gt;The "fill" property may mean slightly different things depending on what kind of node we set it on. On a base node with position and size, we are telling the engine to draw a rectangle with the given color. On a Text node, we are setting the fill color for the text. &lt;/p&gt;

&lt;h3&gt;
  
  
  children (optional)
&lt;/h3&gt;

&lt;p&gt;This one is a bit magical, as hinted at before: nodes defined as children will be drawn after their parent, relative to their parent's position, and inherit the parent's opacity. Hiding the parent will also hide all of its children.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seriously though... an editor?
&lt;/h2&gt;

&lt;p&gt;While I hope the above sparks the imagination, I bet it also looks a little daunting if you're thinking about even mildly complex scenes. There is no editor. Will there be one? Well, maybe. I can't see any merit in trying to build an editor like Godot, instead, as much as possible, I want to leverage available tools. For example, the TileMap node imports maps from the excellent TileD map editor - and includes support for collision data and item spawns, and indeed should in the future support embedded animated tiles, and parallax layers. In a way, that's most of your Editor needs taken care of. I also don't see a need to provide a code editor for the engine - there are so many options better than anything I could give you: vscode/codium, VIM, or even EMACS for the masochists among us. Use what makes you happy.&lt;/p&gt;

&lt;p&gt;Unfortunately that does leave a few gaps: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Composing individual components&lt;/li&gt;
&lt;li&gt;Creating UI layouts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Open source tools are notoriously bad at marketing themselves, so perhaps solutions for these exist that I simply haven't come across yet. Perhaps in the end, I'll create a small editor to compose Sprite components and UI layouts. First, however, I'd like to actually have a functioning demo game running on this Mini Jam Lab of mine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;JSON is a practical format because it is widely supported, many tools exist to create and manipulate these files. However, it's not great for humans to read and write. Other options exist, but sacrifice heavily on tooling. Perhaps another, better way exists to serialize a scene - if anyone has a suggestion I'd love to hear it!&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>miniscript</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Plotting a course: MiniJamLab</title>
      <dc:creator>Armen</dc:creator>
      <pubDate>Thu, 27 Jun 2024 13:15:16 +0000</pubDate>
      <link>https://dev.to/armen138/plotting-a-course-minijamlab-ada</link>
      <guid>https://dev.to/armen138/plotting-a-course-minijamlab-ada</guid>
      <description>&lt;p&gt;As the toy game engine is starting to take shape, it's time to put some thought into what I really want from it. First, perhaps a (very) short list of what I don't want:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This won't be a general purpose game engine&lt;/li&gt;
&lt;li&gt;This will not even attempt to compete with the wonderful solutions already out there&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now before we get into what we &lt;em&gt;do&lt;/em&gt; want out of this, let's give it a name:&lt;br&gt;
&lt;strong&gt;MiniJamLab&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mini: Miniscript is the primary behavior scripting language&lt;/li&gt;
&lt;li&gt;Jam: Intended rapid development cycles like Game Jams&lt;/li&gt;
&lt;li&gt;Lab: Experimental, handle with care!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Things that set &lt;em&gt;MiniJamLab&lt;/em&gt; apart from general purpose game engines
&lt;/h2&gt;

&lt;p&gt;One of the goals, as the name implies, is to increase the development velocity of small games, an as you might have guessed, this can't be done without making some sacrifices. In order to reduce the amount of boilerplate code required to get something running, we need a &lt;em&gt;higher level of abstraction&lt;/em&gt;. Our game script shouldn't have to worry about opening a window, getting a drawing context, loading image data, decoding the image and writing pixels. But how &lt;em&gt;high&lt;/em&gt; do we go? Do we attach behaviors to a &lt;strong&gt;Sprite&lt;/strong&gt;, a &lt;strong&gt;Button&lt;/strong&gt;, a &lt;strong&gt;TileMap&lt;/strong&gt;? &lt;br&gt;
This is where the sacrifice comes in: to rather than defining a 100 kinds of nodes you might add to your scene, get the intersection of the ones you need. A &lt;strong&gt;Sprite&lt;/strong&gt;, &lt;strong&gt;Button&lt;/strong&gt; and &lt;strong&gt;TileMap&lt;/strong&gt; all have a few things in common: They are displayed, and may interact with user input. You might say that each of them is an &lt;em&gt;Actor&lt;/em&gt; in the scene, and a behavior attached may determine if and where it is displayed, and what to do with incoming user input. We could take this further! If we further sacrifice our ability to be "general purpose" and, for example, only allow &lt;em&gt;Tower Defense&lt;/em&gt; games, then all we need is a way to configure a &lt;strong&gt;Map&lt;/strong&gt;, a number of &lt;strong&gt;Towers&lt;/strong&gt; and a number of &lt;strong&gt;Enemies&lt;/strong&gt;, which all have enough intersection to be scripted the same way. &lt;/p&gt;

&lt;p&gt;In short, in order to determine the "ideal" level of abstraction for behavior scripts, we need to think long and hard about &lt;em&gt;what kind of games&lt;/em&gt; we want to build with this. &lt;/p&gt;

&lt;p&gt;So let's set some goals, MiniJamLab should be able to power at least:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A platformer. Classic.&lt;/li&gt;
&lt;li&gt;An RPG or Rogue-Like&lt;/li&gt;
&lt;li&gt;A Real-Time or Turn-Based Strategy game&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The platformer is the odd duck here - it is the only one that won't work on a tile-based coordinate system, but other than that, there is enough intersection between these games to provide a single Actor type node to the scripting environment. The first demo/sample will also be a platformer, so I can focus on the required features for this first. &lt;/p&gt;

&lt;p&gt;Well, that's enough for now - next update I'll go a bit deeper into what Miniscript is, why it's great, and how MiniJamLab will use it.&lt;/p&gt;

</description>
      <category>miniscript</category>
      <category>gamedev</category>
      <category>typescript</category>
      <category>namingthingsishard</category>
    </item>
    <item>
      <title>The new and shiny</title>
      <dc:creator>Armen</dc:creator>
      <pubDate>Sun, 23 Jun 2024 17:39:08 +0000</pubDate>
      <link>https://dev.to/armen138/the-new-and-shiny-4eil</link>
      <guid>https://dev.to/armen138/the-new-and-shiny-4eil</guid>
      <description>&lt;p&gt;Every once in a while I come across something new (to me) and interesting, and it makes me wonder... could I build a game engine on this? (spoiler alert: the answer is always yes). Recently I came across MiniScript, an embeddable scripting language that has apparently been around for years, but somehow escaped my attention until now. There are at least 3 implementations of the MiniScript interpreter, in C++, C# and TypeScript, which allows a lot of flexibility in what tools and frameworks to embed with. For my experiment, I've chosen TypeScript, as it is a language I use often in my day to day work, and allows for fast prototyping with excellent tooling.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what do I call it?
&lt;/h2&gt;

&lt;p&gt;Oh, naming things - certainly one of the hardest parts of the entire project. I will base a lot of this project on concepts I used to build the A2D engine (over 12 years ago now!), but calling it A2D2 just sounds like a drone I'm not looking for. I've asked a chatbot to help me come up with a name and the best it could do was "MiniJamLab", which I guess isn't the worst. Suggestions welcome, though.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Goals
&lt;/h2&gt;

&lt;p&gt;First I want to say I'm not looking to build the next big thing, competing with the likes of Godot (I love Godot). &lt;/p&gt;

&lt;p&gt;So, goals:&lt;/p&gt;

&lt;h4&gt;
  
  
  Avoid callbacks
&lt;/h4&gt;

&lt;p&gt;12 years ago I built A2D around event listeners - which meant, as was customary for the time in JavaScript, &lt;em&gt;callback hell&lt;/em&gt;. This time around, I want to avoid callbacks as much as possible, and instead keep things synchronous where possible, and use async/await where not.&lt;/p&gt;

&lt;h4&gt;
  
  
  Separate behavior scripts (using MiniScript!)
&lt;/h4&gt;

&lt;p&gt;There should be no need for boilerplate code in the bahavior scripts. No creating drawing contexts, manipulating pixels, etc. Let the Engine handle the stuff, and write the code that actually makes things happen.&lt;/p&gt;

&lt;h4&gt;
  
  
  Testable code
&lt;/h4&gt;

&lt;p&gt;This one gets me every time. I get excited and have half of the thing built and running a game of sorts before I realize I haven't added &lt;em&gt;any&lt;/em&gt; unit tests! This time will be different. TDD is the name of the game, and it forces me to think about architecture differently, producing more testable code.&lt;/p&gt;

&lt;h4&gt;
  
  
  Leverage existing tools and formats
&lt;/h4&gt;

&lt;p&gt;Why build a map editor if a perfectly good one exists already? Why invent a configuration file format if JSON and YAML are perfectly fine for the job? Let's not create headaches for solved problems (I know, the entire "Game Engine" problem has been solved, but let me have a little fun with this, ok?)&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons Learned
&lt;/h2&gt;

&lt;p&gt;And finally, I'm re-reading a lot of my own old code, particularly in the old A2D engine code, to see how I solved the common problems at the time, and what I can learn from my mistakes.&lt;/p&gt;

&lt;p&gt;More updates to come... &lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>typescript</category>
      <category>miniscript</category>
    </item>
  </channel>
</rss>
