Changed back the sliding fix because it was buggy
[supertux.git] / src / player.cpp
1 //  $Id$
2 //
3 //  SuperTux -  A Jump'n Run
4 //  Copyright (C) 2003 Tobias Glaesser <tobi.web@gmx.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20 #include <math.h>
21 #include <iostream>
22 #include <cassert>
23 #include "gameloop.h"
24 #include "globals.h"
25 #include "player.h"
26 #include "defines.h"
27 #include "scene.h"
28 #include "tile.h"
29 #include "sprite.h"
30 #include "screen.h"
31
32 #define AUTOSCROLL_DEAD_INTERVAL 300
33
34 Surface* tux_life;
35
36 Sprite* smalltux_gameover;
37 Sprite* smalltux_star;
38 Sprite* largetux_star;
39
40 PlayerSprite smalltux;
41 PlayerSprite largetux;
42 PlayerSprite icetux;
43 PlayerSprite firetux;
44
45 PlayerKeymap keymap;
46
47 PlayerKeymap::PlayerKeymap()
48 {
49   keymap.jump  = SDLK_UP;
50   keymap.duck  = SDLK_DOWN;
51   keymap.left  = SDLK_LEFT;
52   keymap.right = SDLK_RIGHT;
53   keymap.fire  = SDLK_LCTRL;
54 }
55
56 void player_input_init(player_input_type* pplayer_input)
57 {
58   pplayer_input->down = UP;
59   pplayer_input->fire = UP;
60   pplayer_input->left = UP;
61   pplayer_input->old_fire = UP;
62   pplayer_input->right = UP;
63   pplayer_input->up = UP;
64   pplayer_input->old_up = UP;
65 }
66
67 void
68 Player::init()
69 {
70   Level* plevel = World::current()->get_level();
71
72   holding_something = false;
73
74   base.width = 32;
75   base.height = 32;
76
77   size = SMALL;
78   got_power = NONE_POWER;
79
80   base.x = plevel->start_pos_x;
81   base.y = plevel->start_pos_y;
82   base.xm = 0;
83   base.ym = 0;
84   previous_base = old_base = base;
85   dir = RIGHT;
86   old_dir = dir;
87   duck = false;
88
89   dying   = DYING_NOT;
90   jumping = false;
91   can_jump = true;
92   butt_jump = false;
93
94   frame_main = 0;
95   frame_ = 0;
96   
97   player_input_init(&input);
98
99   invincible_timer.init(true);
100   skidding_timer.init(true);
101   safe_timer.init(true);
102   frame_timer.init(true);
103   kick_timer.init(true);
104
105   physic.reset();
106 }
107
108 int
109 Player::key_event(SDLKey key, int state)
110 {
111   if(key == keymap.right)
112     {
113       input.right = state;
114       return true;
115     }
116   else if(key == keymap.left)
117     {
118       input.left = state;
119       return true;
120     }
121   else if(key == keymap.jump)
122     {
123       input.up = state;
124       return true;
125     }
126   else if(key == keymap.duck)
127     {
128       input.down = state;
129       return true;
130     }
131   else if(key == keymap.fire)
132     {
133       if (state == UP)
134         input.old_fire = UP;
135       input.fire = state;
136       return true;
137     }
138   else
139     return false;
140 }
141
142 void
143 Player::level_begin()
144 {
145   base.x  = 100;
146   base.y  = 170;
147   base.xm = 0;
148   base.ym = 0;
149   previous_base = old_base = base;
150   duck = false;
151
152   dying = DYING_NOT;
153
154   player_input_init(&input);
155
156   invincible_timer.init(true);
157   skidding_timer.init(true);
158   safe_timer.init(true);
159   frame_timer.init(true);
160
161   physic.reset();
162 }
163
164 void
165 Player::action(double frame_ratio)
166 {
167   bool jumped_in_solid = false;
168
169   if (input.fire == UP)
170     holding_something = false;
171
172   /* Move tux: */
173   previous_base = base;
174
175   /* --- HANDLE TUX! --- */
176   if(dying == DYING_NOT)
177     handle_input();
178
179   physic.apply(frame_ratio, base.x, base.y);
180
181   if(dying == DYING_NOT) 
182     {
183       base_type target = base;
184
185       collision_swept_object_map(&old_base, &base);
186
187       if (!invincible_timer.started()
188           && (isspike(base.x, base.y) || isspike(base.x + base.width, base.y)
189           ||  isspike(base.x, base.y + base.height)
190           ||  isspike(base.x + base.width, base.y + base.height)))
191       {
192          kill(SHRINK);
193       }
194
195       // Don't accelerate Tux if he is running against a wall
196       if (target.x != base.x)
197         {
198           physic.set_velocity_x(0);
199         }
200
201       // special exception for cases where we're stuck under tiles after
202       // being ducked. In this case we drift out
203       if(!duck && on_ground() && old_base.x == base.x && old_base.y == base.y
204          && collision_object_map(base))
205         {
206           base.x += frame_ratio * WALK_SPEED * (dir ? 1: -1);
207           previous_base = old_base = base;
208         }
209
210       // Land:
211       if (!on_ground())
212         {
213           physic.enable_gravity(true);
214           if(under_solid())
215             {
216               // fall down
217               physic.set_velocity_y(0);
218               jumped_in_solid = true;
219             }
220         }
221       else
222         {
223           /* Land: */
224           if (physic.get_velocity_y() < 0)
225             {
226               base.y = (int)(((int)base.y / 32) * 32);
227               physic.set_velocity_y(0);
228             }
229
230           physic.enable_gravity(false);
231           /* Reset score multiplier (for multi-hits): */
232           if (!invincible_timer.started())
233             player_status.score_multiplier = 1;
234         }
235
236       if(jumped_in_solid)
237         {
238           if (isbrick(base.x, base.y) ||
239               isfullbox(base.x, base.y))
240             {
241               World::current()->trygrabdistro(base.x, base.y - 32,BOUNCE);
242               World::current()->trybumpbadguy(base.x, base.y - 64);
243
244               World::current()->trybreakbrick(base.x, base.y, size == SMALL);
245
246               bumpbrick(base.x, base.y);
247               World::current()->tryemptybox(base.x, base.y, RIGHT);
248             }
249
250           if (isbrick(base.x+ 31, base.y) ||
251               isfullbox(base.x+ 31, base.y))
252             {
253               World::current()->trygrabdistro(base.x+ 31, base.y - 32,BOUNCE);
254               World::current()->trybumpbadguy(base.x+ 31, base.y - 64);
255
256               if(size == BIG)
257                 World::current()->trybreakbrick(base.x+ 31, base.y, size == SMALL);
258
259               bumpbrick(base.x+ 31, base.y);
260               World::current()->tryemptybox(base.x+ 31, base.y, LEFT);
261             }
262         }
263
264       grabdistros();
265
266       if (jumped_in_solid)
267         {
268           ++base.y;
269           ++old_base.y;
270           if(on_ground())
271             {
272               /* Make sure jumping is off. */
273               jumping = false;
274             }
275         }
276     }
277
278   /* ---- DONE HANDLING TUX! --- */
279
280   // check some timers
281   skidding_timer.check();
282   invincible_timer.check();
283   safe_timer.check();
284   kick_timer.check();
285 }
286
287 bool
288 Player::on_ground()
289 {
290   return ( issolid(base.x + base.width / 2, base.y + base.height) ||
291            issolid(base.x + 1, base.y + base.height) ||
292            issolid(base.x + base.width - 1, base.y + base.height)  );
293 }
294
295 bool
296 Player::under_solid()
297 {
298   return ( issolid(base.x + base.width / 2, base.y) ||
299            issolid(base.x + 1, base.y) ||
300            issolid(base.x + base.width - 1, base.y)  );
301 }
302
303 void
304 Player::handle_horizontal_input()
305 {
306   float vx = physic.get_velocity_x();
307   float vy = physic.get_velocity_y();
308   float ax = physic.get_acceleration_x();
309   float ay = physic.get_acceleration_y();
310
311   float dirsign = 0;
312   if(input.left == DOWN && input.right == UP && (!duck || physic.get_velocity_y() != 0)) {
313       old_dir = dir;
314       dir = LEFT;
315       dirsign = -1;
316   } else if(input.left == UP && input.right == DOWN && (!duck || physic.get_velocity_y() != 0)) {
317       old_dir = dir;
318       dir = RIGHT;
319       dirsign = 1;
320   }
321
322   if (input.fire == UP) {
323       ax = dirsign * WALK_ACCELERATION_X;
324       // limit speed
325       if(vx >= MAX_WALK_XM && dirsign > 0) {
326         vx = MAX_WALK_XM;
327         ax = 0;
328       } else if(vx <= -MAX_WALK_XM && dirsign < 0) {
329         vx = -MAX_WALK_XM;
330         ax = 0;
331       }
332   } else {
333       ax = dirsign * RUN_ACCELERATION_X;
334       // limit speed
335       if(vx >= MAX_RUN_XM && dirsign > 0) {
336         vx = MAX_RUN_XM;
337         ax = 0;
338       } else if(vx <= -MAX_RUN_XM && dirsign < 0) {
339         vx = -MAX_RUN_XM;
340         ax = 0;
341       }
342   }
343
344   // we can reach WALK_SPEED without any acceleration
345   if(dirsign != 0 && fabs(vx) < WALK_SPEED) {
346     vx = dirsign * WALK_SPEED;
347   }
348
349   // changing directions?
350   if(on_ground() && ((vx < 0 && dirsign >0) || (vx>0 && dirsign<0))) {
351       if(fabs(vx)>SKID_XM && !skidding_timer.check()) {
352           skidding_timer.start(SKID_TIME);
353           play_sound(sounds[SND_SKID], SOUND_CENTER_SPEAKER);
354           ax *= 2.5;
355       } else {
356           ax *= 2;
357       }
358   }
359
360   // we get slower when not pressing any keys
361   if(dirsign == 0) {
362       if(fabs(vx) < WALK_SPEED) {
363           vx = 0;
364           ax = 0;
365       } else if(vx < 0) {
366           ax = WALK_ACCELERATION_X * 1.5;
367       } else {
368           ax = WALK_ACCELERATION_X * -1.5;
369       }
370   }
371
372   // if we're on ice slow down acceleration or deceleration
373   if (isice(base.x, base.y + base.height))
374   {
375     /* the acceleration/deceleration rate on ice is inversely proportional to
376      * the current velocity.
377      */
378
379     // increasing 1 will increase acceleration/deceleration rate
380     // decreasing 1 will decrease acceleration/deceleration rate
381     //  must stay above zero, though
382     if (ax != 0) ax *= 1 / fabs(vx);
383   }
384
385   physic.set_velocity(vx, vy);
386   physic.set_acceleration(ax, ay);
387 }
388
389 void
390 Player::handle_vertical_input()
391 {
392   // Press jump key
393   if(input.up == DOWN && can_jump && on_ground())
394     {
395       if(duck) { // only jump a little bit when in duck mode {
396         physic.set_velocity_y(3);
397       } else {
398         // jump higher if we are running
399         if (fabs(physic.get_velocity_x()) > MAX_WALK_XM)
400           physic.set_velocity_y(5.8);
401         else
402           physic.set_velocity_y(5.2);
403       }
404
405       --base.y;
406       jumping = true;
407       can_jump = false;
408       if (size == SMALL)
409         play_sound(sounds[SND_JUMP], SOUND_CENTER_SPEAKER);
410       else
411         play_sound(sounds[SND_BIGJUMP], SOUND_CENTER_SPEAKER);
412     }
413   // Let go of jump key
414   else if(input.up == UP && jumping && physic.get_velocity_y() > 0)
415     {
416       jumping = false;
417       physic.set_velocity_y(0);
418     }
419
420   if (input.down == DOWN && !on_ground() && !duck && size == BIG)
421     butt_jump = true;
422   else if (input.down == UP)
423     butt_jump = false;
424   if (input.down == DOWN && butt_jump && on_ground())
425   {
426     if(World::current()->trybreakbrick(base.x, base.y + base.height, false)
427       || World::current()->trybreakbrick(
428           base.x + base.width, base.y + base.height, false)) {
429         // make tux jumping a little bit again after breaking the bricks
430         physic.set_velocity_y(2);
431     }
432     butt_jump = false;
433   }
434
435   if ( (issolid(base.x + base.width / 2, base.y + base.height + 64) ||
436         issolid(base.x + 1, base.y + base.height + 64) ||
437         issolid(base.x + base.width - 1, base.y + base.height + 64))
438        && jumping  == false
439        && can_jump == false
440        && input.up == DOWN
441        && input.old_up == UP)
442     {
443       can_jump = true;
444     }
445
446   input.old_up = input.up;
447 }
448
449 void
450 Player::handle_input()
451 {
452   /* Handle horizontal movement: */
453     handle_horizontal_input();
454
455   /* Jump/jumping? */
456
457   if (on_ground() && input.up == UP)
458     can_jump = true;
459   handle_vertical_input();
460
461   /* Shoot! */
462   if (input.fire == DOWN && input.old_fire == UP && got_power != NONE_POWER)
463     {
464       World::current()->add_bullet(base.x, base.y, physic.get_velocity_x(), dir);
465       input.old_fire = DOWN;
466     }
467
468   /* tux animations: */
469   if(!frame_timer.check())
470     {
471       frame_timer.start(25);
472       if (input.right == UP && input.left == UP)
473         {
474           frame_main = 1;
475           frame_ = 1;
476         }
477       else
478         {
479           if ((input.fire == DOWN && (global_frame_counter % 2) == 0) ||
480               (global_frame_counter % 4) == 0)
481             frame_main = (frame_main + 1) % 4;
482
483           frame_ = frame_main;
484
485           if (frame_ == 3)
486             frame_ = 1;
487         }
488     }
489
490   /* Duck! */
491   if (input.down == DOWN && size == BIG && !duck && physic.get_velocity_y() == 0 && on_ground())
492     {
493       duck = true;
494       base.height = 32;                             
495       base.y += 32;
496       // changing base size confuses collision otherwise
497       old_base = previous_base = base;
498     }
499   else if(input.down == UP && size == BIG && duck)
500     {
501       // try if we can really unduck
502       base.y -= 32;
503       base.height = 64;
504       // when unducking in air we need some space to do so
505       if(on_ground() || !collision_object_map(base)) {
506         duck = false;
507         // changing base size confuses collision otherwise
508         old_base = previous_base = base;                                
509       } else {
510         // undo the ducking changes
511         base.y += 32;
512         base.height = 32;
513       }   
514     }
515 }
516
517 void
518 Player::grow()
519 {
520   if(size == BIG)
521     return;
522   
523   size = BIG;
524   base.height = 64;
525   base.y -= 32;
526
527   old_base = previous_base = base;
528 }
529
530 void
531 Player::grabdistros()
532 {
533   /* Grab distros: */
534   if (!dying)
535     {
536       World::current()->trygrabdistro(base.x, base.y, NO_BOUNCE);
537       World::current()->trygrabdistro(base.x+ 31, base.y, NO_BOUNCE);
538
539       World::current()->trygrabdistro(base.x, base.y + base.height, NO_BOUNCE);
540       World::current()->trygrabdistro(base.x+ 31, base.y + base.height, NO_BOUNCE);
541
542       if(size == BIG)
543         {
544           World::current()->trygrabdistro(base.x, base.y + base.height / 2, NO_BOUNCE);
545           World::current()->trygrabdistro(base.x+ 31, base.y + base.height / 2, NO_BOUNCE);
546         }
547
548     }
549
550   /* Enough distros for a One-up? */
551   if (player_status.distros >= DISTROS_LIFEUP)
552     {
553       player_status.distros = player_status.distros - DISTROS_LIFEUP;
554       if(player_status.lives < MAX_LIVES)
555         ++player_status.lives;
556       /*We want to hear the sound even, if MAX_LIVES is reached*/
557       play_sound(sounds[SND_LIFEUP], SOUND_CENTER_SPEAKER);
558     }
559 }
560
561 void
562 Player::draw()
563 {
564   if (!safe_timer.started() || (global_frame_counter % 2) == 0)
565     {
566       if (dying == DYING_SQUISHED)
567         {
568           smalltux_gameover->draw(base.x, base.y);
569         }
570       else
571         {
572           PlayerSprite* sprite;
573           
574           if (size == SMALL)
575             sprite = &smalltux;
576           else if (got_power == FIRE_POWER)
577             sprite = &firetux;
578           else if (got_power == ICE_POWER)
579             sprite = &icetux;
580           else
581             sprite = &largetux;
582           
583           if (duck && size != SMALL)
584             {
585               if (dir == RIGHT)
586                 sprite->duck_right->draw(base.x, base.y);
587               else 
588                 sprite->duck_left->draw(base.x, base.y);
589             }
590           else if (skidding_timer.started())
591             {
592               if (dir == RIGHT)
593                 sprite->skid_right->draw(base.x, base.y);
594               else
595                 sprite->skid_left->draw(base.x, base.y); 
596             }
597           else if (kick_timer.started())
598             {
599               if (dir == RIGHT)
600                 sprite->kick_right->draw(base.x, base.y);
601               else
602                 sprite->kick_left->draw(base.x, base.y); 
603             }
604           else if (physic.get_velocity_y() != 0)
605             {
606               if (dir == RIGHT)
607                 sprite->jump_right->draw(base.x, base.y);
608               else
609                 sprite->jump_left->draw(base.x, base.y);                   
610             }
611           else
612             {
613               if (fabsf(physic.get_velocity_x()) < 1.0f) // standing
614                 {
615                   if (dir == RIGHT)
616                     sprite->stand_right->draw( base.x, base.y);
617                   else
618                     sprite->stand_left->draw( base.x, base.y);
619                 }
620               else // moving
621                 {
622                   if (dir == RIGHT)
623                     sprite->walk_right->draw(base.x, base.y);
624                   else
625                     sprite->walk_left->draw(base.x, base.y);
626                 }
627             }
628                       
629           // Draw arm overlay graphics when Tux is holding something
630           if (holding_something && physic.get_velocity_y() == 0)
631             {
632               if (dir == RIGHT)
633                 sprite->grab_right->draw(base.x, base.y);
634               else
635                 sprite->grab_left->draw(base.x, base.y);
636             }
637
638           // Draw blinking star overlay
639           if (invincible_timer.started() &&
640              (invincible_timer.get_left() > TUX_INVINCIBLE_TIME_WARNING || global_frame_counter % 3))
641             {
642               if (size == SMALL || duck)
643                 smalltux_star->draw(base.x, base.y);
644               else
645                 largetux_star->draw(base.x, base.y);
646             }
647         }
648     }     
649   
650   if (debug_mode)
651     fillrect(base.x - scroll_x, base.y - scroll_y, 
652              base.width, base.height, 75,75,75, 150);
653 }
654
655 void
656 Player::collision(void* p_c_object, int c_object)
657 {
658   BadGuy* pbad_c = NULL;
659   Trampoline* ptramp_c = NULL;
660
661   switch (c_object)
662     {
663     case CO_BADGUY:
664       pbad_c = (BadGuy*) p_c_object;
665
666      /* Hurt player if he touches a badguy */
667       if (!pbad_c->dying && !dying &&
668           !safe_timer.started() &&
669           pbad_c->mode != BadGuy::HELD)
670         {
671           if (pbad_c->mode == BadGuy::FLAT && input.fire == DOWN
672                && !holding_something)
673             {
674               holding_something = true;
675               pbad_c->mode = BadGuy::HELD;
676               pbad_c->base.y-=8;
677             }
678           else if (pbad_c->mode == BadGuy::FLAT)
679             {
680               // Don't get hurt if we're kicking a flat badguy!
681             }
682           else if (pbad_c->mode == BadGuy::KICK)
683             {
684               /* Hurt if you get hit by kicked laptop: */
685               if (!invincible_timer.started())
686                 {
687                   kill(SHRINK);
688                 }
689               else
690                 pbad_c->kill_me(20);
691             }
692           else if (pbad_c->frozen_timer.check() && (pbad_c->kind == BAD_MRBOMB
693               || pbad_c->kind == BAD_JUMPY || pbad_c->kind == BAD_FISH
694               || pbad_c->kind == BAD_SPIKY))
695                 pbad_c->kill_me(20);
696           else
697             {
698               if (!invincible_timer.started())
699                 {
700                   kill(SHRINK);
701                 }
702               else
703                 {
704                   pbad_c->kill_me(25);
705                 }
706             }
707           player_status.score_multiplier++;
708         }
709       break;
710
711     case CO_TRAMPOLINE:
712       ptramp_c = (Trampoline*) p_c_object;
713       
714       // Pick up trampoline
715       if (ptramp_c->mode != Trampoline::M_HELD && input.fire == DOWN && !holding_something && on_ground())
716       {
717         holding_something = true;
718         ptramp_c->mode = Trampoline::M_HELD;
719         ptramp_c->base.y -= 8;
720       }
721       // Set down trampoline
722       else if (ptramp_c->mode == Trampoline::M_HELD && input.fire != DOWN)
723       {
724         holding_something = false;
725         ptramp_c->mode = Trampoline::M_NORMAL;
726         ptramp_c->base.y += 8;
727         ptramp_c->physic.set_velocity(physic.get_velocity_x(), physic.get_velocity_y());
728
729         //if (dir == RIGHT)
730         //  ptramp_c->base.x = base.x + base.width+1;
731         //else /* LEFT */
732         //  ptramp_c->base.x = base.x - base.width-1;
733       }
734 /*
735       // Don't let tux walk through trampoline
736       else if (ptramp_c->mode != Trampoline::M_HELD && on_ground())
737       {
738         if (physic.get_velocity_x() > 0) // RIGHT
739         {
740           physic.set_velocity_x(0);
741           base.x = ptramp_c->base.x - base.width;
742         }
743         else if (physic.get_velocity_x() < 0) // LEFT
744         {
745           physic.set_velocity_x(0);
746           base.x = ptramp_c->base.x + ptramp_c->base.width;
747         }
748       }
749 */
750
751       break;
752
753     default:
754       break;
755     }
756
757 }
758
759 /* Kill Player! */
760
761 void
762 Player::kill(HurtMode mode)
763 {
764   play_sound(sounds[SND_HURT], SOUND_CENTER_SPEAKER);
765
766   physic.set_velocity_x(0);
767
768   if (mode == SHRINK && size == BIG)
769     {
770       if (got_power != NONE_POWER)
771         {
772           got_power = NONE_POWER;
773         }
774       else
775         {
776           size = SMALL;
777           base.height = 32;
778           duck = false;
779         }
780       safe_timer.start(TUX_SAFE_TIME);
781     }
782   else
783     {
784       physic.enable_gravity(true);
785       physic.set_acceleration(0, 0);
786       physic.set_velocity(0, 7);
787       if(dying != DYING_SQUISHED)
788       --player_status.lives;
789       dying = DYING_SQUISHED;
790     }
791 }
792
793 void
794 Player::is_dying()
795 {
796   remove_powerups();
797   dying = DYING_NOT;
798 }
799
800 bool Player::is_dead()
801 {
802   if(base.y > screen->h + scroll_y || base.y > World::current()->get_level()->height*32 ||
803       base.x < scroll_x - AUTOSCROLL_DEAD_INTERVAL)  // can happen in auto-scrolling
804     return true;
805   else
806     return false;
807 }
808
809 /* Remove Tux's power ups */
810 void
811 Player::remove_powerups()
812 {
813   got_power = NONE_POWER;
814   size = SMALL;
815   base.height = 32;
816 }
817
818 void
819 Player::check_bounds(bool back_scrolling, bool hor_autoscroll)
820 {
821   /* Keep tux in bounds: */
822   if (base.x < 0)
823     { // Lock Tux to the size of the level, so that he doesn't fall of
824       // on the left side
825       base.x = 0;
826     }
827
828   /* Keep in-bounds, vertically: */
829   if (base.y > World::current()->get_level()->height * /*TILE_HEIGHT*/ 32)
830     {
831       kill(KILL);
832     }
833
834   if(base.x < scroll_x && (!back_scrolling || hor_autoscroll))  // can happen if back scrolling is disabled
835     base.x = scroll_x;
836
837   if(hor_autoscroll)
838     {
839     if(base.x == scroll_x)
840       if(issolid(base.x+32, base.y) || (size != SMALL && issolid(base.x+32, base.y+32)))
841         kill(KILL);
842
843     if(base.x + base.width > scroll_x + screen->w)
844       base.x = scroll_x + screen->w - base.width;
845     }
846     
847 }
848
849 // EOF //
850