Debian Codegraph @

src/vertical.cpp

raw symbols SCIP
1 /***************************************************************************
2 vertical.cpp - description
3 -------------------
4 begin : Thu Aug 17 2000
5 copyright : (C) 2000 by Waldemar Baraldi
6 email : [email protected]
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 "vertical.h"
19 #include "pointervertical.h"
20
21 Vertical::Vertical(){
22 p=new PointerVertical();
23 }
24
25 Vertical::~Vertical(){
26 delete p;
27 }
28
29 bool Vertical::hasConnection(CardinalPoint con){
30 return (con==South || con==North);
31 }
32
33 CardinalPoint Vertical::getOutput(CardinalPoint input){
34 if (input==ro) return Void;
35 switch (input){
36 case South: return North;
37 case North:return South;
38 default:return Void;
39 }
40 }
41
42 void Vertical::restrictAsOutput(CardinalPoint con){
43 if (con==North || con==South) ro=con;
44 }
45
46 bool Vertical::isRestrictedAsOutput(CardinalPoint con){
47 return (con==ro);
48 }
49
50 void Vertical::incFullLevel(CardinalPoint input,unsigned int amount){
51 if ((input==North || input==South) && input!=ro)
52 if ((used_input==Void) || (used_input==input)){
53 full_level+=amount;
54 used_input=input;
55 }
56 }
57
58 int Vertical::getFullLevel(CardinalPoint input){
59 if (used_input==input)
60 return full_level;
61 return -1;
62 }
63
64 Pointer * Vertical::getPointer(){
65 return p;
66 }
67
68 void Vertical::paint(VideoManager * vm){
69
70 Image * ima;
71 if (fixed)
72 ima=(vm->getImageManager())->getImage(new Str("vertical_b.png"));
73 else
74 ima=(vm->getImageManager())->getImage(new Str("vertical.png"));
75 vm->blit(ima, x, y);
76
77 if (ro!=Void) paintRestriction(vm, ro);
78
79 paintFlow(vm);
80
81 if (bonus!=NormalBonus) paintBonus(vm, bonus);
82
83 //if (last) paintExclamation(vm);
84
85 }
86
87 void Vertical::paintFlow(VideoManager * vm){
88 if (full_level>0){
89 Image * aux=(vm->getImageManager())->getImage(new Str("flow.png"));
90 int xof=x+PipeWidth/2-aux->width()/2;
91 int yof=aux->height()/2;
92 int total, f;
93 vm->setClipping(x, y, PipeWidth, PipeHeight);
94 vm->enableClipping(true);
95 if (used_input==North){
96 total=y-yof;
97 f=1;
98 }
99 else{
100 total=PipeHeight+y-yof;
101 f=-1;
102 }
103 for (int i=0; i<full_level+Gran;i+=Gran)
104 vm->blit(aux, xof, total+f*(int)((float)i/(float)full()*(float)PipeHeight));
105 vm->enableClipping(false); }
106 }
107