Help - Error - Assertion failed: rx >= 0...
ryan lee

Can anyone help me with what this might mean.. the program works fine until I add a some code c++ using Allegro 5 I a debug error:

Debug error R6010 - Abort() has been called

Assertion failed: rx >= 0, file allegro-git\addons\primitives\high_primitives.c, line 944

this is the code that I'm inserting that seems to cause the problem. To save me inserting my full main file I have just snipped this code, obviously when i'm using it I'm putting the code in all the right places.

Complete newbie here and any help would be massively appreciated! Thanks

[code]
void InitFASTCAR(FASTCAR &fastcarr);
void DrawFASTCAR(FASTCAR &fastcarr);
void StartFASTCAR(FASTCAR &fastcarr);
void UpdateFASTCAR(FASTCAR &fastcarr);

FASTCAR fastcarr;

InitFASTCAR(fastcarr);

StartFASTCAR(fastcarr);
UpdateFASTCAR(fastcarr);

DrawFASTCAR(fastcarr);

void InitFASTCAR(FASTCAR &fastcarr)
{
fastcarr.ID = FC;
fastcarr.live = false;
fastcarr.speed = 8;
fastcarr.boundx = 35;
fastcarr.boundy = 25;
}
void DrawFASTCAR(FASTCAR &fastcarr)
{
al_draw_filled_rounded_rectangle(fastcarr.x, fastcarr.y, fastcarr.x +70, fastcarr.y +50, fastcarr.x - 4,fastcarr.y - 4,al_map_rgb(255,0,0));

al_draw_filled_rounded_rectangle(fastcarr.x, fastcarr.y, fastcarr.x +70, fastcarr.y +50, fastcarr.x - 4,fastcarr.y - 4,al_map_rgb(50,50,50));
}
void StartFASTCAR(FASTCAR &fastcarr)
{
if(!fastcarr.live)
{
if(rand() % 500 == 0)
{
fastcarr.live = true;
fastcarr.x = width;
fastcarr.y = 30 + rand() % (height - 60);
}
}
}

void UpdateFASTCAR(FASTCAR &fastcarr)
{

if(fastcarr.live)
{
fastcarr.x -= fastcarr.speed;

if(fastcarr.x < 0)
fastcarr.live = false;


}

}
[/code]

Jeff Bernard

al_draw_filled_rounded_rectangle parameter rx and ry must be greater than zero.

// Are you sure you want variable radii here?
al_draw_filled_rounded_rectangle(fastcarr.x, fastcarr.y, fastcarr.x +70, fastcarr.y +50, fastcarr.x - 4,fastcarr.y - 4,al_map_rgb(255,0,0));

ryan lee

Aha! Your a legend thank you so much! I've just changed it to a normal rectangle as I can't really figure out the rounded thing for now!

Thanks again! ;D

Jeff Bernard

Imagine a rounded rectangle was a normal rectangle, but with 4 ovals instead of the corners. The parameters rx and ry are the horizontal and vertical radii of the ovals. So increasing those parameters would put larger ovals on the corners, so the corners would be more round.

ryan lee

Ah I see, so I wouldn't need to use my 'object's' x and y position variables, just a single number?

Edgar Reynaldo

Imagine an ellipse with the specified radii, and then cut it in four and put it on the corners of the rectangle. hradius and vradius must be less than half the width and height respectively.

Thread #612644. Printed from Allegro.cc