| 1 | /*************************************************************************** |
| 2 | exit.cpp - description |
| 3 | ------------------- |
| 4 | begin : Sat Oct 21 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 "exit.h" |
| 19 | |
| 20 | Exit::Exit(CardinalPoint connection):Pipe(){ |
| 21 | con=connection; |
| 22 | } |
| 23 | |
| 24 | Exit::~Exit(){} |
| 25 | |
| 26 | bool Exit::hasConnection(CardinalPoint con){ |
| 27 | return (this->con==con); |
| 28 | } |
| 29 | |
| 30 | CardinalPoint Exit::getOutput(CardinalPoint input){ |
| 31 | return Void; |
| 32 | } |
| 33 | |
| 34 | bool Exit::isRemovable(){ |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | void Exit::incFullLevel(CardinalPoint input,unsigned int amount){ |
| 39 | full_level+=amount; |
| 40 | used_input=Void; |
| 41 | } |
| 42 | |
| 43 | int Exit::getFullLevel(CardinalPoint input){ |
| 44 | return this->full_level; |
| 45 | } |
| 46 | |
| 47 | Pointer * Exit::getPointer(){ |
| 48 | return NULL; |
| 49 | } |
| 50 | |
| 51 | void Exit::paint(VideoManager * vm){ |
| 52 | Image * aux, *ima; |
| 53 | |
| 54 | if (con==East || con==West) |
| 55 | ima=(vm->getImageManager())->getImage(new Str("exit_h.png")); |
| 56 | else |
| 57 | ima=(vm->getImageManager())->getImage(new Str("exit_v.png")); |
| 58 | aux=new Image(ima); |
| 59 | switch (con){ |
| 60 | case South:{aux->flip(HAxis);break;} |
| 61 | case West:{aux->flip(VAxis);break;} |
| 62 | default:break; |
| 63 | } |
| 64 | vm->blit(aux, x, y); |
| 65 | delete aux; |
| 66 | |
| 67 | if (full_level>0){ |
| 68 | ima=(vm->getImageManager())->getImage(new Str("flow.png")); |
| 69 | vm->setClipping(x, y, PipeWidth, PipeHeight); |
| 70 | vm->enableClipping(true); |
| 71 | switch (con){ |
| 72 | case North:case South:{ |
| 73 | int xof=x+PipeWidth/2-ima->width()/2; |
| 74 | int yof; |
| 75 | float factor=(float)PipeHeight/(float)(full()); |
| 76 | if (con==North) yof=y-ima->height()/2; |
| 77 | else{ |
| 78 | yof=y+PipeHeight-ima->height()/2; |
| 79 | factor =-factor; |
| 80 | } |
| 81 | for (int i=0;i<full_level/2+Gran;i+=Gran) |
| 82 | vm->blit(ima, xof, (int)(yof+(float)i*factor)); |
| 83 | break; |
| 84 | } |
| 85 | case East: case West:{ |
| 86 | int xof; |
| 87 | int yof=y+PipeHeight/2-ima->height()/2;; |
| 88 | float factor=(float)PipeWidth/(float)(full()); |
| 89 | if (con==West) xof=x-ima->width()/2; |
| 90 | else{ |
| 91 | xof=x+PipeWidth-ima->width()/2; |
| 92 | factor =-factor; |
| 93 | } |
| 94 | for (int i=0;i<full_level/2+Gran;i+=Gran) |
| 95 | vm->blit(ima, (int)(xof+(float)i*factor), yof); |
| 96 | break; |
| 97 | } |
| 98 | default:break; |
| 99 | } |
| 100 | vm->enableClipping(false); |
| 101 | } |
| 102 | } |
| 103 |