c++ – I can’t use allegro draw function in function on visual studio2022


(sorry for my bad english)
I want to create a pong game whit classes on c++. So i used classes and object using allegro5 as graphic library, i installed it whit the NutGen.
I create the class of the rectangle and the class of the ball, but i have an issues when i call their methods render. To make this project i used visual studio. The error is

Severity    Code    Description Project File    Line    Suppression State   Details
Error   LNK2019 unresolved external symbol __imp_al_draw_filled_circle referenced in function "public: void __cdecl Pallina::render(void)" (?render@Pallina@@QEAAXXZ)   Pong122 C:\Users\user\source\repos\Pong122\Pong122\Pallina.obj  1       

So the compiler don’t find the function al_draw_filled_circle, so how can i solve? it’s a problem of allegro or visual studio?

I creathed this class, it’s named pallina(it’s ball in italian)

Pallina.h

#pragma once
#include "Intestazione.h"
#include "Rectangle.h"

class Pallina
{
private:
    float x;
    float y;
    float ray;
    bool condx;
    bool condy;
        //CollisonSchreen it's used to make the ball bounce when touch the schreen
    collissionSchreen* scr;

public:
    ~Pallina();

    Pallina(collissionSchreen* schren);
    void movement(Rectangle p);
    void render();
};

Pallina.cpp


#include "Pallina.h"

Pallina::~Pallina() {
    delete scr;
}

Pallina::Pallina(collissionSchreen* schren) {
    x = schren->x / 2;
    y = schren->y1 / 2;
    condx = rand() % 1;
    condy = rand() % 1;
    scr = schren;
    ray = 10;
}


void Pallina::movement(Rectangle p)
{
    //Mov on x
    if (condx) {
        if (x + ray < scr->x) {
            x += MOVEMENTBALL;
        }
        else {
            condx = false;
        }
    }
    else {
        if (x - ray > p.getx2())
            x -= MOVEMENTBALL;

        else if ((x-ray) <= p.getx2() && (x+ray) > p.getx1() && (y-ray) > p.gety1() && (y+ray) < p.gety2()) {
            condx = true;
            p.gotaPoint();
        }

        else
            x -= MOVEMENTBALL;
    }

    //Mov on Y
    if (condy) {
        if (x + ray < scr->y1)
            x += MOVEMENTBALL;
        else
            condy = false;
    }
    else {
        if (x - ray > scr->y2)
            x -= MOVEMENTBALL;
        else
            condy = true;
    }
}

void Pallina::render(){
    al_draw_filled_circle(x,y,ray,al_map_rgb(255,255,255));
}

So what can i do?
(Edit)
I forgot to say all the other function work, but only the draw function in function i create cause the problem

Leave a Reply

Your email address will not be published. Required fields are marked *