pie 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,43 +1,52 @@
1
1
  # Pie
2
2
 
3
- A game development DSL, inspired by Yasuko Ohba's Ruby Kaigi talk and a late night coversaton with @knowtheory, @wycats, @sarahmei and @ultrasaurus.
4
-
5
- This is very experimental and marginally useful. Spec works, but coverage is meager.
3
+ A game development DSL, inspired by Yasuko Ohba's Ruby Kaigi talk and a late night conversation with @knowtheory, @wycats, @sarahmei and @ultrasaurus.
6
4
 
7
5
  Pie requires Ruby 1.9, because it is so cool.
8
6
 
9
7
  ## Examples
10
8
 
11
- ### Book
12
9
 
13
- There is a sample in book.rb. To use it:
14
10
 
15
- ruby book.rb
11
+ ### Game
12
+
13
+ pie game.pie
16
14
 
17
15
  then go to:
18
- http://localhost:4567/ship
19
- http://localhost:4567/building
20
- http://localhost:4567/tower
16
+ http://localhost:31415/park
21
17
 
22
- Someday there will be UI to change pages.
18
+ Follow links to wander around the game world. Yes, that is all there is right now.
23
19
 
24
- ### Game
20
+ ### Book -- NOT WORKING YET
21
+
22
+ There is a sample in book.rb. To use it:
25
23
 
26
- ruby game.rb
24
+ pie book.pie
27
25
 
28
26
  then go to:
29
- http://localhost:4567/park
27
+ http://localhost:31415/ship
28
+ http://localhost:31415/building
29
+ http://localhost:31415/tower
30
30
 
31
- Follow links to wander around the game world. Yes, that is all there is right now.
31
+ Someday there will be UI to change pages.
32
+
33
+ ## Issues?
34
+
35
+ Bugs and features are tracked here: http://www.pivotaltracker.com/projects/115060
36
+
37
+ I want to try to resist adding any new features until we have no bugs and kid-friendly error messages. Help is welcome. Feel free to fork and submit pull requests or just tweet or email ideas.
32
38
 
33
39
 
34
40
  ## Pie Contributors
35
41
 
36
- Core team
42
+ Core team (in order of appearance)
43
+
37
44
  * Sarah Allen
38
45
  * Sarah Mei
46
+ * Rich Kilmer
39
47
 
40
48
  Contributors
49
+
50
+ * Dan Steinicke
41
51
  * Akira Matsuda
42
52
  * Chad Fowler
43
-
@@ -1,55 +1,57 @@
1
1
  module Pie
2
-
3
- class DeadEnd < String
4
- def dead_end?
5
- true
6
- end
7
- end
8
2
 
9
3
  class Direction < String
10
- def opposite(display_name = nil)
11
- if display_name
12
- @display_name = display_name
4
+
5
+ def opposite(opposite_name = nil)
6
+ if opposite_name
7
+ @opposite_name = opposite_name
13
8
  else
14
- @display_name
9
+ @opposite_name
15
10
  end
16
11
  end
17
12
  def dead_end?
18
- false
13
+ @opposite_name.nil?
19
14
  end
20
15
  end
21
16
 
22
- def direction(forward, back)
17
+ def direction(forward, back = nil)
23
18
  dir = Direction.new(forward)
24
- dir.opposite(back)
19
+ dir.opposite(back) if back
25
20
  dir
26
21
  end
27
22
 
23
+ def dead_end(name)
24
+ direction(name)
25
+ end
26
+
28
27
  def north
29
- @north ||= direction('Go North', 'Go South')
28
+ @north ||= direction(Pie.localized(:go_north), Pie.localized(:go_south))
30
29
  end
31
30
 
32
31
  def south
33
- @south ||= direction('Go South', 'Go North')
32
+ @south ||= direction(Pie.localized(:go_south), Pie.localized(:go_north))
34
33
  end
34
+
35
35
  def east
36
- @east ||= direction('Go East', 'Go West')
36
+ @east ||= direction(Pie.localized(:go_east), Pie.localized(:go_west))
37
37
  end
38
+
38
39
  def west
39
- @west ||= direction('Go West', 'Go East')
40
- end
41
- def dead_end(name)
42
- DeadEnd.new(name)
40
+ @west ||= direction(Pie.localized(:go_west), Pie.localized(:go_east))
43
41
  end
42
+
44
43
  def north!
45
44
  dead_end(north)
46
45
  end
46
+
47
47
  def south!
48
48
  dead_end(south)
49
49
  end
50
+
50
51
  def east!
51
52
  dead_end(east)
52
53
  end
54
+
53
55
  def west!
54
56
  dead_end(west)
55
57
  end
data/lib/pie.rb CHANGED
@@ -7,6 +7,28 @@ module Pie
7
7
  def self.[]=(key, value)
8
8
  (@map ||= {})[key] = value
9
9
  end
10
+
11
+ def self.language=(language)
12
+ @language = language
13
+ end
14
+
15
+ def self.localized(id)
16
+ @values ||= {
17
+ :japanese => {
18
+ :go_north => "Go North (in jp!)",
19
+ :go_south => "Go South (in jp!)",
20
+ :go_east => "Go East (in jp!)",
21
+ :go_west => "Go West (in jp!)"
22
+ },
23
+ :english => {
24
+ :go_north => "Go North",
25
+ :go_south => "Go South",
26
+ :go_east => "Go East",
27
+ :go_west => "Go West"
28
+ }
29
+ }
30
+ @values[@language || :english][id]
31
+ end
10
32
 
11
33
  def template(name = nil)
12
34
  if name
@@ -46,6 +68,10 @@ module Pie
46
68
  Pie[:places] ||= {}
47
69
  end
48
70
 
71
+ def language(language)
72
+ Pie.language = language
73
+ end
74
+
49
75
  end
50
76
 
51
77
  require 'place'
@@ -3,7 +3,7 @@
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6
- <title><%= $current %></title>
6
+ <title><%= current_place.name %></title>
7
7
  <style type="text/css" media="screen">
8
8
 
9
9
 
@@ -49,12 +49,12 @@
49
49
  </head>
50
50
 
51
51
  <body>
52
- <img src="<%= $pie.current_image %>" class="bg" />
52
+ <img src="<%= current_image %>" class="bg" />
53
53
  <div id="content">
54
- <p><%= $pie.current_description %></p>
54
+ <p><%= current_place.description %></p>
55
55
  <p>
56
- <% $pie.places[$current].links.each do |place_name, label| %>
57
- <%= " <a href='#{place_name}'>#{label.to_s}</a> " %>
56
+ <% current_place.paths.each do |place_name, label| %>
57
+ <%= " <a href='#{place_name}'>#{label}</a> " %>
58
58
  <% end %>
59
59
  </p>
60
60
  </div>
@@ -48,9 +48,9 @@
48
48
  </head>
49
49
 
50
50
  <body>
51
- <img src="<%= $pie.current_image %>" class="bg" />
51
+ <img src="<%= current_image %>" class="bg" />
52
52
  <div id="content">
53
- <p><%= $pie.current_description %></p>
53
+ <p><%= current_place.description %></p>
54
54
  </div>
55
55
  </body>
56
56
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sarah Allen, Sarah Mei, Rich Kilmer
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-19 00:00:00 -07:00
17
+ date: 2010-09-30 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -28,20 +28,15 @@ extra_rdoc_files: []
28
28
 
29
29
  files:
30
30
  - lib/direction.rb
31
- - lib/direction.rb~
32
31
  - lib/pie.rb
33
- - lib/pie.rb~
34
32
  - lib/pie_server.rb
35
- - lib/pie_server.rb~
36
33
  - lib/place.rb
37
- - lib/place.rb~
38
- - bin/pie
39
- - bin/pie~
40
34
  - views/full_screen.erb
41
35
  - views/game_screen.erb
42
36
  - views/image_page.erb
43
37
  - README.md
44
38
  - MIT-LICENSE.txt
39
+ - bin/pie
45
40
  has_rdoc: true
46
41
  homepage: http://github.com/blazingcloud/pie
47
42
  licenses: []
data/bin/pie~ DELETED
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env ruby
2
- if RUBY_VERSION < "1.9.0"
3
- puts "Error: pie requires Ruby 1.9, please use RVM."
4
- exit
5
- end
6
-
7
- if ARGV.size == 0
8
- puts "Usage: pie myfile"
9
- exit
10
- end
11
-
12
- pie_file = ARGV.first
13
- pie_file = "#{pie_file}.pie" unless File.exist?(pie_file)
14
-
15
- unless File.exist?(pie_file)
16
- puts "Unknown file #{ARGV.first}, please try again."
17
- exit
18
- end
19
-
20
- begin
21
- require 'pie'
22
- rescue LoadError
23
- $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
24
- require 'pie'
25
- end
26
-
27
- include Pie
28
- load pie_file
29
-
30
- require 'pie_server'
31
- WebApp.run!
@@ -1,61 +0,0 @@
1
- module Pie
2
- class String
3
- def dead_end?
4
- true
5
- end
6
- end
7
-
8
- class DeadEnd < String
9
- def dead_end?
10
- true
11
- end
12
- end
13
-
14
- class Direction < String
15
- def opposite(display_name = nil)
16
- if display_name
17
- @display_name = display_name
18
- else
19
- @display_name
20
- end
21
- end
22
- def dead_end?
23
- false
24
- end
25
- end
26
-
27
- def direction(forward, back)
28
- dir = Direction.new(forward)
29
- dir.opposite(back)
30
- dir
31
- end
32
-
33
- def north
34
- @north ||= direction('Go North', 'Go South')
35
- end
36
-
37
- def south
38
- @south ||= direction('Go South', 'Go North')
39
- end
40
- def east
41
- @east ||= direction('Go East', 'Go West')
42
- end
43
- def west
44
- @west ||= direction('Go West', 'Go East')
45
- end
46
- def dead_end(name)
47
- DeadEnd.new(name)
48
- end
49
- def north!
50
- dead_end(north)
51
- end
52
- def south!
53
- dead_end(south)
54
- end
55
- def east!
56
- dead_end(east)
57
- end
58
- def west!
59
- dead_end(west)
60
- end
61
- end
@@ -1,50 +0,0 @@
1
- module Pie
2
-
3
- def self.[](key)
4
- (@map ||= {})[key]
5
- end
6
-
7
- def self.[]=(key, value)
8
- (@map ||= {})[key] = value
9
- end
10
-
11
- def template(name = nil)
12
- if name
13
- Pie[:template] = name.to_sym
14
- else
15
- Pie[:template] || :image_page
16
- end
17
- end
18
-
19
- def images
20
- Pie[:images] ||= {}
21
- end
22
-
23
- def image(image_maps)
24
- images.merge!(image_maps)
25
- end
26
-
27
- def place(options)
28
- Place.new(options)
29
- end
30
-
31
- def current_place(name=nil)
32
- if name
33
- Pie[:current_place] = places[name.to_sym]
34
- else
35
- Pie[:current_place]
36
- end
37
- end
38
-
39
- def current_image
40
- images[current_place.name] if current_place
41
- end
42
-
43
- def places
44
- Pie[:places] ||= {}
45
- end
46
-
47
- end
48
-
49
- require 'place'
50
- require 'direction'
@@ -1,21 +0,0 @@
1
- require 'sinatra/base'
2
-
3
- class WebApp < Sinatra::Base
4
- set :root, File.join(File.expand_path(File.dirname(__FILE__)), "..")
5
-
6
- get '/' do
7
- "hello"
8
- end
9
-
10
- get '/:place_name' do
11
- name = params[:place_name].to_sym
12
- puts "going to place with name #{name}"
13
- current_place(name) unless name.nil?
14
- puts "current place name is #{current_place.name}"
15
- puts "current place is #{current_place.description}"
16
- puts "--- skip out"; return if current_place.nil?
17
- puts "current links are #{current_place.paths.inspect}"
18
- puts "displaying template: #{template.inspect}"
19
- erb template
20
- end
21
- end
@@ -1,47 +0,0 @@
1
- class Pie::Place
2
-
3
- attr_reader :name, :description, :paths
4
-
5
- def initialize(options)
6
- @paths = {}
7
- extract_standard_options(options)
8
- extract_name_and_description(options)
9
- build_place_method
10
- register_place
11
- end
12
-
13
- def to_s
14
- @name
15
- end
16
-
17
- def path(nodes)
18
- nodes.each do |place_name, direction|
19
- paths[place_name] = direction
20
- places[place_name].paths[name] = direction.opposite unless direction.dead_end? || !direction.respond_to?(:dead_end?)
21
- end
22
- end
23
-
24
- private
25
-
26
- def extract_name_and_description(options)
27
- raise "You seem to have extras option in this place!" unless options.length == 1
28
- @name = options.keys.first
29
- @description = options.values.first
30
- end
31
-
32
- def extract_standard_options(options)
33
- end
34
-
35
- def build_place_method
36
- Pie.module_eval %{
37
- def #{name}
38
- places[:#{name}]
39
- end
40
- }
41
- end
42
-
43
- def register_place
44
- places[name] = self
45
- end
46
-
47
- end