cursetank 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .rvmrc
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
- gem 'pry'
3
2
  # Specify your gem's dependencies in cursetank.gemspec
4
3
  gemspec
data/README.md CHANGED
@@ -1,27 +1,21 @@
1
1
  # Cursetank
2
2
 
3
- TODO: Write a gem description
3
+ A ruby & curses based fishtank for your terminal!
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'cursetank'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
7
  $ gem install cursetank
18
8
 
19
9
  ## Usage
20
10
 
21
- TODO: Write usage instructions here
11
+ Fire up a terminal (max window preferred) and run "cursetank"
12
+
13
+ [Video of what it looks like](https://vimeo.com/52319135)
22
14
 
23
15
  ## Contributing
24
16
 
17
+ New Species requests/ASCII art are gladly accepted!!!
18
+
25
19
  1. Fork it
26
20
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
21
  3. Commit your changes (`git commit -am 'Add some feature'`)
data/lib/cursetank.rb CHANGED
@@ -1,9 +1,9 @@
1
- require "cursetank/version"
2
- require 'cursetank/tank_objects/basic_fish'
3
- require 'cursetank/tank_objects/bubble'
4
- require 'cursetank/tank_objects/plant'
1
+ require "cursetank/tank_objects/basic_fish"
2
+ require "cursetank/tank_objects/octopus"
3
+ require "cursetank/tank_objects/bubble"
4
+ require "cursetank/tank_objects/plant"
5
5
 
6
- require 'curses'
6
+ require "curses"
7
7
 
8
8
  module Cursetank
9
9
  include Curses
@@ -17,6 +17,7 @@ module Cursetank
17
17
  def main
18
18
  @plantlife_back = setup_plantlife
19
19
  @fishes = setup_fishes
20
+ @octopuses = setup_octopuses
20
21
  @plantlife_front = setup_plantlife
21
22
  @bubbles = []
22
23
  loop do
@@ -26,6 +27,9 @@ module Cursetank
26
27
  @fishes.each do | f |
27
28
  f.draw
28
29
  end
30
+ @octopuses.each do | o |
31
+ o.draw
32
+ end
29
33
  @plantlife_front.each do | p |
30
34
  p.draw
31
35
  end
@@ -73,6 +77,21 @@ module Cursetank
73
77
  end
74
78
  fishes
75
79
  end
80
+
81
+ # http://grammarist.com/usage/octopi-octopuses/
82
+ def setup_octopuses
83
+ octopuses = []
84
+ octopuscount = rand(1..5)
85
+ octopuscount.times do | i |
86
+ rand_x = rand(50)
87
+ rand_y = rand(50)
88
+ rand_speed = rand(0.1..0.3)
89
+ rand_color = rand(1..3)
90
+ dir_right = -1
91
+ octopuses << Octopus.new({window: @win, dir_right: dir_right, pos_x: rand_x, pos_y: rand_y, speed:rand_speed, color: rand_color})
92
+ end
93
+ octopuses
94
+ end
76
95
 
77
96
  def setup_curses
78
97
  Curses.init_screen()
@@ -89,4 +108,4 @@ module Cursetank
89
108
 
90
109
  end
91
110
 
92
- end
111
+ end
@@ -0,0 +1,53 @@
1
+ #####
2
+ ##### cursetank!
3
+ #####
4
+ require 'cursetank/tank_objects/tank_object'
5
+ module Cursetank
6
+ class Octopus < TankObject
7
+
8
+ def initialize(args={})
9
+ super(args)
10
+ @height = 5
11
+ @width = 8
12
+ @swin = @win.subwin(@height, @width, 0, 0)
13
+ @color = args.fetch(:color, 1)
14
+ @speed = args.fetch(:speed, 0.1)
15
+ end
16
+
17
+ def frames
18
+ # credit to (hh) from http://ascii.co.uk/art/octopus
19
+ octopus_frame1 = <<-OCTOPUS_FRAME1
20
+ ,---.
21
+ ( @ @ )
22
+ ).-.(
23
+ '/|||\\`
24
+ '|`
25
+ OCTOPUS_FRAME1
26
+ octopus_frame2 = <<-OCTOPUS_FRAME2
27
+ ,---.
28
+ ( @ @ )
29
+ ).-.(
30
+ \\|||/
31
+ |'|
32
+ OCTOPUS_FRAME2
33
+ [octopus_frame1, octopus_frame2]
34
+ end
35
+
36
+ def draw
37
+ set_direction
38
+ @frame += @speed
39
+ @frame = 0 if @frame > @maxframes - 1
40
+ @swin.setpos(0, 0)
41
+ @swin.move(@pos_y, @pos_x)
42
+ frame = frames[@frame.round.to_i]
43
+ @swin.attron(Curses.color_pair(@color)){
44
+ @swin.addstr(frame)
45
+ }
46
+ change_col = rand(10)
47
+ @pos_y += @speed * @dir_down
48
+ @pos_x += @speed * @dir_right if change_col == 7
49
+ @swin.refresh()
50
+ end
51
+
52
+ end
53
+ end
@@ -1,3 +1,3 @@
1
1
  module Cursetank
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cursetank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -30,6 +30,7 @@ files:
30
30
  - lib/cursetank.rb
31
31
  - lib/cursetank/tank_objects/basic_fish.rb
32
32
  - lib/cursetank/tank_objects/bubble.rb
33
+ - lib/cursetank/tank_objects/octopus.rb
33
34
  - lib/cursetank/tank_objects/plant.rb
34
35
  - lib/cursetank/tank_objects/tank_object.rb
35
36
  - lib/cursetank/version.rb