~ubuntu-branches/ubuntu/natty/smc/natty

« back to all changes in this revision

Viewing changes to src/objects/moving_platform.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Muammar El Khatib
  • Date: 2008-10-20 00:31:35 UTC
  • mfrom: (1.1.4 upstream) (5.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081020003135-5ac8cpecomfohvv5
Tags: 1.6-1
* New upstream release. (Closes:#479415)
* Bumped standards version to 3.8.0.
* debian/control: dpatch build dependency has been removed temporarily.
* debian/control: smc-data does not depend on smc anymore. This change will
  avoid a circular dependency. (Closes: #478712)
* smc does not segfault. (Closes: #500039, #491590) 
* Icon is not missed in Gnome Menu. Thanks to Saïvann for providing a 
  solution. (Closes: #491885)
* debian/control: smc-data's and smc-music's descriptions have been improved.
  (Closes: #493630)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
           moving_platform.cpp  -  default moving platforms handler
3
 
                             -------------------
4
 
    copyright            :      (C) 2005 - 2007 by Florian Richter
 
2
 * moving_platform.cpp  -  default moving platforms handler
 
3
 *
 
4
 * Copyright (C) 2005 - 2008 Florian Richter
5
5
 ***************************************************************************/
6
6
/*
7
7
   This program is free software; you can redistribute it and/or modify
17
17
#include "../core/camera.h"
18
18
#include "../core/game_core.h"
19
19
#include "../video/gl_surface.h"
 
20
#include "../core/framerate.h"
 
21
#include "../video/renderer.h"
 
22
#include "../user/savegame.h"
 
23
#include "../core/i18n.h"
20
24
 
21
25
/* *** *** *** *** *** *** *** cMoving_Platform *** *** *** *** *** *** *** *** *** *** */
22
26
 
23
27
cMoving_Platform :: cMoving_Platform( float x, float y )
24
28
: cImageObjectSprite( x, y )
25
29
{
26
 
        Init();
 
30
        cMoving_Platform::Init();
27
31
}
28
32
 
29
 
cMoving_Platform :: cMoving_Platform( XMLAttributes &attributes )
 
33
cMoving_Platform :: cMoving_Platform( CEGUI::XMLAttributes &attributes )
30
34
: cImageObjectSprite()
31
35
{
32
 
        Init();
33
 
        Create_from_Stream( attributes );
 
36
        cMoving_Platform::Init();
 
37
        cMoving_Platform::Create_from_Stream( attributes );
34
38
}
35
39
 
36
40
cMoving_Platform :: ~cMoving_Platform( void )
45
49
        posz = 0.085f;
46
50
 
47
51
        player_range = 2000;
48
 
 
49
 
        Set_Massivetype( MASS_HALFMASSIVE );
 
52
        can_be_ground = 1;
 
53
 
 
54
        platform_state = PLATFORM_STAY;
 
55
        touch_counter = 0;
 
56
        shake_dir_counter = 0;
 
57
        shake_counter = 0;
 
58
 
 
59
        Set_Massive_Type( MASS_HALFMASSIVE );
50
60
        Set_Max_Distance( 150 );
51
61
        Set_Speed( 3 );
 
62
        Set_Touch_Time( 0 );
 
63
        Set_Shake_Time( 16 );
 
64
        Set_Touch_Move_Time( 0 );
 
65
 
 
66
        Set_Direction( DIR_RIGHT, 1 );
 
67
 
52
68
        Set_Middle_Count( 2 );
53
 
 
54
 
        Set_Direction( DIR_RIGHT );
55
 
 
56
69
        // create default images
57
70
        images.push_back( pVideo->Get_Surface( "slider/grey_1/slider_left.png" ) );
58
71
        images.push_back( pVideo->Get_Surface( "slider/grey_1/slider_middle.png" ) );
59
72
        images.push_back( pVideo->Get_Surface( "slider/grey_1/slider_right.png" ) );
60
73
        Set_Image( 1, 1 );
61
74
 
62
 
        Update_rect();
 
75
        Update_Rect();
63
76
 
64
77
        Create_Name();
65
78
}
67
80
cMoving_Platform *cMoving_Platform :: Copy( void )
68
81
{
69
82
        cMoving_Platform *moving_platform = new cMoving_Platform( startposx, startposy );
70
 
        moving_platform->Set_Massivetype( massivetype );
71
 
        moving_platform->Set_Direction( start_direction );
 
83
        moving_platform->Set_Massive_Type( massivetype );
 
84
        moving_platform->Set_Direction( start_direction, 1 );
72
85
        moving_platform->Set_Max_Distance( max_distance );
73
86
        moving_platform->Set_Speed( speed );
 
87
        moving_platform->Set_Touch_Time( touch_time );
 
88
        moving_platform->Set_Shake_Time( shake_time );
 
89
        moving_platform->Set_Touch_Move_Time( touch_move_time );
74
90
        moving_platform->Set_Middle_Count( middle_count );
75
 
        moving_platform->Set_image_top_left( images[0] );
76
 
        moving_platform->Set_image_top_middle( images[1] );
77
 
        moving_platform->Set_image_top_right( images[2] );
 
91
        moving_platform->Set_Image_Top_Left( images[0] );
 
92
        moving_platform->Set_Image_Top_Middle( images[1] );
 
93
        moving_platform->Set_Image_Top_Right( images[2] );
78
94
 
79
95
        return moving_platform;
80
96
}
81
97
 
82
 
void cMoving_Platform :: Create_from_Stream( XMLAttributes &attributes )
 
98
void cMoving_Platform :: Create_from_Stream( CEGUI::XMLAttributes &attributes )
83
99
{
84
100
        // position
85
101
        Set_Pos( static_cast<float>(attributes.getValueAsInteger( "posx" )), static_cast<float>(attributes.getValueAsInteger( "posy" )), 1 );
86
102
        // massive type
87
 
        Set_Massivetype( Get_Massivetype_id( attributes.getValueAsString( "massive_type", Get_Massivetype_name( massivetype ) ).c_str() ) );
 
103
        Set_Massive_Type( Get_Massive_Type_Id( attributes.getValueAsString( "massive_type", Get_Massive_Type_Name( massivetype ) ).c_str() ) );
88
104
        // direction
89
 
        Set_Direction( Get_Direction_id( attributes.getValueAsString( "direction", Get_Direction_name( start_direction ) ).c_str() ) );
 
105
        Set_Direction( Get_Direction_Id( attributes.getValueAsString( "direction", Get_Direction_Name( start_direction ) ).c_str() ), 1 );
90
106
        // max distance
91
107
        Set_Max_Distance( attributes.getValueAsInteger( "max_distance", max_distance ) );
92
108
        // speed
93
109
        Set_Speed( attributes.getValueAsFloat( "speed", speed ) );
 
110
        // touch_time
 
111
        Set_Touch_Time( attributes.getValueAsFloat( "touch_time", touch_time ) );
 
112
        // shake time
 
113
        Set_Shake_Time( attributes.getValueAsFloat( "shake_time", shake_time ) );
 
114
        // touch move time
 
115
        Set_Touch_Move_Time( attributes.getValueAsFloat( "touch_move_time", touch_move_time ) );
94
116
        // middle image count
95
117
        Set_Middle_Count( attributes.getValueAsInteger( "middle_img_count", middle_count ) );
96
 
        // Image Top Left
97
 
        Set_image_top_left( pVideo->Get_Surface( attributes.getValueAsString( "image_top_left", images[0]->Get_filename() ).c_str() ) );
98
 
        // Image Top Middle
99
 
        Set_image_top_middle( pVideo->Get_Surface( attributes.getValueAsString( "image_top_middle", images[1]->Get_filename() ).c_str() ) );
100
 
        // Image Top Right
101
 
        Set_image_top_right( pVideo->Get_Surface( attributes.getValueAsString( "image_top_right", images[2]->Get_filename() ).c_str() ) );
 
118
        // image top left
 
119
        Set_Image_Top_Left( pVideo->Get_Surface( attributes.getValueAsString( "image_top_left", images[0]->Get_Filename() ).c_str() ) );
 
120
        // image top middle
 
121
        Set_Image_Top_Middle( pVideo->Get_Surface( attributes.getValueAsString( "image_top_middle", images[1]->Get_Filename() ).c_str() ) );
 
122
        // image top right
 
123
        Set_Image_Top_Right( pVideo->Get_Surface( attributes.getValueAsString( "image_top_right", images[2]->Get_Filename() ).c_str() ) );
102
124
}
103
125
 
104
126
void cMoving_Platform :: Save_to_Stream( ofstream &file )
110
132
        file << "\t\t<Property name=\"posx\" value=\"" << static_cast<int>(startposx) << "\" />" << std::endl;
111
133
        file << "\t\t<Property name=\"posy\" value=\"" << static_cast<int>(startposy) << "\" />" << std::endl;
112
134
        // massive type
113
 
        file << "\t\t<Property name=\"massive_type\" value=\"" << Get_Massivetype_name( massivetype ) << "\" />" << std::endl;
 
135
        file << "\t\t<Property name=\"massive_type\" value=\"" << Get_Massive_Type_Name( massivetype ) << "\" />" << std::endl;
114
136
        // direction
115
 
        file << "\t\t<Property name=\"direction\" value=\"" << Get_Direction_name( start_direction ) << "\" />" << std::endl;
 
137
        file << "\t\t<Property name=\"direction\" value=\"" << Get_Direction_Name( start_direction ) << "\" />" << std::endl;
116
138
        // max distance
117
139
        file << "\t\t<Property name=\"max_distance\" value=\"" << max_distance << "\" />" << std::endl;
118
140
        // speed
119
141
        file << "\t\t<Property name=\"speed\" value=\"" << speed << "\" />" << std::endl;
 
142
        // touch time
 
143
        file << "\t\t<Property name=\"touch_time\" value=\"" << touch_time << "\" />" << std::endl;
 
144
        // shake time
 
145
        file << "\t\t<Property name=\"shake_time\" value=\"" << shake_time << "\" />" << std::endl;
 
146
        // touch move time
 
147
        file << "\t\t<Property name=\"touch_move_time\" value=\"" << touch_move_time << "\" />" << std::endl;
120
148
        // middle image count
121
149
        file << "\t\t<Property name=\"middle_img_count\" value=\"" << middle_count << "\" />" << std::endl;
122
150
        // image top left
123
 
        file << "\t\t<Property name=\"image_top_left\" value=\"" << images[0]->Get_filename( 1 ) << "\" />" << std::endl;
 
151
        file << "\t\t<Property name=\"image_top_left\" value=\"" << images[0]->Get_Filename( 1 ) << "\" />" << std::endl;
124
152
        // image top middle
125
 
        file << "\t\t<Property name=\"image_top_middle\" value=\"" << images[1]->Get_filename( 1 ) << "\" />" << std::endl;
 
153
        file << "\t\t<Property name=\"image_top_middle\" value=\"" << images[1]->Get_Filename( 1 ) << "\" />" << std::endl;
126
154
        // image top right
127
 
        file << "\t\t<Property name=\"image_top_right\" value=\"" << images[2]->Get_filename( 1 ) << "\" />" << std::endl;
 
155
        file << "\t\t<Property name=\"image_top_right\" value=\"" << images[2]->Get_Filename( 1 ) << "\" />" << std::endl;
128
156
 
129
157
        // end moving_platform
130
158
        file << "\t</moving_platform>" << std::endl;
131
159
}
132
160
 
133
 
void cMoving_Platform :: Set_Massivetype( MassiveType mtype )
 
161
void cMoving_Platform :: Load_from_Savegame( cSave_Level_Object *save_object )
 
162
{
 
163
        // direction
 
164
        if( save_object->exists( "direction" ) )
 
165
        {
 
166
                direction = static_cast<ObjectDirection>(string_to_int( save_object->Get_Value( "direction" ) ));
 
167
        }
 
168
 
 
169
        // platform state
 
170
        if( save_object->exists( "platform_state" ) )
 
171
        {
 
172
                platform_state = static_cast<Moving_Platform_State>(string_to_int( save_object->Get_Value( "platform_state" ) ));
 
173
        }
 
174
 
 
175
        // new position x
 
176
        if( save_object->exists( "new_posx" ) )
 
177
        {
 
178
                Set_Pos_X( string_to_float( save_object->Get_Value( "new_posx" ) ) );
 
179
        }
 
180
 
 
181
        // new position y
 
182
        if( save_object->exists( "new_posy" ) )
 
183
        {
 
184
                Set_Pos_Y( string_to_float( save_object->Get_Value( "new_posy" ) ) );
 
185
        }
 
186
 
 
187
        // velocity x
 
188
        if( save_object->exists( "velx" ) )
 
189
        {
 
190
                velx = string_to_float( save_object->Get_Value( "velx" ) );
 
191
        }
 
192
 
 
193
        // velocity y
 
194
        if( save_object->exists( "vely" ) )
 
195
        {
 
196
                vely = string_to_float( save_object->Get_Value( "vely" ) );
 
197
        }
 
198
 
 
199
        // visible
 
200
        if( save_object->exists( "visible" ) )
 
201
        {
 
202
                Set_Visible( string_to_int( save_object->Get_Value( "visible" ) ) > 0 );
 
203
        }
 
204
}
 
205
 
 
206
cSave_Level_Object *cMoving_Platform :: Save_to_Savegame( void )
 
207
{
 
208
        cSave_Level_Object *save_object = new cSave_Level_Object();
 
209
 
 
210
        // default values
 
211
        save_object->type = type;
 
212
        save_object->properties.push_back( cSave_Level_Object_Property( "posx", int_to_string( static_cast<int>(startposx) ) ) );
 
213
        save_object->properties.push_back( cSave_Level_Object_Property( "posy", int_to_string( static_cast<int>(startposy) ) ) );
 
214
 
 
215
        // direction
 
216
        save_object->properties.push_back( cSave_Level_Object_Property( "direction", int_to_string( direction ) ) );
 
217
 
 
218
        // platform state
 
219
        save_object->properties.push_back( cSave_Level_Object_Property( "platform_state", int_to_string( platform_state ) ) );
 
220
 
 
221
        // new position ( only save if needed )
 
222
        if( startposx != posx || startposy != posy )
 
223
        {
 
224
                save_object->properties.push_back( cSave_Level_Object_Property( "new_posx", int_to_string( static_cast<int>(posx) ) ) );
 
225
                save_object->properties.push_back( cSave_Level_Object_Property( "new_posy", int_to_string( static_cast<int>(posy) ) ) );
 
226
        }
 
227
 
 
228
        // velocity
 
229
        save_object->properties.push_back( cSave_Level_Object_Property( "velx", float_to_string( velx ) ) );
 
230
        save_object->properties.push_back( cSave_Level_Object_Property( "vely", float_to_string( vely ) ) );
 
231
 
 
232
        // visible ( only save if needed )
 
233
        if( !visible )
 
234
        {
 
235
                save_object->properties.push_back( cSave_Level_Object_Property( "visible", int_to_string( visible ) ) );
 
236
        }
 
237
 
 
238
        return save_object;
 
239
}
 
240
 
 
241
void cMoving_Platform :: Set_Massive_Type( MassiveType mtype )
134
242
{
135
243
        massivetype = mtype;
136
244
 
154
262
        Create_Name();
155
263
}
156
264
 
157
 
void cMoving_Platform :: Set_Direction( ObjectDirection dir )
 
265
void cMoving_Platform :: Set_Direction( ObjectDirection dir, bool new_start_direction /* = 0 */ )
158
266
{
159
 
        // already set
160
 
        if( start_direction == dir )
 
267
        cImageObjectSprite::Set_Direction( dir, new_start_direction );
 
268
 
 
269
        if( new_start_direction )
161
270
        {
162
 
                return;
 
271
                // changed direction
 
272
                if( dir != start_direction )
 
273
                {
 
274
                        // set back start position
 
275
                        Set_Pos( startposx, startposy );
 
276
                        // reset velocity
 
277
                        Set_Velocity( 0, 0 );
 
278
                }
 
279
 
 
280
                // update name
 
281
                Create_Name();
163
282
        }
164
283
 
165
 
        cImageObjectSprite::Set_Direction( dir, 1 );
166
 
        Create_Name();
 
284
        // Set new velocity
 
285
        Update_Velocity();
167
286
}
168
287
 
169
288
void cMoving_Platform :: Set_Max_Distance( int nmax_distance )
180
299
{
181
300
        speed = val;
182
301
 
183
 
        if( speed < 0 )
184
 
        {
185
 
                speed = 0;
186
 
        }
 
302
        // set velocity
 
303
        Update_Velocity();
 
304
 
 
305
        Create_Name();
 
306
}
 
307
 
 
308
void cMoving_Platform :: Set_Touch_Time( float val )
 
309
{
 
310
        touch_time = val;
 
311
 
 
312
        if( touch_time < 0 )
 
313
        {
 
314
                touch_time = 0;
 
315
        }
 
316
 
 
317
        Create_Name();
 
318
}
 
319
 
 
320
void cMoving_Platform :: Set_Shake_Time( float val )
 
321
{
 
322
        shake_time = val;
 
323
 
 
324
        if( shake_time < 0 )
 
325
        {
 
326
                shake_time = 0;
 
327
        }
 
328
}
 
329
 
 
330
void cMoving_Platform :: Set_Touch_Move_Time( float val )
 
331
{
 
332
        touch_move_time = val;
 
333
 
 
334
        if( touch_move_time < 0 )
 
335
        {
 
336
                touch_move_time = 0;
 
337
        }
 
338
 
 
339
        // set back start position
 
340
        Set_Pos( startposx, startposy );
 
341
        // reset velocity
 
342
        Set_Velocity( 0, 0 );
 
343
 
 
344
        Create_Name();
187
345
}
188
346
 
189
347
void cMoving_Platform :: Set_Middle_Count( int val )
196
354
        }
197
355
}
198
356
 
199
 
void cMoving_Platform :: Set_image_top_left( GL_Surface *surface )
 
357
void cMoving_Platform :: Set_Image_Top_Left( GL_Surface *surface )
200
358
{
201
359
        if( !surface )
202
360
        {
204
362
        }
205
363
 
206
364
        images[0] = surface;
207
 
        Update_rect();
 
365
        Update_Rect();
208
366
}
209
367
 
210
 
void cMoving_Platform :: Set_image_top_middle( GL_Surface *surface )
 
368
void cMoving_Platform :: Set_Image_Top_Middle( GL_Surface *surface )
211
369
{
212
370
        if( !surface )
213
371
        {
215
373
        }
216
374
 
217
375
        images[1] = surface;
218
 
        Update_rect();
 
376
 
 
377
        // middle image sets main image
 
378
        curr_img = -1;
 
379
        Set_Image( 1, 1 );
 
380
        Update_Rect();
219
381
}
220
382
 
221
 
void cMoving_Platform :: Set_image_top_right( GL_Surface *surface )
 
383
void cMoving_Platform :: Set_Image_Top_Right( GL_Surface *surface )
222
384
{
223
385
        if( !surface )
224
386
        {
226
388
        }
227
389
 
228
390
        images[2] = surface;
229
 
        Update_rect();
 
391
        Update_Rect();
230
392
}
231
393
 
232
394
void cMoving_Platform :: Update( void )
236
398
                return;
237
399
        }
238
400
 
239
 
        if( direction == DIR_UP )
240
 
        {
241
 
                velx = 0;
242
 
                vely = -speed;
243
 
 
244
 
                if( posy - startposy < 0 )
245
 
                {
246
 
                        direction = DIR_DOWN;
247
 
                }
248
 
        }
249
 
        else if( direction == DIR_DOWN )
250
 
        {
251
 
                velx = 0;
252
 
                vely = speed;
253
 
 
254
 
                if( posy - startposy > max_distance )
255
 
                {
256
 
                        direction = DIR_UP;
257
 
                }
258
 
        }
259
 
        else if( direction == DIR_LEFT )
260
 
        {
261
 
                velx = -speed;
262
 
                vely = 0;
263
 
 
264
 
                if( posx - startposx < 0 )
265
 
                {
266
 
                        direction = DIR_RIGHT;
267
 
                }
268
 
        }
269
 
        else if( direction == DIR_RIGHT )
270
 
        {
271
 
                velx = speed;
272
 
                vely = 0;
273
 
 
274
 
                if( posx - startposx > max_distance )
275
 
                {
276
 
                        direction = DIR_LEFT;
 
401
        // move time should be smaller than touch time because it should
 
402
        // start moving (if it is moving) before shaking starts.
 
403
        // if larger than touch time then the platform state will change 
 
404
        // and touch_counter will never be more than move_time
 
405
        if( touch_time || touch_move_time )
 
406
        {
 
407
                if( platform_state == PLATFORM_TOUCHED )
 
408
                {
 
409
                        touch_counter += pFramerate->speedfactor;
 
410
                }
 
411
        }
 
412
 
 
413
        // if able to fall
 
414
        if( touch_time )
 
415
        {
 
416
                if( platform_state == PLATFORM_TOUCHED && touch_counter > touch_time )
 
417
                {
 
418
                        platform_state = PLATFORM_SHAKE;
 
419
                }
 
420
                else if( platform_state == PLATFORM_SHAKE )
 
421
                {
 
422
                        shake_dir_counter += pFramerate->speedfactor;
 
423
 
 
424
                        // move into opposite direction
 
425
                        if( shake_dir_counter > 0.8f )
 
426
                        {
 
427
                                float move_x = 0;
 
428
                                if( posx > startposx )
 
429
                                {
 
430
                                        move_x = -3;
 
431
                                }
 
432
                                else
 
433
                                {
 
434
                                        move_x = 3;
 
435
                                }
 
436
 
 
437
                                // move
 
438
                                col_pos.x -= move_x;
 
439
                                Move( move_x, 0, 1 );
 
440
 
 
441
                                shake_dir_counter = 0;
 
442
                        }
 
443
 
 
444
                        shake_counter += pFramerate->speedfactor;
 
445
 
 
446
                        if( shake_counter > shake_time )
 
447
                        {
 
448
                                platform_state = PLATFORM_FALL;
 
449
                        }
 
450
                }
 
451
                else if( platform_state == PLATFORM_FALL )
 
452
                {
 
453
                        if( vely < 25 )
 
454
                        {
 
455
                                vely += 2.1f * pFramerate->speedfactor;
 
456
 
 
457
                                // limit falling velocity
 
458
                                if( vely > 25 )
 
459
                                {
 
460
                                        vely = 25;
 
461
                                }
 
462
                        }
 
463
 
 
464
                        // drop objects when falling fast
 
465
                        if( can_be_ground && vely > 15 )
 
466
                        {
 
467
                                can_be_ground = 0;
 
468
                        }
 
469
 
 
470
                        if( posx > startposx )
 
471
                        {
 
472
                                Add_Rotation_Z( 1.5f );
 
473
                        }
 
474
                        else
 
475
                        {
 
476
                                Add_Rotation_Z( -1.5f );
 
477
                        }
 
478
 
 
479
                        // below screen
 
480
                        if( col_rect.y + col_rect.h > pActive_Camera->limit_rect.y + game_res_h )
 
481
                        {
 
482
                                platform_state = PLATFORM_STAY;
 
483
                                Set_Visible( 0 );
 
484
                        }
 
485
                }
 
486
        }
 
487
 
 
488
        // if moving
 
489
        if( speed && platform_state != PLATFORM_FALL && ( !touch_move_time || touch_counter > touch_move_time ) )
 
490
        {
 
491
                // distance to final position
 
492
                float dist_to_final_pos = 0;
 
493
 
 
494
                if( direction == DIR_LEFT )
 
495
                {
 
496
                        dist_to_final_pos = 0 - ( startposx - posx );
 
497
                }
 
498
                else if( direction == DIR_RIGHT )
 
499
                {
 
500
                        dist_to_final_pos = max_distance + ( startposx - posx );
 
501
                }
 
502
                else if( direction == DIR_UP )
 
503
                {
 
504
                        dist_to_final_pos = 0 - ( startposy - posy );
 
505
                }
 
506
                else if( direction == DIR_DOWN )
 
507
                {
 
508
                        dist_to_final_pos = max_distance + ( startposy - posy );
 
509
                }
 
510
 
 
511
                // reached final position
 
512
                if( dist_to_final_pos <= 0 )
 
513
                {
 
514
                        // unset velocity
 
515
                        Set_Velocity( 0, 0 );
 
516
                        // set new direction
 
517
                        Set_Direction( Get_Opposite_Direction( direction ) );
 
518
                }
 
519
                // slow down near final position
 
520
                else if( dist_to_final_pos < max_distance * 0.2f )
 
521
                {
 
522
                        if( direction == DIR_DOWN )
 
523
                        {
 
524
                                if( vely > 0 )
 
525
                                {
 
526
                                        // slow down
 
527
                                        if( vely > speed * 0.3f )
 
528
                                        {
 
529
                                                vely *= 1 - ( 0.05f * pFramerate->speedfactor );
 
530
 
 
531
                                                // reached lowest value
 
532
                                                if( vely <= speed * 0.3f )
 
533
                                                {
 
534
                                                        vely = speed * 0.3f;
 
535
                                                }
 
536
                                        }
 
537
                                }
 
538
                                else
 
539
                                {
 
540
                                        // set lowest value
 
541
                                        vely = speed * 0.3f;
 
542
                                }
 
543
                        }
 
544
                        else if( direction == DIR_UP )
 
545
                        {
 
546
                                if( vely < 0 )
 
547
                                {
 
548
                                        // slow down
 
549
                                        if( vely < -speed * 0.3f )
 
550
                                        {
 
551
                                                vely *= 1 - ( 0.05f * pFramerate->speedfactor );
 
552
 
 
553
                                                // reached lowest value
 
554
                                                if( vely >= -speed * 0.3f )
 
555
                                                {
 
556
                                                        vely = -speed * 0.3f;
 
557
                                                }
 
558
                                        }
 
559
                                }
 
560
                                else
 
561
                                {
 
562
                                        // set lowest value
 
563
                                        vely = -speed * 0.3f;
 
564
                                }
 
565
                        }
 
566
                        else if( direction == DIR_LEFT )
 
567
                        {
 
568
                                if( velx < 0 )
 
569
                                {
 
570
                                        // slow down
 
571
                                        if( velx < -speed * 0.3f )
 
572
                                        {
 
573
                                                velx *= 1 - ( 0.05f * pFramerate->speedfactor );
 
574
 
 
575
                                                // reached lowest value
 
576
                                                if( velx >= -speed * 0.3f )
 
577
                                                {
 
578
                                                        velx = -speed * 0.3f;
 
579
                                                }
 
580
                                        }
 
581
                                }
 
582
                                else
 
583
                                {
 
584
                                        // set lowest value
 
585
                                        velx = -speed * 0.3f;
 
586
                                }
 
587
                        }
 
588
                        else if( direction == DIR_RIGHT )
 
589
                        {
 
590
                                if( velx > 0 )
 
591
                                {
 
592
                                        // slow down
 
593
                                        if( velx > speed * 0.3f )
 
594
                                        {
 
595
                                                velx *= 1 - ( 0.05f * pFramerate->speedfactor );
 
596
 
 
597
                                                // reached lowest value
 
598
                                                if( velx <= speed * 0.3f )
 
599
                                                {
 
600
                                                        velx = speed * 0.3f;
 
601
                                                }
 
602
                                        }
 
603
                                }
 
604
                                else
 
605
                                {
 
606
                                        // set lowest value
 
607
                                        velx = speed * 0.3f;
 
608
                                }
 
609
                        }
 
610
                }
 
611
                // not near final position
 
612
                else
 
613
                {
 
614
                        Update_Velocity();
277
615
                }
278
616
        }
279
617
}
285
623
                return;
286
624
        }
287
625
 
288
 
        // todo : update & optimize
289
 
        float x = posx;
290
 
        float startx = startposx;
291
 
 
292
 
        // Start
293
 
        Set_Image( 0, 1, 0 );
294
 
        cImageObjectSprite::Draw( request );
295
 
        posx += Get_Image( 0 )->w;
296
 
        startposx += Get_Image( 0 )->w;
297
 
        Update_Position_Rect();
298
 
 
299
 
        // Middle
300
 
        Set_Image( 1, 1, 0 );
301
 
        for( unsigned int i = 0; i < middle_count; i++ )
302
 
        {
303
 
                cImageObjectSprite::Draw();
304
 
                posx += Get_Image( 1 )->w;
305
 
                startposx += Get_Image( 1 )->w;
306
 
                Update_Position_Rect();
307
 
        }
308
 
 
309
 
        // End
310
 
        Set_Image( 2, 1, 0 );
311
 
        cImageObjectSprite::Draw();
312
 
 
313
 
        posx = x;
314
 
        startposx = startx;
315
 
 
316
 
        Update_rect();
 
626
        cSurfaceRequest *surface_request;
 
627
        float x = 0;
 
628
 
 
629
        // top left
 
630
        if( images[0] )
 
631
        {
 
632
                // Start
 
633
                image = images[0];
 
634
                start_image = images[0];
 
635
                // create request
 
636
 
 
637
                surface_request = new cSurfaceRequest();
 
638
                // draw only first image complete
 
639
                cImageObjectSprite::Draw( surface_request );
 
640
                surface_request->pos_x += x;
 
641
                x += images[0]->w;
 
642
                // add request
 
643
                pRenderer->Add( surface_request );
 
644
        }
 
645
 
 
646
        // top middle
 
647
        if( images[1] )
 
648
        {
 
649
                // Middle
 
650
                image = images[1];
 
651
                start_image = images[1];
 
652
                for( unsigned int i = 0; i < middle_count; i++ )
 
653
                {
 
654
                        // create request
 
655
                        surface_request = new cSurfaceRequest();
 
656
                        cImageObjectSprite::Draw_Image( surface_request);
 
657
                        surface_request->pos_x += x;
 
658
                        x += images[1]->w;
 
659
                        // add request
 
660
                        pRenderer->Add( surface_request );
 
661
                }
 
662
        }
 
663
 
 
664
        // top right
 
665
        if( images[2] )
 
666
        {
 
667
                // End
 
668
                image = images[2];
 
669
                start_image = images[2];
 
670
                // create request
 
671
                surface_request = new cSurfaceRequest();
 
672
                cImageObjectSprite::Draw_Image( surface_request );
 
673
                surface_request->pos_x += x;
 
674
                //x += images[2]->w;
 
675
                // add request
 
676
                pRenderer->Add( surface_request );
 
677
        }
 
678
 
 
679
        Update_Rect();
317
680
        Update_Position_Rect();
318
681
 
319
682
        // draw distance rect
320
 
        if( editor_level_enabled )
 
683
        if( editor_level_enabled && speed )
321
684
        {
322
 
                if( direction == DIR_RIGHT || direction == DIR_LEFT )
323
 
            {
324
 
            pVideo->Draw_Rect( startposx - pCamera->x, startposy - pCamera->y, max_distance + col_rect.w, 15, posz - 0.000001f, &whitealpha128 );
325
 
            }
326
 
                else if( direction == DIR_DOWN || direction == DIR_UP )
327
 
            {
328
 
            pVideo->Draw_Rect( startposx - pCamera->x, startposy - pCamera->y, 15, max_distance + col_rect.h, posz - 0.000001f, &whitealpha128 );
329
 
            }
 
685
                if( start_direction == DIR_RIGHT || start_direction == DIR_LEFT )
 
686
                {
 
687
                        pVideo->Draw_Rect( startposx - pActive_Camera->x, startposy - pActive_Camera->y, max_distance + col_rect.w, 15, posz - 0.000001f, &whitealpha128 );
 
688
                }
 
689
                else if( start_direction == DIR_DOWN || start_direction == DIR_UP )
 
690
                {
 
691
                        pVideo->Draw_Rect( startposx - pActive_Camera->x, startposy - pActive_Camera->y, 15, max_distance + col_rect.h, posz - 0.000001f, &whitealpha128 );
 
692
                }
330
693
        }
331
694
}
332
695
 
333
 
void cMoving_Platform :: Update_rect( void )
 
696
void cMoving_Platform :: Update_Rect( void )
334
697
{
 
698
        // clear
335
699
        col_rect.w = 0;
336
700
        rect.w = 0;
 
701
 
 
702
        // get width
337
703
        if( images[0] )
338
704
        {
339
 
                col_rect.w += images[0]->col_w;
340
705
                rect.w += images[0]->w;
341
706
        }
342
707
        if( images[1] )
343
708
        {
344
 
                col_rect.w += images[1]->col_w * middle_count;
345
709
                rect.w += images[1]->w * middle_count;
346
710
        }
347
711
        if( images[2] )
348
712
        {
349
 
                col_rect.w += images[2]->col_w;
350
713
                rect.w += images[2]->w;
351
714
        }
352
715
 
 
716
        // set width
 
717
        col_rect.w = rect.w;
353
718
        start_rect.w = rect.w;
354
719
}
355
720
 
356
 
bool cMoving_Platform :: is_Update_valid( void )
357
 
{
 
721
void cMoving_Platform :: Update_Velocity( void )
 
722
{
 
723
        // set velocity
 
724
        if( speed > 0 && ( !touch_move_time || touch_counter > touch_move_time ) )
 
725
        {
 
726
                if( direction == DIR_UP )
 
727
                {
 
728
                        if( vely > -speed )
 
729
                        {
 
730
                                vely += -speed * 0.1f * pFramerate->speedfactor;
 
731
                        }
 
732
                }
 
733
                else if( direction == DIR_DOWN )
 
734
                {
 
735
                        if( vely < speed )
 
736
                        {
 
737
                                vely += speed * 0.1f * pFramerate->speedfactor;
 
738
                        }
 
739
                }
 
740
                else if( direction == DIR_LEFT )
 
741
                {
 
742
                        if( velx > -speed )
 
743
                        {
 
744
                                velx += -speed * 0.1f * pFramerate->speedfactor;
 
745
                        }
 
746
                }
 
747
                else if( direction == DIR_RIGHT )
 
748
                {
 
749
                        if( velx < speed )
 
750
                        {
 
751
                                velx += speed * 0.1f * pFramerate->speedfactor;
 
752
                        }
 
753
                }
 
754
        }
 
755
        else
 
756
        {
 
757
                // unset velocity
 
758
                Set_Velocity( 0, 0 );
 
759
        }
 
760
}
 
761
 
 
762
bool cMoving_Platform :: Is_Update_Valid( void )
 
763
{
 
764
        // if not visible
358
765
        if( !visible )
359
766
        {
360
767
                return 0;
370
777
                cMovingSprite *moving_sprite = static_cast<cMovingSprite *>(obj);
371
778
 
372
779
                // don't handle if not moving upwards or slower
373
 
                if( moving_sprite->is_onTop( this ) && direction == DIR_UP && moving_sprite->vely > vely )
 
780
                if( moving_sprite->Is_on_Top( this ) && direction == DIR_UP && moving_sprite->vely > vely )
374
781
                {
375
 
                        // halfmassive only if no ground but massive always picks you up
376
 
                        if( ( massivetype == MASS_HALFMASSIVE && !moving_sprite->ground_object ) ||
377
 
                                 ( massivetype == MASS_MASSIVE && moving_sprite->ground_object != this ) )
378
 
                        {
379
 
                                return 1;
 
782
                        // halfmassive
 
783
                        if( massivetype == MASS_HALFMASSIVE )
 
784
                        {
 
785
                                // only if no ground
 
786
                                if( !moving_sprite->ground_object )
 
787
                                {
 
788
                                        return 2;
 
789
                                }
 
790
                        }
 
791
                        // massive
 
792
                        else if( massivetype == MASS_MASSIVE )
 
793
                        {
 
794
                                // always pick up
 
795
                                if( moving_sprite->ground_object != this )
 
796
                                {
 
797
                                        moving_sprite->ground_object = this;
 
798
                                        return 0;
 
799
                                }
380
800
                        }
381
801
                }
382
802
 
384
804
        }
385
805
        if( obj->type == TYPE_BALL )
386
806
        {
387
 
                if( obj->is_onTop( this ) )
 
807
                if( obj->Is_on_Top( this ) )
388
808
                {
389
 
                        obj->Set_onTop( this, 0 );
 
809
                        obj->Set_on_Top( this, 0 );
390
810
 
391
811
                        return 1;
392
812
                }
404
824
                // send collision
405
825
                Send_Collision( collision );
406
826
        }
 
827
 
 
828
        if( collision->direction == DIR_TOP )
 
829
        {
 
830
                if( ( touch_time || touch_move_time ) && platform_state == PLATFORM_STAY )
 
831
                {
 
832
                        platform_state = PLATFORM_TOUCHED;
 
833
                }
 
834
 
 
835
        }
407
836
}
408
837
 
409
838
void cMoving_Platform :: Editor_Activate( void )
410
839
{
411
 
        WindowManager &wmgr = WindowManager::getSingleton();
 
840
        CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
412
841
 
413
842
        // max distance
414
 
        Editbox *editbox = static_cast<Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_max_distance" ));
 
843
        CEGUI::Editbox *editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_max_distance" ));
 
844
        Editor_Add( UTF8_("Distance"), UTF8_("Movable distance into its direction"), editbox, 120 );
415
845
 
416
 
        Editor_Add( editbox, 120 );
417
 
        editbox->setTooltipText( "Max Distance" );
418
846
        editbox->setText( int_to_string( max_distance ) );
419
 
        editbox->subscribeEvent( Editbox::EventTextChanged, Event::Subscriber( &cMoving_Platform::Editor_Max_Distance_Key, this ) );
 
847
        editbox->subscribeEvent( CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber( &cMoving_Platform::Editor_Max_Distance_Key, this ) );
420
848
 
421
849
        // speed
422
 
        editbox = static_cast<Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_speed" ));
423
 
        editbox->setTooltipText( "Speed" );
424
 
        Editor_Add( editbox, 120 );
 
850
        editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_speed" ));
 
851
        Editor_Add( UTF8_("Speed"), UTF8_("Maximum speed"), editbox, 120 );
425
852
 
426
853
        editbox->setText( float_to_string( speed ) );
427
 
        editbox->subscribeEvent( Editbox::EventTextChanged, Event::Subscriber( &cMoving_Platform::Editor_Speed_Key, this ) );
 
854
        editbox->subscribeEvent( CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber( &cMoving_Platform::Editor_Speed_Key, this ) );
 
855
 
 
856
        // touch time
 
857
        editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_touch_time" ));
 
858
        Editor_Add( UTF8_("Touch time"), UTF8_("Time when touched until shaking starts"), editbox, 120 );
 
859
 
 
860
        editbox->setText( float_to_string( touch_time ) );
 
861
        editbox->subscribeEvent( CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber( &cMoving_Platform::Editor_Touch_Time_Key, this ) );
 
862
 
 
863
        // shake time
 
864
        editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_shake_time" ));
 
865
        Editor_Add( UTF8_("Shake time"), UTF8_("Time it's shaking until falling"), editbox, 120 );
 
866
 
 
867
        editbox->setText( float_to_string( shake_time ) );
 
868
        editbox->subscribeEvent( CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber( &cMoving_Platform::Editor_Shake_Time_Key, this ) );
 
869
 
 
870
        // touch move time
 
871
        editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_move_time" ));
 
872
        Editor_Add( UTF8_("Touch move time"), UTF8_("If set does not move until this time has elapsed after touched"), editbox, 120 );
 
873
 
 
874
        editbox->setText( float_to_string( touch_move_time ) );
 
875
        editbox->subscribeEvent( CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber( &cMoving_Platform::Editor_Touch_Move_Time_Key, this ) );
428
876
 
429
877
        // horizontal middle image count
430
 
        editbox = static_cast<Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_hor_middle_count" ));
431
 
        editbox->setTooltipText( "Horizontal Middle Image Count" );
432
 
        Editor_Add( editbox, 120 );
 
878
        editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_hor_middle_count" ));
 
879
        Editor_Add( UTF8_("Hor image count"), UTF8_("Horizontal middle image count"), editbox, 120 );
433
880
 
434
881
        editbox->setText( int_to_string( middle_count ) );
435
 
        editbox->subscribeEvent( Editbox::EventTextChanged, Event::Subscriber( &cMoving_Platform::Editor_Hor_Middle_Count_Key, this ) );
 
882
        editbox->subscribeEvent( CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber( &cMoving_Platform::Editor_Hor_Middle_Count_Key, this ) );
436
883
 
437
884
        // image top left
438
 
        editbox = static_cast<Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_image_top_left" ));
439
 
        editbox->setTooltipText( "Image Top Left" );
440
 
        Editor_Add( editbox, 200 );
 
885
        editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_image_top_left" ));
 
886
        Editor_Add( UTF8_("Image top left"), UTF8_("Image top left"), editbox, 200 );
441
887
 
442
 
        editbox->setText( images[0]->Get_filename( 1 ) );
443
 
        editbox->subscribeEvent( Editbox::EventTextChanged, Event::Subscriber( &cMoving_Platform::Editor_Image_Top_Left_Key, this ) );
 
888
        editbox->setText( images[0]->Get_Filename( 1 ) );
 
889
        editbox->subscribeEvent( CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber( &cMoving_Platform::Editor_Image_Top_Left_Key, this ) );
444
890
 
445
891
        // image top middle
446
 
        editbox = static_cast<Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_image_top_middle" ));
447
 
        editbox->setTooltipText( "Image Top Middle" );
448
 
        Editor_Add( editbox, 200 );
 
892
        editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_image_top_middle" ));
 
893
        Editor_Add( UTF8_("Image top middle"), UTF8_("Image top middle"), editbox, 200 );
449
894
 
450
 
        editbox->setText( images[1]->Get_filename( 1 ) );
451
 
        editbox->subscribeEvent( Editbox::EventTextChanged, Event::Subscriber( &cMoving_Platform::Editor_Image_Top_Middle_Key, this ) );
 
895
        editbox->setText( images[1]->Get_Filename( 1 ) );
 
896
        editbox->subscribeEvent( CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber( &cMoving_Platform::Editor_Image_Top_Middle_Key, this ) );
452
897
 
453
898
        // image top right
454
 
        editbox = static_cast<Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_image_top_right" ));
455
 
        editbox->setTooltipText( "Image Top Right" );
456
 
        Editor_Add( editbox, 200 );
457
 
 
458
 
        editbox->setText( images[2]->Get_filename( 1 ) );
459
 
        editbox->subscribeEvent( Editbox::EventTextChanged, Event::Subscriber( &cMoving_Platform::Editor_Image_Top_Right_Key, this ) );
460
 
 
461
 
 
462
 
        // set position
463
 
        Editor_pos_update();
 
899
        editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "editor_moving_platform_image_top_right" ));
 
900
        Editor_Add( UTF8_("Image top right"), UTF8_("Image top right"), editbox, 200 );
 
901
 
 
902
        editbox->setText( images[2]->Get_Filename( 1 ) );
 
903
        editbox->subscribeEvent( CEGUI::Editbox::EventTextChanged, CEGUI::Event::Subscriber( &cMoving_Platform::Editor_Image_Top_Right_Key, this ) );
 
904
 
 
905
        // init
 
906
        Editor_Init();
464
907
}
465
908
 
466
 
bool cMoving_Platform :: Editor_Max_Distance_Key( const EventArgs &event )
 
909
bool cMoving_Platform :: Editor_Max_Distance_Key( const CEGUI::EventArgs &event )
467
910
{
468
 
        const WindowEventArgs &windowEventArgs = static_cast<const WindowEventArgs&>( event );
469
 
        string str_text = static_cast<Editbox *>( windowEventArgs.window )->getText().c_str();
 
911
        const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
 
912
        string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();
470
913
 
471
914
        Set_Max_Distance( string_to_int( str_text ) );
472
915
 
473
916
        return 1;
474
917
}
475
918
 
476
 
bool cMoving_Platform :: Editor_Speed_Key( const EventArgs &event )
 
919
bool cMoving_Platform :: Editor_Speed_Key( const CEGUI::EventArgs &event )
477
920
{
478
 
        const WindowEventArgs &windowEventArgs = static_cast<const WindowEventArgs&>( event );
479
 
        string str_text = static_cast<Editbox *>( windowEventArgs.window )->getText().c_str();
 
921
        const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
 
922
        string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();
480
923
 
481
924
        Set_Speed( string_to_float( str_text ) );
482
925
 
483
926
        return 1;
484
927
}
485
928
 
486
 
bool cMoving_Platform :: Editor_Hor_Middle_Count_Key( const EventArgs &event )
487
 
{
488
 
        const WindowEventArgs &windowEventArgs = static_cast<const WindowEventArgs&>( event );
489
 
        string str_text = static_cast<Editbox *>( windowEventArgs.window )->getText().c_str();
 
929
bool cMoving_Platform :: Editor_Touch_Time_Key( const CEGUI::EventArgs &event )
 
930
{
 
931
        const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
 
932
        string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();
 
933
 
 
934
        Set_Touch_Time( string_to_float( str_text ) );
 
935
 
 
936
        return 1;
 
937
}
 
938
 
 
939
bool cMoving_Platform :: Editor_Shake_Time_Key( const CEGUI::EventArgs &event )
 
940
{
 
941
        const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
 
942
        string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();
 
943
 
 
944
        Set_Shake_Time( string_to_float( str_text ) );
 
945
 
 
946
        return 1;
 
947
}
 
948
 
 
949
bool cMoving_Platform :: Editor_Touch_Move_Time_Key( const CEGUI::EventArgs &event )
 
950
{
 
951
        const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
 
952
        string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();
 
953
 
 
954
        Set_Touch_Move_Time( string_to_float( str_text ) );
 
955
 
 
956
        return 1;
 
957
}
 
958
 
 
959
bool cMoving_Platform :: Editor_Hor_Middle_Count_Key( const CEGUI::EventArgs &event )
 
960
{
 
961
        const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
 
962
        string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();
490
963
 
491
964
        Set_Middle_Count( string_to_int( str_text ) );
492
965
 
493
966
        return 1;
494
967
}
495
968
 
496
 
bool cMoving_Platform :: Editor_Image_Top_Left_Key( const EventArgs &event )
497
 
{
498
 
        const WindowEventArgs &windowEventArgs = static_cast<const WindowEventArgs&>( event );
499
 
        string str_text = static_cast<Editbox *>( windowEventArgs.window )->getText().c_str();
500
 
 
501
 
        Set_image_top_left( pVideo->Get_Surface( str_text ) );
502
 
 
503
 
        return 1;
504
 
}
505
 
 
506
 
bool cMoving_Platform :: Editor_Image_Top_Middle_Key( const EventArgs &event )
507
 
{
508
 
        const WindowEventArgs &windowEventArgs = static_cast<const WindowEventArgs&>( event );
509
 
        string str_text = static_cast<Editbox *>( windowEventArgs.window )->getText().c_str();
510
 
 
511
 
        Set_image_top_middle( pVideo->Get_Surface( str_text ) );
512
 
 
513
 
        return 1;
514
 
}
515
 
 
516
 
bool cMoving_Platform :: Editor_Image_Top_Right_Key( const EventArgs &event )
517
 
{
518
 
        const WindowEventArgs &windowEventArgs = static_cast<const WindowEventArgs&>( event );
519
 
        string str_text = static_cast<Editbox *>( windowEventArgs.window )->getText().c_str();
520
 
 
521
 
        Set_image_top_right( pVideo->Get_Surface( str_text ) );
 
969
bool cMoving_Platform :: Editor_Image_Top_Left_Key( const CEGUI::EventArgs &event )
 
970
{
 
971
        const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
 
972
        string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();
 
973
 
 
974
        Set_Image_Top_Left( pVideo->Get_Surface( str_text ) );
 
975
 
 
976
        return 1;
 
977
}
 
978
 
 
979
bool cMoving_Platform :: Editor_Image_Top_Middle_Key( const CEGUI::EventArgs &event )
 
980
{
 
981
        const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
 
982
        string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();
 
983
 
 
984
        Set_Image_Top_Middle( pVideo->Get_Surface( str_text ) );
 
985
 
 
986
        return 1;
 
987
}
 
988
 
 
989
bool cMoving_Platform :: Editor_Image_Top_Right_Key( const CEGUI::EventArgs &event )
 
990
{
 
991
        const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
 
992
        string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();
 
993
 
 
994
        Set_Image_Top_Right( pVideo->Get_Surface( str_text ) );
522
995
 
523
996
        return 1;
524
997
}
525
998
 
526
999
void cMoving_Platform :: Create_Name( void )
527
1000
{
528
 
        name = "Moving Platform - " + Get_Direction_name( start_direction ) + " - " + Get_Massivetype_name( massivetype );
 
1001
        name.clear();
 
1002
 
 
1003
        if( touch_time )
 
1004
        {
 
1005
                name = _("Falling ");
 
1006
        }
 
1007
        if( touch_move_time )
 
1008
        {
 
1009
                name += _("Delayed ");
 
1010
        }
 
1011
        if( speed )
 
1012
        {
 
1013
                name += _("Moving ");
 
1014
        }
 
1015
 
 
1016
        name += _("Platform - ") + Get_Direction_Name( start_direction ) + " - " + Get_Massive_Type_Name( massivetype );
529
1017
}