a-panzer 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8098c4f1a12202b9c6e03123923ed8327c39c489
4
+ data.tar.gz: 6a623b393c2055d2abe5d00c7ef439337f5d6951
5
+ SHA512:
6
+ metadata.gz: cbed8f5e7f72293a7075a644e3496fee66e1623c6042d666338fc8f35cbb48c16f9369ed92fa20ecbaa5487db4f812041027bb6e6d76dd6ead16ea57e462530b
7
+ data.tar.gz: 7fd59fc219a041b34fe70e2c3630ce7d601b11de1362cc93fa4c5f3ebc06e7031d3108f0615957ade389126d83ac12c498719890b07376dcdd0b5333f1b4fc7e
@@ -0,0 +1,20 @@
1
+ Copyright (C) 2013 Michael Grosser <michael@grosser.it>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'dispel'
5
+ require 'a_panzer'
6
+
7
+ def draw(ttt)
8
+ [*(ttt.board), status_line(ttt), "q=Quit r=Reset arrows=Move space=Shoot"].join("\n")
9
+ end
10
+
11
+ def status_line(game)
12
+ if game.pew?
13
+ "Pew!!!!"
14
+ elsif game.moving?
15
+ "*Rumble*"
16
+ else
17
+ ""
18
+ end
19
+ end
20
+
21
+ Dispel::Screen.open do |screen|
22
+ game = APanzer::Game.new
23
+ screen.draw draw(game)
24
+
25
+ Dispel::Keyboard.output timeout: 0.5 do |key|
26
+ case key
27
+ when :timeout then game.animate
28
+ when :right then game.move(1)
29
+ when :left then game.move(-1)
30
+ when " " then game.shoot
31
+ when "q", :"Ctrl+c" then break
32
+ when "r" then game = APanzer::Game.new
33
+ end
34
+ screen.draw draw(game)
35
+ end
36
+ end
@@ -0,0 +1,76 @@
1
+ module APanzer
2
+ class Game
3
+ PANZER = []
4
+ PANZER << <<-SPRITE
5
+
6
+ \\
7
+ |"""\\-=
8
+ (____)
9
+ SPRITE
10
+ PANZER << <<-SPRITE
11
+ __,-.
12
+ \\ ( .`-')
13
+ |"""\\-=(_ (_,_)
14
+ (____) `--'
15
+ SPRITE
16
+ PANZER << <<-SPRITE
17
+ __,-.
18
+ \\ ( .`-')_.o
19
+ |"""\\-=(_ (_,_)
20
+ (____) `--'
21
+ SPRITE
22
+ PANZER << <<-SPRITE
23
+ ..,-. _.--""""o
24
+ \\ : .`-';_.-"
25
+ |"""\\-=:. (.,.)
26
+ (____) `:-'
27
+ SPRITE
28
+ PANZER << <<-SPRITE
29
+ .. . _.--""""--.
30
+ \\ : . : ; . " "-.
31
+ |"""\\-=:. :.,.; `.
32
+ (____) `.:' o
33
+ SPRITE
34
+
35
+ def initialize
36
+ @position = 0
37
+ @sprite = 0
38
+ @pew = false
39
+ @moving = false
40
+ end
41
+
42
+ def board
43
+ PANZER[@sprite].split("\n").map { |l| "#{" " * @position}#{l}" }
44
+ end
45
+
46
+ def pew?
47
+ @pew
48
+ end
49
+
50
+ def moving?
51
+ @moving
52
+ end
53
+
54
+ def move(x)
55
+ return if @pew
56
+ @moving = x
57
+ animate
58
+ end
59
+
60
+ def shoot
61
+ @pew = true
62
+ animate
63
+ end
64
+
65
+ def animate
66
+ if @pew
67
+ @sprite += 1
68
+ @sprite %= PANZER.size
69
+ @pew = false if @sprite == 0
70
+ elsif @moving
71
+ @position += @moving
72
+ @moving = false if @position == 0
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,3 @@
1
+ module APanzer
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: a-panzer
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Grosser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dispel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.7
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.7
27
+ description:
28
+ email: michael@grosser.it
29
+ executables:
30
+ - a-panzer
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - MIT-LICENSE
35
+ - bin/a-panzer
36
+ - lib/a_panzer.rb
37
+ - lib/a_panzer/version.rb
38
+ homepage: https://github.com/grosser/a-panzer
39
+ licenses:
40
+ - MIT
41
+ metadata: {}
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 2.0.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 2.2.2
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: A. Panzer game
62
+ test_files: []