source: abuse/trunk/src/morpher.cpp @ 494

Last change on this file since 494 was 494, checked in by Sam Hocevar, 11 years ago

style: remove trailing spaces, fix copyright statements.

File size: 2.2 KB
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
5 *
6 *  This software was released into the Public Domain. As with most public
7 *  domain software, no warranty is made or implied by Crack dot Com or
8 *  Jonathan Clark.
9 */
10
11#include "config.h"
12
13#include "morpher.h"
14#include "game.h"
15#include "objects.h"
16#include "view.h"
17
18void morph_char::draw(game_object *who, view *v)
19{
20  if (fleft)
21  {
22    int32_t rx,ry;
23    the_game->game_to_mouse(who->x-(cx>>16),who->y-(cy>>16),v,rx,ry);
24    mor->show(screen,rx,ry,color_table,pal,1000);
25    cx+=dcx;
26    cy+=dcy;
27    fleft--;
28  }
29}
30
31
32
33morph_char::morph_char(game_object *who, int to_type, void (*stat_fun)(int), int anneal, int frames)
34{
35  mor=NULL;
36  character_type *t1=figures[who->otype],*t2=figures[to_type];
37  if (!t1->has_sequence(morph_pose) || t1->morph_mask<0 ||
38      !t2->has_sequence(morph_pose) || t2->morph_mask<0)
39    fleft=0;
40  else
41  {
42    if (anneal==-1)
43    {
44      switch (morph_detail)
45      {
46    case HIGH_DETAIL :
47    { anneal=30; } break;
48    case MEDIUM_DETAIL :
49    { anneal=15; } break;
50    case LOW_DETAIL :
51    { anneal=8; } break;
52    case POOR_DETAIL :
53    { anneal=3; } break;
54      }
55    }
56
57    fleft=frames;
58    trans_image *h1=new trans_image(cache.img(t1->morph_mask),"morph tmp"),
59                *h2=new trans_image(cache.img(t2->morph_mask),"morph tmp");
60    super_morph *sm=new super_morph(h1,h2,anneal,stat_fun);
61    if (sm->t)
62    {
63      delete h1;
64      delete h2;
65      figure *f1=t1->get_sequence(morph_pose)->get_figure(0),
66      *f2=t2->get_sequence(morph_pose)->get_figure(0);
67      image *i1=f1->forward->make_image(),
68      *i2=f2->forward->make_image();
69
70      mor=new smorph_player(sm,pal,i1,i2,fleft,who->direction);
71      delete i2;
72      delete i1;
73      delete sm;
74
75      if (who->direction>0)
76      {
77    cx=((int)f1->xcfg)<<16;
78    dcx=(((int)f2->xcfg-(int)f1->xcfg)<<16)/(fleft-1);
79      } else
80      {
81    cx=(mor->w-((int)f1->xcfg))<<16;
82    dcx=((((int)f1->xcfg-(int)f2->xcfg))<<16)/(fleft-1);
83      }
84      cy=((int)f1->height()-1)<<16;
85      dcy=((f2->height()-f1->height())<<16)/(fleft-1);
86    } else
87    {
88      delete sm;
89      fleft=0;
90    }
91  }
92}
93
94
95
96
97
98
99
100
101
102
103
Note: See TracBrowser for help on using the repository browser.