zombie-chaser 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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/ui/ui.rb ADDED
@@ -0,0 +1,117 @@
1
+ require 'gosu'
2
+
3
+ class ZIndex
4
+ LAYERS = [:world, :dead, :human, :zombie, :overlay]
5
+
6
+ def self.for(type); LAYERS.index(type) end
7
+ end
8
+
9
+ class Actor
10
+
11
+ def self.window=(window); @window = window end
12
+ def self.window; @window end
13
+
14
+ def self.sprites
15
+ @sprites ||= Dir['ui/sprites/*.png'].inject({}) do |sprites,f|
16
+ sprite = File.basename(f,'.*').split('-')
17
+ sprites[sprite.first] ||= {}
18
+ sprites[sprite.first][sprite.last] = Gosu::Image.new(window, f, false)
19
+ sprites
20
+ end
21
+ end
22
+
23
+ def image
24
+ #self.class.sprites['robot']['idle'] #FIXME adjust this to indicate human versus zombie, and status of alive, dying or dead
25
+ self.class.sprites[actor_type][actor_state]
26
+ end
27
+
28
+ def actor_type
29
+ raise NotImplementedError
30
+ end
31
+
32
+ def draw
33
+ image.draw_rot(x, y, z, actor_direction)
34
+ end
35
+
36
+ def x
37
+ @successful_step_count * 10 + 10
38
+ end
39
+
40
+ def y
41
+ 100
42
+ end
43
+
44
+ def z
45
+ #(data['state'] == 'dead') ? ZIndex.for(:dead) : ZIndex.for(data['type'].to_sym)
46
+ ZIndex.for(:human)
47
+ end
48
+
49
+ def window
50
+ self.class.window
51
+ end
52
+ end
53
+
54
+ class Window < Gosu::Window
55
+
56
+ attr_accessor :grid
57
+ attr_writer :human, :current_zombie
58
+
59
+ def initialize
60
+ super(400, 300, false)
61
+
62
+ self.caption = 'Zombie-chaser'
63
+ self.grid = 1
64
+
65
+ @grass = Gosu::Image.new(self, 'ui/tiles/grass.png', true)
66
+ @shrubbery = Gosu::Image.new(self, 'ui/tiles/shrubbery.png', true)
67
+ end
68
+
69
+ def draw
70
+ draw_scenery
71
+ draw_human
72
+ draw_zombie
73
+ end
74
+
75
+ def button_down(id)
76
+ close if id == Gosu::Button::KbEscape
77
+ end
78
+
79
+ # private
80
+
81
+ def tile_positions
82
+ w, h = @grass.width, @grass.height
83
+ @tile_positions ||= {
84
+ :x => (0...width).to_a.inject([]) {|a,x| a << x if x % w == 0; a},
85
+ :y => (0...height).to_a.inject([]) {|a,y| a << y if y % h == 0; a}
86
+ }
87
+ end
88
+
89
+ def map
90
+ @map ||= tile_positions[:y].map do |y|
91
+ tile_positions[:x].map do |x|
92
+ {
93
+ :x => x,
94
+ :y => y,
95
+ :tile => (rand(32) % 32 == 0) ? @shrubbery : @grass
96
+ }
97
+ end
98
+ end
99
+ end
100
+
101
+ def draw_scenery
102
+ map.each do |row|
103
+ row.each do |col|
104
+ col[:tile].draw(col[:x], col[:y], ZIndex.for(:world))
105
+ end
106
+ end
107
+ end
108
+
109
+ def draw_human
110
+ @human.draw
111
+ end
112
+
113
+ def draw_zombie
114
+ @current_zombie.draw if defined?(@current_zombie)
115
+ end
116
+
117
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zombie-chaser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Grimm
8
+ - Ryan Davis
9
+ - Eric Hodel
10
+ - Kevin Clark
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+
15
+ date: 2009-12-07 00:00:00 +11:00
16
+ default_executable: zombie-chaser
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: gosu
20
+ type: :runtime
21
+ version_requirement:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: "0"
27
+ version:
28
+ description: A zombie-themed graphic(al) user interface for mutation testing
29
+ email: andrew.j.grimm@gmail.com
30
+ executables:
31
+ - zombie-chaser
32
+ extensions: []
33
+
34
+ extra_rdoc_files:
35
+ - README.txt
36
+ files:
37
+ - README.txt
38
+ - Rakefile
39
+ - bin/zombie-chaser
40
+ - lib/chaser.rb
41
+ - lib/human.rb
42
+ - lib/interface.rb
43
+ - lib/test_unit_handler.rb
44
+ - lib/world.rb
45
+ - lib/zombie_test_chaser.rb
46
+ - test/fixtures/chased.rb
47
+ - test/test_chaser.rb
48
+ - test/test_unit.rb
49
+ - test/test_zombie.rb
50
+ - ui/icons/death.png
51
+ - ui/icons/robot.png
52
+ - ui/sprites/robot-attacking.png
53
+ - ui/sprites/robot-dead.png
54
+ - ui/sprites/robot-dying.png
55
+ - ui/sprites/robot-idle.png
56
+ - ui/sprites/robot-moving.png
57
+ - ui/sprites/robot-turning.png
58
+ - ui/sprites/tank-attacking.png
59
+ - ui/sprites/tank-dead.png
60
+ - ui/sprites/tank-idle.png
61
+ - ui/sprites/tank-moving.png
62
+ - ui/sprites/tank-turning.png
63
+ - ui/sprites/witch-attacking.png
64
+ - ui/sprites/witch-dead.png
65
+ - ui/sprites/witch-idle.png
66
+ - ui/sprites/witch-moving.png
67
+ - ui/sprites/witch-turning.png
68
+ - ui/sprites/zombie-attacking.png
69
+ - ui/sprites/zombie-dead.png
70
+ - ui/sprites/zombie-dying.png
71
+ - ui/sprites/zombie-idle.png
72
+ - ui/sprites/zombie-moving.png
73
+ - ui/sprites/zombie-turning.png
74
+ - ui/tiles/grass.png
75
+ - ui/tiles/shrubbery.png
76
+ - ui/ui.rb
77
+ has_rdoc: true
78
+ homepage: http://andrewjgrimm.wordpress.com/2009/11/08/declare-war-on-everything-with-chaser/
79
+ licenses: []
80
+
81
+ post_install_message:
82
+ rdoc_options:
83
+ - --charset=UTF-8
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
91
+ version:
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: "0"
97
+ version:
98
+ requirements: []
99
+
100
+ rubyforge_project:
101
+ rubygems_version: 1.3.5
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: Lightweight mutation testing ... with ZOMBIES!!!
105
+ test_files:
106
+ - test/fixtures/chased.rb
107
+ - test/test_chaser.rb
108
+ - test/test_unit.rb
109
+ - test/test_zombie.rb