Skip to content

Instantly share code, notes, and snippets.

@poemdexter
Forked from vaxinate/player.rb
Created April 7, 2012 14:21

Revisions

  1. @vaxinate vaxinate revised this gist Apr 7, 2012. 2 changed files with 13 additions and 15 deletions.
    12 changes: 12 additions & 0 deletions player.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    class Player

    def initialize(window)
    @bandit_sprite = Gosu::Image.new(window, "bandit.bmp", false)
    @x = @y = 0
    end

    def draw
    @bandit_sprite.draw(24*@x, 24*@y, 1)
    end

    end
    16 changes: 1 addition & 15 deletions hurf.rb → test.rb
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,5 @@
    # in player.rb
    class Player

    def initialize(window)
    @bandit_sprite = Gosu::Image.new(window, "bandit.bmp", false)
    @x = @y = 0
    end

    def draw
    @bandit_sprite.draw(24*@x, 24*@y, 1)
    end

    end

    # in test.rb which i run 'ruby test.rb' in console
    require 'gosu'
    require_relative 'player'

    class GameWindow < Gosu::Window
    def initialize
  2. poemdexter created this gist Apr 7, 2012.
    46 changes: 46 additions & 0 deletions hurf.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    # in player.rb
    class Player

    def initialize(window)
    @bandit_sprite = Gosu::Image.new(window, "bandit.bmp", false)
    @x = @y = 0
    end

    def draw
    @bandit_sprite.draw(24*@x, 24*@y, 1)
    end

    end

    # in test.rb which i run 'ruby test.rb' in console
    require 'gosu'

    class GameWindow < Gosu::Window
    def initialize
    super 480, 480, false
    self.caption = "Dan's Shit Game For Idiots: Dubstep Protocol"

    @target_sprite = Gosu::Image.new(self, "target.bmp", true)

    @grid = Array.new(20,[])
    @grid = @grid.map {Array.new(20,0)}

    @player = Player.new(self)
    end

    def update
    end

    def draw
    @grid.each_with_index do |inner, x|
    inner.each_index do |y|
    @target_sprite.draw(x*24,y*24,0)
    end
    end

    @player.draw
    end
    end

    window = GameWindow.new
    window.show