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

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

ps3: make everything compile on the PS3. Of course, nothing links yet
because so much support is missing.

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
[555]11#if defined HAVE_CONFIG_H
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
22void morph_char::draw(game_object *who, view *v)
23{
24  if (fleft)
25  {
[16]26    int32_t rx,ry;
[2]27    the_game->game_to_mouse(who->x-(cx>>16),who->y-(cy>>16),v,rx,ry);
28    mor->show(screen,rx,ry,color_table,pal,1000);
29    cx+=dcx;
[124]30    cy+=dcy;
[2]31    fleft--;
32  }
33}
34
35
36
37morph_char::morph_char(game_object *who, int to_type, void (*stat_fun)(int), int anneal, int frames)
[124]38{
[2]39  mor=NULL;
40  character_type *t1=figures[who->otype],*t2=figures[to_type];
[124]41  if (!t1->has_sequence(morph_pose) || t1->morph_mask<0 ||
[2]42      !t2->has_sequence(morph_pose) || t2->morph_mask<0)
43    fleft=0;
44  else
45  {
46    if (anneal==-1)
47    {
48      switch (morph_detail)
49      {
[124]50    case HIGH_DETAIL :
51    { anneal=30; } break;
52    case MEDIUM_DETAIL :
53    { anneal=15; } break;
54    case LOW_DETAIL :
55    { anneal=8; } break;
56    case POOR_DETAIL :
57    { anneal=3; } break;
[2]58      }
59    }
60
61    fleft=frames;
[541]62    TransImage *h1=new TransImage(cache.img(t1->morph_mask),"morph tmp"),
63                *h2=new TransImage(cache.img(t2->morph_mask),"morph tmp");
[2]64    super_morph *sm=new super_morph(h1,h2,anneal,stat_fun);
65    if (sm->t)
66    {
67      delete h1;
68      delete h2;
69      figure *f1=t1->get_sequence(morph_pose)->get_figure(0),
70      *f2=t2->get_sequence(morph_pose)->get_figure(0);
[531]71      image *i1=f1->forward->ToImage(),
72      *i2=f2->forward->ToImage();
[2]73
74      mor=new smorph_player(sm,pal,i1,i2,fleft,who->direction);
75      delete i2;
76      delete i1;
77      delete sm;
78
79      if (who->direction>0)
80      {
[124]81    cx=((int)f1->xcfg)<<16;
82    dcx=(((int)f2->xcfg-(int)f1->xcfg)<<16)/(fleft-1);
[2]83      } else
84      {
[124]85    cx=(mor->w-((int)f1->xcfg))<<16;
86    dcx=((((int)f1->xcfg-(int)f2->xcfg))<<16)/(fleft-1);
[2]87      }
88      cy=((int)f1->height()-1)<<16;
89      dcy=((f2->height()-f1->height())<<16)/(fleft-1);
[124]90    } else
[2]91    {
92      delete sm;
93      fleft=0;
94    }
[124]95  }
[2]96}
97
98
99
100
101
102
103
104
105
106
107
Note: See TracBrowser for help on using the repository browser.