
require 'yaml'

class SaveLoadGame
  #to output class variables use accessors
  attr_accessor :background_x1, :background_x2, :rocketpx, :rocketpy, :rocketa, :bullets, :crates, :ammo, :score, :starter, :ending

  #constructor for the class
  def initialize
    #declare variable currentYear as a class variable (hence @ sign)
    @background_x1
    @background_x2
    
    @rocketpx
    @rocketpy
    @rocketa
    @bullets
    @crates
    @ammo

    @score
    @starter
    @ending
    
  end


  
  def save(background_x1,background_x2,rocketpx,rocketpy,rocketa,bullets,crates,ammo,score, starter,ending)
    t = SaveLoadGame.new
    t.background_x1 = background_x1
    t.background_x2 = background_x2
    t.rocketpx  = rocketpx
    t.rocketpy = rocketpy
    t.rocketa = rocketa
    t.bullets = bullets
    t.crates =crates
    t.ammo =ammo
  
    t.score = score
    t.starter = starter
    t.ending = ending


    
    file = File.open('save.txt','w')
    #serialize to a yaml file
    file.write(t.to_yaml)
    file.close
    
  end
  
  def load
    t = SaveLoadGame.new
    file = File.open('save.txt','r')
   
    t = YAML::load(file)
      
   
  end

  
  

end






















