bugün
- babalar gününüz kutlu olsun12
- hangi tür taş tercih edersiniz13
- bu saldırı bize yapılsaydı nasıl karşılık verirdik23
- ankara'da su fiyatlarına yüzde 169 zam17
- as maca8
- anın görüntüsü15
- claudia s cloud35
- tebriz'i vurmak bizi vurmaktır48
- kürtlerin türkleri moğol olarak tanımlaması14
- düşün ki o bunu okuyor10
- uzun boylu erkek isteyen kısa boylu kız14
- beyaz bikini11
- kızını zenci ile evlendiren baba12
- allah neden israili durdurmuyor10
- israil'i türklere dost sanmak32
- 13 haziran 2025 iran'ın israil'e saldırması22
- cast away9
- escorta evlenme teklifi etmek12
- 13 haziran 2025 israil'in iran'a saldırması48
- yemek yerken izlemelik şeyler16
- en son ne yediniz12
- iran14
- biriniz çay demlese de dağıtsa11
- bik bik ve true aşkı23
- abridgeeeee9
- daha güzeliyle tanışınca önceki kadını unutmak8
- binyamin netanyahu10
- sakız adasında sakızlı muhallebi yemek10
- baklava abartılmış balon bir tatlıdır11
- sözlüğe çükünün resmini atan erkek8
- en son aldığınız iltifat10
- osimhen liverpool pendik gs12
- iran kağıttan kaplandır23
- hangi sözlük kızı daha güzel11
- iranın ırzına geçilmiş8
- akp döneminde israil'in coşması12
- kürdün en büyük dostu türk tür21
- true yu neden evlendiremiyoruz11
- ay tırnağım kırıldı diyen erkek12
görsel
1920x1080 piksel genişliğinde, siyah arkaplanda bir penceremiz olsun, bunu 15x15 piksellik kutularla karolara dönüştürüp, ızgara grid düzeni yaratalım. çizgiler 1 piksel genişliğinde beyaz olucak.
grid düzleminde, mouse cursor, üzerinde olduğu her karoyu kırmızıya,
yatay ve dikey eksende taradığı tüm karoları da sarıya boyasın.
ekranda rastgele bir karoyu yeşil seçelim.
ve bu yeşil alanın,
mouse cursor un olduğu kırmızı karoyu her tıkladığımızda,
en kısa yolu nasıl seçtiğini merak ediyorsanız eğer,
cevabı çok basit.
path-finder algoritması!
#include <SFML/Graphics.hpp>
#include <vector>
#include <cmath>
int main() {
// 1920x1080 window
sf::RenderWindow window(sf::VideoMode(1920, 1080), "15x15 Grid with Mouse Highlight and Character");
window.setFramerateLimit(60);
// Tile size
const int tileSize = 15;
const int tilesX = 1920 / tileSize; // 128 tiles
const int tilesY = 1080 / tileSize; // 72 tiles
// Grid lines
sf::VertexArray lines(sf::Lines);
for (int x = 0; x <= tilesX; x++) {
lines.append(sf::Vertex(sf::Vector2f(x * tileSize, 0), sf::Color::White));
lines.append(sf::Vertex(sf::Vector2f(x * tileSize, 1080), sf::Color::White));
}
for (int y = 0; y <= tilesY; y++) {
lines.append(sf::Vertex(sf::Vector2f(0, y * tileSize), sf::Color::White));
lines.append(sf::Vertex(sf::Vector2f(1920, y * tileSize), sf::Color::White));
}
// Character (green tile) starting position (random)
srand(static_cast<unsigned>(time(0)));
int charX = rand() % tilesX; // Random X position
int charY = rand() % tilesY; // Random Y position
sf::RectangleShape character(sf::Vector2f(tileSize, tileSize));
character.setFillColor(sf::Color::Green);
// Target position for the character (where the mouse clicks)
int targetX = charX;
int targetY = charY;
// Path history (to paint with transparent blue)
std::vector<sf::Vector2i> path;
sf::Color transparentBlue(0, 0, 255, 100); // Transparent blue (alpha=100)
// Game loop
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
// Left mouse button click to set target
if (event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left) {
sf::Vector2i mousePos = sf::Mouse::getPosition(window);
targetX = mousePos.x / tileSize;
targetY = mousePos.y / tileSize;
path.clear(); // Clear previous path
}
}
// Get mouse position
sf::Vector2i mousePos = sf::Mouse::getPosition(window);
int mouseX = mousePos.x / tileSize;
int mouseY = mousePos.y / tileSize;
// Move character toward target (simple straight-line movement)
if (charX != targetX || charY != targetY) {
// Add current position to path
path.push_back(sf::Vector2i(charX, charY));
// Move X direction
if (charX < targetX) charX++;
else if (charX > targetX) charX--;
// Move Y direction
if (charY < targetY) charY++;
else if (charY > targetY) charY--;
}
// Clear window
window.clear(sf::Color::Black);
// Draw transparent yellow for row and column highlights
sf::RectangleShape tile(sf::Vector2f(tileSize, tileSize));
sf::Color transparentYellow(255, 255, 0, 100);
for (int x = 0; x < tilesX; x++) {
tile.setPosition(x * tileSize, mouseY * tileSize);
tile.setFillColor(transparentYellow);
window.draw(tile);
}
for (int y = 0; y < tilesY; y++) {
tile.setPosition(mouseX * tileSize, y * tileSize);
tile.setFillColor(transparentYellow);
window.draw(tile);
}
// Draw the path (transparent blue)
for (const auto& pos : path) {
tile.setPosition(pos.x * tileSize, pos.y * tileSize);
tile.setFillColor(transparentBlue);
window.draw(tile);
}
// Draw character (green tile)
character.setPosition(charX * tileSize, charY * tileSize);
window.draw(character);
// Draw mouse-highlighted tile (red)
tile.setPosition(mouseX * tileSize, mouseY * tileSize);
tile.setFillColor(sf::Color::Red);
window.draw(tile);
// Draw grid lines on top
window.draw(lines);
// Update window
window.display();
}
return 0;
}
1920x1080 piksel genişliğinde, siyah arkaplanda bir penceremiz olsun, bunu 15x15 piksellik kutularla karolara dönüştürüp, ızgara grid düzeni yaratalım. çizgiler 1 piksel genişliğinde beyaz olucak.
grid düzleminde, mouse cursor, üzerinde olduğu her karoyu kırmızıya,
yatay ve dikey eksende taradığı tüm karoları da sarıya boyasın.
ekranda rastgele bir karoyu yeşil seçelim.
ve bu yeşil alanın,
mouse cursor un olduğu kırmızı karoyu her tıkladığımızda,
en kısa yolu nasıl seçtiğini merak ediyorsanız eğer,
cevabı çok basit.
path-finder algoritması!
#include <SFML/Graphics.hpp>
#include <vector>
#include <cmath>
int main() {
// 1920x1080 window
sf::RenderWindow window(sf::VideoMode(1920, 1080), "15x15 Grid with Mouse Highlight and Character");
window.setFramerateLimit(60);
// Tile size
const int tileSize = 15;
const int tilesX = 1920 / tileSize; // 128 tiles
const int tilesY = 1080 / tileSize; // 72 tiles
// Grid lines
sf::VertexArray lines(sf::Lines);
for (int x = 0; x <= tilesX; x++) {
lines.append(sf::Vertex(sf::Vector2f(x * tileSize, 0), sf::Color::White));
lines.append(sf::Vertex(sf::Vector2f(x * tileSize, 1080), sf::Color::White));
}
for (int y = 0; y <= tilesY; y++) {
lines.append(sf::Vertex(sf::Vector2f(0, y * tileSize), sf::Color::White));
lines.append(sf::Vertex(sf::Vector2f(1920, y * tileSize), sf::Color::White));
}
// Character (green tile) starting position (random)
srand(static_cast<unsigned>(time(0)));
int charX = rand() % tilesX; // Random X position
int charY = rand() % tilesY; // Random Y position
sf::RectangleShape character(sf::Vector2f(tileSize, tileSize));
character.setFillColor(sf::Color::Green);
// Target position for the character (where the mouse clicks)
int targetX = charX;
int targetY = charY;
// Path history (to paint with transparent blue)
std::vector<sf::Vector2i> path;
sf::Color transparentBlue(0, 0, 255, 100); // Transparent blue (alpha=100)
// Game loop
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
// Left mouse button click to set target
if (event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left) {
sf::Vector2i mousePos = sf::Mouse::getPosition(window);
targetX = mousePos.x / tileSize;
targetY = mousePos.y / tileSize;
path.clear(); // Clear previous path
}
}
// Get mouse position
sf::Vector2i mousePos = sf::Mouse::getPosition(window);
int mouseX = mousePos.x / tileSize;
int mouseY = mousePos.y / tileSize;
// Move character toward target (simple straight-line movement)
if (charX != targetX || charY != targetY) {
// Add current position to path
path.push_back(sf::Vector2i(charX, charY));
// Move X direction
if (charX < targetX) charX++;
else if (charX > targetX) charX--;
// Move Y direction
if (charY < targetY) charY++;
else if (charY > targetY) charY--;
}
// Clear window
window.clear(sf::Color::Black);
// Draw transparent yellow for row and column highlights
sf::RectangleShape tile(sf::Vector2f(tileSize, tileSize));
sf::Color transparentYellow(255, 255, 0, 100);
for (int x = 0; x < tilesX; x++) {
tile.setPosition(x * tileSize, mouseY * tileSize);
tile.setFillColor(transparentYellow);
window.draw(tile);
}
for (int y = 0; y < tilesY; y++) {
tile.setPosition(mouseX * tileSize, y * tileSize);
tile.setFillColor(transparentYellow);
window.draw(tile);
}
// Draw the path (transparent blue)
for (const auto& pos : path) {
tile.setPosition(pos.x * tileSize, pos.y * tileSize);
tile.setFillColor(transparentBlue);
window.draw(tile);
}
// Draw character (green tile)
character.setPosition(charX * tileSize, charY * tileSize);
window.draw(character);
// Draw mouse-highlighted tile (red)
tile.setPosition(mouseX * tileSize, mouseY * tileSize);
tile.setFillColor(sf::Color::Red);
window.draw(tile);
// Draw grid lines on top
window.draw(lines);
// Update window
window.display();
}
return 0;
}
Gündemdeki Haberler
güncel Önemli Başlıklar