本文整理汇总了C++中DrawList类的典型用法代码示例。如果您正苦于以下问题:C++ DrawList类的具体用法?C++ DrawList怎么用?C++ DrawList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DrawList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawMagnifyingGlass
void MinigameBbAnt::drawMagnifyingGlass(DrawList &drawList) {
scale2x(_objects[0].x - 28, _objects[0].y - 27);
drawList.clear();
drawList.add(_objects[0].anim->frameIndices[0], _objects[0].x, _objects[0].y, _objects[0].priority);
drawList.add(_objects[0].anim->frameIndices[1], _objects[0].x, _objects[0].y, _objects[0].priority);
drawList.add(_objects[0].anim->frameIndices[2], _objects[0].x, _objects[0].y, _objects[0].priority);
}
示例2: debug
void BbvsEngine::loadScene(int sceneNum) {
debug(0, "BbvsEngine::loadScene() sceneNum: %d", sceneNum);
Common::String sprFilename = Common::String::format("vnm/vspr%04d.vnm", sceneNum);
Common::String gamFilename = Common::String::format("vnm/game%04d.vnm", sceneNum);
_screen->clear();
_spriteModule->load(sprFilename.c_str());
_gameModule->load(gamFilename.c_str());
Palette palette = _spriteModule->getPalette();
_screen->setPalette(palette);
// Preload sounds
for (uint i = 0; i < _gameModule->getPreloadSoundsCount(); ++i) {
Common::String filename = Common::String::format("snd/snd%05d.aif", _gameModule->getPreloadSound(i));
_sound->loadSound(filename);
}
if (sceneNum >= kMainMenu) {
DrawList drawList;
drawList.add(_gameModule->getBgSpriteIndex(0), 0, 0, 0);
_screen->drawDrawList(drawList, _spriteModule);
drawScreen();
}
}
示例3: buildDrawList1
void MinigameBbAnt::buildDrawList2(DrawList &drawList) {
buildDrawList1(drawList);
drawList.add(getAnimation(168)->frameIndices[0], 40, 100, 2000);
drawNumber(drawList, _counter1, 190, 112);
drawNumber(drawList, _countdown5, 258, 112);
drawList.add(getAnimation(169)->frameIndices[0], 120, 120, 2000);
drawNumber(drawList, _counter4, 192, 132);
}
示例4: DrawListRef
BufferedDrawList::DrawListRef BufferedDrawList::forUpdate() {
DrawList* dl;
for(;;) {
dl = &Dl[Ui];
if(--Ui == 0) Ui = 2;
if (dl == Rendering || dl == ToRender)continue;
break;
}
dl->clear();
return DrawListRef( *dl, *this);
}
示例5: Point
void AsteroidField::Asteroid::Draw(DrawList &draw, const Point ¢er, const Point ¢erVelocity) const
{
Point pos = location - center;
pos = Point(remainder(pos.X(), WRAP), remainder(pos.Y(), WRAP));
draw.Add(animation, pos, angle.Unit() * .5, velocity - centerVelocity);
}
示例6: Draw
// Draw the asteroids, centered on the given location.
void AsteroidField::Draw(DrawList &draw, const Point ¢er, double zoom) const
{
for(const Asteroid &asteroid : asteroids)
asteroid.Draw(draw, center, zoom);
for(const shared_ptr<Minable> &minable : minables)
draw.Add(*minable);
}
示例7:
void C_3DObject_Group::addDrawList(DrawList &dlist, Port_3D &port)
{
int i;
if ((n_objects > 0) && isVisible(port))
{
for (i = 0; i<n_objects;i++)
if (objects[i]->visible)
objects[i]->draw_prep(port);
for (i=0;i<n_objects;i++)
{
if (objects[i]->visible && objects[i]->visible_flag)
dlist.add_object(objects[i]);
}
}
}
示例8: TestDrawListRandom
void TestDrawListRandom(int numEntries) {
DrawList<MyData> list;
std::vector<double> configured;
std::vector<double> drawn;
const unsigned int cnt = numEntries;
const unsigned int numDraw = cnt * 4096;
double probSum = 0;
list.resize(cnt);
drawn.resize(cnt);
configured.resize(cnt);
// fill
for (unsigned int i = 0; i < cnt; ++i) {
double rnd = double(rand()) / double(RAND_MAX);
configured[i] = rnd;
list.set(i, MyData(i,i), rnd);
probSum += rnd;
}
// draw
for (unsigned int i = 0; i < numDraw; ++i) {
MyData& d = list.draw();
drawn[d.x]++;
}
// compare
for (unsigned int i = 0; i < cnt; ++i) {
double a = (configured[i] / probSum);
double b = (drawn[i] / numDraw);
ASSERT_NEAR(a, b, a*0.50); // allow 50% difference between cfg and drawn
}
}
示例9: drawNumber
int Minigame::drawNumber(DrawList &drawList, int number, int x, int y) {
int digits = 1, rightX = x;
for (int mag = 10; number / mag != 0; mag *= 10)
++digits;
rightX = x + digits * 10;
x = rightX;
while (digits--) {
const int n = number % 10;
x -= 10;
drawList.add(_numbersAnim->frameIndices[n], x, y, 2000);
number /= 10;
}
return rightX;
}
示例10: fmod
// Draw any instances of this asteroid that are on screen.
void AsteroidField::Asteroid::Draw(DrawList &draw, const Point ¢er, double zoom) const
{
// Any object within this range must be drawn.
Point topLeft = center + (Screen::TopLeft() - size) / zoom;
Point bottomRight = center + (Screen::BottomRight() + size) / zoom;
// Figure out the position of the first instance of this asteroid that is to
// the right of and below the top left corner of the screen.
double startX = fmod(position.X() - topLeft.X(), WRAP);
startX += topLeft.X() + WRAP * (startX < 0.);
double startY = fmod(position.Y() - topLeft.Y(), WRAP);
startY += topLeft.Y() + WRAP * (startY < 0.);
// Draw any instances of this asteroid that are on screen.
for(double y = startY; y < bottomRight.Y(); y += WRAP)
for(double x = startX; x < bottomRight.X(); x += WRAP)
draw.Add(*this, Point(x, y));
}
示例11: TEST
/** assert that cumulative values are correctly calculated when drawing the first time */
TEST(DrawList, Cumulative) {
DrawList<MyData> list;
list.push_back(MyData(), 0.11);
list.push_back(MyData(), 0.22);
list.push_back(MyData(), 0.33);
list.push_back(MyData(), 0.44);
list.push_back(MyData(), 0.55);
list.push_back(MyData(), 0.66);
for (DrawListEntry<MyData>& dle : list.entries) {
ASSERT_EQ(0, dle.cumulativeProbability);
}
list.draw();
ASSERT_FLOAT_EQ(0.11f, list.entries[0].cumulativeProbability);
ASSERT_FLOAT_EQ(0.33f, list.entries[1].cumulativeProbability);
ASSERT_FLOAT_EQ(0.66f, list.entries[2].cumulativeProbability);
ASSERT_FLOAT_EQ(1.10f, list.entries[3].cumulativeProbability);
ASSERT_FLOAT_EQ(1.65f, list.entries[4].cumulativeProbability);
ASSERT_FLOAT_EQ(2.31f, list.entries[5].cumulativeProbability);
list.set(0, MyData(), 0.22);
ASSERT_FLOAT_EQ(0.00f, list.entries[0].cumulativeProbability);
ASSERT_FLOAT_EQ(0.33f, list.entries[1].cumulativeProbability);
ASSERT_FLOAT_EQ(0.66f, list.entries[2].cumulativeProbability);
ASSERT_FLOAT_EQ(1.10f, list.entries[3].cumulativeProbability);
ASSERT_FLOAT_EQ(1.65f, list.entries[4].cumulativeProbability);
ASSERT_FLOAT_EQ(2.31f, list.entries[5].cumulativeProbability);
list.draw();
ASSERT_FLOAT_EQ(0.22f, list.entries[0].cumulativeProbability);
ASSERT_FLOAT_EQ(0.44f, list.entries[1].cumulativeProbability);
ASSERT_FLOAT_EQ(0.77f, list.entries[2].cumulativeProbability);
ASSERT_FLOAT_EQ(1.21f, list.entries[3].cumulativeProbability);
ASSERT_FLOAT_EQ(1.76f, list.entries[4].cumulativeProbability);
ASSERT_FLOAT_EQ(2.42f, list.entries[5].cumulativeProbability);
}
示例12: display
//---------------------------------------------------------------------------
// void display(void)
void display()
{
glClear(GL_COLOR_BUFFER_BIT); // clear the backbuffer
//draw all the Static Stuff -> map data
for (Drawable* drawable : Static) {
drawable->draw();
}
//draw everything on the drawlist
for (Drawable* drawable : drawList){
drawable->draw();
//delete the pointers to the drawable on the drawlist
delete drawable;
}
//lastly draw the text -> ensures the text is always draw on top
for (Drawable* drawable : DrawTextList) {
drawable->draw();
//delete the ponter to the drawable
delete drawable;
}
// Visualize the drawing commands
glFlush(); // Execute all commands waiting to be executed
glutSwapBuffers(); // Swap the backbuffer and frontbuffer
//clear the drawing & text list
drawList.clear();
DrawTextList.clear();
}
示例13: path
//draw the path from the map file
void path() {
for (int i = 0; i < mapSizex; i++) {
for (int j = 0; j < mapSizey; j++) {
float x = i*20;
float y = j*20;
if (Map[i][j] == '/' ) {
//draw the path where enemy's walk
Color color = { 0.47265625, 0.33203125, 0.28125 };
PointF begin1 = { x,y };
PointF begin2 = { (x),(y+20) };
PointF begin3 = { (x-20),(y+20) };
PointF begin4 = { (x - 20), (y) };
Sqaure* sq = new Sqaure(begin1, begin2, begin3, begin4, color);
Static.push_back(sq);
//drawList.push_back(sq);
}
//path where building is allowed
if (Map[i][j] == '*' || Map[i][j] == 'T') {
//draw the building site
Color color = { 0 , 0.47265625, 0.41796875 };
PointF begin1 = { x,y };
PointF begin2 = { (x),(y + 20) };
PointF begin3 = { (x - 20),(y + 20) };
PointF begin4 = { (x - 20), (y) };
Sqaure* sq = new Sqaure(begin1, begin2, begin3, begin4, color);
Static.push_back(sq);
//drawList.push_back(sq);
}
//end point of the map
if (Map[i][j] == 'E') {
//draw the end map
Color color = { 1.0f, 0.4f, 0.4f };
PointF begin1 = { x,y };
PointF begin2 = { (x),(y + 20) };
PointF begin3 = { (x - 20),(y + 20) };
PointF begin4 = { (x - 20), (y) };
Sqaure* sq = new Sqaure(begin1, begin2, begin3, begin4, color);
Static.push_back(sq);
//drawList.push_back(sq);
}
//if the map data contains nothing special
else {
continue;
}
}
}
}
示例14: drawBullet
//draw the actual bullet's as is seen on screen
void drawBullet() {
//define colors and width of the bullet
Color color = { 0.9f, 0.9f, 0.9f }; //white bullets
float lind = 2.0;
//itterate over the bullet vector
for (unsigned i = 0; i < bulletvector.size(); i++) {
PointF BulletPos = bulletvector.at(i)->Move();
// if bullet is out of screen
if (BulletPos[0] > windowWidth || BulletPos[1] > windowHeight || BulletPos[0] < 0 || BulletPos[1] < 0) {
//delete the bulelt from the vector and the pointer to the bullet
delete bulletvector.at(i);
bulletvector.erase(bulletvector.begin() + i);
}
else {
//update the movement of the bullet
bulletvector.at(i)->Update(BulletPos);
//draw the bullet +5 becuase of the width of the bullet
PointF BulletPos2 = { BulletPos[0], (BulletPos[1] + 5) };
Line* bulletline = new Line{ BulletPos , BulletPos2 , color, lind };
//push to the draw list
drawList.push_back(bulletline);
}
}
}
示例15: raster
//make a grid
void raster() {
Color color = { 0.40625,0.76171875,0.63671875 };
int rasterHoogte = windowHeight;
int rasterBreedte = windowWidth;
int res = 15;
float radius = 2.5;
int seg = 5;
float varx;
float vary;
for (int i = 0; i < (rasterBreedte/res); i++) {
for (int j = 0; j < ((rasterHoogte)/res); j++) {
varx = 20 * i;
vary = 20 * j;
//make a grid if the width still has 200 pixels
if ((windowWidth - 200) > varx) {
PointF posPixel = { varx , vary };
Circle* dots = new Circle(posPixel, color, radius, seg);
Static.push_back(dots);
}
else {
continue;
}
}
}
//draw the grid
path();
}