/usr/include/mmpong/helpers.h is in libmmpong0.9-dev 0.9.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | /*
Copyright (C) 2008 Kai Hertel
This file is part of mmpong.
mmpong is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
mmpong is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with mmpong. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __HELPERS_HEADER__
#define __HELPERS_HEADER__
#include <math.h>
#include "game.h"
#include "dllhelper.h"
#ifdef __cplusplus
extern "C" {
#endif
EXPORT int bounce_ball_linear(struct gameplay *, float *, float *, float, float, float);
static inline int outside(ball)
const struct gameball *ball;
{
if ((ball->pos[0] < 0) || (ball->pos[1] < 0)) return (-1);
if ((ball->pos[0] > 1) || (ball->pos[1] > 1)) return 1;
return 0;
}
static inline float outby(val)
float val;
{
if (val < 0) return val;
if (val > 1) return val -1;
return 0;
}
static inline int hit(pad, pos)
const struct gamepaddle *pad;
float pos;
{
return (pad->mean - pad->size/2 <= pos) && (pad->mean + pad->size/2 >= pos);
}
static inline float distance(p,q)
const float p[2], q[2];
{
float scp= 0;
for (int idx= 0; idx< 2; idx++) {
float h= p[idx] - q[idx];
scp+= h * h;
}
return sqrtf(scp);
}
#ifdef __cplusplus
}
#endif
#endif
|