go_gamification 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/images/go_gamification/background.png +0 -0
- data/app/assets/images/go_gamification/cloud.png +0 -0
- data/app/assets/javascripts/go_gamification/bhive.js.erb +1298 -0
- data/app/assets/javascripts/go_gamification/character-new.js.erb +224 -0
- data/lib/go_gamification/version.rb +1 -1
- metadata +47 -43
@@ -0,0 +1,224 @@
|
|
1
|
+
var charX = 50;
|
2
|
+
var charY = 108;
|
3
|
+
|
4
|
+
var breathInc = 0.1;
|
5
|
+
var breathDir = 1;
|
6
|
+
var breathAmt = 0;
|
7
|
+
var breathMax = 2;
|
8
|
+
var maxEyeHeight = 14;
|
9
|
+
var curEyeHeight = maxEyeHeight;
|
10
|
+
var eyeOpenTime = 0;
|
11
|
+
var timeBtwBlinks = 200;
|
12
|
+
var blinkUpdateTime = 1;
|
13
|
+
var blinkCounter = 0;
|
14
|
+
var numFramesDrawn = 0;
|
15
|
+
var curFPS = 0;
|
16
|
+
|
17
|
+
var isJumping = false;
|
18
|
+
var jumpHeight = 45;
|
19
|
+
var cloudSpeed = 0.5;
|
20
|
+
|
21
|
+
var parts = [
|
22
|
+
{name: 'leftArm',ident: "<%= asset_path 'go_gamification/leftArm' %>", visible: true, x: charX + 40, y: charY - 42 - breathAmt},
|
23
|
+
{name:'leftArmjump',ident: "<%= asset_path 'go_gamification/leftArm-jump' %>", visible: false, x: charX + 40, y: charY - 42 - breathAmt},
|
24
|
+
{name: 'legs',ident: "<%= asset_path 'go_gamification/legs' %>", visible: true, x: charX, y: charY},
|
25
|
+
{name: 'legsjump',ident: "<%= asset_path 'go_gamification/legs-jump' %>", visible: false, x: charX, y: charY-6},
|
26
|
+
{name: 'torso',ident: "<%= asset_path 'go_gamification/torso' %>", visible: true, x: charX, y: charY - 50},
|
27
|
+
{name: 'head',ident: "<%= asset_path 'go_gamification/head' %>", visible: true, x: charX - 10, y: charY - 125 - breathAmt},
|
28
|
+
{name: 'hair',ident: "<%= asset_path 'go_gamification/hair' %>", visible: true, x: charX - 37, y: charY - 138 - breathAmt},
|
29
|
+
{name: 'rightArm',ident: "<%= asset_path 'go_gamification/rightArm' %>", visible: true, x: charX - 15, y: charY - 42 - breathAmt},
|
30
|
+
{name: 'rightArmjump',ident: "<%= asset_path 'go_gamification/rightArm-jump' %>", visible: false, x: charX - 35, y: charY - 42 - breathAmt},
|
31
|
+
|
32
|
+
];
|
33
|
+
|
34
|
+
var bodyParts = [];
|
35
|
+
|
36
|
+
var num_of_imgs = parts.length + 2;
|
37
|
+
var loaded_imgs = 0;
|
38
|
+
|
39
|
+
function myLoop() {
|
40
|
+
bg.draw();
|
41
|
+
|
42
|
+
//update the cloud
|
43
|
+
cx = cloud.x - cloudSpeed;
|
44
|
+
|
45
|
+
if(cx+cloud.width < 0) {
|
46
|
+
cx = engine._stageWidth + 20;
|
47
|
+
cy = Math.floor(Math.random()*230);
|
48
|
+
cloud.y = cy;
|
49
|
+
}
|
50
|
+
|
51
|
+
cloud.x = cx;
|
52
|
+
cloud.draw();
|
53
|
+
|
54
|
+
x = charX;
|
55
|
+
y = charY;
|
56
|
+
|
57
|
+
if(isJumping) {
|
58
|
+
y -= jumpHeight;
|
59
|
+
}
|
60
|
+
|
61
|
+
character.y = y;
|
62
|
+
// Update parts for breathing
|
63
|
+
bodyParts.head.y = charY - 125 - breathAmt;
|
64
|
+
bodyParts.hair.y = charY - 138 - breathAmt;
|
65
|
+
|
66
|
+
if(isJumping) {
|
67
|
+
bodyParts.leftArmjump.visible = true;
|
68
|
+
bodyParts.rightArmjump.visible = true;
|
69
|
+
bodyParts.legsjump.visible = true;
|
70
|
+
|
71
|
+
bodyParts.leftArm.visible = false;
|
72
|
+
bodyParts.rightArm.visible = false;
|
73
|
+
bodyParts.legs.visible = false;
|
74
|
+
} else {
|
75
|
+
bodyParts.leftArmjump.visible = false;
|
76
|
+
bodyParts.rightArmjump.visible = false;
|
77
|
+
bodyParts.legsjump.visible = false;
|
78
|
+
|
79
|
+
bodyParts.leftArm.visible = true;
|
80
|
+
bodyParts.rightArm.visible = true;
|
81
|
+
bodyParts.legs.visible = true;
|
82
|
+
|
83
|
+
bodyParts.leftArm.y = charY - 42 - breathAmt;
|
84
|
+
bodyParts.rightArm.y = charY - 42 - breathAmt;
|
85
|
+
}
|
86
|
+
|
87
|
+
bodyParts.leftEye.y = charY - 68 - breathAmt;
|
88
|
+
bodyParts.rightEye.y = charY - 68 - breathAmt;
|
89
|
+
|
90
|
+
eyeOpenTime += blinkUpdateTime;
|
91
|
+
|
92
|
+
if(eyeOpenTime >= timeBtwBlinks) {
|
93
|
+
blink();
|
94
|
+
}
|
95
|
+
|
96
|
+
bodyParts.leftEye.height = curEyeHeight;
|
97
|
+
bodyParts.rightEye.height = curEyeHeight;
|
98
|
+
|
99
|
+
character.draw();
|
100
|
+
fps_text.text = "Current FPS: " + engine.getFPS();
|
101
|
+
fps_text.draw();
|
102
|
+
updateBreath();
|
103
|
+
}
|
104
|
+
|
105
|
+
$(document).ready(function() {
|
106
|
+
engine = new bHive({
|
107
|
+
width: 301,
|
108
|
+
height: 301,
|
109
|
+
domobject: 'stageholder',
|
110
|
+
backgroundColor: '#000'
|
111
|
+
});
|
112
|
+
|
113
|
+
engine.addEventListener('onclick',function(e) {
|
114
|
+
// Jumping
|
115
|
+
if(!isJumping) {
|
116
|
+
isJumping = true;
|
117
|
+
setTimeout(land, 500);
|
118
|
+
}
|
119
|
+
});
|
120
|
+
|
121
|
+
character = engine.createClip({
|
122
|
+
x: charX,
|
123
|
+
y: charY
|
124
|
+
});
|
125
|
+
|
126
|
+
for(part in parts) {
|
127
|
+
o = parts[part];
|
128
|
+
bodyParts[o.name] = engine.createBitmap({
|
129
|
+
src: o.ident ,
|
130
|
+
x: o.x,
|
131
|
+
y: o.y,
|
132
|
+
visible: o.visible
|
133
|
+
});
|
134
|
+
|
135
|
+
bodyParts[o.name].addEventListener('onload',increaseLoaded);
|
136
|
+
character.add(bodyParts[o.name]);
|
137
|
+
}
|
138
|
+
|
139
|
+
bodyParts['leftEye'] = engine.createShape({
|
140
|
+
shape: 'elipse',
|
141
|
+
style: 'filled',
|
142
|
+
x: charX + 47,
|
143
|
+
y: charY - 68 - breathAmt,
|
144
|
+
width: 8,
|
145
|
+
height: curEyeHeight,
|
146
|
+
});
|
147
|
+
|
148
|
+
bodyParts['rightEye'] = engine.createShape({
|
149
|
+
shape: 'elipse',
|
150
|
+
style: 'filled',
|
151
|
+
x: charX + 58,
|
152
|
+
y: charY - 68 - breathAmt,
|
153
|
+
width: 8,
|
154
|
+
height: curEyeHeight
|
155
|
+
});
|
156
|
+
|
157
|
+
character.add(bodyParts['leftEye']);
|
158
|
+
character.add(bodyParts['rightEye']);
|
159
|
+
|
160
|
+
bg = engine.createBitmap({
|
161
|
+
src: "<%= asset_path 'go_gamification/background' %>",
|
162
|
+
x: 0,
|
163
|
+
y: 0
|
164
|
+
});
|
165
|
+
|
166
|
+
bg.addEventListener('onload',increaseLoaded);
|
167
|
+
|
168
|
+
cloud = engine.createBitmap({
|
169
|
+
src: "<%= asset_path 'go_gamification/cloud' %>",
|
170
|
+
x: engine._stageWidth + 20,
|
171
|
+
y: 80
|
172
|
+
});
|
173
|
+
|
174
|
+
cloud.addEventListener('onload',increaseLoaded);
|
175
|
+
|
176
|
+
fps_text = engine.createText({
|
177
|
+
text: "FPS",
|
178
|
+
color: 'rgba(255,255,255,1)',
|
179
|
+
x: 20,
|
180
|
+
y: 20
|
181
|
+
});
|
182
|
+
|
183
|
+
setTimeout("checkforload()",1000);
|
184
|
+
});
|
185
|
+
|
186
|
+
function increaseLoaded() {
|
187
|
+
loaded_imgs++;
|
188
|
+
}
|
189
|
+
|
190
|
+
function checkforload() {
|
191
|
+
if(loaded_imgs == num_of_imgs) {
|
192
|
+
console.log("loaded");
|
193
|
+
engine.theLoop(myLoop);
|
194
|
+
} else {
|
195
|
+
setTimeout("checkforload()",1000);
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
function updateBreath() {
|
200
|
+
if (breathDir === 1) { // breath in
|
201
|
+
breathAmt -= breathInc;
|
202
|
+
if (breathAmt < -breathMax) {
|
203
|
+
breathDir = -1;
|
204
|
+
}
|
205
|
+
} else { // breath out
|
206
|
+
breathAmt += breathInc;
|
207
|
+
if(breathAmt > breathMax) {
|
208
|
+
breathDir = 1;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
}
|
212
|
+
|
213
|
+
function blink() {
|
214
|
+
curEyeHeight -= 2;
|
215
|
+
if (curEyeHeight <= 0) {
|
216
|
+
eyeOpenTime = 0;
|
217
|
+
curEyeHeight = maxEyeHeight;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
|
221
|
+
function land() {
|
222
|
+
isJumping = false;
|
223
|
+
}
|
224
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_gamification
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- João Carlos Ottobboni
|
@@ -14,56 +14,56 @@ dependencies:
|
|
14
14
|
name: draper
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: carrierwave
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sqlite3
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: go_gamification engine
|
@@ -73,54 +73,58 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
-
|
77
|
-
-
|
78
|
-
- app/assets/images/go_gamification/hair.png
|
79
|
-
- app/assets/images/go_gamification/head.png
|
76
|
+
- app/controllers/gamification/levels_controller.rb
|
77
|
+
- app/controllers/gamification/rewards_controller.rb
|
80
78
|
- app/assets/images/go_gamification/leftArm-jump.png
|
81
|
-
- app/assets/images/go_gamification/
|
82
|
-
- app/assets/images/go_gamification/
|
83
|
-
- app/assets/images/go_gamification/legs.png
|
79
|
+
- app/assets/images/go_gamification/background.png
|
80
|
+
- app/assets/images/go_gamification/hair.png
|
84
81
|
- app/assets/images/go_gamification/rightArm-jump.png
|
82
|
+
- app/assets/images/go_gamification/cloud.png
|
85
83
|
- app/assets/images/go_gamification/rightArm.png
|
86
84
|
- app/assets/images/go_gamification/torso.png
|
87
|
-
- app/assets/
|
85
|
+
- app/assets/images/go_gamification/head.png
|
86
|
+
- app/assets/images/go_gamification/legs.png
|
87
|
+
- app/assets/images/go_gamification/leftArm.png
|
88
|
+
- app/assets/images/go_gamification/legs-jump.png
|
89
|
+
- app/assets/javascripts/go_gamification/bhive.js.erb
|
90
|
+
- app/assets/javascripts/go_gamification/character-new.js.erb
|
88
91
|
- app/assets/javascripts/go_gamification/excanvas.js
|
89
|
-
- app/
|
90
|
-
- app/controllers/gamification/rewards_controller.rb
|
91
|
-
- app/helpers/gamification/application_helper.rb
|
92
|
+
- app/assets/javascripts/go_gamification/character.js.erb
|
92
93
|
- app/helpers/gamification/rewards_helper.rb
|
93
|
-
- app/
|
94
|
-
- app/
|
95
|
-
- app/
|
96
|
-
- app/models/gamification/level.rb
|
97
|
-
- app/models/gamification/medal.rb
|
98
|
-
- app/models/gamification/reward.rb
|
99
|
-
- app/uploaders/gamification/image_uploader.rb
|
100
|
-
- app/views/gamification/levels/_form.html.erb
|
94
|
+
- app/helpers/gamification/application_helper.rb
|
95
|
+
- app/views/gamification/rewards/_presentation.html.erb
|
96
|
+
- app/views/gamification/rewards/_reward.html.erb
|
101
97
|
- app/views/gamification/levels/edit.html.erb
|
98
|
+
- app/views/gamification/levels/show.html.erb
|
102
99
|
- app/views/gamification/levels/index.html.erb
|
100
|
+
- app/views/gamification/levels/_form.html.erb
|
103
101
|
- app/views/gamification/levels/new.html.erb
|
104
|
-
- app/views/gamification/levels/show.html.erb
|
105
|
-
- app/views/gamification/rewards/_presentation.html.erb
|
106
|
-
- app/views/gamification/rewards/_reward.html.erb
|
107
102
|
- app/views/gamification/scorings/create.html.erb
|
108
|
-
-
|
103
|
+
- app/uploaders/gamification/image_uploader.rb
|
104
|
+
- app/models/gamification.rb
|
105
|
+
- app/models/application_record.rb
|
106
|
+
- app/models/gamification/medal.rb
|
107
|
+
- app/models/gamification/level.rb
|
108
|
+
- app/models/gamification/goal.rb
|
109
|
+
- app/models/gamification/reward.rb
|
109
110
|
- config/routes.rb
|
110
|
-
-
|
111
|
+
- config/initializers/assets.rb
|
111
112
|
- db/migrate/20171020181620_create_go_gamification_scorings.rb
|
112
|
-
- db/migrate/
|
113
|
+
- db/migrate/20171020181447_create_go_gamification_tasks.rb
|
114
|
+
- db/migrate/20171026001848_alter_table_go_gamification_count.rb
|
115
|
+
- db/migrate/20171026003231_alter_table_go_gamification_levels.rb
|
113
116
|
- db/migrate/20171020182119_create_go_gamification_medals.rb
|
114
|
-
- db/migrate/20171020182210_add_description_to_go_gamification_medals.rb
|
115
|
-
- db/migrate/20171020182248_rename_go_gamification_tasks_to_goals.rb
|
116
117
|
- db/migrate/20171020182329_add_seen_at_to_go_gamification_rewards.rb
|
118
|
+
- db/migrate/20171020182210_add_description_to_go_gamification_medals.rb
|
117
119
|
- db/migrate/20171023230506_create_go_gamification_levels.rb
|
118
|
-
- db/migrate/
|
119
|
-
- db/migrate/
|
120
|
-
- lib/
|
120
|
+
- db/migrate/20171020182248_rename_go_gamification_tasks_to_goals.rb
|
121
|
+
- db/migrate/20171020182027_rename_everything.rb
|
122
|
+
- lib/tasks/go_gamification_tasks.rake
|
121
123
|
- lib/go_gamification/engine.rb
|
122
124
|
- lib/go_gamification/version.rb
|
123
|
-
- lib/
|
125
|
+
- lib/go_gamification.rb
|
126
|
+
- MIT-LICENSE
|
127
|
+
- Rakefile
|
124
128
|
homepage: http://www.gorails.com.br
|
125
129
|
licenses:
|
126
130
|
- MIT
|
@@ -131,17 +135,17 @@ require_paths:
|
|
131
135
|
- lib
|
132
136
|
required_ruby_version: !ruby/object:Gem::Requirement
|
133
137
|
requirements:
|
134
|
-
- -
|
138
|
+
- - '>='
|
135
139
|
- !ruby/object:Gem::Version
|
136
140
|
version: '0'
|
137
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
142
|
requirements:
|
139
|
-
- -
|
143
|
+
- - '>='
|
140
144
|
- !ruby/object:Gem::Version
|
141
145
|
version: '0'
|
142
146
|
requirements: []
|
143
147
|
rubyforge_project:
|
144
|
-
rubygems_version: 2.
|
148
|
+
rubygems_version: 2.0.14.1
|
145
149
|
signing_key:
|
146
150
|
specification_version: 4
|
147
151
|
summary: go_gamification engine
|