本文整理汇总了C++中Dot类的典型用法代码示例。如果您正苦于以下问题:C++ Dot类的具体用法?C++ Dot怎么用?C++ Dot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: blit
bool bScreen::blit(Dot in)
{
SDL_Surface *temp = NULL;
SDL_Surface *nScreen = NULL;
SDL_Rect *player = new SDL_Rect;
SDL_Rect pos;
SDL_Rect offset;
SDL_Rect camera;
bool success = false;
camera = in.getCamera();
offset.x = 0;
offset.y = 0;
pos.x = (in.getx()) - (camera.x);
pos.y = (in.gety())- (camera.y);
temp = in.getPlayerImage(0);
player->x = 10 + ((in.phase/2)*PLAYERSPRITEW);
player->y = 3 + ((in.direction)*PLAYERSPRITEH);
player->w = 20;
player->h = 30;
SDL_BlitSurface(this->background, &camera, this->screen, &offset);
SDL_BlitSurface(temp , player, this->screen, &pos );
//rember to ask about possible memory leak here
// delete temp;
return success;
}
示例2: StoryScreen
void
Worldmap::update_locked_nodes()
{
// FIXME: This shouldn't be a polling function
path_graph->graph.for_each_node(unlock_nodes(path_graph.get()));
#if 0
bool credits_unlocked = false;
StatManager::instance()->get_bool(worldmap.get_short_name() + "-endstory-seen", credits_unlocked);
if (!credits_unlocked)
{
// See if the last level is finished
Dot* dot = path_graph->get_dot(final_node);
if (dot)
{
if (dot->finished())
{
ScreenManager::instance()->push_screen(new StoryScreen(worldmap.get_end_story()));
}
}
else
{
log_info("Error: Worldmap: Last level missing");
}
}
#endif
}
示例3: rand
Asteroid::Asteroid(int ast_size){
int i, gen, dots, interval, angle, radius, min_radius, delta_radius;
Asteroid* ast;
Dot d;
item = NULL;
dots = 3*pow(2,ast_size);
interval = 360/dots;
min_radius = 10*pow(2,ast_size);
delta_radius = 1.25*min_radius;
//Generating vertex
for(i=0; i<dots; i++){
angle = rand()%interval + i*interval;
radius = rand()%delta_radius + min_radius;
d.setX(radius*cos(angle*PI/180));
d.setY(radius*sin(angle*PI/180));
loop_vertex.push_back(d);
}
if(ast_size != SMALL){
//Generating subparts
gen = rand()%2+2;
while(gen>0){
ast = new Asteroid(ast_size-1);
d.setX(rand()%4-2);
d.setY(rand()%4-2);
ast->setSpeed(d);
parts.push_back(ast);
gen--;
}
}
if(ast_size == BIG){
//Generating item
gen = rand()%(NUM_ITEMS*3);
if(gen%3 == 0){
item = new Item(gen/3);
item->setSpeed(rand()%360, 0.25);
}
}
//Adjusting centroid
centralize();
//setColor(0, 1, (float)(BIG - ast_size)/BIG);
setColor(0, (GLfloat)(ast_size*0.125 + 0.75), (GLfloat)(0.25-ast_size*0.125));
setHandling(1);
if(rand()%2 == 0){
commands[TURN_LEFT] = true;
}
else{
commands[TURN_RIGHT] = true;
}
}
示例4: whichSide
float Dot::whichSide(Dot a, Dot b){
float xa = a.getX();
float ya = a.getY();
float xb = b.getX();
float yb = b.getY();
return (xa*yb - ya*xb + y*(xb-xa) + x*(ya-yb));
}
示例5: nearestCenter
void GraphicsScene::connectToNearest(Dot *start){
if(!centersPointers.isEmpty()){
Dot *end = nearestCenter(start);
QGraphicsItem *newConnection = new Connection(start->getPosPointer(),end->getPosPointer());
addItem(newConnection);
start->setConnection(((Connection*)newConnection));
update(QRectF(-50,-50,1000,1000));
}
}
示例6: randFloat
void ParticleEngineApp::update()
{
if (int(app::getElapsedFrames()) % 120 == 0) {
mDotLoc.x = randFloat(0.0f, app::getWindowWidth());
mDotLoc.y = randFloat(0.0f, app::getWindowHeight());
mDotCol = ColorA(randFloat(), randFloat(), randFloat(), 1.0f);
}
if (mIsPressed) {
mDot.addParticles(N_PARTICLES, mMouseLoc, mMouseVel);
}
mDot.update(mDotLoc, mDotCol);
}
示例7: main
int main( int argc, char* args[] ) {
//Start up SDL and create window
if( !init() ) {
printf( "Failed to initialize!\n" );
} else {
//Load media
if( !loadMedia() ) {
printf( "Failed to load media!\n" );
} else {
//Main loop flag
bool quit = false;
//Event handler
SDL_Event e;
//The dot that will be moving around on the screen
Dot dot;
//While application is running
while( !quit ) {
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 ) {
//User requests quit
if( e.type == SDL_QUIT ) {
quit = true;
}
//Handle input for the dot
dot.handleEvent( e );
}
//Move the dot
dot.move();
//Clear screen
SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
SDL_RenderClear( gRenderer );
//Render objects
dot.render();
//Update screen
SDL_RenderPresent( gRenderer );
}
}
}
//Free resources and close SDL
close();
return 0;
}
示例8: pingu_pos
void
Worldmap::draw(DrawingContext& gc)
{
Vector2i pingu_pos(static_cast<int>(pingus->get_pos().x),
static_cast<int>(pingus->get_pos().y));
int min, max;
int width = worldmap.get_width();
int height = worldmap.get_height();
if (width >= gc.get_width())
{
min = gc.get_width()/2;
max = width - gc.get_width()/2;
}
else
{
min = width - gc.get_width()/2;
max = gc.get_width()/2;
}
pingu_pos.x = Math::clamp(min, pingu_pos.x, max);
if (height >= gc.get_height())
{
min = gc.get_height()/2;
max = height - gc.get_height()/2;
}
else
{
min = height - gc.get_height()/2;
max = gc.get_height()/2;
}
pingu_pos.y = Math::clamp(min, pingu_pos.y, max);
gc_state.set_size(gc.get_width(), gc.get_height());
gc_state.set_pos(Vector2i(pingu_pos.x, pingu_pos.y));
gc_state.push(gc);
for (auto i = drawables.begin (); i != drawables.end (); ++i)
{
(*i)->draw(gc);
}
Vector2f mpos = gc_state.screen2world(Vector2i(mouse_x, mouse_y));
Dot* dot = path_graph->get_dot(mpos.x, mpos.y);
if (dot)
dot->draw_hover(gc);
gc_state.pop(gc);
}
示例9: QRectF
Dot* GraphicsScene::nearestCenter(Dot *dot){
double nearestDistance = QRectF(-50,-50,1000,1000).width();
Dot *nearestCenterPointer;
for(int i = 0; i < centersPointers.size(); i++){
Dot *center = centersPointers.at(i);
double newDistance = distance(dot->getPos(),center->getPos());
if(newDistance < nearestDistance){
nearestDistance = newDistance;
nearestCenterPointer = centersPointers.at(i);
}
}
return nearestCenterPointer;
}
示例10: get_position
SDL_Rect sword :: get_position(Dot myDot, Setup foo)
{
if(look_up)
{
box.x = myDot.box.x;
box.y = (myDot.box.y - le) + properHeight;
weaponsT.loadFromFile( "first_test12.bmp" );
}
else if(look_down && !myDot.is_onGround()) ///very much so temp--- this should be its own move, once i get moves sorted :D
{
box.x = myDot.box.x;
box.y = myDot.box.y + myDot.box.h;
weaponsT.loadFromFile( "first_test11.bmp" );
}
else
{
if(!direction)
{
box.x = myDot.box.x + trueWidth;
weaponsT.loadFromFile( "first_test10.bmp" );
}
else
{
box.x = (myDot.box.x - 128) + (128 - trueWidth);
weaponsT.loadFromFile( "first_test9.bmp" );
}
box.y = myDot.box.y + trueHeight/2;
return box;
}
}
示例11: get_position
SDL_Rect gun :: get_position(Dot myDot, Setup foo)
{
if(look_up)
{
box.x = myDot.box.x;
box.y = myDot.box.y;
weapons2T.loadFromFile( "first_test16.bmp" );
}
else if(look_down && !myDot.is_onGround()) ///very much so temp--- this should be its own move, once i get moves sorted :D
{
box.x = myDot.box.x;
box.y = myDot.box.y + (myDot.box.h - speed);
weapons2T.loadFromFile( "first_test15.bmp" );
}
else
{
if(!direction)
{
box.x = myDot.box.x + (trueWidth - speed);
weapons2T.loadFromFile( "first_test14.bmp" );
}
else
{
box.x = (myDot.box.x - 128) + (128 - trueWidth);
weapons2T.loadFromFile( "first_test13.bmp" );
}
box.y = myDot.box.y + trueHeight/2;
}
return box;
}
示例12: draw
void Polygon::draw(){
unsigned int i;
Dot d;
glLoadIdentity();
glTranslatef(position.getX(), position.getY(), 0);
glRotated(direction, 0, 0, 1);
glColor3f(color[RED], color[GREEN], color[BLUE]);
glBegin(GL_LINES);
for(i=0; i<lines_vertex.size(); i++){
d = lines_vertex.at(i);
glVertex2f(d.getX(), d.getY());
}
glEnd();
glBegin(GL_LINE_STRIP);
for(i=0; i<strip_vertex.size(); i++){
d = strip_vertex.at(i);
glVertex2f(d.getX(), d.getY());
}
glEnd();
glBegin(GL_LINE_LOOP);
for(i=0; i<loop_vertex.size(); i++){
d = loop_vertex.at(i);
glVertex2f(d.getX(), d.getY());
}
glEnd();
}
示例13: get_pingus
void
Worldmap::enter_level()
{
NodeId node = get_pingus()->get_node();
if (node != NoNode)
{
Dot* dot = path_graph->get_dot(node);
if (dot)
{
dot->on_click();
}
}
else
{
if (globals::developer_mode)
log_info("Worldmap: Pingus not on level");
}
}
示例14: Dot
void Picture::mousePressEvent(QMouseEvent *e)
{
if (e->button() == Qt::LeftButton) {
if (selectedPoints.size() < 8)
{
Dot* dot = new Dot(this);
dot->show();
update();
dot->move(e->x(), e->y());
Vector3i *newPoint = new Vector3i(e->x(), e->y(), 1);
selectedPoints.push_back(*newPoint);
}
else
{
double w = (double)boardDimensions->x();
double h = (double)boardDimensions->y();
double divisor = w;
if(w>h)
divisor = h;
w = ((double)boardDimensions->x()/divisor);
h = ((double)boardDimensions->y()/divisor);
realWorldPoints.push_back(Vector3d(0, 0, 1));
realWorldPoints.push_back(Vector3d(0, h, 1));
realWorldPoints.push_back(Vector3d(w, h, 1));
realWorldPoints.push_back(Vector3d(w, 0, 1));
// Calculate H Matrix
MatrixXd H = Utils::calculateHomographyMatrix(selectedPoints, realWorldPoints);
QImage inputImage = QImage("/home/fschuindt/dev/qt-persperctive-distortion-remotion/work-1/MyActions/brahma01.jpg");
QImage outputImage = Utils::applyHomography(H, inputImage, vector<Vector3i>(selectedPoints.begin()+4, selectedPoints.end()));
Utils::saveImage(outputImage, "/home/fschuindt/teste.jpg");
}
}
}
示例15: while
void GraphicsScene::updateConnections(){
int i = 0;
while(i<items().size()){
QGraphicsItem *activeItem = items().at(i);
if(((CustomItem*)activeItem)->getName() == std::string("Connection")){
removeItem(activeItem);
}
else{
i++;
}
}
i = 0;
while(i<items().size()){
QGraphicsItem *activeItem = items().at(i);
if(((CustomItem*)activeItem)->getName() == std::string("Dot")){
Dot *dot = ((Dot*)activeItem);
if(!dot->isCenter()){
connectToNearest(dot);
}
}
i++;
}
update(QRectF(-50,-50,1000,1000));
}