hasu 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Michael Fairley
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ Makes iterating with Gosu more better.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ require 'gosu'
2
+ $:.unshift '../lib'
3
+ require 'hasu'
4
+ Hasu.load 'rect.rb'
5
+
6
+ class Example < Gosu::Window
7
+ prepend Hasu
8
+
9
+ def initialize
10
+ super(640, 480, false)
11
+ end
12
+
13
+ def reset
14
+ @rect = Rect.new(10, 100, 10, 100)
15
+ end
16
+
17
+ def update
18
+ end
19
+
20
+ def draw
21
+ @rect.draw(self)
22
+ end
23
+ end
24
+
25
+ Hasu.run(Example)
@@ -0,0 +1,18 @@
1
+ class Rect
2
+ attr_reader :x1, :x2, :y1, :y2
3
+
4
+ def initialize(x1, x2, y1, y2)
5
+ @x1 = x1
6
+ @x2 = x2
7
+ @y1 = y1
8
+ @y2 = y2
9
+ end
10
+
11
+ def color
12
+ Gosu::Color::WHITE
13
+ end
14
+
15
+ def draw(window)
16
+ window.draw_quad(x1, y1, color, x2, y1, color, x2, y2, color, x1, y2, color)
17
+ end
18
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hasu/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hasu"
8
+ spec.version = Hasu::VERSION
9
+ spec.authors = ["Michael Fairley"]
10
+ spec.email = ["michaelfairley@gmail.com"]
11
+ spec.description = %q{Prototype Gosu games with ease}
12
+ spec.summary = %q{Prototype Gosu games with ease}
13
+ spec.homepage = "https://github.com/michaelfairley/hasu"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,93 @@
1
+ require "hasu/version"
2
+
3
+ module Hasu
4
+ def self.reloads
5
+ @files ||= {}
6
+ end
7
+
8
+ def self.load(path)
9
+ reloads[path] = File.mtime(path)
10
+ begin
11
+ super
12
+ true
13
+ rescue Exception => e
14
+ Hasu.error = e
15
+ false
16
+ end
17
+ end
18
+
19
+ def self.error
20
+ @error
21
+ end
22
+
23
+ def self.error=(error)
24
+ @error = error
25
+ end
26
+
27
+ def self.run(window)
28
+ unless @running
29
+ @running = true
30
+ window.new.show
31
+ end
32
+ end
33
+
34
+ def self.reload!
35
+ to_reload = reloads.select{|f,t| File.mtime(f) > t}
36
+
37
+ !to_reload.empty? && to_reload.all? do |file,_|
38
+ puts "Reloading #{file}"
39
+ load(file)
40
+ end
41
+ end
42
+
43
+ def self.prepended(other)
44
+ includer = caller.first.split(":").first
45
+ reloads[includer] = File.mtime(includer)
46
+ end
47
+
48
+ def initialize(*)
49
+ super
50
+ reset
51
+ end
52
+
53
+ def update(*)
54
+ if Hasu.reload!
55
+ Hasu.error = nil
56
+ end
57
+ unless Hasu.error
58
+ super
59
+ end
60
+ rescue => e
61
+ Hasu.error = e
62
+ end
63
+
64
+ def draw(*)
65
+ if Hasu.error
66
+ ([Hasu.error.inspect] + Hasu.error.backtrace).each_with_index do |line, i|
67
+ _hasu_font.draw(line, 10, 10 + i * 16, 0)
68
+ end
69
+ else
70
+ begin
71
+ super
72
+ rescue => e
73
+ Hasu.error = e
74
+ draw
75
+ end
76
+ end
77
+ end
78
+
79
+ def _hasu_font
80
+ @_hasu_font ||= Gosu::Font.new(self, Gosu::default_font_name, 16)
81
+ end
82
+
83
+ def button_down(id)
84
+ case id
85
+ when Gosu::KbEscape
86
+ close
87
+ when Gosu::Window.char_to_button_id('r')
88
+ reset
89
+ else
90
+ super(id)
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,3 @@
1
+ module Hasu
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hasu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michael Fairley
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: &70285023087620 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70285023087620
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70285023087200 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70285023087200
36
+ description: Prototype Gosu games with ease
37
+ email:
38
+ - michaelfairley@gmail.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - Gemfile
45
+ - LICENSE.txt
46
+ - README.md
47
+ - Rakefile
48
+ - example/example.rb
49
+ - example/rect.rb
50
+ - hasu.gemspec
51
+ - lib/hasu.rb
52
+ - lib/hasu/version.rb
53
+ homepage: https://github.com/michaelfairley/hasu
54
+ licenses:
55
+ - MIT
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 1.8.7
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: Prototype Gosu games with ease
78
+ test_files: []
79
+ has_rdoc: