BASEOBJ.CPP
资源名称:tc3d.zip [点击查看]
上传用户:abcdshs
上传日期:2007-01-07
资源大小:1858k
文件大小:1k
源码类别:
游戏
开发平台:
Visual C++
- // (C) Copyright 1996 by Anthony J. Carin. All Rights Reserved.
- #include <stdafx.h>
- #include <baseobj.h>
- #include "levels.h"
- #include "higharea.h"
- baseobject::baseobject(CString& filename) : qentry()
- {
- if (!filename.IsEmpty())
- m_body = new image(filename);
- else
- m_body = 0;
- m_type = BASEOBJECT;
- }
- baseobject::~baseobject()
- {
- delete m_body;
- }
- void baseobject::draw()
- {
- view c;
- c = m_view;
- c.setzdir(c.zdirection()+zposition);
- c.setxdir(c.xdirection()+xposition);
- c.setydir(c.ydirection()+yposition);
- if (m_body)
- {
- m_body->setto(c);
- m_body->draw();
- }
- }
- const float EXTRAHIGHT = .25f;
- void baseobject::settledown(float y)
- {
- float newy = 0.0f;
- coordinate tmp = m_view;
- higharea *tmpptr = Game->HighAreas()->First();
- while (tmpptr != NULL)
- {
- if (tmpptr->iswithin(location()) &&
- newy < tmpptr->hight())
- newy = tmpptr->hight();
- tmpptr = Game->HighAreas()->Next();
- }
- if (newy)
- y += (newy + EXTRAHIGHT);
- if (tmp.y() > y)
- {
- tmp.sety(tmp.y()-0.4f);
- m_view.stepto(tmp, 1.0f);
- }
- else if (tmp.y() < y)
- {
- m_view.sety(y);
- }
- }