| 1 | /** |
| 2 | * Copyright (c) 2006-2023 LOVE Development Team |
| 3 | * |
| 4 | * This software is provided 'as-is', without any express or implied |
| 5 | * warranty. In no event will the authors be held liable for any damages |
| 6 | * arising from the use of this software. |
| 7 | * |
| 8 | * Permission is granted to anyone to use this software for any purpose, |
| 9 | * including commercial applications, and to alter it and redistribute it |
| 10 | * freely, subject to the following restrictions: |
| 11 | * |
| 12 | * 1. The origin of this software must not be misrepresented; you must not |
| 13 | * claim that you wrote the original software. If you use this software |
| 14 | * in a product, an acknowledgment in the product documentation would be |
| 15 | * appreciated but is not required. |
| 16 | * 2. Altered source versions must be plainly marked as such, and must not be |
| 17 | * misrepresented as being the original software. |
| 18 | * 3. This notice may not be removed or altered from any source distribution. |
| 19 | **/ |
| 20 | |
| 21 | #include "wrap_CircleShape.h" |
| 22 | |
| 23 | namespace love |
| 24 | { |
| 25 | namespace physics |
| 26 | { |
| 27 | namespace box2d |
| 28 | { |
| 29 | |
| 30 | CircleShape *luax_checkcircleshape(lua_State *L, int idx) |
| 31 | { |
| 32 | return luax_checktype<CircleShape>(L, idx); |
| 33 | } |
| 34 | |
| 35 | int w_CircleShape_getRadius(lua_State *L) |
| 36 | { |
| 37 | CircleShape *c = luax_checkcircleshape(L, 1); |
| 38 | lua_pushnumber(L, c->getRadius()); |
| 39 | return 1; |
| 40 | } |
| 41 | |
| 42 | int w_CircleShape_setRadius(lua_State *L) |
| 43 | { |
| 44 | CircleShape *c = luax_checkcircleshape(L, 1); |
| 45 | float r = (float)luaL_checknumber(L, 2); |
| 46 | c->setRadius(r); |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | int w_CircleShape_getPoint(lua_State *L) |
| 51 | { |
| 52 | CircleShape *c = luax_checkcircleshape(L, 1); |
| 53 | float x, y; |
| 54 | c->getPoint(x, y); |
| 55 | lua_pushnumber(L, x); |
| 56 | lua_pushnumber(L, y); |
| 57 | return 2; |
| 58 | } |
| 59 | |
| 60 | int w_CircleShape_setPoint(lua_State *L) |
| 61 | { |
| 62 | CircleShape *c = luax_checkcircleshape(L, 1); |
| 63 | c->setPoint((float) luaL_checknumber(L, 2), (float) luaL_checknumber(L, 3)); |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | static const luaL_Reg w_CircleShape_functions[] = |
| 68 | { |
| 69 | { "getRadius" , w_CircleShape_getRadius }, |
| 70 | { "setRadius" , w_CircleShape_setRadius }, |
| 71 | { "getPoint" , w_CircleShape_getPoint }, |
| 72 | { "setPoint" , w_CircleShape_setPoint }, |
| 73 | { 0, 0 } |
| 74 | }; |
| 75 | |
| 76 | extern "C" int luaopen_circleshape(lua_State *L) |
| 77 | { |
| 78 | return luax_register_type(L, &CircleShape::type, w_Shape_functions, w_CircleShape_functions, nullptr); |
| 79 | } |
| 80 | |
| 81 | } // box2d |
| 82 | } // physics |
| 83 | } // love |
| 84 | |