<?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: Matthew Bland</title>
    <description>The latest articles on DEV Community by Matthew Bland (@mabla0531).</description>
    <link>https://dev.to/mabla0531</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%2F283411%2Fe5ee86bc-a777-4cbe-90aa-98c3f6bdca6a.jpg</url>
      <title>DEV Community: Matthew Bland</title>
      <link>https://dev.to/mabla0531</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mabla0531"/>
    <language>en</language>
    <item>
      <title>Suggestions for coding stream time/day, content, languages</title>
      <dc:creator>Matthew Bland</dc:creator>
      <pubDate>Sun, 13 Sep 2020 00:10:08 +0000</pubDate>
      <link>https://dev.to/mabla0531/suggestions-for-coding-stream-time-day-content-languages-1hg7</link>
      <guid>https://dev.to/mabla0531/suggestions-for-coding-stream-time-day-content-languages-1hg7</guid>
      <description>&lt;p&gt;It's been a while DEV! A few months ago I toyed with the idea of streaming coding sessions where I'd do some casual coding tutorials with a better interaction with the viewers than say a YouTube video.  After COVID sent me home from college early, though, the idea kinda died. Well, I'm back at my true home again and I'm looking into the idea once more. Is this something you feel you would be interested in, and if so what type of content would you want?&lt;/p&gt;

</description>
      <category>watercooler</category>
      <category>java</category>
      <category>cpp</category>
    </item>
    <item>
      <title>Writing Good Tick Limiters</title>
      <dc:creator>Matthew Bland</dc:creator>
      <pubDate>Tue, 04 Feb 2020 18:09:12 +0000</pubDate>
      <link>https://dev.to/mabla0531/writing-good-tick-limiters-33a3</link>
      <guid>https://dev.to/mabla0531/writing-good-tick-limiters-33a3</guid>
      <description>&lt;p&gt;Something I've seen in sooo many game tutorials at the start is that a lot of people are making a tick limiter much more difficult than it really should be. If you're not familiar with it, a tick limiter is used to limit the number of ticks per second so that the game runs the same speed on every device. &lt;/p&gt;

&lt;p&gt;(All code is written in Java).&lt;/p&gt;

&lt;p&gt;I see so many people do this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;long newTime = System.nanoTime();
long frameTime = newTime - currentTime;

currentTime = newTime;
accumulator += frameTime;

while (accumulator &amp;gt;= nanosPerLogicTick) {
    //tick and stuff
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Or the even worse one:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int fps = 60;
double timePerTick = 1000000000 / fps;
double delta = 0;
long now;
long lastTime = System.nanoTime();
long timer = 0;
int ticks = 0;

while(running){
    now = System.nanoTime();
    delta += (now - lastTime) / timePerTick;
    timer += now - lastTime;
    lastTime = now;

    if(delta &amp;gt;= 1){
        //tick and stuff
        ticks++;
        delta--;
    }

    if(timer &amp;gt;= 1000000000){
        ticks = 0;
        timer = 0;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Wow... doesn't that seem a little extra? Turns out in Java it's as simple as this:&lt;/p&gt;

&lt;p&gt;(Global var containing last time)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private long lastTick = System.currentTimeMillis();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And finally, the if statement:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (System.currentTimeMillis() - lastTick &amp;gt;= (1000 / 60)) {
    lastTick = System.currentTimeMillis();
    //tick and stuff
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;

</description>
      <category>java</category>
      <category>gamedev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Vector for() iterator returning a null (or zero) object for each iteration (solved)</title>
      <dc:creator>Matthew Bland</dc:creator>
      <pubDate>Mon, 13 Jan 2020 23:33:27 +0000</pubDate>
      <link>https://dev.to/mabla0531/vector-for-iterator-returning-a-null-or-zero-object-for-each-iteration-nd7</link>
      <guid>https://dev.to/mabla0531/vector-for-iterator-returning-a-null-or-zero-object-for-each-iteration-nd7</guid>
      <description>&lt;p&gt;Update, I think I have permanent brain damage.&lt;/p&gt;

&lt;p&gt;I have a vector of tiles for a 2d game, each tile has an x and y and a get function. If I iterate over this vector using for (Tile t : tiles) and call t.getX() it returns 0 for every tile. Why is this? Should I be using a pointer instead? More verbose code below. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (Tile t : tiles)
{
    if (sf::IntRect(t.getX(), t.getY(), t.getX() + 32, t.getY() + 32).contains(sf::Vector2i(x, y)))
    {
        return t;
    }
    return tiles.front();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I later found out that the return tiles.front(); is returning always if the first tile scanned isn't solid. Therefore moving it one line down will work. I found this because visual studio said not all control paths return. Of course. &lt;/p&gt;

</description>
      <category>cpp</category>
      <category>help</category>
    </item>
    <item>
      <title>Learn Readability and Conciseness Early</title>
      <dc:creator>Matthew Bland</dc:creator>
      <pubDate>Tue, 07 Jan 2020 19:07:37 +0000</pubDate>
      <link>https://dev.to/mabla0531/learn-readability-and-conciseness-early-5b0n</link>
      <guid>https://dev.to/mabla0531/learn-readability-and-conciseness-early-5b0n</guid>
      <description>&lt;p&gt;But why?&lt;/p&gt;

&lt;p&gt;A little background first: I started programming when I was 11; my parents were both Software Engineers and so one day they decided to show me a little of what they did. They started me simply, with &lt;a href="http://www.pachesoft.com/rockerferbasic/" rel="noopener noreferrer"&gt;Rockerfer Basic&lt;/a&gt;. I caught on pretty quickly and bought a C++ book when I was 12. I didn't learn too much since it was a For Dummies book and was geared more towards business managers that could use a little C++ to automate things if they needed it. It did let me dip my feet into the world of programming, though, which proved to be fairly useful. At the time I thought I could be better at programming if I just tried to master every single thing C++ had to offer (fairly dumb in retrospect considering the complexity of C++ and my age). Later on, I decided to learn some Java through YouTube tutorials and eventually in High School later. This time with Java, I tried to focus less on just learning every technique I could and what this and that keyword does, and more on how to make code concise, easier to read, and faster. &lt;/p&gt;

&lt;p&gt;I didn't really begin to see the benefits of this until my college career. &lt;em&gt;Knowing the language is only a small part of the battle.&lt;/em&gt; It helped me way more to know the concepts of making code concise, readable, and fast than just trying to learn everything about one language (or a little about a lot of languages). I've now found that transferring to another language is much easier, partly because I'm familiar with C++ syntax, but mostly because I  know many of the programming techniques it takes to really be a good developer. I've now been able to breeze through the lower, mid, and some high-level programming classes at my University. &lt;/p&gt;

&lt;p&gt;So how would I personally recommend going about learning programming techniques? Well, of course, there is an incredible site with great information on what not to do called DEV.to! I've also found that CPPCon talks on YouTube are incredibly informative on this subject, e.g. &lt;a href="https://www.youtube.com/watch?v=MBRoCdtZOYg" rel="noopener noreferrer"&gt;Kate Gregory's talk about how important variable naming is&lt;/a&gt;, as well as some other (more extreme) rants and talks about how functional and procedural programming is better than OOP in many cases, such as &lt;a href="https://www.youtube.com/watch?v=o9pEzgHorH0" rel="noopener noreferrer"&gt;Stop Writing Classes&lt;/a&gt; (my favorite part is his explanation of an API that starts at &lt;a href="https://youtu.be/o9pEzgHorH0?t=270" rel="noopener noreferrer"&gt;4:30&lt;/a&gt;) and &lt;a href="https://www.youtube.com/watch?v=IRTfhkiAqPw" rel="noopener noreferrer"&gt;Object-Oriented Programming is Embarassing&lt;/a&gt;. The gist of these videos isn't to completely ignore OOP, but instead to focus on readability and minimal line count as well as to stop writing a class for everything (looking at you Java) that shouldn't need polymorphism or multiple instances, which I've found helps incredibly with conciseness, readability, and sometimes speed.&lt;/p&gt;

&lt;p&gt;A good personal example is when I wrote an SFML game in C++. A YouTube video that explained the base game/rendering/ticking and states etc. claimed that you need to write a class for the game. In C++! Of course, this is extra; why would you need to polymorph the game? Will you ever have multiple different games running at once? No, that's when you make a different game altogether. I managed to get the 3 file, ~50 line base engine for the window down to a 1 file, ~20 line project, purely because a separate .cpp file and .h file that held a class for the game was unnecessary and the render() and tick() methods could be put in the file with the game loop and main method. &lt;/p&gt;

&lt;p&gt;BUT, this is just my opinion! Some of you may have found that it is better to wait, and some of you may not have had the same exposure to programming that I did. So feel free to tell me I'm wrong in the comments or anything I may have misinterpreted that may come back to bite me in my career. Thanks for coming to my TED talk, and good luck with all your projects DEV Community!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
