Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Spartacus

Pages: [1]
1
I just start it using CSFML in  school. So is completely new for me. Im trying to understand how it works.
Thank you.

2
I need to break this code into three pieces. Header file .h,  implementation file .c and the main file.
Thank you.

//include directive
#include <stdio.h>
#include <SFML/Graphics.h>


int main(void)
{
   
    // change the size of the window
    sfVideoMode mode = {200, 300, 32};
    sfRenderWindow* window;
    sfCircleShape* circle;
    sfSprite* sprite;
    sfEvent event;
   
    // allocates memory
    window = sfRenderWindow_create(mode, "Olti Asllanaj", sfResize | sfClose, NULL);
    if (!window)
        return 1;
   
    //create a circle to display
    circle = sfCircleShape_create();
    if(!circle)
        return 1;
   
    //changes the radius of the circle
    sfCircleShape_setRadius(circle, 100);
    //changes the color of the cicrcle
    sfCircleShape_setFillColor(circle, sfRed);
   
    // checks if the window is open
    while (sfRenderWindow_isOpen(window))
    {
       
        while (sfRenderWindow_pollEvent(window, &event))
        {
            // close window: exit
            if (event.type == sfEvtClosed)
                sfRenderWindow_close(window);
        }
       
        // Clear screen and change the color of the window
        sfRenderWindow_clear(window, sfBlack);
        sfRenderWindow_drawCircleShape(window, circle, NULL);
       
        //displaly window
        sfRenderWindow_display(window);
    }
    //destroy the window and the circle
    sfCircleShape_destroy(circle);
    sfRenderWindow_destroy(window);
   
    return 0;
}

Pages: [1]