void updateNrender(){ float a, b; float time; u32 ms; getTimeElapsed(&ms); time = ms / 1000.f; getMousePosition(&a, &b); paddleX = s2p(a); paddleRot = s2p(b); static float rotate = 0; static float vx = 0, vy = -1, px = 0, py = 0, av =0; static char hasBounced = 0; rotate += av*time; px += time*vx, py += time*vy; square_rotateTo(ball, rotate); square_traslateTo(ball, px, py); square_traslateTo(paddle, paddleX, paddleY); square_rotateTo(paddle, paddleRot); squareList_update_pos(Sprites.squareList, buffer); //CHECK COLLISION :) if(hasBounced!= 1 && px <-1){ bounce(TAU/4, &vx, &vy, &av, 1.);hasBounced = 1; } if(hasBounced!=2 && px> 1){ bounce(-TAU/4, &vx, &vy, &av, 1.);hasBounced = 2;} if(hasBounced!=3 && py >1){ bounce(-TAU/2, &vx, &vy, &av, 1.); hasBounced = 3; } if(py <-1){ game_die(); } if(hasBounced!=4 && px<= paddleX+0.4 && px>=paddleX-0.4 && py<=paddleY+0.05 && py>=paddleY-0.05) { bounce(3/4*TAU-paddleRot, &vx, &vy, &av, 1.2); hasBounced = 4; score++; } puun_MouseClick click; getMouseClick(&click); puun_KEY key; getKeyboardKey(&key); if(click) printf("MOUSE CLICKED\n"); if(key.isPressed) printf("%c\n", key.key); glClearColor(1.0, 1.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); renderSpriteList(Sprites); //uniImg.id = ballId; //uniImg.texnum = 0; //render_squareList(Squares, (Data)&uniImg, 1); puun_SWAP_BUFFERS(); //SDL_GL_SwapBuffers(); }
bool FormatGRO::load(string file) { p.clear(); v.resize(0); if (IO::readFile(file,v)==true) { int last=atoi(v[1].c_str())+1; for (int i=2; i<=last; i++) p.push_back( s2p(v[i]) ); return true; } return false; }
bool FormatAAM::load(string file) { vector<string> v; p.clear(); if (IO::readFile(file,v)==true) { IO::strip(v,"#"); unsigned int n=atoi(v[0].c_str()); for (unsigned int i=1; i<=n; i++) p.push_back( s2p(v.at(i)) ); return true; } return false; }
QvisLineStyleWidget::QvisLineStyleWidget(int style, QWidget *parent) : QWidget(parent) { // Create some pixmaps and store them in the application global // pixmap cache. QPixmap style1Pixmap; if(!QPixmapCache::find("visit_gui_linestyle1", style1Pixmap)) { AugmentPixmap(style1); QPixmap s1p((const char **)augmentedData); QPixmapCache::insert("visit_gui_linestyle1", s1p); style1Pixmap = s1p; } QPixmap style2Pixmap; if(!QPixmapCache::find("visit_gui_linestyle2", style2Pixmap)) { AugmentPixmap(style2); QPixmap s2p((const char **)augmentedData); QPixmapCache::insert("visit_gui_linestyle2", s2p); style2Pixmap = s2p; } QPixmap style3Pixmap; if(!QPixmapCache::find("visit_gui_linestyle3", style3Pixmap)) { AugmentPixmap(style3); QPixmap s3p((const char **)augmentedData); QPixmapCache::insert("visit_gui_linestyle3", s3p); style3Pixmap = s3p; } QPixmap style4Pixmap; if(!QPixmapCache::find("visit_gui_linestyle4", style4Pixmap)) { AugmentPixmap(style4); QPixmap s4p((const char **)augmentedData); QPixmapCache::insert("visit_gui_linestyle4", s4p); style4Pixmap = s4p; } // Create the combo box and add the pixmaps to it. QHBoxLayout *topLayout = new QHBoxLayout(this); topLayout->setMargin(0); lineStyleComboBox = new QComboBox(this); lineStyleComboBox->addItem(QIcon(style1Pixmap), "solid"); lineStyleComboBox->addItem(QIcon(style2Pixmap), "dash"); lineStyleComboBox->addItem(QIcon(style3Pixmap), "dash/dot"); lineStyleComboBox->addItem(QIcon(style4Pixmap), "dotted"); lineStyleComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); lineStyleComboBox->setCurrentIndex(style); topLayout->addWidget(lineStyleComboBox); connect(lineStyleComboBox, SIGNAL(activated(int)), this, SIGNAL(lineStyleChanged(int))); }
/* ---------------------------------------------------------------------------- * Reads a child node's value, and uses it to set a variable. * Will not do anything if the child's value is empty. * child: Name of the child node. * var: The var to set. This is a point. */ void reader_setter::set(const string &child, point &var) { string s = node->get_child_by_name(child)->value; if(s.empty()) return; var = s2p(s); }
QvisLineWidthWidget::QvisLineWidthWidget(int width_, QWidget *parent) : QWidget(parent) { // Create some pixmaps and store them in the application global // pixmap cache. QPixmap style1Pixmap; if(!QPixmapCache::find("visit_gui_linewidth1", style1Pixmap)) { AugmentPixmap(style1); QPixmap s1p((const char **)augmentedData); QPixmapCache::insert("visit_gui_linewidth1", s1p); style1Pixmap = s1p; } QPixmap style2Pixmap; if(!QPixmapCache::find("visit_gui_linewidth2", style2Pixmap)) { AugmentPixmap(style2); QPixmap s2p((const char **)augmentedData); QPixmapCache::insert("visit_gui_linewidth2", s2p); style2Pixmap = s2p; } QPixmap style3Pixmap; if(!QPixmapCache::find("visit_gui_linewidth3", style3Pixmap)) { AugmentPixmap(style3); QPixmap s3p((const char **)augmentedData); QPixmapCache::insert("visit_gui_linewidth3", s3p); style3Pixmap = s3p; } QPixmap style4Pixmap; if(!QPixmapCache::find("visit_gui_linewidth4", style4Pixmap)) { AugmentPixmap(style4); QPixmap s4p((const char **)augmentedData); QPixmapCache::insert("visit_gui_linewidth4", s4p); style4Pixmap = s4p; } QPixmap style5Pixmap; if(!QPixmapCache::find("visit_gui_linewidth5", style5Pixmap)) { AugmentPixmap(style5); QPixmap s5p((const char **)augmentedData); QPixmapCache::insert("visit_gui_linewidth5", s5p); style5Pixmap = s5p; } QPixmap style6Pixmap; if(!QPixmapCache::find("visit_gui_linewidth6", style6Pixmap)) { AugmentPixmap(style6); QPixmap s6p((const char **)augmentedData); QPixmapCache::insert("visit_gui_linewidth6", s6p); style6Pixmap = s6p; } QPixmap style7Pixmap; if(!QPixmapCache::find("visit_gui_linewidth7", style7Pixmap)) { AugmentPixmap(style7); QPixmap s7p((const char **)augmentedData); QPixmapCache::insert("visit_gui_linewidth7", s7p); style7Pixmap = s7p; } QPixmap style8Pixmap; if(!QPixmapCache::find("visit_gui_linewidth8", style8Pixmap)) { AugmentPixmap(style8); QPixmap s8p((const char **)augmentedData); QPixmapCache::insert("visit_gui_linewidth8", s8p); style8Pixmap = s8p; } QPixmap style9Pixmap; if(!QPixmapCache::find("visit_gui_linewidth9", style9Pixmap)) { AugmentPixmap(style9); QPixmap s9p((const char **)augmentedData); QPixmapCache::insert("visit_gui_linewidth9", s9p); style9Pixmap = s9p; } QPixmap style10Pixmap; if(!QPixmapCache::find("visit_gui_linewidth10", style10Pixmap)) { AugmentPixmap(style10); QPixmap s10p((const char **)augmentedData); QPixmapCache::insert("visit_gui_linewidth10", s10p); style10Pixmap = s10p; } // Create the combo box and add the pixmaps to it. QHBoxLayout *topLayout = new QHBoxLayout(this); topLayout->setMargin(0); topLayout->setSpacing(0); lineWidthComboBox = new QComboBox(this); lineWidthComboBox->addItem(QIcon(style1Pixmap),"1"); lineWidthComboBox->addItem(QIcon(style2Pixmap),"2"); lineWidthComboBox->addItem(QIcon(style3Pixmap),"3"); lineWidthComboBox->addItem(QIcon(style4Pixmap),"4"); lineWidthComboBox->addItem(QIcon(style5Pixmap),"5"); lineWidthComboBox->addItem(QIcon(style6Pixmap),"6"); lineWidthComboBox->addItem(QIcon(style7Pixmap),"7"); lineWidthComboBox->addItem(QIcon(style8Pixmap),"8"); lineWidthComboBox->addItem(QIcon(style9Pixmap),"9"); lineWidthComboBox->addItem(QIcon(style10Pixmap),"10"); lineWidthComboBox->setCurrentIndex(width_); topLayout->addWidget(lineWidthComboBox); connect(lineWidthComboBox, SIGNAL(activated(int)), this, SIGNAL(lineWidthChanged(int))); }
void updateMouse(int x, int y) { paddleX = s2p(x); paddleRot = s2p(y); }