Add function to compare colors

This commit is contained in:
Amine B. Hassouna
2018-11-29 21:10:16 +01:00
parent d46a8ad54a
commit 93b2fab53e
2 changed files with 10 additions and 0 deletions

View File

@@ -31,6 +31,8 @@
#ifndef UTILS_H
#define UTILS_H
#include <stdbool.h>
#include <SDL2/SDL.h>
@@ -63,4 +65,6 @@ long long Utils_time();
void Utils_randInit();
int Utils_rand(int min, int max);
bool Utils_equalColors(SDL_Color color1, SDL_Color color2);
#endif // UTILS_H

View File

@@ -72,3 +72,9 @@ int Utils_rand(int min, int max)
{
return ( rand() % (max + 1) ) + min;
}
bool Utils_equalColors(SDL_Color color1, SDL_Color color2)
{
//return color1.r == color2.r && color1.g == color2.g && color1.b == color2.b && color1.a == color2.a;
return *((Sint32 *) &color1) == *((Sint32 *) &color2);
}