diff --git a/README.md b/README.md index eef2f71..5cba3e4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Hohmann Miner Mine stuff and then get more stuff but in space. -![](preview.png) +![](media/preview.png) diff --git a/preview.png b/media/preview.png similarity index 100% rename from preview.png rename to media/preview.png diff --git a/app.rb b/src/app.rb similarity index 86% rename from app.rb rename to src/app.rb index 86b021d..744da15 100755 --- a/app.rb +++ b/src/app.rb @@ -10,16 +10,17 @@ load "objects.rb" load "controller.rb" class Window < Gosu::Window - attr_accessor :freeze, :caption, :physobjs, :planets, :controller, :camera, :ui + attr_accessor :caption, attr_reader :width, :height, :fonts - def initialize(title, width, height, physobjs = [], planets = []) + def initialize(title, width, height, universe) super width, height @width, @height = width, height self.caption = "#{title}| #{width}x#{height}" - @physobjs = physobjs - @planets = planets + #@physobjs = physobjs + #@planets = planets + @universe = universe @font = Gosu::Font.new(self, MAIN_FONT, 18) @font2 = Gosu::Font.new(self, MAIN_FONT, 20) @@ -33,20 +34,15 @@ class Window < Gosu::Window button: @font_button } - @freeze = true - @controller = nil - - @camera = Vector[0, 0] - @ui = [] end def start_game - cube = Player.new("Alpha", self, 8, 8) - cube.show_info = false - cube.thrust = 0.0075 - cube.pos = Vector[800, 450 + 500] - cube.vel = Vector[1, 0] - self.controller = cube + ply = Player.new("Player", self, 8, 8) + ply.show_info = false + ply.thrust = 0.0075 + ply.pos = Vector[800, 450 + 500] + ply.vel = Vector[1, 0] + self.controller = ply cube2 = PhysCube.new("Beta", self, 8, 8) cube2.pos = Vector[800, 450 + 300] @@ -66,9 +62,8 @@ class Window < Gosu::Window self.planets << sol self.planets << planet - self.planets << cube - self.physobjs << cube + self.physobjs << ply self.physobjs << cube2 self.physobjs << planet end diff --git a/config.rb b/src/config.rb similarity index 100% rename from config.rb rename to src/config.rb diff --git a/controller.rb b/src/lib/controller.rb similarity index 100% rename from controller.rb rename to src/lib/controller.rb diff --git a/gosu_plugin.rb b/src/lib/gosu_plugin.rb similarity index 100% rename from gosu_plugin.rb rename to src/lib/gosu_plugin.rb diff --git a/objects.rb b/src/lib/objects.rb similarity index 100% rename from objects.rb rename to src/lib/objects.rb diff --git a/physobj.rb b/src/lib/physobj.rb similarity index 100% rename from physobj.rb rename to src/lib/physobj.rb diff --git a/ui.rb b/src/lib/ui.rb similarity index 88% rename from ui.rb rename to src/lib/ui.rb index 9062956..3b99605 100644 --- a/ui.rb +++ b/src/lib/ui.rb @@ -80,7 +80,7 @@ class Button < UI def render sel = self.hover? ? :selected : :default - # self.draw_rect(self.x, self.y, self.width, self.height, self.colors[:background][sel]) + self.draw_rect(self.x, self.y, self.width, self.height, self.colors[:background][sel]) self.draw_text(self.text, self.font, self.width/2 - self.text_width/2, self.height/2 - self.text_height/2, self.colors[:text][sel]) end @@ -102,12 +102,12 @@ class MainMenu < UI self.draw_text(titletext, self.window.fonts[:title], self.width/2 - titlewidth/2, self.height/4) playbtn = Button.new(self.window, self, "Play", self.window.fonts[:button]) - #playbtn.x, playbtn.y = self.width/2 - playbtn.width/2, self.height/2 - playbtn.height/2 + playbtn.x, playbtn.y = self.width/2 - playbtn.width/2, self.height/2 - playbtn.height/2 playbtn.render -# quitbtn = Button.new(self.window, self, "Quit", self.window.fonts[:button]) -# quitbtn.x, quitbtn.y = self.width/2 - quitbtn.width/2, quitbtn.height + playbtn.y + 16 -# quitbtn.render + quitbtn = Button.new(self.window, self, "Quit", self.window.fonts[:button]) + quitbtn.x, quitbtn.y = self.width/2 - quitbtn.width/2, quitbtn.height + playbtn.y + 16 + quitbtn.render end end end diff --git a/src/lib/universe.rb b/src/lib/universe.rb new file mode 100644 index 0000000..5992ee0 --- /dev/null +++ b/src/lib/universe.rb @@ -0,0 +1,16 @@ +class Universe + attr_accessor :freeze, :physobjs, :planets, :controller, :camera, :ui + def initialize(seed, window) + @seed = seed + @window = window + + @physobjs = [] + @planets = [] + + @freeze = true + @controller = nil + + @camera = Vector[0, 0] + @ui = [] + end +end