Permalink
Browse files

added tests and tweaks

  • Loading branch information...
1 parent 3e4ac22 commit 37d63144bf4f0300c64b48392125472a11cc94b7 @bendangelo committed Jan 28, 2012
View
@@ -96,7 +96,7 @@ This will take you through some quick steps to display an image on a canvas elem
* Refresh srcs to find the image: `entityjs refresh`
-* In `mygame/src/scenes/load.js` add at the bottom:
+* In `mygame/scripts/scenes/load.js` add:
```
re.scene('home')
@@ -107,9 +107,9 @@ re.scene('home')
* Open up mygame/play.html to view your game
-* In the root directory type: `entityjs min`
+* In the root directory type: `entityjs build`
-* Checkout `/mygame/lib/min` to see your finished game
+* Checkout `/mygame/builds` to see your finished game
* You can now upload the game online and show people.
View
@@ -1 +1,10 @@
require "bundler/gem_tasks"
+
+begin
+ require 'jasmine'
+ load 'jasmine/tasks/jasmine.rake'
+rescue LoadError
+ task :jasmine do
+ abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
+ end
+end
View
@@ -10,4 +10,9 @@ args = ARGV.dup
ARGV.clear
command = args.shift.strip rescue 'help'
-return Entityjs::Command.run(command, args)
+code = Entityjs::Command.run(command, args)
+
+if code == 2
+ puts "EntityJS game not found"
+ puts "Move inside the root directory"
+end
View
@@ -1,53 +0,0 @@
------------------------------------------------------------------------------------------
-Version 0.2.2 [Dec 6, 2011]
-
-Fixed distanceTo on point component.
-Added length argument to query filter / map.
-Removed multiple scene creation from re.scene.
-Components now dispatch dispose on entity removal.
-Renamed re.tile globals.
-Mouse now has optional toScreen coordinates.
-Screen now has screen convertions globals.
-Text input focus disables keyboard input.
-
------------------------------------------------------------------------------------------
-Version 0.2.1 [Oct 11, 2011]
-
-Added timestep component.
-Added rect component.
-Added circle component.
-Renamed size to hittest component.
-Add distanceTo to point component.
-Returning false on a signal will remove it.
-Added wait component.
-Renamed sprimate to flicker.
-Renamed position to anchor.
-Remove coordinate object properties.
-Renamed define to extend.
-
------------------------------------------------------------------------------------------
-Version 0.2 [Sept 30, 2011]
-
-Added query catching.
-Added log component.
-System is now extendable and can be used on multiple canvases.
-Added ticker component.
-Load now removes directories.
-Renamed default to inherit.
-Load now creates generic extensions.
-Sound component added.
-Keyboard, mouse, canvas and sounds now work in all browsers.
-Added scale and rotation to draw components.
-Implemented hitmap component.
-Adding signals now accepts a third context argument.
-Sprimate now accepts string frames.
-Added screen component.
-Added bitfont component.
-Added random component.
-Added playlist component.
-Added position component.
-
------------------------------------------------------------------------------------------
-Version 0.1 [Sept 15, 2011]
-
-First release
View
@@ -3,25 +3,77 @@ module Entityjs
class Assets
def self.to_js
- out = %Q(re.load.path = 'assets/';
-
+ out = %Q(
+ re.load.path = 'assets/';
+ re.assets = {
+ images:#{self.images_to_js},
+ sounds:#{self.sounds_to_js}
+ };
+ #{self.datas_to_js}
)
end
def self.images_to_js
- s = self.search('images').join(', ')
+ s = self.search('images').collect{|i| "'#{i}'"}.join(', ')
"[#{s}]"
end
def self.sounds_to_js
- s = self.search('sounds').join(', ')
+ s = self.search('sounds').collect{|i| "'#{i}'"}.join(', ')
"[#{s}]"
end
def self.datas_to_js
+ s = self.search
+
+ out = ''
+
+ s.each do |i|
+
+ basename = File.basename(i)
+ dirname = File.dirname(i)
+
+ #make singular
+ if dirname[-1] == 's'
+ dirname = dirname[0..-2]
+ end
+
+ contents = IO.read(Config.instance.assets_folder+'/'+i)
+ #remove dot from extension
+ ext = File.extname(i)
+
+ case ext
+ when '.json'
+ contents = contents
+
+ when '.tmx'
+ raise 'Support coming soon..'
+
+ when '.xml'
+ raise 'Support coming soon..'
+
+ when '.csv'
+ raise 'Support coming soon..'
+
+ when '.yml'
+ raise 'Support coming soon...'
+
+ else
+ raise 'File '+i+' is invalid'
+
+ end
+
+ out += %Q(
+ re.e('#{basename} #{dirname}')
+ .attr(#{contents});
+ )
+
+ end
+
+ out
end
def self.search(type='*')
View
@@ -1,4 +1,5 @@
-Dir["#{Entityjs::root}/lib/entityjs/*/*"].each {|f| require f }
+Dir.glob("#{Entityjs::root}/lib/entityjs/*.rb").each {|f| require f }
+Dir.glob("#{Entityjs::root}/lib/entityjs/*/*.rb").each {|f| require f }
# 0 - ok
# 1 - command not found
@@ -30,6 +31,7 @@ def self.run(command, args=nil)
return 0
when /^(help|h)$/
+ puts '---- Commands ----'
puts 'entityjs new [name] [comp]+'
puts 'entityjs comp [name]'
puts 'entityjs test [name]'
@@ -1,3 +1,5 @@
+require 'fileutils'
+
module Entityjs
class New
@@ -14,13 +16,19 @@ def self.generate(args)
FileUtils.cp_r template, name
+ puts "Created: #{name}"
+ puts "Path: ./#{name}"
+ puts "Version: #{Entityjs::VERSION}"
+ puts "Website: http://entityjs.com"
+ puts ""
+
Dirc.change_dir(name)
comps.each do |c|
Entityjs::Command.run('comp', c)
end
- Entityjs::Command.run('ref')
+ Entityjs::Command.run('refresh')
return true
end
@@ -13,26 +13,29 @@ def self.generate(args=nil)
merg = ent | srcs
- Dirc.change_dir('tmp')
-
- file_name = 'game.debug.js'
+ file_name = 'tmp/game.debug.js'
license = Dirc.get_license
File.open(file_name, "w+") do |f|
+ #add license
f.write(license+"\n")
+ #add javascript srcs
merg.each do |s|
scrip = "<script src='#{s}' type='text/javascript'></script>"
f.write("document.write(\"#{scrip}\");\n")
end
+ #add files
+ f.write(Assets.to_js)
+
end
- puts "Refreshed /tmp/#{file_name}"
+ puts "Refreshed: #{file_name}"
return true
end
@@ -0,0 +1,22 @@
+function Player() {
+}
+Player.prototype.play = function(song) {
+ this.currentlyPlayingSong = song;
+ this.isPlaying = true;
+};
+
+Player.prototype.pause = function() {
+ this.isPlaying = false;
+};
+
+Player.prototype.resume = function() {
+ if (this.isPlaying) {
+ throw new Error("song is already playing");
+ }
+
+ this.isPlaying = true;
+};
+
+Player.prototype.makeFavorite = function() {
+ this.currentlyPlayingSong.persistFavoriteStatus(true);
+};
@@ -0,0 +1,7 @@
+function Song() {
+}
+
+Song.prototype.persistFavoriteStatus = function(value) {
+ // something complicated
+ throw new Error("not yet implemented");
+};
@@ -0,0 +1,73 @@
+# src_files
+#
+# Return an array of filepaths relative to src_dir to include before jasmine specs.
+# Default: []
+#
+# EXAMPLE:
+#
+# src_files:
+# - lib/source1.js
+# - lib/source2.js
+# - dist/**/*.js
+#
+src_files:
+ - src/**/*.js
+
+# stylesheets
+#
+# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
+# Default: []
+#
+# EXAMPLE:
+#
+# stylesheets:
+# - css/style.css
+# - stylesheets/*.css
+#
+stylesheets:
+
+# helpers
+#
+# Return an array of filepaths relative to spec_dir to include before jasmine specs.
+# Default: ["helpers/**/*.js"]
+#
+# EXAMPLE:
+#
+# helpers:
+# - helpers/**/*.js
+#
+helpers:
+
+# spec_files
+#
+# Return an array of filepaths relative to spec_dir to include.
+# Default: ["**/*[sS]pec.js"]
+#
+# EXAMPLE:
+#
+# spec_files:
+# - **/*[sS]pec.js
+#
+spec_files:
+
+# src_dir
+#
+# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
+# Default: project root
+#
+# EXAMPLE:
+#
+# src_dir: public
+#
+src_dir:
+
+# spec_dir
+#
+# Spec directory path. Your spec_files must be returned relative to this path.
+# Default: spec/javascripts
+#
+# EXAMPLE:
+#
+# spec_dir: spec/javascripts
+#
+spec_dir:
@@ -0,0 +1,23 @@
+module Jasmine
+ class Config
+
+ # Add your overrides or custom config code here
+
+ end
+end
+
+
+# Note - this is necessary for rspec2, which has removed the backtrace
+module Jasmine
+ class SpecBuilder
+ def declare_spec(parent, spec)
+ me = self
+ example_name = spec["name"]
+ @spec_ids << spec["id"]
+ backtrace = @example_locations[parent.description + " " + example_name]
+ parent.it example_name, {} do
+ me.report_spec(spec["id"])
+ end
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit 37d6314

Please sign in to comment.