social_stream 0.23.4 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- data/base/app/assets/images/flags/pt.png +0 -0
- data/base/app/assets/javascripts/social_stream.toolbar.js +41 -0
- data/base/app/assets/stylesheets/settings.css +1 -0
- data/base/app/controllers/activity_actions_controller.rb +44 -0
- data/base/app/controllers/followers_controller.rb +39 -0
- data/base/app/helpers/activities_helper.rb +10 -10
- data/base/app/helpers/activity_actions_helper.rb +35 -0
- data/base/app/helpers/contacts_helper.rb +1 -1
- data/base/app/helpers/followers_helper.rb +5 -0
- data/base/app/helpers/toolbar_helper.rb +55 -68
- data/base/app/models/activity_action.rb +28 -0
- data/base/app/models/activity_object.rb +11 -2
- data/base/app/models/actor.rb +23 -33
- data/base/app/models/contact.rb +32 -43
- data/base/app/models/group.rb +2 -6
- data/base/app/models/relation.rb +1 -1
- data/base/app/models/relation/follow.rb +14 -0
- data/base/app/models/tie.rb +30 -30
- data/base/app/models/user.rb +8 -0
- data/base/app/views/activities/_options.html.erb +0 -1
- data/base/app/views/activity_actions/_follow_form.html.erb +10 -0
- data/base/app/views/activity_actions/_follow_sentence.html.erb +3 -0
- data/base/app/views/activity_actions/_update_form.js.erb +2 -0
- data/base/app/views/activity_actions/create.js.erb +1 -0
- data/base/app/views/activity_actions/update.js.erb +1 -0
- data/base/app/views/avatars/index.html.erb +1 -1
- data/base/app/views/cheesecake/index.html.erb +1 -1
- data/base/app/views/contacts/{_link.html.erb → _link_custom.html.erb} +0 -0
- data/base/app/views/contacts/_link_follow.html.erb +12 -0
- data/base/app/views/contacts/edit.html.erb +1 -1
- data/base/app/views/contacts/index.html.erb +1 -1
- data/base/app/views/contacts/index.js.erb +1 -1
- data/base/app/views/contacts/new.html.erb +1 -1
- data/base/app/views/conversations/index.html.erb +1 -1
- data/base/app/views/conversations/index.js.erb +1 -1
- data/base/app/views/conversations/show.html.erb +1 -1
- data/base/app/views/conversations/show.js.erb +1 -1
- data/base/app/views/devise/registrations/edit.html.erb +1 -1
- data/base/app/views/followers/destroy.js.erb +1 -0
- data/base/app/views/followers/index.html.erb +5 -0
- data/base/app/views/followers/update.js.erb +1 -0
- data/base/app/views/groups/_show.html.erb +1 -1
- data/base/app/views/groups/new.html.erb +1 -1
- data/base/app/views/layouts/_header_dropdown_menu.html.erb +5 -3
- data/base/app/views/messages/new.html.erb +1 -1
- data/base/app/views/messages/new.js.erb +1 -1
- data/base/app/views/objects/_show.html.erb +1 -1
- data/base/app/views/profiles/edit.html.erb +1 -1
- data/base/app/views/profiles/show.html.erb +1 -1
- data/base/app/views/relation/customs/index.html.erb +1 -1
- data/base/app/views/settings/index.html.erb +1 -1
- data/base/app/views/settings/index.js.erb +1 -0
- data/base/app/views/ties/index.html.erb +1 -1
- data/base/app/views/toolbar/_logo.html.erb +0 -7
- data/base/app/views/users/_show.html.erb +1 -1
- data/base/config/locales/en.yml +16 -6
- data/base/config/locales/es.yml +15 -6
- data/base/config/locales/pt.yml +507 -0
- data/base/config/locales/rails.pt.yml +192 -0
- data/base/config/routes.rb +20 -7
- data/base/db/migrate/20120316093946_create_activity_actions.rb +15 -0
- data/base/db/migrate/20120316113728_activity_action_follow.rb +23 -0
- data/base/lib/generators/social_stream/base/install_generator.rb +0 -4
- data/base/lib/generators/social_stream/base/templates/initializer.rb +7 -0
- data/base/lib/inherited_resources/social_stream.rb +18 -0
- data/base/lib/rails/social_stream.rb +23 -0
- data/base/lib/social_stream-base.rb +7 -3
- data/base/lib/social_stream/base/dependencies.rb +3 -2
- data/base/lib/social_stream/base/engine.rb +6 -6
- data/base/lib/social_stream/base/version.rb +1 -1
- data/base/lib/social_stream/models/channeled.rb +8 -0
- data/base/lib/social_stream/models/object.rb +1 -3
- data/base/lib/social_stream/models/subtype.rb +31 -25
- data/base/lib/social_stream/models/supertype.rb +54 -19
- data/base/lib/social_stream/views/toolbar/base.rb +143 -0
- data/base/lib/tasks/db/populate.rake +1 -1
- data/base/social_stream-base.gemspec +1 -3
- data/base/spec/dummy/config/initializers/social_stream.rb +7 -0
- data/base/spec/models/activity_action_spec.rb +26 -0
- data/base/spec/models/tie_spec.rb +2 -2
- data/documents/app/views/common_documents/_headers.html.erb +1 -1
- data/documents/lib/social_stream-documents.rb +4 -2
- data/documents/lib/social_stream/documents/engine.rb +3 -3
- data/documents/lib/social_stream/documents/version.rb +1 -1
- data/documents/lib/social_stream/views/toolbar/documents.rb +28 -0
- data/documents/social_stream-documents.gemspec +1 -1
- data/events/app/assets/javascripts/social_stream.event.js +33 -0
- data/events/app/assets/stylesheets/events.css.scss +37 -0
- data/events/app/views/events/_event.html.erb +3 -44
- data/events/app/views/events/_event_date.html.erb +20 -0
- data/events/app/views/events/_event_date_sidebar.html.erb +14 -0
- data/events/app/views/events/_event_details.html.erb +21 -0
- data/events/app/views/events/_event_poster.html.erb +9 -0
- data/events/app/views/events/_event_sidebar.html.erb +10 -0
- data/events/app/views/events/index.html.erb +1 -1
- data/events/app/views/events/index.js.erb +1 -1
- data/events/config/locales/en.yml +6 -0
- data/events/config/locales/es.yml +7 -0
- data/events/lib/social_stream/events/version.rb +1 -1
- data/events/social_stream-events.gemspec +2 -2
- data/lib/social_stream/version.rb +1 -1
- data/linkser/lib/social_stream/linkser/version.rb +1 -1
- data/linkser/social_stream-linkser.gemspec +1 -1
- data/presence/app/assets/images/games/sfighter/abobo/abobo.png +0 -0
- data/presence/app/assets/images/games/sfighter/abobo/abobo_block_81x130x1.png +0 -0
- data/presence/app/assets/images/games/sfighter/abobo/abobo_die_156x119x1.png +0 -0
- data/presence/app/assets/images/games/sfighter/abobo/abobo_hit_108x120x3.png +0 -0
- data/presence/app/assets/images/games/sfighter/abobo/abobo_idle_100x121x3.png +0 -0
- data/presence/app/assets/images/games/sfighter/abobo/abobo_kick_137x130x2.png +0 -0
- data/presence/app/assets/images/games/sfighter/abobo/abobo_punch_131x170x4.png +0 -0
- data/presence/app/assets/images/games/sfighter/abobo/abobo_walk_backward_94x126x6.png +0 -0
- data/presence/app/assets/images/games/sfighter/abobo/abobo_walk_forward_94x126x6.png +0 -0
- data/presence/app/assets/images/games/sfighter/cvs/cvs_block_69x99x2.png +0 -0
- data/presence/app/assets/images/games/sfighter/cvs/cvs_die_150x110x1.png +0 -0
- data/presence/app/assets/images/games/sfighter/cvs/cvs_hit_59x103x1.png +0 -0
- data/presence/app/assets/images/games/sfighter/cvs/cvs_idle_59x106x6.png +0 -0
- data/presence/app/assets/images/games/sfighter/cvs/cvs_kick_156x106x9.png +0 -0
- data/presence/app/assets/images/games/sfighter/cvs/cvs_punch_120x104x6.png +0 -0
- data/presence/app/assets/images/games/sfighter/cvs/cvs_walk_backward_58x106x5.png +0 -0
- data/presence/app/assets/images/games/sfighter/cvs/cvs_walk_forward_58x106x5.png +0 -0
- data/presence/app/assets/images/games/sfighter/stage/background1.png +0 -0
- data/presence/app/assets/images/games/sfighter/stage/background2.png +0 -0
- data/presence/app/assets/images/games/sfighter/stage/background3.png +0 -0
- data/presence/app/assets/images/games/sfighter/stage/foreground.png +0 -0
- data/presence/app/assets/images/games/sfighter/stage/ground.png +0 -0
- data/presence/app/assets/images/games/sfighter/thumbnail.png +0 -0
- data/presence/app/assets/images/games/ter/classic_circle.png +0 -0
- data/presence/app/assets/images/games/ter/classic_thumbnail.png +0 -0
- data/presence/app/assets/images/games/ter/modern_thumbnail.png +0 -0
- data/presence/app/assets/images/webcam.png +0 -0
- data/presence/app/assets/javascripts/jquery.ui.chatbox.sstreampresence.js +2 -2
- data/presence/app/assets/javascripts/presence_XmppClient.js.erb +3 -1
- data/presence/app/assets/javascripts/presence_game.js.erb +13 -6
- data/presence/app/assets/javascripts/presence_game_comunication.js.erb +83 -13
- data/presence/app/assets/javascripts/presence_game_factory.js.erb +47 -0
- data/presence/app/assets/javascripts/presence_game_interface.js.erb +143 -53
- data/presence/app/assets/javascripts/presence_game_sfighter.js.erb +583 -0
- data/presence/app/assets/javascripts/presence_game_ter.js.erb +20 -9
- data/presence/app/assets/javascripts/presence_uiManager.js.erb +0 -2
- data/presence/app/assets/javascripts/presence_utilities.js +1 -1
- data/presence/app/assets/javascripts/presence_videochat.js.erb +5 -0
- data/presence/app/assets/javascripts/social_stream-presence.js +1 -0
- data/presence/app/assets/stylesheets/chat.css.scss +59 -6
- data/presence/config/locales/en.yml +1 -1
- data/presence/config/locales/es.yml +1 -1
- data/presence/lib/social_stream-presence.rb +4 -0
- data/presence/lib/social_stream/presence/engine.rb +6 -0
- data/presence/lib/social_stream/presence/version.rb +1 -1
- data/presence/lib/social_stream/views/toolbar/presence.rb +28 -0
- data/presence/social_stream-presence.gemspec +1 -1
- data/social_stream.gemspec +5 -5
- metadata +92 -41
- data/base/app/assets/javascripts/toolbar.js +0 -22
- data/base/app/views/layouts/_settings.html.erb +0 -18
- data/base/app/views/toolbar/_home.html.erb +0 -15
- data/base/app/views/toolbar/_messages.html.erb +0 -15
- data/base/app/views/toolbar/_profile.html.erb +0 -28
- data/base/lib/generators/social_stream/base/templates/navigation.rb +0 -4
- data/base/lib/social_stream/toolbar_config/base.rb +0 -94
- data/documents/lib/social_stream/toolbar_config/documents.rb +0 -27
- data/events/lib/social_stream/toolbar_config/events.rb +0 -22
@@ -0,0 +1,583 @@
|
|
1
|
+
////////////////////
|
2
|
+
// Street Fighter //
|
3
|
+
////////////////////
|
4
|
+
|
5
|
+
PRESENCE.GAME.SFIGTHER = (function(P,$,undefined){
|
6
|
+
|
7
|
+
//Gamecore
|
8
|
+
var CORE = P.GAME
|
9
|
+
|
10
|
+
//Games variables
|
11
|
+
var game; //Game and player are objects defined in the gamecore.
|
12
|
+
var name = "Street Fighter"
|
13
|
+
var player = null;
|
14
|
+
var playing=true;
|
15
|
+
|
16
|
+
//Character Ids
|
17
|
+
var cvsId = "cvs";
|
18
|
+
var aboboId = "abobo";
|
19
|
+
var characterId = null;
|
20
|
+
|
21
|
+
// Possible moves;
|
22
|
+
var IDLE= 0;
|
23
|
+
var WALK_FORWARD= 1;
|
24
|
+
var WALK_BACKWARD= 2;
|
25
|
+
var PUNCH= 3;
|
26
|
+
var KICK= 4;
|
27
|
+
var BLOCK= 5;
|
28
|
+
var BEATEN= 6;
|
29
|
+
var DIE= 7;
|
30
|
+
|
31
|
+
var PLAYGROUND_WIDTH = 800 ;
|
32
|
+
var PLAYGROUND_HEIGHT = 200;
|
33
|
+
var image_path = "/assets/games/sfighter/";
|
34
|
+
|
35
|
+
//Fighters
|
36
|
+
var abobo;
|
37
|
+
var cvs;
|
38
|
+
|
39
|
+
//We must define our ACTION object.
|
40
|
+
//The information exchanged between players is performed through the exchange of action type objects.
|
41
|
+
//We can define our own types of actions, with different fields
|
42
|
+
function action(player,movement) {
|
43
|
+
this.player = player;
|
44
|
+
this.move = movement;
|
45
|
+
this.type = "movement";
|
46
|
+
}
|
47
|
+
|
48
|
+
|
49
|
+
var lastAction = null;
|
50
|
+
|
51
|
+
//Html Divs
|
52
|
+
var divID = null;
|
53
|
+
|
54
|
+
|
55
|
+
////////////////
|
56
|
+
// STARTER //
|
57
|
+
////////////////
|
58
|
+
//The core will invoke this method automatically to start the game.
|
59
|
+
//*myPlayer = myself
|
60
|
+
//*myGame = Game object (is the same for all players)
|
61
|
+
//*myDivID = Div to render the game
|
62
|
+
var init = function(myPlayer,myGame,myDivID){
|
63
|
+
player = myPlayer;
|
64
|
+
game = myGame;
|
65
|
+
divID = "playground";
|
66
|
+
|
67
|
+
if(myGame.players[0].id == myPlayer.id){
|
68
|
+
//Play with abobo
|
69
|
+
characterId = aboboId;
|
70
|
+
} else {
|
71
|
+
//Play with cvs
|
72
|
+
characterId = cvsId;
|
73
|
+
}
|
74
|
+
|
75
|
+
//Setting options
|
76
|
+
game.options = settingOptions(myGame.options);
|
77
|
+
|
78
|
+
playing=true;
|
79
|
+
|
80
|
+
drawBackground();
|
81
|
+
|
82
|
+
settingKeyBoardEvents();
|
83
|
+
|
84
|
+
initFighters();
|
85
|
+
|
86
|
+
//register the main callback
|
87
|
+
registerMainCallBack();
|
88
|
+
|
89
|
+
//start loading!
|
90
|
+
$().setLoadBar("loadingBar", 600);
|
91
|
+
|
92
|
+
//Show welcome message
|
93
|
+
$.playground().startGame(function(){
|
94
|
+
$("#welcomMessage").fadeOut(2000, function(){$(this).remove()});
|
95
|
+
});
|
96
|
+
}
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
//Set defaults for unspecified options
|
101
|
+
var settingOptions = function(myOptions){
|
102
|
+
//Apply default options for non specified opts.
|
103
|
+
return myOptions;
|
104
|
+
};
|
105
|
+
|
106
|
+
|
107
|
+
//Register the main callback
|
108
|
+
function registerMainCallBack(){
|
109
|
+
$.playground().registerCallback(function(){
|
110
|
+
|
111
|
+
var cvs = $("#cvs");
|
112
|
+
var cvsF = cvs.data("fighter");
|
113
|
+
var cvsLeft = cvs.position().left;
|
114
|
+
|
115
|
+
var abobo = $("#abobo");
|
116
|
+
var aboboF = abobo.data("fighter");
|
117
|
+
var aboboLeft = abobo.position().left;
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
//hit?
|
122
|
+
if(cvsLeft+cvsF.animations[cvsF.currentState].width - 2 > aboboLeft){
|
123
|
+
if((cvsF.currentState == KICK || cvsF.currentState == PUNCH) && aboboF.currentState != BEATEN){
|
124
|
+
if (aboboF.currentState == KICK || aboboF.currentState == PUNCH) {
|
125
|
+
hit(abobo)
|
126
|
+
hit(cvs)
|
127
|
+
} else if (aboboF.currentState != BLOCK){
|
128
|
+
hit(abobo)
|
129
|
+
}
|
130
|
+
} else if ((aboboF.currentState == KICK || aboboF.currentState == PUNCH) && cvsF.currentState != BEATEN) {
|
131
|
+
if (cvsF.currentState != BLOCK){
|
132
|
+
hit(cvs)
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
//Move
|
138
|
+
if(cvsF.currentState == WALK_FORWARD){
|
139
|
+
if((cvsLeft+cvsF.animations[cvsF.currentState].width+2) < aboboLeft){
|
140
|
+
cvs.css("left", cvsLeft+2);
|
141
|
+
}
|
142
|
+
} else if ((cvsLeft > 50) && (cvsF.currentState == WALK_BACKWARD)){
|
143
|
+
cvs.css("left", cvsLeft-2)
|
144
|
+
}
|
145
|
+
|
146
|
+
if(aboboF.currentState == WALK_FORWARD){
|
147
|
+
if((cvsLeft+cvsF.animations[cvsF.currentState].width+2) < aboboLeft){
|
148
|
+
abobo.css("left", aboboLeft - 2);
|
149
|
+
}
|
150
|
+
} else if ((aboboLeft < 650) && (aboboF.currentState == WALK_BACKWARD)){
|
151
|
+
abobo.css("left", aboboLeft + 2);
|
152
|
+
}
|
153
|
+
|
154
|
+
var al = abobo.position().left - aboboF.animations[aboboF.currentState].deltaX;
|
155
|
+
var cl = cvs.position().left - cvsF.animations[cvsF.currentState].deltaX;
|
156
|
+
|
157
|
+
|
158
|
+
var centerPos = (al - cl)/2 + cl;
|
159
|
+
scrollStage(-(centerPos-400)*0.5);
|
160
|
+
|
161
|
+
return false;
|
162
|
+
}, 30);
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
///////////////////////////
|
167
|
+
// Setting Keyboard Events
|
168
|
+
///////////////////////////
|
169
|
+
|
170
|
+
var keyList = new Array();
|
171
|
+
keyList[37]=false //leftKey
|
172
|
+
keyList[39]=false //rightKey
|
173
|
+
keyList[65]=false //A=PUNCH
|
174
|
+
keyList[83]=false //S=KICK
|
175
|
+
keyList[90]=false //Z=BLOCK
|
176
|
+
|
177
|
+
var previousKey = null;
|
178
|
+
var currentKey = null;
|
179
|
+
|
180
|
+
function settingKeyBoardEvents(){
|
181
|
+
$(window).keydown(function(evt){
|
182
|
+
if (typeof keyList[evt.which] != "undefined") {
|
183
|
+
if (currentKey == evt.which) {
|
184
|
+
keyList[currentKey] = true;
|
185
|
+
return
|
186
|
+
}
|
187
|
+
previousKey = currentKey
|
188
|
+
currentKey = evt.which
|
189
|
+
if (previousKey != null) {
|
190
|
+
keyList[previousKey] = false;
|
191
|
+
}
|
192
|
+
keyList[currentKey] = true;
|
193
|
+
}
|
194
|
+
}).keyup(function(evt){
|
195
|
+
if (typeof keyList[evt.which] != "undefined") {
|
196
|
+
}
|
197
|
+
});
|
198
|
+
}
|
199
|
+
|
200
|
+
function nextMove(fighter,adversary){
|
201
|
+
if(fighter.data("fighter").currentState == DIE){
|
202
|
+
return DIE;
|
203
|
+
}
|
204
|
+
for(var key in keyList){
|
205
|
+
if (keyList[key]){
|
206
|
+
keyList[key] = false
|
207
|
+
var leftOriented = fighter.position().left-adversary.position().left > 0;
|
208
|
+
|
209
|
+
switch (key) {
|
210
|
+
case "37":
|
211
|
+
//Left key
|
212
|
+
if(leftOriented){
|
213
|
+
return WALK_FORWARD
|
214
|
+
} else {
|
215
|
+
return WALK_BACKWARD
|
216
|
+
}
|
217
|
+
|
218
|
+
case "39":
|
219
|
+
//Right key
|
220
|
+
if(leftOriented){
|
221
|
+
return WALK_BACKWARD
|
222
|
+
} else {
|
223
|
+
return WALK_FORWARD
|
224
|
+
}
|
225
|
+
|
226
|
+
case "65":
|
227
|
+
//A
|
228
|
+
return PUNCH
|
229
|
+
case "83":
|
230
|
+
//S
|
231
|
+
return KICK
|
232
|
+
case "90":
|
233
|
+
//Z
|
234
|
+
return BLOCK
|
235
|
+
}
|
236
|
+
}
|
237
|
+
}
|
238
|
+
return IDLE
|
239
|
+
}
|
240
|
+
|
241
|
+
|
242
|
+
///////////////////////////
|
243
|
+
// DRAW METHODS //
|
244
|
+
///////////////////////////
|
245
|
+
|
246
|
+
var drawBackground = function(){
|
247
|
+
var containderDiv = document.createElement('div');
|
248
|
+
containderDiv.setAttribute('id', divID);
|
249
|
+
containderDiv.setAttribute('style', "width: 800px; height: 200px;");
|
250
|
+
$("#wrapper_body").prepend(containderDiv)
|
251
|
+
|
252
|
+
var welcomeMessageDiv = document.createElement('div');
|
253
|
+
welcomeMessageDiv.setAttribute('id', "welcomMessage");
|
254
|
+
welcomeMessageDiv.setAttribute('style', "position: absolute; top: 0px; width: 800px; height: 200px; color: white; z-index: 1000; background: #333;");
|
255
|
+
$("#" + divID).prepend(welcomeMessageDiv)
|
256
|
+
|
257
|
+
$("#" + divID).playground({height: PLAYGROUND_HEIGHT, width: PLAYGROUND_WIDTH, refreshRate: 30, keyTracker: true});
|
258
|
+
|
259
|
+
//Playground Sprites
|
260
|
+
var foreground = new $.gameQuery.Animation({imageURL: image_path + "/stage/foreground.png", type: $.gameQuery.ANIMATION_VERTICAL});
|
261
|
+
var ground = new $.gameQuery.Animation({imageURL: image_path + "/stage/ground.png"});
|
262
|
+
var background1 = new $.gameQuery.Animation({imageURL: image_path + "/stage/background1.png"});
|
263
|
+
var background2 = new $.gameQuery.Animation({imageURL: image_path + "/stage/background2.png"});
|
264
|
+
var background3 = new $.gameQuery.Animation({imageURL: image_path + "/stage/background3.png"});
|
265
|
+
$.playground().addSprite( "background3",
|
266
|
+
{posx: 90, posy: 0,
|
267
|
+
height: 200, width: 534,
|
268
|
+
animation: background3})
|
269
|
+
.addSprite( "background2",
|
270
|
+
{posx:30, posy: -50,
|
271
|
+
height: 180, width: 432,
|
272
|
+
animation: background2})
|
273
|
+
.addSprite( "background1",
|
274
|
+
{posx:50, posy: -150,
|
275
|
+
height: 317, width: 749,
|
276
|
+
animation: background1})
|
277
|
+
.addSprite( "ground",
|
278
|
+
{posx: -300, posy: 0,
|
279
|
+
height: 200, width: 1493,
|
280
|
+
animation: ground}).addGroup("fighters").end()
|
281
|
+
.addSprite( "foreground",
|
282
|
+
{posx:-800, posy: 165,
|
283
|
+
height: 44, width: 2000,
|
284
|
+
animation: foreground});
|
285
|
+
$("#sceengraph").css("background-color","#121423");
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
function initFighters(){
|
290
|
+
cvs = {
|
291
|
+
id: cvsId,
|
292
|
+
health: 100,
|
293
|
+
currentState : IDLE,
|
294
|
+
position: 250,
|
295
|
+
adversary: "#abobo",
|
296
|
+
animations: [ {animation: new $.gameQuery.Animation({ imageURL: image_path + "/cvs/cvs_idle_59x106x6.png",
|
297
|
+
numberOfFrame: 6,
|
298
|
+
delta: 59,
|
299
|
+
rate:240,
|
300
|
+
type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_CALLBACK}),
|
301
|
+
deltaX: 0, deltaY: 0, width: 59, height: 106},
|
302
|
+
{animation: new $.gameQuery.Animation({ imageURL: image_path + "/cvs/cvs_walk_forward_58x106x5.png",
|
303
|
+
numberOfFrame: 5,
|
304
|
+
delta: 58,
|
305
|
+
rate:240,
|
306
|
+
type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_CALLBACK}),
|
307
|
+
deltaX: 0, deltaY: 0, width: 58, height: 106},
|
308
|
+
{animation: new $.gameQuery.Animation({ imageURL: image_path + "/cvs/cvs_walk_backward_58x106x5.png",
|
309
|
+
numberOfFrame: 5,
|
310
|
+
delta: 58,
|
311
|
+
rate:240,
|
312
|
+
type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_CALLBACK}),
|
313
|
+
deltaX: 0, deltaY: 0, width: 58, height: 106},
|
314
|
+
{animation: new $.gameQuery.Animation({ imageURL: image_path + "/cvs/cvs_punch_120x104x6.png",
|
315
|
+
numberOfFrame: 6,
|
316
|
+
delta: 120,
|
317
|
+
rate:120,
|
318
|
+
type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_CALLBACK}),
|
319
|
+
deltaX: 0, deltaY: 2, width: 120, height: 104},
|
320
|
+
{animation: new $.gameQuery.Animation({ imageURL: image_path + "/cvs/cvs_kick_156x106x9.png",
|
321
|
+
numberOfFrame: 9,
|
322
|
+
delta: 156,
|
323
|
+
rate:90,
|
324
|
+
type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_CALLBACK}),
|
325
|
+
deltaX: -20, deltaY: 0, width: 156, height: 106},
|
326
|
+
{animation: new $.gameQuery.Animation({ imageURL: image_path + "/cvs/cvs_block_69x99x2.png",
|
327
|
+
numberOfFrame: 2,
|
328
|
+
delta: 69,
|
329
|
+
rate:480,
|
330
|
+
type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_CALLBACK}),
|
331
|
+
deltaX: 0, deltaY: 7, width: 69, height: 99},
|
332
|
+
{animation: new $.gameQuery.Animation({ imageURL: image_path + "/cvs/cvs_hit_59x103x1.png",
|
333
|
+
rate: 720,
|
334
|
+
type: $.gameQuery.ANIMATION_CALLBACK}),
|
335
|
+
deltaX: 0, deltaY: 3, width: 59, height: 103},
|
336
|
+
{animation: new $.gameQuery.Animation({ imageURL: image_path + "/cvs/cvs_die_150x110x1.png",
|
337
|
+
numberOfFrame: 1,
|
338
|
+
rate: 720,
|
339
|
+
type: $.gameQuery.ANIMATION_CALLBACK}),
|
340
|
+
deltaX: 0, deltaY: 3, width: 150, height: 110},
|
341
|
+
]
|
342
|
+
}
|
343
|
+
|
344
|
+
$("#fighters").addSprite("cvs",
|
345
|
+
{posx: 250,
|
346
|
+
posy: 70,
|
347
|
+
height: 106,
|
348
|
+
width: 58,
|
349
|
+
animation: cvs.animations[0].animation,
|
350
|
+
geometry: $.gameQuery.GEOMETRY_RECTANGLE,
|
351
|
+
callback: animate});
|
352
|
+
$("#cvs").data("fighter", cvs);
|
353
|
+
|
354
|
+
|
355
|
+
abobo = {
|
356
|
+
id: aboboId,
|
357
|
+
health: 100,
|
358
|
+
currentState : IDLE,
|
359
|
+
position: 500,
|
360
|
+
adversary: "#cvs",
|
361
|
+
animations: [ {animation: new $.gameQuery.Animation({ imageURL: image_path + "/abobo/abobo_idle_100x121x3.png",
|
362
|
+
numberOfFrame: 3,
|
363
|
+
delta: 100,
|
364
|
+
rate:190,
|
365
|
+
type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_CALLBACK}),
|
366
|
+
deltaX: 0, deltaY: 49, width: 100, height: 121},
|
367
|
+
{animation: new $.gameQuery.Animation({ imageURL: image_path + "/abobo/abobo_walk_forward_94x126x6.png",
|
368
|
+
numberOfFrame: 6,
|
369
|
+
delta: 94,
|
370
|
+
rate:240,
|
371
|
+
type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_CALLBACK}),
|
372
|
+
deltaX: 0, deltaY: 44, width: 94, height: 126},
|
373
|
+
{animation: new $.gameQuery.Animation({ imageURL: image_path + "/abobo/abobo_walk_backward_94x126x6.png",
|
374
|
+
numberOfFrame: 6,
|
375
|
+
delta: 94,
|
376
|
+
rate:240,
|
377
|
+
type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_CALLBACK}),
|
378
|
+
deltaX: 0, deltaY: 44, width: 94, height: 126},
|
379
|
+
{animation: new $.gameQuery.Animation({ imageURL: image_path + "/abobo/abobo_punch_131x170x4.png",
|
380
|
+
numberOfFrame: 4,
|
381
|
+
delta: 131,
|
382
|
+
rate:150,
|
383
|
+
type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_CALLBACK}),
|
384
|
+
deltaX: -30, deltaY: 0, width: 131, height: 170},
|
385
|
+
{animation: new $.gameQuery.Animation({ imageURL: image_path + "/abobo/abobo_kick_137x130x2.png",
|
386
|
+
numberOfFrame: 2,
|
387
|
+
delta: 137,
|
388
|
+
rate:500,
|
389
|
+
type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_CALLBACK}),
|
390
|
+
deltaX: 20, deltaY: 40, width: 137, height: 130},
|
391
|
+
{animation: new $.gameQuery.Animation({ imageURL: image_path + "/abobo/abobo_block_81x130x1.png",
|
392
|
+
rate:700,
|
393
|
+
type: $.gameQuery.ANIMATION_CALLBACK}),
|
394
|
+
deltaX: 0, deltaY: 40, width: 81, height: 130},
|
395
|
+
{animation: new $.gameQuery.Animation({ imageURL: image_path + "/abobo/abobo_hit_108x120x3.png",
|
396
|
+
numberOfFrame: 3,
|
397
|
+
delta: 108,
|
398
|
+
rate:240,
|
399
|
+
type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_CALLBACK}),
|
400
|
+
deltaX: 0, deltaY: 50, width: 108, height: 120},
|
401
|
+
{animation: new $.gameQuery.Animation({ imageURL: image_path + "/abobo/abobo_die_156x119x1.png",
|
402
|
+
numberOfFrame: 1,
|
403
|
+
delta: 0,
|
404
|
+
rate:500,
|
405
|
+
type: $.gameQuery.ANIMATION_HORIZONTAL | $.gameQuery.ANIMATION_CALLBACK}),
|
406
|
+
deltaX: 0, deltaY: 50, width: 156, height: 120}]
|
407
|
+
}
|
408
|
+
|
409
|
+
$("#fighters").addSprite("abobo",
|
410
|
+
{posx: 550,
|
411
|
+
posy: 60,
|
412
|
+
height: 121,
|
413
|
+
width: 100,
|
414
|
+
animation: abobo.animations[0].animation,
|
415
|
+
geometry: $.gameQuery.GEOMETRY_RECTANGLE,
|
416
|
+
callback: animate});
|
417
|
+
$("#abobo").data("fighter", abobo);
|
418
|
+
}
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
//////////////////////////////
|
423
|
+
// ANIMATION CALLBACKS //
|
424
|
+
//////////////////////////////
|
425
|
+
|
426
|
+
function animate(sprite){
|
427
|
+
sprite = $(sprite);
|
428
|
+
fighter = sprite.data("fighter");
|
429
|
+
adversary = $(fighter.adversary);
|
430
|
+
adversaryFighter = adversary.data("fighter");
|
431
|
+
|
432
|
+
var nextState = IDLE;
|
433
|
+
|
434
|
+
if (fighter.id == characterId) {
|
435
|
+
//myfighter
|
436
|
+
nextState = nextMove(sprite,adversary)
|
437
|
+
var myaction = new action(nextState)
|
438
|
+
sendAction(myaction)
|
439
|
+
} else {
|
440
|
+
if (lastAction != null) {
|
441
|
+
nextState = lastAction.move
|
442
|
+
}
|
443
|
+
}
|
444
|
+
|
445
|
+
changeAnimation(sprite, fighter.animations, nextState, fighter.currentState);
|
446
|
+
|
447
|
+
if(nextState == PUNCH || nextState == KICK){
|
448
|
+
sprite.css("z-index", 20);
|
449
|
+
} else if(fighter.currentState == PUNCH || fighter.currentState == KICK){
|
450
|
+
sprite.css("z-index", undefined);
|
451
|
+
}
|
452
|
+
|
453
|
+
fighter.currentState = nextState;
|
454
|
+
}
|
455
|
+
|
456
|
+
|
457
|
+
var scrollStage = function (offset){
|
458
|
+
if(offset > 50){
|
459
|
+
offset = 50;
|
460
|
+
} else if(offset < -50) {
|
461
|
+
offset = -50;
|
462
|
+
}
|
463
|
+
$("#foreground").css("left", ""+(-800 + offset/0.5)+"px");
|
464
|
+
|
465
|
+
$("#ground").css("left", ""+(-300 + offset)+"px");
|
466
|
+
$("#fighters").css("left", ""+ offset +"px");
|
467
|
+
|
468
|
+
$("#background1").css("left", ""+(50 + offset/2)+"px");
|
469
|
+
$("#background2").css("left", ""+(30 + offset/4)+"px");
|
470
|
+
$("#background3").css("left", ""+(90 + offset/5)+"px");
|
471
|
+
}
|
472
|
+
|
473
|
+
|
474
|
+
/*replace with new*/
|
475
|
+
var changeAnimation = function(sprite, animationArry, newAnimation , oldAnimation){
|
476
|
+
sprite
|
477
|
+
.setAnimation(animationArry[newAnimation].animation)
|
478
|
+
.width(animationArry[newAnimation].width)
|
479
|
+
.height(animationArry[newAnimation].height)
|
480
|
+
.css("top", sprite.position().top + animationArry[newAnimation].deltaY - animationArry[oldAnimation].deltaY)
|
481
|
+
.css("left", sprite.position().left + animationArry[newAnimation].deltaX - animationArry[oldAnimation].deltaX);
|
482
|
+
};
|
483
|
+
|
484
|
+
|
485
|
+
function hit(sprite){
|
486
|
+
var spriteF = sprite.data("fighter");
|
487
|
+
spriteF.health = spriteF.health - 45;
|
488
|
+
if(spriteF.health<0){
|
489
|
+
changeAnimation(sprite, spriteF.animations, DIE, spriteF.currentState);
|
490
|
+
spriteF.currentState = DIE;
|
491
|
+
playing = false;
|
492
|
+
} else {
|
493
|
+
changeAnimation(sprite, spriteF.animations, BEATEN, spriteF.currentState);
|
494
|
+
spriteF.currentState = BEATEN;
|
495
|
+
}
|
496
|
+
}
|
497
|
+
|
498
|
+
|
499
|
+
////////////////////////////////
|
500
|
+
// CORE CONFIG CALLBACKS //
|
501
|
+
////////////////////////////////
|
502
|
+
|
503
|
+
//Optional methods that can be invoked by the core
|
504
|
+
|
505
|
+
//The Core provides basic validation
|
506
|
+
//We can include our own validation conditions here!
|
507
|
+
//The core will invoke this method automatically in the validation process
|
508
|
+
var validateParams = function(myPlayer,myGame,myDivID){
|
509
|
+
|
510
|
+
if(myGame.players.length != 2){
|
511
|
+
return new CORE.createValidationResult(false,"This game needs two players");
|
512
|
+
}
|
513
|
+
return new CORE.createValidationResult(true,"Ok");
|
514
|
+
}
|
515
|
+
|
516
|
+
|
517
|
+
//MinimumRequirements to execute this game
|
518
|
+
var minimumRequirements = function(){
|
519
|
+
var requirements = new Array();
|
520
|
+
return requirements;
|
521
|
+
}
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
/////////////////////////////////
|
526
|
+
// GAMECORE CALLS & CALLBACKS // * To send our actions to other players we will use the << sendAction >> method.
|
527
|
+
///////////////////////////////// * When some player send us a action, the core will invoke the << onActionReceived >> method.
|
528
|
+
|
529
|
+
var sendAction = function(action){
|
530
|
+
CORE.sendAction(game,action)
|
531
|
+
return;
|
532
|
+
}
|
533
|
+
|
534
|
+
var onActionReceived = function(action){
|
535
|
+
lastAction = action;
|
536
|
+
return;
|
537
|
+
}
|
538
|
+
|
539
|
+
//Get action type method
|
540
|
+
var getActionType = function(move){
|
541
|
+
switch (key) {
|
542
|
+
case IDLE:
|
543
|
+
return "movement"
|
544
|
+
case WALK_FORWARD:
|
545
|
+
return "movement"
|
546
|
+
case WALK_BACKWARD:
|
547
|
+
return "movement"
|
548
|
+
case PUNCH:
|
549
|
+
return "trigger"
|
550
|
+
case KICK:
|
551
|
+
return "trigger"
|
552
|
+
case BLOCK:
|
553
|
+
return "movement"
|
554
|
+
case BEATEN:
|
555
|
+
return "trigger"
|
556
|
+
case DIE:
|
557
|
+
return "trigger"
|
558
|
+
}
|
559
|
+
}
|
560
|
+
|
561
|
+
//Getters
|
562
|
+
var getName = function(){
|
563
|
+
return name
|
564
|
+
}
|
565
|
+
|
566
|
+
var getGame = function(){
|
567
|
+
return game;
|
568
|
+
}
|
569
|
+
|
570
|
+
var getMyplayer = function(){
|
571
|
+
return player;
|
572
|
+
}
|
573
|
+
|
574
|
+
|
575
|
+
return {
|
576
|
+
init: init,
|
577
|
+
getName: getName,
|
578
|
+
validateParams: validateParams,
|
579
|
+
minimumRequirements: minimumRequirements,
|
580
|
+
onActionReceived: onActionReceived
|
581
|
+
};
|
582
|
+
|
583
|
+
}) (PRESENCE, jQuery);
|