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

Last change on this file since 2 was 2, checked in by Sam Hocevar, 14 years ago
  • imported original 0.7.0 tarball
File size: 1.9 KB
Line 
1#include "morpher.hpp"
2#include "game.hpp"
3#include "objects.hpp"
4#include "view.hpp"
5
6void morph_char::draw(game_object *who, view *v)
7{
8  if (fleft)
9  {
10    long rx,ry;
11    the_game->game_to_mouse(who->x-(cx>>16),who->y-(cy>>16),v,rx,ry);
12    mor->show(screen,rx,ry,color_table,pal,1000);
13    cx+=dcx;
14    cy+=dcy; 
15    fleft--;
16  }
17}
18
19
20
21morph_char::morph_char(game_object *who, int to_type, void (*stat_fun)(int), int anneal, int frames)
22
23  mor=NULL;
24  character_type *t1=figures[who->otype],*t2=figures[to_type];
25  if (!t1->has_sequence(morph_pose) || t1->morph_mask<0 ||
26      !t2->has_sequence(morph_pose) || t2->morph_mask<0)
27    fleft=0;
28  else
29  {
30    if (anneal==-1)
31    {
32      switch (morph_detail)
33      {
34        case HIGH_DETAIL :
35        { anneal=30; } break;
36        case MEDIUM_DETAIL :
37        { anneal=15; } break;
38        case LOW_DETAIL :
39        { anneal=8; } break;
40        case POOR_DETAIL :
41        { anneal=3; } break;
42      }
43    }
44
45    fleft=frames;
46    trans_image *h1=new trans_image(cash.img(t1->morph_mask),"morph tmp"),
47                *h2=new trans_image(cash.img(t2->morph_mask),"morph tmp");
48    super_morph *sm=new super_morph(h1,h2,anneal,stat_fun);
49    if (sm->t)
50    {
51      delete h1;
52      delete h2;
53      figure *f1=t1->get_sequence(morph_pose)->get_figure(0),
54      *f2=t2->get_sequence(morph_pose)->get_figure(0);
55      image *i1=f1->forward->make_image(),
56      *i2=f2->forward->make_image();
57
58      mor=new smorph_player(sm,pal,i1,i2,fleft,who->direction);
59      delete i2;
60      delete i1;
61      delete sm;
62
63      if (who->direction>0)
64      {
65        cx=((int)f1->xcfg)<<16;
66        dcx=(((int)f2->xcfg-(int)f1->xcfg)<<16)/(fleft-1);
67      } else
68      {
69        cx=(mor->w-((int)f1->xcfg))<<16;
70        dcx=((((int)f1->xcfg-(int)f2->xcfg))<<16)/(fleft-1);
71      }
72      cy=((int)f1->height()-1)<<16;
73      dcy=((f2->height()-f1->height())<<16)/(fleft-1);
74    } else
75    {
76      delete sm;
77      fleft=0;
78    }
79  }   
80}
81
82
83
84
85
86
87
88
89
90
91
Note: See TracBrowser for help on using the repository browser.