Rotação Simples - Galeria de Exemplos
Rotação Simples

Descrição: Este exemplo demonstra como fazer a rotação de um objeto.

Autor: Edirlei Soares de Lima

Download: Exemplos12.zip

 

Código Fonte:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "Graphics.h"
Graphics graphics;
float rotation_angle = 0;
int rotation_speed = 120;
void MainLoop()
{  
    rotation_angle += rotation_speed * graphics.GetElapsedTime();
    if (rotation_angle > 360)
        rotation_angle = 0;
    graphics.RotateBegin(rotation_angle);
    graphics.FillRectangle2D(300, 200, 500, 400);
    graphics.RotateEnd();
}
int main(void)
{
    graphics.CreateMainWindow(800, 600, "Exemplo 12 - Rotação");
    graphics.SetBackgroundColor(0,0,0);
    graphics.SetColor(35, 191, 27);
        
    graphics.SetMainLoop(MainLoop);
    graphics.StartMainLoop();
    return 0;
}