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
RevLine 
[56]1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
[494]4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
[56]5 *
6 *  This software was released into the Public Domain. As with most public
[555]7 *  domain software, no warranty is made or implied by Crack dot Com, by
8 *  Jonathan Clark, or by Sam Hocevar.
[56]9 */
10
[732]11#if HAVE_CONFIG_H
[555]12#   include "config.h"
13#endif
[56]14
[512]15#include "common.h"
16
[481]17#include "morpher.h"
18#include "game.h"
19#include "objects.h"
20#include "view.h"
[2]21
[691]22void morph_char::draw(GameObject *who, view *v)
[2]23{
[657]24    if (fleft)
25    {
[692]26        ivec2 pos = the_game->GameToMouse(who->m_pos - ivec2(cx >> 16, cy >> 16), v);
[694]27        mor->show(main_screen, pos.x, pos.x, color_table, g_palette, 1000);
[657]28        cx += dcx;
29        cy += dcy;
30        fleft--;
31    }
[2]32}
33
34
35
[691]36morph_char::morph_char(GameObject *who, int to_type, void (*stat_fun)(int), int anneal, int frames)
[124]37{
[2]38  mor=NULL;
[642]39  CharacterType *t1=figures[who->otype],*t2=figures[to_type];
[124]40  if (!t1->has_sequence(morph_pose) || t1->morph_mask<0 ||
[2]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      {
[124]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;
[2]57      }
58    }
59
60    fleft=frames;
[541]61    TransImage *h1=new TransImage(cache.img(t1->morph_mask),"morph tmp"),
62                *h2=new TransImage(cache.img(t2->morph_mask),"morph tmp");
[2]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);
[709]70      AImage *i1=f1->forward->ToImage(),
[531]71      *i2=f2->forward->ToImage();
[2]72
[694]73      mor = new smorph_player(sm, g_palette, i1, i2, fleft, who->direction);
[2]74      delete i2;
75      delete i1;
76      delete sm;
77
78      if (who->direction>0)
79      {
[124]80    cx=((int)f1->xcfg)<<16;
81    dcx=(((int)f2->xcfg-(int)f1->xcfg)<<16)/(fleft-1);
[2]82      } else
83      {
[124]84    cx=(mor->w-((int)f1->xcfg))<<16;
85    dcx=((((int)f1->xcfg-(int)f2->xcfg))<<16)/(fleft-1);
[2]86      }
87      cy=((int)f1->height()-1)<<16;
88      dcy=((f2->height()-f1->height())<<16)/(fleft-1);
[124]89    } else
[2]90    {
91      delete sm;
92      fleft=0;
93    }
[124]94  }
[2]95}
96
97
98
99
100
101
102
103
104
105
106
Note: See TracBrowser for help on using the repository browser.