我打算制作一款游戏,我想为这款游戏制作一些背景动画.其中一个动画是旋转矩形.我看了一遍,我找不到任何形式的数学或逻辑,允许我旋转一个矩形(SDL_Rect是具体的,但你可能已经知道).
我无法弄清楚自己的数学,我真的没有任何工作代码,所以我无法显示任何东西.
基本上我正在寻找某种类型的逻辑,我可以应用矩形的坐标,这样每当主游戏循环循环时,它将旋转矩形一定程度的度数.
我正在为我的项目创建基本的单元测试。出于某种原因,在测试我是否收到ControllerBase.Problem(String, String, Nullable<Int32>, String, String)
响应时,我不断收到 NullReferenceException 。我确定问题是与控制器实际运行不符,因为当控制器运行时它似乎表现得非常好。
控制器:
[HttpGet("{id}")]
[Produces("application/json")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public IActionResult GetPatient([GuidNotEmpty] Guid id)
{
Patient patient = null;
patient = _patientDbService.FindPatient(id);
if (patient == null) {
return Problem("Patient not found.", string.Empty, StatusCodes.Status404NotFound,
"An error occurred.", "https://tools.ietf.org/html/rfc7231#section-6.5.1");
}
return Ok(patient);
}
Run Code Online (Sandbox Code Playgroud)
测试:
[Fact]
public void TestGetPatientFromIdPatientNotFound()
{
// Act
IActionResult result = _patientController.GetPatient(Guid.NewGuid());
// Assert
Assert.IsType<ObjectResult>(result);
Assert.NotNull(((ObjectResult)result).Value);
Assert.IsType<ProblemDetails>(((ObjectResult)result).Value);
Assert.Equal(((ObjectResult)result).StatusCode, StatusCodes.Status404NotFound);
}
Run Code Online (Sandbox Code Playgroud)
结果:
X PatientServiceTest.PatientServiceUnitTest.TestGetPatientFromIdPatientNotFound [1ms]
Error Message:
System.NullReferenceException : Object reference not set to …
Run Code Online (Sandbox Code Playgroud) 对于我正在编写的一些代码,我有一个函数指针.我使用它已经有一段时间了,但我不知道是否需要显式释放指针.这是我的代码的简化版本
struct Person
{
void (*action) ();
}
void action()
{
printf("Action has been called\n");
}
int main()
{
Person p;
p->action = &action;
// My question is whether or not I need to do this
// free (p->action);
// p->action = NULL;
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
c++ ×2
.net-core ×1
asp.net-core ×1
c ×1
c# ×1
rectangles ×1
rotation ×1
sdl ×1
unit-testing ×1