1
SFML projects / Re: PixelWindow - a very simple framework for direct pixel rendering
« on: August 27, 2022, 05:50:18 pm »
Just implemented Conway's game of life with this https://github.com/Jallenbah/simple-game-of-life
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Hey,
I was wondering if you did the .NET port? Because I would like to ask if I could use it.
Best regards pizzadox
Looks neat!
Kind of wonder though, if the design of a single frame draw callback function is good enough for more complex things.
I feel like calling a function on the PixelWindow and passing in the pixel data, would feel more natural, but you'd then of course have to move the main loop outside of the PixelWindow.
struct CharImg
{
char cha;
sf::Image img;
};
sf::Image* Font::GetCharImage(char character)
{
for(int i = 0; i < chars.size(); i++)
{
if(chars[i]->cha == character)
return &chars[i]->img;
}
return 0;
}
void Font::DrawText(std::string string, sf::Vector2f position, sf::Vector2f scale, sf::RenderWindow* rwindow)
{
std::vector<sf::Sprite> spriteVector;
sf::Vector2f nextpos(position);
for(int i = 0; i < string.length(); i++)
{
if(string[i] == '\n')
nextpos = sf::Vector2f(position.x, nextpos.y + (10 * scale.y));
else if(string[i] == ' ')
nextpos.x += (7 * scale.x);
else
{
spriteVector.push_back(sf::Sprite(*GetCharImage(string[i]), nextpos, scale));
nextpos.x += (7 * scale.x);
}
}
for(int i = 0; i < spriteVector.size(); i++)
{
rwindow->Draw(spriteVector[i]);
}
}
Doesn't work on Linux