c++-Raylib为什么我的矩形列不能工作?
发布时间:2022-06-24 07:39:54 193
相关标签: # golang
这是一张图片:https://i.stack.imgur.com/q5Th5.png
这是我的密码
struct Mat
{
float X, Y;
float SpeedX, SpeedY;
float Force;
float Gravity;
Vector2 MousePos;
Vector2 size;
Color color;
Rectangle GetShape() {
return Rectangle{ MousePos.x, MousePos.y, size.x, size.y };
}
void DrawMat() {
DrawRectangleRec(GetShape(), color);
MousePos.y += 9.81f;
if (MousePos.y < 0) {
MousePos.y *= -1;
}
else if (MousePos.y > GetScreenHeight() - size.y) {
MousePos.y = GetScreenHeight() - size.y;
}
}
};
int main() {
InitWindow(800, 600, "Speed Z Presends to you... Satisfiying, Amazing, Niffty, Dreamy. SIMULATOR");
SetWindowState(FLAG_VSYNC_HINT);
Mat Sand;
Sand.MousePos = { -100, -100 };
Sand.size = { 5, 5 };
Sand.color = YELLOW;
Sand.X = Sand.MousePos.x;
Sand.Y = Sand.MousePos.y;
Sand.SpeedX = 300;
Sand.SpeedY = 500;
Mat Brick;
Brick.MousePos = { -100, -100 };
Brick.size = { 5, 5 };
Brick.color = RED;
Vector2 Mousepos = {-100, -100};
bool Mouseclicked = false;
Vector2 RectSize = { 2, 2 };
int Numof = 0;
std::vector positions = {};
while (!WindowShouldClose())
{
if (CheckCollisionRecs(Sand.GetShape() , Brick.GetShape()))
{
Sand.color = GREEN;
}
BeginDrawing();
ClearBackground(BLACK);
for (size_t i = 0; i < positions.size(); i++)
{
positions[i].DrawMat();
}
if (IsKeyPressed(KEY_ONE)) {
Numof = 1;
}
if (Numof == 1)
{
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
{
Mouseclicked = true;
Mousepos = GetMousePosition();
Sand.MousePos = GetMousePosition();
positions.push_back(Sand);
}
}
if (IsKeyPressed(KEY_TWO)) {
Numof = 2;
}
if (Numof == 2) {
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
{
Mouseclicked = true;
Mousepos = GetMousePosition();
Brick.MousePos = GetMousePosition();
positions.push_back(Brick);
}
}
DrawFPS(10, 10);
EndDrawing();
CloseWindow();
}
return 0;
}
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报