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