i am trying to make sand simulation but u get stack overflow Eror:
Unhandled exception at 0x00007FF66B384BD7 in Project2.exe: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x000000D975E03000).
And that is my code:
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <vector>
#include <iostream>
#include <Windows.h>
using std::vector;
const int Width = 1000;
const int Height = 800;
int main() {
sf::RenderWindow window(sf::VideoMode(Width, Height), "title");
vector <sf::CircleShape> Draw;
float Platform[Width][Height];
for (int i = 0; i < Width; i++) {
for (int j = 0; j < Height; j++) {
Platform[i][j] = 0;
}
}
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
switch (event.type) {
case sf::Event::Closed:
window.close();
break;
default:
break;
} // event check
} // while Event
window.clear(sf::Color::Black);
//////////////////////////
if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
sf::Vector2i mousePosition{ sf::Mouse::getPosition(window) };
sf::Vector2f mouseCoord{ window.mapPixelToCoords(mousePosition) };
float x1 = mouseCoord.x;
float y1 = mouseCoord.y;
int x = (int)x1;
int y = (int)y1;
Platform[x][y] = 1;
} // Mouse Pressed
/////////////////////////
window.display();
}// main While
return 0;
}
i try new option , but its not work and i use vector but get another eror