<?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: Rootooner</title>
    <description>The latest articles on DEV Community by Rootooner (@rootooner).</description>
    <link>https://dev.to/rootooner</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%2F937415%2F62816322-8007-46f8-9f1b-7f687cc35ed7.png</url>
      <title>DEV Community: Rootooner</title>
      <link>https://dev.to/rootooner</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rootooner"/>
    <language>en</language>
    <item>
      <title>My first game in JavaScript...</title>
      <dc:creator>Rootooner</dc:creator>
      <pubDate>Thu, 13 Oct 2022 14:55:33 +0000</pubDate>
      <link>https://dev.to/rootooner/my-first-game-in-javascript-3al7</link>
      <guid>https://dev.to/rootooner/my-first-game-in-javascript-3al7</guid>
      <description>&lt;p&gt;SO I made a game, but this was for my computer science class with &lt;strong&gt;CodeHS.&lt;/strong&gt; It is fairly simple with just pressing the ball that has different colors on it. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Colors for the ball in the code:&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;//Red&lt;br&gt;
//Yellow &lt;br&gt;
//Green&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;//THE CODE&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;`var RADIUS = 100;&lt;br&gt;
var OFF_SCREEN = -200;&lt;br&gt;
var DELAY = 600;&lt;br&gt;
var ball;&lt;br&gt;
var score = 10;&lt;br&gt;
var scoreText;&lt;br&gt;
var WIN_SCORE = 20; &lt;/p&gt;

&lt;p&gt;//Starts the program start code&lt;br&gt;
function start(){&lt;br&gt;
    setUpBall();&lt;br&gt;
    setTimer(changeBall, DELAY);&lt;br&gt;
    mouseClickMethod(clickHandler)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;scoreText = new Text(score);
scoreText.setPosition(0, getHeight())
add(scoreText)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;function clickHandler(e){&lt;br&gt;
    var elem = getElementAt(e.getX(),e.getY());&lt;br&gt;
        if(elem != null &amp;amp;&amp;amp; elem.getColor() == &lt;br&gt;
        Color.green){&lt;br&gt;
                println("Great!")&lt;br&gt;
                score++;&lt;br&gt;
        }else{&lt;br&gt;
            println("Fail.")&lt;br&gt;
            score--;&lt;br&gt;
        }&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    if(score == 0){
        displayMessage("You Lose :(");
    }
    if(score == WIN_SCORE){
        displayMessage("You Win!!! :D");
    }

    scoreText.setText(score);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;function displayMessage(text){&lt;br&gt;
    stopTimer(changeBall);&lt;br&gt;
    var msg = new Text(text);&lt;br&gt;
    msg.setPosition(getWidth()/2 - msg.getWidth()/2&lt;br&gt;
    ,200)&lt;br&gt;
    add(msg)&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;//Sets up the ball for the game to be used with. &lt;br&gt;
function setUpBall(){&lt;br&gt;
    ball = new Circle(RADIUS);&lt;br&gt;
    ball.setPosition(OFF_SCREEN, OFF_SCREEN);&lt;br&gt;
    add(ball);&lt;/p&gt;

&lt;p&gt;}&lt;br&gt;
//Makes the ball go in a random position every 500 milliseconds&lt;br&gt;
function changeBall(){&lt;br&gt;
    var x = Randomizer.nextInt(ball.getRadius(),&lt;br&gt;
        getWidth() - ball.getRadius());&lt;br&gt;
    var y = Randomizer.nextInt(ball.getRadius(), &lt;br&gt;
        getHeight() - ball.getRadius());&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    ball.setColor(Randomizer.nextColor());



    ball.setPosition(x, y); 
    changeColor();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
/&lt;em&gt;changes the color of the ball from red to yellow when it&lt;br&gt;
moves every time to a new position.&lt;/em&gt;/ &lt;br&gt;
function changeColor(){&lt;br&gt;
    var colorCode = Randomizer.nextInt(0, 2);&lt;br&gt;
        var color;&lt;br&gt;
        if(colorCode == 0){&lt;br&gt;
            color = Color.red;&lt;br&gt;
        }else if(colorCode == 1){&lt;br&gt;
            color = Color.yellow;&lt;br&gt;
        }else{&lt;br&gt;
            color = Color.green&lt;br&gt;
        }&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    ball.setColor(color);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}`&lt;/p&gt;

&lt;h2&gt;
  
  
  The Result
&lt;/h2&gt;




&lt;p&gt;&lt;a href="https://codehs.com/sandbox/id/my-first-javascript-game-vQE9Su/run"&gt;https://codehs.com/sandbox/id/my-first-javascript-game-vQE9Su/run&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TFVHCmeV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2dn851nre1cer40nh1z8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TFVHCmeV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2dn851nre1cer40nh1z8.png" alt="Image description" width="433" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks! :D&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Hello</title>
      <dc:creator>Rootooner</dc:creator>
      <pubDate>Wed, 05 Oct 2022 05:16:59 +0000</pubDate>
      <link>https://dev.to/rootooner/hello-560m</link>
      <guid>https://dev.to/rootooner/hello-560m</guid>
      <description>&lt;p&gt;Hi, I am a new user in the dev community and hope to make frequent posts about what I am doing. I do a lot of programming when I have free time from school and work. My favorite hobby is creating and developing games through the power of code. I also love seeing software and hardware being developed.  I know more of JavaScript, but I am still learning more of it, and have not mastered in the langauge yet. What is it that I can learn more from the community on becoming a better dev? Thanks!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
