Mana
Loading...
Searching...
No Matches
imageparticle.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2006-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "imageparticle.h"
23
24#include "graphics.h"
25
26#include "resources/image.h"
27
29 Particle(map),
30 mImageRef(image)
31{
33}
34
36
37bool ImageParticle::draw(Graphics *graphics, int offsetX, int offsetY) const
38{
39 if (!isAlive() || !mImage)
40 return false;
41
42 int screenX = (int) mPos.x + offsetX - mImage->getWidth() / 2;
43 int screenY = (int) mPos.y - (int)mPos.z + offsetY - mImage->getHeight()/2;
44
45 // Check if on screen
46 if (screenX + mImage->getWidth() < 0
47 || screenX > graphics->getWidth()
48 || screenY + mImage->getHeight() < 0
49 || screenY > graphics->getHeight())
50 return false;
51
53 return graphics->drawImage(mImage, screenX, screenY);
54}
Vector mPos
Position in pixels relative to map.
Definition actor.h:114
A central point of control for graphics.
Definition graphics.h:78
int getHeight() const
Returns the logical height of the screen.
Definition graphics.h:226
bool drawImage(const Image *image, int x, int y)
Blits an image onto the screen.
Definition graphics.cpp:36
int getWidth() const
Returns the logical width of the screen.
Definition graphics.h:221
ImageParticle(Map *map, Image *image)
Constructor.
ResourceRef< Image > mImageRef
Image * mImage
The image used for this particle.
~ImageParticle() override
bool draw(Graphics *graphics, int offsetX, int offsetY) const override
Draws the particle image.
Defines a class for loading and storing images.
Definition image.h:45
int getHeight() const
Returns the height of the image.
Definition image.h:89
int getWidth() const
Returns the width of the image.
Definition image.h:83
void setAlpha(float alpha)
Sets the alpha value of this image.
Definition image.cpp:176
A tile map.
Definition map.h:147
A particle spawned by a ParticleEmitter.
Definition particle.h:42
float getCurrentAlpha() const
Calculates the current alpha transparency taking current fade status into account.
Definition particle.cpp:410
bool isAlive() const
Definition particle.h:228
float z
Definition vector.h:173
float y
Definition vector.h:172
float x
Definition vector.h:171
Graphics * graphics
Definition client.cpp:104