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

Last change on this file since 489 was 481, checked in by Sam Hocevar, 10 years ago

Fuck the history, I'm renaming all .hpp files to .h for my own sanity.

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