int main() { vesa_fd = open("$vesa", O_RDONLY); struct vesa_setmode_req req = { WIDTH, HEIGHT, BITS_PER_PIXEL }; color_t color; int fd = open("$mouse", O_RDONLY); struct mousedata data; int ballX = WIDTH/2 - BALL_SIZE / 2; int ballY = HEIGHT/2 - BALL_SIZE /2; int velX = 10; int velY = 10; COLOR(color, BITS_PER_PIXEL).r = 255; COLOR(color, BITS_PER_PIXEL).g = 255; COLOR(color, BITS_PER_PIXEL).b = 255; ioctl(vesa_fd, SETMODE, &req); while (1) { // read mouse position read(fd, &data, sizeof(data)); data.y = 199 - data.y; data.x = data.x * WIDTH / 320; data.y = data.y * HEIGHT / 200; // draw ball and racket moveBall(&ballX,&ballY,&velX,&velY,data.y); drawBall(ballX,ballY,color); drawRacket(data.y,color); ioctl(vesa_fd, FLUSH, 0); usleep(10000); } return 0; }
void DrawGLScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(rtri,0.0f,-6.0f); glBegin(GL_POLYGON); glColor3f(1.0f,0.0f,0.0f); glVertex3f(-1.0f, 1.0f, 0.0f); glVertex3f(0.4f, 1.0f, 0.0f); glVertex3f(1.0f, 0.4f, 0.0f); glVertex3f( 1.0f,0.0f, 0.0f); glVertex3f(-1.0f,0.0f, 0.0f); glEnd(); drawBall(); rtri += 0.005f; // Increase The Rotation Variable For The Triangle if(rtri>2) rtri = -2.0f; rquad -= 15.0f; // Decrease The Rotation Variable For The Quad // swap the buffers to display, since double buffering is used. glutSwapBuffers(); }
int main() { vga_fd = open("/dev/vga", O_RDONLY); ioctl(vga_fd, SETVGAMODE, (void*)vga_mode_320x200x256); int fd = open("/dev/mouse", O_RDONLY); mousestate_t data; int ballX = WIDTH/2 - BALL_SIZE / 2; int ballY = HEIGHT/2 - BALL_SIZE /2; int velX = 10; int velY = 10; char color = 1; while (1) { clear_buffer(buffer); // read mouse position read(fd, &data, sizeof(data)); data.y = 199 - data.y; data.x = data.x * WIDTH / 320; data.y = data.y * HEIGHT / 200; // draw ball and racket moveBall(&ballX,&ballY,&velX,&velY,data.y); drawBall(ballX,ballY,color); drawRacket(data.y,color); ioctl(vga_fd, FLUSHVGA, buffer); usleep(10000); } return 0; }
void initializeGame(ball *aBall, paddle *p1, paddle *p2){ uint32_t blue = 0x000099; //black = 0x0; uint32_t gold = 0xffff00; //white = 0xffffff; aBall->x = START_BALL_X; aBall->y = START_BALL_Y; aBall->vX = -VEL_X; aBall->vY = 0; p1->x = START_PAD_1_X; p1->y = START_PAD_1_Y; p1->direction = IDLE; p2->x = START_PAD_2_X; p2->y = START_PAD_2_Y; p2->direction = IDLE; if ( (p1->score == 4) || (p2->score == 4) ){ p1->score = 0; p2->score = 0; } fill(blue); drawHalf(gold); drawScoreboard(p1,p2); drawPaddle(gold,START_PAD_1_Y,START_PAD_1_X); drawPaddle(gold,START_PAD_2_Y,START_PAD_2_X); drawBall(gold,aBall); startGP(); }
void TipsPainter::drawBallTraj(const BallTraj& traj, int queue_number) { if ((traj.trList.emptyTraj())||(traj.trList.count()==1)) return; //error QPen old = pen(); setTipTrajectoryPen(traj, queue_number); QListIterator<NaturalPoint> iter(traj.trList); QRealPoint item2 = iter.next(); QRealPoint item1(0,0); while(iter.hasNext()) { item1 = item2; item2 = iter.next(); drawLine(round(item1), round(item2)); } if (traj.type!=stepping) drawBall(Ball(round(item2),traj.radius,traj.type,0), true); if (!traj.velMarks.empty()) drawVelocityDots(traj); setPen(old); }
void Lines::paintEvent(QPaintEvent *e){ Q_UNUSED(e); QPainter qp(this); /*Create serial object */ try { // Make a SimpleSerial object with the parameter for your Wunderboard/OS this->tmp = this->wunder->readLine(); /*handles odd SimpleSerial Problems*/ if(this->tmp.length() != 3) adcval = MADC; //send it back to the middle else adcval = atoi(this->tmp.c_str()) - MADC ; } catch(boost::system::system_error& e) { std::cerr<<tmp<<": Error: "<<std::endl;//<<e.what()<<std::endl; } qp.setWindow(0,0, 800, 600); drawBoundary(&qp); drawPaddle(&qp); drawBall(&qp); drawBlocks(&qp); check_collision(); }
// sets old coordinates, checks for collisions, then sets new // coordinates based on collision data void updateBallPos() { // first get paddle position int paddlePos = getPaddlePosition(); if(onPaddle) { oldball.x = ball.x; oldball.y = ball.y; ball.x = paddlePos + (PADDLE_WIDTH / 2); } else { oldball.x = ball.x; oldball.y = ball.y; checkBallCollisions(paddlePos); ball.x += xdir*speed; ball.y += ydir*speed; } drawBall(); }
static void drawTurtleBody() { glColor3f(1,0,0); glPushMatrix(); glTranslatef(0,0,.5); glScalef(.36,.2,.24); drawBall(); glPopMatrix(); }
/* * BALL & PLAYER MOVEMENT */ void moveBallSprite(GameVars *gameVars){ //Reposition ball - check for events moveBall(gameVars); //Draw ball drawBall(gameVars->ball); }
void testBallMoves() { int startStateIndex, numStartStates; GravPngScoreChange scoreChange; #define NUM_START_STATES 10 StartState startStates[NUM_START_STATES] = { straightLeftPaddleNonTopCollision, noStartState, straightRightNonTopCollision, straightLeftPaddleRearCollision, straightRightPaddleRearCollision, straightRightPaddleBottomCollision, straightRightPaddleTopCollision, straightLeftPaddleTopCollision, straightLeftPaddleBottomCollision}; numStartStates = NUM_START_STATES; startStateIndex = 0; setupSpriteMemPtrs(); fillSpriteMem(); initGameObjects(startStates[startStateIndex]); drawBall(&ball); drawPaddleSprites(&paddleOne, &paddleTwo); printPaddle(&paddleTwo); printBall(&ball); printCourt(&court); while(1) { scoreChange = updatePongGame(&gPngGame); if(scoreChange == PLAYER_ONE_GOAL || scoreChange == PLAYER_TWO_GOAL) { flashScreen(); startStateIndex++; if(startStateIndex < numStartStates) { if(startStates[startStateIndex] == noStartState) { resetPongGame(&gPngGame); gPngGame.isPlayerOneHuman = true; } else { initGameObjects(startStates[startStateIndex]); } } else { return; } } if(startStates[startStateIndex] == noStartState) { handlePlayerInput(&gPngGame, true); //playerOneInput(&gPngGame); playerTwoInput(&gPngGame); } drawBall(&ball); drawPaddleSprites(&paddleOne, &paddleTwo); } }
static void drawTurtleHead() { glColor3f(0,1,0); glPushMatrix(); glTranslatef(-.43,0,.5); glScalef(.062,.016,.051); drawBall(); glPopMatrix(); glColor3f(0,1,0); glPushMatrix(); glTranslatef(.38,0,.5); glScalef(.03,.02,.02); drawBall(); glPopMatrix(); }
void main() { byte pattern[GHOST_WD] = {GHOST}; // Initialize the happy face pattern in memory ballStruct ball; //Initalize all the ball parameters ball.position.x = 5; ball.position.y = 5; ball.velocity.x = -1; ball.velocity.y = -1; ball.pattern = pattern; ball.width = GHOST_WD; ballStruct *ballPtr = &ball; // === Initialize system ================================================ IFG1=0; /* clear interrupt flag1 */ WDTCTL=WDTPW+WDTHOLD; /* stop WD */ init(); initNokia(); initInterrupt(); clearDisplay(); drawBall(ballPtr); while(1) { if(!(TACTL & (BIT5|BIT4))) // The program uses the Memory Control register to check if there is an inturrupt, an inturrupt has occured with the clock has stopped { clearDisplay(); moveBall(ballPtr); drawBall(ballPtr); TACTL |= MC_1; // Reset the Memory Control register to count up mode and resume (this process is fairly nice as it slows down the refresh speed) } } }
void updateFrame(uint32_t pY1, uint32_t pY2, uint32_t ballX, uint32_t ballY, ball *aBall, paddle *p1, paddle *p2){ uint32_t gold = 0xffff00; //white = 0xffffff; uint32_t blue = 0x000099; //black = 0x0; drawHalf(gold); drawScoreboard(p1,p2); drawPaddle(gold,pY1,START_PAD_1_X); drawPaddle(gold,pY2,START_PAD_2_X); drawBall(gold,aBall); startGP(); }
void calcBallPosition(ball *aBall, paddle *p1, paddle *p2){ uint32_t collisionType = isCollision(aBall,p1,p2); uint32_t blue = 0x000099; //black = 0x0; if (collisionType == P1){ if( p1->direction == UP ) { aBall->vY = aBall->vY - 1; aBall->vX = -aBall->vX; } else if( p1->direction == DOWN ) { aBall->vY = aBall->vY + 1; aBall->vX = -aBall->vX; } else if( p1->direction == IDLE ) { aBall->vY = aBall->vY; aBall->vX = -aBall->vX; } } else if (collisionType == P2){ if( p2->direction == UP ) { aBall->vY = aBall->vY - 1; aBall->vX = -aBall->vX; } else if( p2->direction == DOWN ) { aBall->vY = aBall->vY + 1; aBall->vX = -aBall->vX; } else if( p2->direction == IDLE ) { aBall->vY = aBall->vY; aBall->vX = -aBall->vX; } } ballInBounds(aBall); // erase ball drawBall(blue,aBall); // calculate new positions aBall->x = aBall->x + aBall->vX; aBall->y = aBall->y + aBall->vY; updateFrame(p1->y, p2->y, aBall->x, aBall->y, aBall, p1, p2); if ( !isXInBounds( aBall->x ) ) { if ( aBall->vX == VEL_X ) { p1->score = p1->score + 1; } else p2->score = p2->score + 1; initializeGame(aBall, p1, p2); } }
void locWmGlDisplay::DrawModel(const KF& model) { drawRobot(QColor(255,255,255,model.alpha*255), model.getState(KF::selfX), model.getState(KF::selfY), model.getState(KF::selfTheta)); if(drawSigmaPoints) { Matrix sigmaPoints = model.CalculateSigmaPoints(); for (int i=1; i < sigmaPoints.getn(); i++) { DrawSigmaPoint(QColor(255,255,255,model.alpha*255), sigmaPoints[KF::selfX][i], sigmaPoints[KF::selfY][i], sigmaPoints[KF::selfTheta][i]); } } drawBall(QColor(255,165,0,255), model.getState(KF::ballX), model.getState(KF::ballY)); }
void draw_pong() { y11 += velocityY1; y2 += velocityY2; px += velocityPx; py += velocityPy; drawPaddle1(y11); drawPaddle2(y2); drawBall(); delay(1); }
void BigPotUI::drawUI(uint8_t alpha, int time, int totoalTime, int volume) { this->_alpha = alpha; if (alpha == 0) return; //_win_w = engine_->getWindowsWidth(); //_win_h = engine_->getWindowsHeight(); engine_->getWindowSize(_win_w, _win_h); this->_time = time; this->_totoalTime = totoalTime; this->_volume = volume; drawBall(); drawText(convertTimeToString(time) + " / " + convertTimeToString(totoalTime)); }
void main() { int gd=0, gm=VGAHI; int i; struct ball b[10]; initgraph(&gd, &gm,"c:\\tc\\bgi\\"); for(i=1;i<=15;i++){ b[i].radius = rand()%20; b[i].x=rand()%getmaxx(); b[i].y=rand()%getmaxy(); b[i].dx=2; b[i].dy=4; } while(!kbhit()) { delay(5); cleardevice(); for(i=1;i<=15;i++) drawBall(&b[i],i); } closegraph(); }
void draw3Line(FastVoxelView &vv,Pos3D p1,Pos3D p2,Pos3D p3,Color c,int a,float s,float s2) { float fp=0,fa=1.0/a; int ip; Pos3D mp(0,0,0); // cdebug(p1<<p2<<p3); for(ip=0;ip<=a;ip++) { float ms=(1-fp)*s+fp*s2; mp=bezier(fp,p1,p2,p3); // cdebug(mp<<"//"<<fp<<"//"<<ms); drawBall(vv,mp,ms,c); fp+=fa; } }
void drawSpriteSel(uchar x, uchar y, uchar s, uchar c, uchar t) { uchar* d; if(t==1) { d = cellAddr(x, y)-1; SET_COLOR(COLOR_BLUE); d[14] = 0x55; d[0x100+14] = 0x55; drawBall1(d, selAnimation[t], s); } else { drawBall(x, y, selAnimation[t], s); } if(c) drawCursor(); if(t==3) sound(1, 10); }
void drawWinnerBlur() { drawRectangle(width,height); drawComponents(); drawBoundary(width,height); calcScore(); drawLeftBlock(x[1],y[1],height); drawRightBlock(x[2],y[2],height); drawBall(x[0],y[0],radius,radius); if(scoreRight==7) { glColor4d(1,1,1,0.7); glBegin(GL_POLYGON); glVertex2d(width/2,0); glVertex2d(width,0); glVertex2d(width,height); glVertex2d(width/2,height); glEnd(); glColor4d(0,0,0,0.7); glBegin(GL_POLYGON); glVertex2d(0,0); glVertex2d(width/2,0); glVertex2d(width/2,height); glVertex2d(0,height); glEnd(); }else { glColor4d(1,1,1,0.7); glBegin(GL_POLYGON); glVertex2d(0,0); glVertex2d(width/2,0); glVertex2d(width/2,height); glVertex2d(0,height); glEnd(); glColor4d(0,0,0,0.7); glBegin(GL_POLYGON); glVertex2d(width/2,0); glVertex2d(width,0); glVertex2d(width,height); glVertex2d(width/2,height); glEnd(); } }
void renderScene(void) { unsigned short i; if (deltaMove) moveMeFlat(deltaMove); if (deltaAngle) { angle += deltaAngle; orientMe(angle); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Draw ground glColor3f(0.9f, 0.9f, 0.9f); glBegin(GL_QUADS); glVertex3f(-100.0f, 0.0f, -100.0f); glVertex3f(-100.0f, 0.0f, 100.0f); glVertex3f( 100.0f, 0.0f, 100.0f); glVertex3f( 100.0f, 0.0f, -100.0f); glEnd(); for (i = 0; i < numParticulas; i++){ // printf("%f - %f X %f - %f\n", lista[i]->x, lista[i]->z, x, z); // glPushMatrix(); glTranslatef(lista[i]->x, 0, lista[i]->z); // glCallList(snowman_display_list);; drawBall(); glTranslatef(-lista[i]->x, 0, -lista[i]->z); moveParticula(lista[i]); glPopMatrix(); } // Draw 36 SnowMen for(int i = 0; i < 36; i++){ //if (boneco[i].live){ glPushMatrix(); glTranslatef(boneco[i].x,0,boneco[i].z); glCallList(boneco[i].dl);; glTranslatef(-boneco[i].x,0,-boneco[i].z); glPopMatrix(); } glutSwapBuffers(); }
void render() { // Clear frame buffer and depth buffer glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); glColor3f(1.0,1.0,1.0); setOrtho(); glPushMatrix(); drawMiddleLine(); drawPaddle(100,startX); drawPaddle(1280-100,startY); drawBall(ballX,ballY); glPopMatrix(); glFlush(); glutSwapBuffers(); }
void breakoutDraw() { clear(); drawPaddle(paddle); drawBall(ball); u8 row; u8 col; for(row=0; row < FIELD_HEIGHT; ++row) { for(col=0; col < FIELD_WIDTH; ++col) { if(bricks[(row*FIELD_WIDTH) + col].alive) drawBrick(row, col, bricks[(row*FIELD_WIDTH) + col]); } } render(); }
/*** シミュレーションループ ***/ static void simLoop(int pause) { if (!pause) { dSpaceCollide(space,0,&nearCallback); // add control(); dWorldStep(world, 0.01); dJointGroupEmpty(contactgroup); // add } const dReal *linear_vel = dBodyGetLinearVel(base.body); const dReal *angular_vel = dBodyGetAngularVel(base.body); printf("linear : %.3f %.3f %.3f\n", linear_vel[0], linear_vel[1], linear_vel[2]); printf("angular: %.3f %.3f %.3f\n", angular_vel[0], angular_vel[1], angular_vel[2]); drawBase(); drawWheel(); // add drawBall(); //add drawGoal(); }
void drawBall(double tempX, double tempY, int tempR,int radius) { if(tempR==radius/2+3 || tempR==radius-radius/4 || tempR==radius-radius/4+1) glColor3d(0.8,0.8,0.8); else glColor3d(0,0,0); glPointSize(1); if(tempR>=0) { double angle,i; glBegin(GL_POINTS); for(i=0;i<360;i++) { angle=i*(M_PI/180); glVertex2d(tempX+(tempR*cos(angle)),tempY+(tempR*sin(angle))); } glEnd(); drawBall(tempX, tempY,tempR-1,radius); } }
void AttitudeIndicatorPlugin::Draw(double x, double y, double scale) { glPushAttrib(GL_ALL_ATTRIB_BITS); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, canvas_->width(), canvas_->height(), 0, -1.0f, 1.0f); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); // Setup coordinate system so that we have a [-1,1]x[1,1] cube on // the screen. QRect rect = placer_.rect(); double s_x = rect.width() / 2.0; double s_y = -rect.height() / 2.0; double t_x = rect.right() - s_x; double t_y = rect.top() - s_y; double m[16] = { s_x, 0, 0, 0, 0, s_y, 0, 0, 0, 0, 1.0, 0, t_x, t_y, 0, 1.0}; glMultMatrixd(m); // Placed in a separate function so that we don't forget to pop the // GL state back. drawBackground(); drawBall(); drawPanel(); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopAttrib(); PrintInfo("OK!"); }
void drawPauseSpace() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0,0,0,0); drawRectangle(width,height); drawComponents(); drawBoundary(width,height); calcScore(); drawLeftBlock(x[1],y[1],height); drawRightBlock(x[2],y[2],height); drawBall(x[0],y[0],radius,radius); glColor4d(1,1,1,0.7); glBegin(GL_POLYGON); glVertex2d(-50,-50); glVertex2d(width+50,-50); glVertex2d(width+50,height+100); glVertex2d(-50,height+100); glEnd(); }
int main() { int gDriver=DETECT,gMode=0,i; initgraph(&gDriver,&gMode,"C:\\TC\\BGI"); float rad=0.01; int string_bottom_x,string_bottom_y; int ball_x,ball_y,sign=1; background(); drawString(320,300); eraseString(320,300); //drawBall(320,320); for(rad=0.01;rad<T;rad+=(sign*0.01)) { string_bottom_y=cos(rad)*L; string_bottom_x=sin(rad)*L; ball_y=cos(rad)*(L+20); ball_x=sin(rad)*(L+20); //cout<<"("<<ball_x<<"|"<<ball_y<<")"; drawString(320-string_bottom_x,100+string_bottom_y); drawBall(320-ball_x,100+ball_y); delay(60); eraseString(320-string_bottom_x,100+string_bottom_y); eraseBall(320-ball_x,100+ball_y); if(ball_y==190&&ball_x==109) { sign=-1; } if(ball_y==190&&ball_x==-109) { sign=1; //getch(); } } getch(); return 0; }
void Ball::drawGameBall() const { activateBallShader(); { //glPushMatrix(); { //glTranslatef(mPos.x, mPos.y, mPos.z); //glScalef(mRadius, mRadius, mRadius); quaternionTransform(mOrientation); /* explosion? */ if (mIsBallInPieces) { drawExplosion(); } else { drawBall(); } } //glPopMatrix(); } deactivateBallShader(); }