Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

EffectDisintegrate.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  */
00009 #include "EffectDisintegrate.h"
00010 
00011 #include "SurfaceLock.h"
00012 #include "PixelTool.h"
00013 #include "Random.h"
00014 
00015 //-----------------------------------------------------------------
00016 /**
00017  * Start as not disintegrated.
00018  */
00019 EffectDisintegrate::EffectDisintegrate()
00020 {
00021     m_disint = DISINT_START;
00022 }
00023 //-----------------------------------------------------------------
00024 void
00025 EffectDisintegrate::updateEffect()
00026 {
00027     if (m_disint > 0) {
00028         m_disint -= DISINT_SPEED;
00029         if (m_disint < 0) {
00030             m_disint = 0;
00031         }
00032     }
00033 }
00034 //-----------------------------------------------------------------
00035 /**
00036  * Returns true for object for who the disint effect is finished.
00037  */
00038 bool
00039 EffectDisintegrate::isDisintegrated() const
00040 {
00041     return 0 == m_disint;
00042 }
00043 //-----------------------------------------------------------------
00044 bool
00045 EffectDisintegrate::isInvisible() const
00046 {
00047     return isDisintegrated();
00048 }
00049 //-----------------------------------------------------------------
00050 /**
00051  * Disintegration effect.
00052  * Draw only some pixels.
00053  */
00054 void
00055 EffectDisintegrate::blit(SDL_Surface *screen, SDL_Surface *surface,
00056         int x, int y)
00057 {
00058     SurfaceLock lock1(screen);
00059     SurfaceLock lock2(surface);
00060 
00061     for (int py = 0; py < surface->h; ++py) {
00062         for (int px = 0; px < surface->w; ++px) {
00063             if (Random::aByte(py * surface->w + px) < m_disint) {
00064                 SDL_Color pixel = PixelTool::getColor(surface, px, py);
00065                 if (pixel.unused == 255) {
00066                     PixelTool::putColor(screen, x + px, y + py, pixel);
00067                 }
00068             }
00069         }
00070     }
00071 }
00072 

Generated on Wed Jun 1 09:54:30 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2