[ create a new paste ] login | about

Link: http://codepad.org/LmZpeq7H    [ raw code | fork ]

C++, pasted on Nov 25:
#include <cstdio>
#include <cmath>
#include "miniwin.h"
using namespace miniwin;

#define pi 3.1416

int main() {
    int i, numero = 2, run = 1;
    float x1, y1, x2, y2, ang, angi = 0;
    

    
    vredimensiona ( 640, 480 );
    
    do {
        //printf("bucle");
        ang = 360 / numero;
        x1 = 520;
        y1 = 240;
        
        //borra el contenido(imagenes) de la pantalla antes de pintar y refrescar
        borra();        
        
        //pinta el circulo
        circulo ( 320, 240, 200 );
        //pinta la linea, pinta el triangulo, quadrado, etc, etc, ...
        for ( i = 0; i <= numero ; i++ ) {
            //
            angi += ang;
            
            if ( angi >= 360 ) {
                angi = 0;
            }
            
            x2 = ceil ( ( ( 200 * cos ( ( angi * pi ) / 180 ) ) + 320 ) );
            y2 = ceil ( ( ( 200 * sin ( ( angi * pi ) / 180 ) ) + 240 ) );
            linea ( x1, y1, x2, y2 );
            
            
            
            x1 = x2;
            y1 = y2;

        }
        //solo cuando llega aqui se muestra los cambios al refrescar la pantalla
        refresca();        
        
        //funcion retorna la tecla pulsada en formato asc2
        int t = tecla();
        
        //si pulsas a
        if ( t == int ( 'A' ) ) {
            //eso grarante que numero no sea cero ya que peta el programa si a numero le asignamos cero
            if ( numero > 2 )
                numero--;
            angi = 0;
            
        }
        //si pulsas s
        if ( t == int ( 'S' ) ) {
            numero++;
            angi = 0;
        }
        
        //solo para fines de comprobacion
        //printf("%d", numero);
        
        if ( t == ESCAPE ) {
            run = 0;
        }

    } while ( run );

    return 0;
}


Create a new paste based on this one


Comments: