<commit_before><!DOCTYPE HTML>
<html>
    <head>
        <link type="text/css" rel="stylesheet" href="../stylesheets/blog-stylesheet.css">

        <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400' rel='stylesheet' type='text/css'>
        <title>
            Blog
        </title>
    </head>

    <body>
        <header>
            <nav>
              <a id="nav" href="../index.html">Home</a>
              <a id="nav" href="../about.html">About</a>
              <a id="nav" href="../projects.html">Projects</a>
              <a id="nav" href="../blog_index.html">Blog</a>
              <a id="nav" href="../contact.html">Contact</a>
              <a id="icon" href="http://twitter.com/maxwell_mears"><img src="../imgs/icons/twitter.png"/></a>
              <a id="icon" href="http://linkedin.com/in/maxwellmears"><img src="../imgs/icons/linkedin.png"></a>
            </nav>
        </header>
        <div id="nextButton">
            <a href="./c4-tech-issues.html"><img src="../imgs/arrow_right.png"></a>
        </div>
        <div id="backButton">
            <a href="./c1-chefs-kitchen.html"><img src="../imgs/arrow_left.png"></a>
        </div>
        <main>
            <div id="text">
                <h1>Classes In Lunar Slingshot</h1>
                <h2>Posted on November 5, 2014</h2>
            </div>
            <div id="postPic" >
                <div class="picBorder">
                    <h2>What is Lunar Slingshot?</h2>
                    <h3><p>Lunar Slingshot is a game I made using the Ruby Gosu gem. I started by using the example game that Gosu provides, then kept building off of that to make lunar slingshot. The game is heavily inspired by MITs "Space War!" which was the first computer game ever made. </p>
                    <img id="imgFitLunar" src="../imgs/lunar_slingshot.png"/>
                    <p>I'm learning a lot from Lunar Slingshot. Specifically the concepts of classes and inheritance became much more clear after needing different objects to have similar but different functionality. I got help with the gravity algorithm among many other things, but the basic concept and design is my own.<p> This project has been the most rewarding, fun, and challenging learning experience in my journey to become a computer programmer to date. It's a work in progress, and there is a lot to add! Take a look at a stripped down version of the Player class below. Can you tell what it's doing?</p></h3><hr>
                    <pre id="lunar">
class Player &lt FloatingObject
  attr_accessor :score, :bullets_remaining

  def initialize(window, player_number)
    super(window)
    @player_number = player_number
    reset_velocity
    @score = 0
    @bullet_sound = Gosu::Sample.new(window, "media/Fire_sound.wav")
    @fire_armed = true
    @bullets_remaining = 4
  end

  def turn_left(do_it)
    if do_it
      @angle -= 2.5
    end
  end

  def turn_right(do_it)
    if do_it
      @angle += 2.5
    end
  end

  def accelerate
    @vel_x += Gosu::offset_x(@angle, 0.009)
    @vel_y += Gosu::offset_y(@angle, 0.009)
  end

  def reset_velocity
    @vel_x = @vel_y = 0.0
    if @player_number != 1
      @angle = 180
    else
      @angle = 0.0
    end
  end

  def fire
    # bullet fade out control
    if @bullets_remaining >= 1
      @bullets_remaining -= 1
      @bullet_sound.play
      my_bullet = Bullet.new(@store_window, @player_number)
      x_offset = Gosu::offset_x(@angle, 16)
      y_offset = Gosu::offset_y(@angle, 16)
      x_vel_offset = Gosu::offset_x(@angle, 1)
      y_vel_offset = Gosu::offset_y(@angle, 1)
      my_bullet.warp(self.x + x_offset, self.y + y_offset)
      my_bullet.warp_vel(self.vel_x + x_vel_offset, self.vel_y + y_vel_offset)
      my_bullet.warp_angle(@angle)
      my_bullet
    else
      nil
    end
  end
end
                    </pre><commit_msg>changed wk-5 ch-7 blog post<commit_after><!DOCTYPE HTML>
<html>
    <head>
        <link type="text/css" rel="stylesheet" href="../stylesheets/blog-stylesheet.css">

        <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400' rel='stylesheet' type='text/css'>
        <title>
            Blog
        </title>
    </head>

    <body>
        <header>
            <nav>
              <a id="nav" href="../index.html">Home</a>
              <a id="nav" href="../about.html">About</a>
              <a id="nav" href="../projects.html">Projects</a>
              <a id="nav" href="../blog_index.html">Blog</a>
              <a id="nav" href="../contact.html">Contact</a>
              <a id="icon" href="http://twitter.com/maxwell_mears"><img src="../imgs/icons/twitter.png"/></a>
              <a id="icon" href="http://linkedin.com/in/maxwellmears"><img src="../imgs/icons/linkedin.png"></a>
            </nav>
        </header>
        <div id="nextButton">
            <a href="./c4-tech-issues.html"><img src="../imgs/arrow_right.png"></a>
        </div>
        <div id="backButton">
            <a href="./c1-chefs-kitchen.html"><img src="../imgs/arrow_left.png"></a>
        </div>
        <main>
            <div id="text">
                <h1>Classes In Lunar Slingshot</h1>
                <h2>Posted on November 5, 2014</h2>
            </div>
            <div id="postPic" >
                <div class="picBorder">
                    <h2>What is Lunar Slingshot?</h2>
                    <h3><p>Lunar Slingshot is a game I made using the Ruby Gosu gem. I started by using the example game that Gosu provides, then kept building off of that to make lunar slingshot. The game is heavily inspired by MITs "Space War!" which was the first computer game ever made. </p>
                    <img id="imgFitLunar" src="../imgs/lunar_slingshot.png"/>
                    <p>I'm learning a lot from Lunar Slingshot. Specifically the concepts of classes and inheritance became much more clear after needing different objects to have similar but different functionality. I got help with the gravity algorithm among many other things, but the basic concept and design is my own.<p> This project has been the most rewarding, fun, and challenging learning experience in my journey to become a computer programmer to date. It's a work in progress, and there is a lot to add! Take a look at the Player class below. Can you tell what it's doing?</p></h3><hr>
                    <pre id="lunar">
class Player &lt FloatingObject
  attr_accessor :score, :bullets_remaining
  def initialize(window, player_number)
    super(window)
    @player_number = player_number
    if @player_number == 1
      @image = Gosu::Image.new(window, "media/Starfighter.png", false)
    else
      @image = Gosu::Image.new(window, "media/Starfighter2.png", false)
    end
    reset_velocity
    @image_jet = Gosu::Image.new(window, "media/Starfighter_jet.png", false)
    @image_jet_p2 = Gosu::Image.new(window, "media/Starfighter_jet_2.png", false)
    @beep = Gosu::Sample.new(window, "media/Beep.wav")
    @score = 0
    @bullet_sound = Gosu::Sample.new(window, "media/Fire_sound.wav")
    @radius= 8
    @fire_armed = true
    @bullets_remaining = 4
    @store_window = window
  end

  def turn_left(do_it)
    if do_it
      @angle -= 2.5
    end
  end

  def turn_right(do_it)
    if do_it
      @angle += 2.5
    end
  end

  def accelerate
    @vel_x += Gosu::offset_x(@angle, 0.009)
    @vel_y += Gosu::offset_y(@angle, 0.009)
  end

  def clear_score
    @score = 0
  end

  def reset_velocity
    @vel_x = @vel_y = 0.0
    if @player_number != 1
      @angle = 180
    else
      @angle = 0.0
    end
  end

  def fire
    # bullet fade out control
    if @bullets_remaining >= 1
      @bullets_remaining -= 1
      @bullet_sound.play
      my_bullet = Bullet.new(@store_window, @player_number)
      x_offset = Gosu::offset_x(@angle, 16)
      y_offset = Gosu::offset_y(@angle, 16)
      x_vel_offset = Gosu::offset_x(@angle, 1)
      y_vel_offset = Gosu::offset_y(@angle, 1)
      my_bullet.warp(self.x + x_offset, self.y + y_offset)
      my_bullet.warp_vel(self.vel_x + x_vel_offset, self.vel_y + y_vel_offset)
      my_bullet.warp_angle(@angle)
      my_bullet
    else
      nil
    end
  end

  def die
    @vel_x = @vel_y = 0
    @bullets_remaining = 4
  end

  def add_bullet
    if @bullets_remaining &lt 5
      @bullets_remaining += 1
    end
  end
end

                    </pre>
{'fraction_non_alphanumeric': 0.13005020320344252, 'fraction_numerical': 0.013626583791537174, 'mean_word_length': 2.329486669319538, 'pattern_counts': {'":': 0, '<': 125, '<?xml version=': 0, '>': 127, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5416383', 'n_tokens_mistral': 2871, 'n_tokens_neox': 2684, 'n_words': 729}