JUST SHARE, LEARN, TOGETHER, LET'S RAWKER

Selasa, 24 Mei 2016

Membuat objek lingkaran sederhana (Papan Panah)

#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <glut.h>
#include<math.h>
using namespace std;

void lingkaran(    int r,int x0, int y0,int point){
    glBegin(GL_POLYGON);
    float phi=3.14;
    for(int i=1;i<=360;i++){
        float sudut=i*(2*phi/point);
        float x=x0+r*cos(sudut);
        float y=y0+r*sin(sudut);
        glVertex2f(x/100,y/100);
    }
    glEnd();
    glFlush();
}
void tampil(){
    //Papan panah
    int i=42;
    while(i>0){
        if(i%2==0){
            glColor3f (1.0, 0.0, 1.0);
        }else{
            glColor3f (0.1, 0.0, 1.0);
        }
        lingkaran(i,0,0,90);
        i=i-3;
    }   
}
int main(int argc, char **argv){
glutCreateWindow("PAPAN PANAH");
glClear(GL_COLOR_BUFFER_BIT);
glutDisplayFunc(tampil);
glutMainLoop();
return 0;
}
RUN :


Share:

0 komentar:

Posting Komentar

Popular Posts

Copyright © Diantarawk! | Powered by Blogger

Design by ThemePacific | Blogger Theme by NewBloggerThemes.com