source: abuse/branches/lol/src/morpher.cpp @ 732

Last change on this file since 732 was 732, checked in by Sam Hocevar, 8 years ago

build: SDL2 compilation fixes.

File size: 2.3 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, by
8 *  Jonathan Clark, or by Sam Hocevar.
9 */
10
11#if HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include "common.h"
16
17#include "morpher.h"
18#include "game.h"
19#include "objects.h"
20#include "view.h"
21
22void morph_char::draw(GameObject *who, view *v)
23{
24    if (fleft)
25    {
26        ivec2 pos = the_game->GameToMouse(who->m_pos - ivec2(cx >> 16, cy >> 16), v);
27        mor->show(main_screen, pos.x, pos.x, color_table, g_palette, 1000);
28        cx += dcx;
29        cy += dcy;
30        fleft--;
31    }
32}
33
34
35
36morph_char::morph_char(GameObject *who, int to_type, void (*stat_fun)(int), int anneal, int frames)
37{
38  mor=NULL;
39  CharacterType *t1=figures[who->otype],*t2=figures[to_type];
40  if (!t1->has_sequence(morph_pose) || t1->morph_mask<0 ||
41      !t2->has_sequence(morph_pose) || t2->morph_mask<0)
42    fleft=0;
43  else
44  {
45    if (anneal==-1)
46    {
47      switch (morph_detail)
48      {
49    case HIGH_DETAIL :
50    { anneal=30; } break;
51    case MEDIUM_DETAIL :
52    { anneal=15; } break;
53    case LOW_DETAIL :
54    { anneal=8; } break;
55    case POOR_DETAIL :
56    { anneal=3; } break;
57      }
58    }
59
60    fleft=frames;
61    TransImage *h1=new TransImage(cache.img(t1->morph_mask),"morph tmp"),
62                *h2=new TransImage(cache.img(t2->morph_mask),"morph tmp");
63    super_morph *sm=new super_morph(h1,h2,anneal,stat_fun);
64    if (sm->t)
65    {
66      delete h1;
67      delete h2;
68      figure *f1=t1->get_sequence(morph_pose)->get_figure(0),
69      *f2=t2->get_sequence(morph_pose)->get_figure(0);
70      AImage *i1=f1->forward->ToImage(),
71      *i2=f2->forward->ToImage();
72
73      mor = new smorph_player(sm, g_palette, i1, i2, fleft, who->direction);
74      delete i2;
75      delete i1;
76      delete sm;
77
78      if (who->direction>0)
79      {
80    cx=((int)f1->xcfg)<<16;
81    dcx=(((int)f2->xcfg-(int)f1->xcfg)<<16)/(fleft-1);
82      } else
83      {
84    cx=(mor->w-((int)f1->xcfg))<<16;
85    dcx=((((int)f1->xcfg-(int)f2->xcfg))<<16)/(fleft-1);
86      }
87      cy=((int)f1->height()-1)<<16;
88      dcy=((f2->height()-f1->height())<<16)/(fleft-1);
89    } else
90    {
91      delete sm;
92      fleft=0;
93    }
94  }
95}
96
97
98
99
100
101
102
103
104
105
106
Note: See TracBrowser for help on using the repository browser.