Category: Tutorials & Practice

  • Rails Girls, Day 2

    It took me a little while to come back to this, as I was never really able to properly figure out what was going wrong with Yarn. Eventually I decided that, since I also have an Ubuntu terminal and Linux running on my machine, I’d get set up over there instead, which let me bypass a lot of the issues I was running into with SQLite3 and Yarn.

    So, onto the next section: Building Your First App.

    Setting Up

    The first steps were to make a directory to store a Rails app in (pretty easy), per their instructions, and then use Rails’ scaffolding setup to generate some ideas.

    This was where I ran into my first hurdle (well, with the design of the tutorial itself — I’m not counting all the technical hoops of the first day): this tutorial is designed to augment a public workshop. What this means is that there are sections that essentially say “Here we’re going to learn about scaffolding. Run this command, and then the coach will tell you what scaffolding is.”

    And then there’s no explanation of scaffolding.

    Which — not the end of the world. Google is free. But it does mean at least a few minutes get expended on sorting through the first couple of results, figuring out which ones are documentation, which are explanations and which are ads, and trying to parse these as quickly as possible without having to do a whole ‘nother tutorial to try and figure them out.

    (For the record, scaffolding is essentially running a command that will quickly write up the basic Model-View-Controller framework of your app for you, which you can then build on. It does exactly what a scaffold should.)

    Working with the Scaffold

    So the first thing, setting up the scaffold, looks a little like this:

    rails generate scaffold idea name:string description:text picture:string

    Guess what was not explained in this tutorial. If you guessed “any of those arguments”, you guessed correctly. I ended up finding the answer in one of the Ruby on Rails Getting Started guides, section 6.1. The quick answer is that this forms a table for storing “ideas” where each idea has three attributes (ideas are rows, attributes are columns). The arguments are the name of each attribute, and its datatype. Simple enough concept, and again something that would probably have come across better in a live workshop.

    [a brief intermission while I check if Rails Girls has recorded any workshops]

    [none that I can find]

    [intermission over, we proceed]

    After setting up the scaffold, updating the database, and running the server, I opened the site and found an empty table with a “New Ideas” button. The button opened a field looking like this:

    The new ideas form and its fields.

    Hey, presto! A couple of ideas later, and the table is beginning to look a little fuller.

    The ideas table, now populated with two ideas: “Add Bear” and “Destroy Bear”.

    And yes, I tested “Show”, “Edit” and “Destroy”. They do about what you’d expect.

    Design

    The next section (again headed off by “The coach will explain this part”) talks about the ‘View’ part of a MVC model, and which part of a view is HTML versus which part is Embedded Ruby (ERB). It doesn’t really explain how the two connect up, nor which part of a view is made of which. I have some familiarity with MVC from my computer science classes, if I didn’t, this would probably be another place where Pilot Stops to Google.

    Went through the design bit; it was semi-easy, semi-interesting. When I’m working in HTML I’m always aware that there’s lots I don’t know, but it all follows so easily from what I do know that it feels like it goes almost too smoothly. I did learn about how ERB works in this context:

    <% %>
    <=% %> 

    and presumably some other similar related ones are the tags one uses to embed Ruby into the page. I found that one out on StackExchange, where I was also assured that Haml is a far superior alternative for embedding Ruby into web pages.

    Saved the code; ran the code.

    I got surprised when saving the code and visiting the main page (localhost:3000) didn’t do anything, though – the styling only appeared on the page for the Ideas app (localhost:3000/ideas). I don’t know why that is yet. Right now my guess is something to do with the idea that there’s only dummy content on the main page, and the scaffold generated is just for the /ideas page. To be investigated.

  • Rails Girls, Day 1

    Well, day 1.5? Day 2? The point is, I did a (very little) bit of the setup yesterday, but ran into a roadblock that I couldn’t resolve until now.

    I’ve been working for a while on how to learn/run Ruby, and for now I’m settled on following some of the Rails Girls guides for creating web apps. Rails Girls is an organization that runs events teaching girls how to code in Ruby on Rails, but they also have tutorials online here.

    So far, this has been an exercise in Googling a lot of stuff to see whether my computer will run things compatibly. The biggest two hurdles have been SQLite3 and Yarn (out of Ruby, Git, Node.js, SQLite3 and Yarn).

    For the former, the issue has been determining whether they have a toolkit for 64-bit computers (they don’t), whether they have SQLite3 itself for 64-bit computers (they do), whether I can run the 32-bit toolkit on my computer (I can), and whether I can mix the 32-bit toolkit with the 64-bit version (I decided not to bother, since I can run the 32-bit version as well).

    For the latter, it’s been trying to figure out why I could successfully install/update Yarn over and over again using Node.js, which was determined to be running, but not actually use any of Yarn’s commands (apparently you have to restart your computer. No one told me).

    Update from several hours later: restarting did not fix it. I think I’ll need to add the folder to my PATH in order to be able to use the commands. Will investigate tomorrow & hopefully be able to write up a little more about what is happening.

  • “Creator Kit: Beginner Code”: Day 4

    Not a whole lot to report today — mostly spent today going through documentation, getting set up again, and trying to pseudocode my way through the effect I wanted to write out. Turns out the windup tutorial actually happens in three stages: one stage for consumables, one for equippable items, and one for equippable tools.

    In the end the thing that turned out to help me most was a combination of pseudocode and working backwards: writing out the objectives I had for the program, then taking tiny steps like “Okay, this needs to return a boolean; it’s consumable, so it returns false” and “Once all of the parameters are set up (even though they aren’t yet), I’ll pass them in here, which will perform the main point of this code)”.

    Working backwards was also an interesting way to diagnose problems, because I’ll find out later whether I’ve made a huge mistake about conceptualizing things, but in the meantime I can isolate all of the syntax issues that are happening while I try and set up my parameters, as a result of not knowing C# very well.

  • “Creator Kit: Beginner Code”: Day 3

    Really, for real, almost nothing to report from today. I fixed the problem in my code, tested it (it worked, because I’m amazing), and finished the last official remaining unit in the project. The unit was to make your own script from scratch, but it was still pretty simple — writing one function which contained one line of code, and then applying it in the Unity editor.

    The main question, as always, is what’s happening next. I think I’m going to work through the last couple units of the game — there are a couple where the time-to-complete is listed as zero, presumably because they’re both optional and pretty free-form. There’s one to customize your game some more, and then a couple which look like they’re about sharing and submitting your mods, which should be quite quick.

    They have two recommended tutorials after this, one for 3D work and one for 2D work, both of which will presumably involve more coding in C#. I’m deciding whether to do them or take a whack at the beginning VR tutorial I found, because one thing this tutorial showed me is that when they say beginner, they really mean it. You didn’t need to have prior coding knowledge or experience to make this tutorial work. Which has left me a little less scared of the VR tutorials, at least the ones that’ll be holding my hand.

    I can’t remember whether I ever linked the Beginner Code tutorial, but here it is. And here’s the Unity documentation/Scripting API.

  • “Creator Kit: Beginner Code”: Day 2

    Today I went through another big chunk of the Creator Kit: Beginner Code tutorial. Yesterday was an introduction to (a review of) variables and functions, plus some syntax for C#. Today was all about classes, and I was both bored and boggled by turns.

    Bored

    It is TBQH not the tutorial’s fault that I already know a lot of the concepts they’re introducing, and that I’m mostly in it for the syntax, but still. I ended up critiquing the lesson structure in my notes halfway through, which isn’t the worst use of my time (learning how to teach is definitely not nothing), but still wasn’t… great.

    The lesson that got me was the unit about writing your own spawner class, which per my notes was structured something like this:

    1. Here’s how to write the syntax for declaring a class (always a good place to start)
    2. Declare your global variables (a good next step, though they didn’t actually call them global variables or explain what the difference would be, which seems important)
    3. Write the most important function, the one you absolutely need your class to be able to perform (a constructor, you say? no, no. just the function which is the primary point of the class. which… i get, but seems backwards)
      1. In writing the most important function, use a class and function which we have written for you elsewhere. This function should be relatively simple to write on your own, even if it would provide redundancy (I assume the function is also needed other places, which means they can’t wait for you to write it in the tutorial. But you won’t write it. We won’t tell you how it works.
      2. Here’s a hint: it’s almost definitely just a modulo operator. That’s it.
    4. Now you get to write the constructor function.
    5. But because we didn’t tell you about what public variables are, your code doesn’t work, and you now have five errors.
    6. That’s it, that’s the end of the unit. See you next time.

    I bet it shows how impressed I was.

    But it was actually good practice for writing code, and I found myself remembering syntax pretty intuitively, which was helpful.

    Boggled

    In order to treat myself and prove what a smart and special programmer I am, I decided to add in a for-loop, using a public int which one could set in Unity. The size of the int would determine how many health potions/how much money spawned at the start of the game.

    Ladies, gentleman, and those of us who know better: I broke everything.

    That’s perhaps a little overdramatic, but essentially, I crashed the Unity editor like six times. You could not change the variable and then run the game without immediately causing the Unity editor to freeze, which in turn forced me to kill the program from the Task Manager.

    If you didn’t change the variable (which by default was 0), everything was fine, by which I mean the game would run without the Unity editor crashing. Everything was not fine, in that zero potions would spawn, with no way to change that.

    Eventually I decided to put my for-loop inside a conditional clause: if the number of potions is less than or equal to zero, don’t bother. If it’s not, try the for-loop.

    This worked, in that the game no longer crashed if you changed the variable. It still left me with absolutely no potions, because the game just did not care what you changed the variable to.

    I gotta figure out how to write to the console in order to speed up my debugging. In the meantime, have a screenshot of my terrible for-loop (with the section it was supposed to replace commented out). That’s all, folks!

    A screenshot of code, consisting of the declaration of two global variables, a function which contains a variable meant to calculate angles and an if-statement containing a for-loop containing a function that is meant to spawn loot. Commented out is the same function outside of the if-statement, but repeated four times.
    Please witness that most important precursor to success: failure.

    UPDATE: I FOUND IT. RIGHT AWAY. ABSOLUTELY CLASSIC.

    (Hint: I asked i to be equal to zero, and also greater than whatever number of objects I wanted to spawn. Oops.)

  • “Creator Kit: Beginner Code”: Day 1

    So, following up from yesterday – today was about the Beginner Code tutorial on Unity. It was, as the name says, very beginner — it did a lot of introducing the concepts of variables and functions, which meant that I skimmed those sections.

    The tutorial started out pretty simple, with a general rundown of how computers, compilers and code all work together, as well as exploring the game to see how different parts of the world work. Then it went into examining scripts, and how to read through C# when written out.

    One thing I really appreciated was that the tutorial made a point of introducing a term that would make no sense without explanation, then immediately linking the documentation and walking you through how to use it. Beginning programmers, like the sort this tutorial is aimed at, may not know what documentation is, or where to find it, or even how to use it; this setup specifically showed how to find it, and then how to interpret what the answers were. This was also nice because Unity uses some specialized terms that are not necessarily present in C# broadly, so when I went to look them up in C#’s documentation, I had a lot of trouble.

    The tutorial walked you first through variables and then through functions by having you edit a script which spawns health potions at the start of the game. The variable you change affects the distance from a central point the potions spawn; the function you change refactors the code to prevent the same function being rewritten four times.

    It has been a while since I wrote code, because I made a pretty silly mistake: I didn’t type my variables when I instantiated them in my function, which led to the same error eight times over, and couldn’t figure out what I’d done wrong. Hopefully I’ll take that lesson forward. It’s been a while since I’ve worked in a strictly typed language.

    I actually worked a little bit ahead, since skimming through the explanations of variables and functions left me with extra time, and managed to get through tomorrow’s agenda and even a little bit of Thursday’s. I’ll be moving things up to compensate.

  • ‘2D Game Kit’: Day 2 (& Other Projects in the Pipeline)

    Went through the back half of the 2D Game Kit (teleporting to another scene, and the video walkthrough). The video walkthrough was interesting — about half of it was information that had been covered partially or completely in the written tutorial, another 25% was inferrable, and the rest was basically new. For example respectively: monsters and how to fight/mod them; the fact that you can set up damageable obstacles and break down objects in your path (the written tutorial only covered damaging monsters, but it works the same way); and how to add items to your inventory and trigger dialogue popups. Still, I don’t think the redundancies were a bad thing, since working through a tutorial by yourself and having a game designer talk through her thought process both lay out two different and useful perspectives. Also, one noted difference between the 2D Game Kit and the Kart modding tutorial – the 2D Game Kit came with a lot of art assets, which I couldn’t change the color or look of easily. In the Kart mods, it was pretty simple to adjust the albedo on any given asset, which weren’t usually art/images.

    Other plans today: get a jump on “Getting Started with Unity”, and maybe look into some project management frameworks I’m not familiar with (specifically, Agile). The Getting Started tutorial looks like it’ll have some redundancies for me — I already worked through go-kart modding, I’ve tooled around a bit with the FPS intro project, and I have at least passing familiarity with the Unity editor by now — but there may be some new tidbits.

    Re: Agile, I’m passing familiar with the concept, but I don’t have a lot of experience with how to apply it properly. What I’m hoping is for better information on how to set up those sorts of recurring, multi-step processes (or whether Gantt charts can be extended easily and intuitively into an Agile framework, because I like Gantt charts a lot).

    This’ll teach me to look ahead — I started poking through “Getting Started with Unity” and it turned out that a lot of it was geared specifically towards the sorts of streams I already worked through with ‘Your First Game Jam’! I’m now wondering whether to work through the FPS and platformer exercises, though I’m planning to skip the kart modding section… but maybe it would be more worth it to move on to a different tutorial?

    As for Agile, I ended up going through a LinkedIn Learning tutorial on “Agile Foundations” that has been pretty disappointing so far. There’s some good information about Agile’s values and mindset, but most of it is evangelizing. I’m hoping there will be more actionable information later on, in the section devoted to Scrum, Kanban, and something called Extreme Programming (!).

    Overall, a pretty scattered day, but I feel like I at least got information I can use in a couple different areas.

  • ‘2D Game Kit’: Day 1

    Today we’re getting started on the 2D Game Kit! The last tutorial was entirely a 3D environment, which was good on the theme of working towards VR, but I’m hoping the 2D Game Kit will give a bit more variety of skills and practice with what I already have.

    Getting quite honestly kind of annoyed with the number of updates Unity puts out. Can’t tell if they’re treating every version as distinct or if each thing is just a few small patches, but it feels like every version is a new and distinct one and they push a new one every two or three weeks. Might just be me though.

    The 2D game tutorial is so far a lot more approachable than any of the 3D tutorials (though that may be the fact that I now have some idea what I’m doing). We’ve covered adding prefab assets, as before — this time, tile painting in order to generate platforms, and the ability to add a prefabricated moving platform. The tutorial shows how to get it to move in a square loop, but I decided to set mine up to move in a triangle.

    The tutorial was actually so straightforward that after my initial notes above, I didn’t end up noting down anything in particular I was having trouble with. Very clear drag-and-drop across the board. It was actually so clear that I’m curious what the walkthrough video will consist of, since the whole thing is another 45 minutes long.

    The 2D Game Kit tutorial I worked through today can be found here: https://learn.unity.com/project/2d-game-kit. I got through parts 1 and 2, though I didn’t finish the last bit (teleporting the player to a new level).

    One thing I ran into which I’ll need to look up a bit more: occasionally I would put a piece of environmental background art (extra backdrop, usually, as I ran out of room on the level) and then be unable to put any ground tiles on top of it. Tomorrow: putting the final touches on teleportation, and seeing what may come from the walkthrough video! (And possibly more…?)

  • ‘My First Game Jam’: Day 3

    Today’s technically day 4, but I got very little done on Friday, and day 3 started by finishing up what I started then. Which was… drumroll… machine learning! Not programming machine learning, but learning how to add a second AI-controlled kart to my karting game, then set up checkpoints for the AI to follow so it could see how to go around the track. I need to neaten up my checkpoints a little – at present my AI gets frightened of a big jump halfway through and turns around to go back to the starting line, where it gets confused and has to stop.

    Setting up the AI kart controls involved making a prefab object for the AI to use as a checkpoint, distributing it around the track so the AI could always locate the next one, setting all the checkpoints as a trigger event, and placing them on the ‘Training Checkpoint’ layer. And also making them invisible, so that I could see the rest of the track (turn off the Mesh Render for this bit).

    Next we moved on to a bit more decoration, aka using billboards – you can set images as an object’s texture using the albedo! Still haven’t answered my question from day 2 vis-a-vis what got my colors stuck, but cool nonetheless.

    Learned how to add new cameras, position them and make them follow the player – you can add them through the main scene editor, position them by aligning with the view (or moving them as you’d move anything else) and attach them to the player by putting them somewhere inside the player’s hierarchy and positioning them accordingly.

    I got to learn how to make new scripts! You can write a new script by creating it as a component, then opening it with your text editor, and proceeding from there. I’m having some issues with mine, however. I copied the code directly from what they were doing, but it looks as though variables that are instantiated but not initialized are meant to be able to be set in Unity. In the tutorial, they have blanks which can be filled by other game objects, but my Unity workspace isn’t displaying them.

    Update: found the issue. I had a double in my code that was meant to be a float. (Can you tell I’m writing these notes as I work through the exercises?) Running into some new issues bugtesting, though – namely, I’m very bad at driving the kart.

    Animation notes: have to create an animation as an asset (apply through Window > Animation > Animation when you have something selected, then hit ‘create’). Created through keyframes – position it where you want it at a keyframe!

    Also some interesting experiences with bugfixing and post processing. The first rule for bugfixing: don’t write code you don’t understand. I ran into an issue that wasn’t even a bug (on Unity’s part). I had an error that didn’t affect compiling, only a piece I had deactivated, so I was fine running the game with it, except I had Error Pause turned on, which meant any error would prevent me from playing the game. One fun bonus of following a tutorial livestream is watching people with more knowledge than me hit the same bugs I’m running into.

    I actually got through the entire rest of the tutorial today, which was honestly pretty incredible. The streamers’ process started to unravel a bit towards the end, when they ran into bugs which they didn’t have time to address and started taking requests from their chat which was overambitious for their time limits, but honestly, that was pretty bolstering. It’s a good reminder not to be intimidated by people who do this professionally — everyone starts somewhere, as they reminded everyone at the end of the stream!

    I’m not going to move onto making my own projects yet; I want to practice with some more tutorials and pick up more skills (especially problemsolving skills) first. I may also look for some C# tutorials so I can understand what it is I’m trying to write when I code.

    As I mentioned before, this stream was located here: https://www.youtube.com/watch?v=Dweo04X7mJU

    It was part of this tutorial: https://learn.unity.com/tutorial/join-your-first-game-jam-1

    Give it a try — it’s much less intimidating than you’d think! And if you’d like to play my game, it’s available here: https://connect.unity.com/p/the-zoomies/ (You have to knock down the donuts; for some reason my change to ‘pins’ in the instructions didn’t take.)

  • ‘My First Game Jam’: Day 2

    Still working through the livestream tutorial, as yesterday. I didn’t get a whole lot done today — my Unity files had gotten out of date, so I had to update a lot of packages before I could get started with the build. Only got through about half of what I had planned, but it was an important chunk nonetheless: how to add assets, add collision physics, and set up events to trigger!

    Clicking and dragging an asset onto the scene adds it to the dropdown menu on the side (technically, we also did this yesterday, but I count it towards today because we did more editing of the asset today). From there you can click into the asset’s menu and add components. Adding a BoxCollider makes the object solid, so you can’t move through it the way you might be able to for other objects. If the object has a script for it, you can also add particular events to trigger when you interact with it, like making a certain sound effect play. I did run into a weird issue where I couldn’t change the color of certain prefab assets, which is something I did a fair bit of yesterday. Haven’t resolved it yet.

    Questions for the future:

    • How do you add events to objects that don’t have scripts for it?
    • What about certain objects (or certain Unity configurations?) allow/prevent changing colors?
css.php