1 /***************************************************************************
2 elbowdownleft.cpp - description
3 -------------------
4 begin : Thu Aug 17 2000
5 copyright : (C) 2000 by Waldemar Baraldi
6 email : baraldi@lacasilla.com.ar
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18 #include "elbowdownleft.h"
19 #include "pointerelbowdownleft.h"
20
ElbowDownLeft()21 ElbowDownLeft::ElbowDownLeft():Pipe(){
22 p=new PointerElbowDownLeft();
23 }
24
~ElbowDownLeft()25 ElbowDownLeft::~ElbowDownLeft(){
26 delete p;
27 }
28
hasConnection(CardinalPoint con)29 bool ElbowDownLeft::hasConnection(CardinalPoint con){
30 return ((con==West) || (con==South));
31 }
32
getOutput(CardinalPoint input)33 CardinalPoint ElbowDownLeft::getOutput(CardinalPoint input){
34 if (input==ro) return Void;
35 switch (input){
36 case South: return West;
37 case West:return South;
38 default:return Void;
39 }
40 }
41
restrictAsOutput(CardinalPoint con)42 void ElbowDownLeft::restrictAsOutput(CardinalPoint con){
43 if (con==South || con==West) ro=con;
44 }
45
isRestrictedAsOutput(CardinalPoint con)46 bool ElbowDownLeft::isRestrictedAsOutput(CardinalPoint con){
47 return (ro==con);
48 }
49
incFullLevel(CardinalPoint input,unsigned int amount)50 void ElbowDownLeft::incFullLevel(CardinalPoint input,unsigned int amount){
51 if ((input==South || input==West) && ro!=input)
52 if ((used_input==Void) || (used_input==input)){
53 full_level+=amount;
54 used_input=input;
55 }
56 }
57
getFullLevel(CardinalPoint input)58 int ElbowDownLeft::getFullLevel(CardinalPoint input){
59 if (input==used_input) return full_level;
60 return 0;
61 }
62
getPointer()63 Pointer * ElbowDownLeft::getPointer(){
64 return p;
65 }
66
paint(VideoManager * vm)67 void ElbowDownLeft::paint(VideoManager * vm){
68 Image * ima;
69 if (fixed)
70 ima=(vm->getImageManager())->getImage(new Str("elbow_swb.png"));
71 else
72 ima=(vm->getImageManager())->getImage(new Str("elbow_sw.png"));
73 vm->blit(ima, x, y);
74
75 if (ro!=Void) paintRestriction(vm,ro);
76 if (full_level>0){
77 Image * aux=(vm->getImageManager())->getImage(new Str("flow.png"));
78 float fwidth=(float)PipeWidth/2;
79 float fheight=(float)PipeHeight/2;
80 float nov=PI/2;
81 vm->setClipping(x, y, PipeWidth, PipeHeight);
82 vm->enableClipping(true);
83 int xaux=x-aux->width()/2;
84 int yaux=y+PipeHeight-aux->width()/2;
85 if (used_input==South){
86 for (int i=0; i<full_level+1;i+=Gran)
87 vm->blit(aux, (int)(xaux+(float)cos((float)i/(float)full() * nov)*fwidth),
88 (int)(yaux-(float)sin((float)i/(float)full() * nov)*fheight));
89 }else{
90 for (int i=0; i<full_level+1;i+=Gran)
91 vm->blit(aux, (int)(xaux+(float)cos((float)(full()-i)/(float)full() * nov)*fwidth),
92 (int)(yaux-(float)sin((float)(full()-i)/(float)full() * nov)*fheight));
93 }
94 vm->enableClipping(false);
95 }
96 if (bonus!=NormalBonus) paintBonus(vm, bonus);
97 }
98