Show swampclient.cpp syntax highlighted
/***************************************************************************
swampclient.cpp
-------------------
begin : Sun Dec 19 2004
copyright : (C) 2004 by Brendon Lloyd Higgins
email : bh_doc@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <client.h>
#include <maptilepos.h>
#include <swamp.h>
#include <swampclient.h>
#include <worldclient.h>
#include <worldpos.h>
#include <ClanLib/display.h>
CL_Sprite* SwampClient::spriteCache = 0;
SwampClient::SwampClient(const Identity& ident, CL_NetPacket &p, int reason):
EntityClient(ident), pos(MapPos::extract(p.input)),
sprite(new CL_Sprite(*spriteCache)) {
}
SwampClient::~SwampClient() {
delete sprite;
}
WorldPos SwampClient::getPos() const {
return pos + MapTilePos(0.5f, 0.5f);
}
bool SwampClient::drawUpdate(const WorldClient* w, unsigned int d) {
sprite->update(d / 1000.0f);
return true;
}
int SwampClient::drawSortIndex(const WorldClient* w) const {
return w->getMap()->findPos(getPos()).y - MapTileClient::picHeightOn2();
}
void SwampClient::draw(const WorldClient* w) const {
CL_Point gp = w->getMap()->findPos(getPos());
sprite->draw(gp.x, gp.y);
}
void SwampClient::predict(const WorldClient* w, unsigned int d) {
}
void SwampClient::onFullUpdate(WorldClient* w, CL_NetPacket& p) {
pos = MapPos::extract(p.input);
}
void SwampClient::loadSprites() {
// TODO blank
spriteCache = new CL_Sprite("effects/swamp/blank", app.getResources());
}
void SwampClient::freeSprites() {
delete spriteCache;
}
See more files for this project here