Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

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.

Messages - Mortal

Pages: 1 2 [3] 4 5 ... 19
Graphics / Re: loadfromfile failing to load an image
« on: January 24, 2020, 07:24:05 pm »
"loadFromFile()" usually print an error message on console screen if it can't open the file. check it if there is a message. if not then make complete and minimal example that produce same error.

General / Re: Text
« on: January 15, 2020, 08:58:13 am »
you can achieve these condition states by introducing a boolean values in your game classes like "bool is_button_pressed;", "bool is_he_chose" ... etc;

and then let the classes that needs those boolean properties to access them. whether by a pointers to the classes or some kind of game patterns that lets the entities in a game reference each other.
it's an inefficient to delete/create text objects every time when the player pressed the button. better to not to draw the text and probably it needs a timer for how long text will be drawn.
however, i think your game won't has a performance issues. since, your game has a few game objects, no collision or physics involved.

in general, it's depend on your game design which class responsible about display the hint text and its life span.

General / Re: How to implement sprite group?
« on: January 10, 2020, 03:28:49 pm »
well, i have almost same error as you have it, i'm using visual studio 2015 [v140]-for widow 8.1.
i made test code to draw colorful circle shapes with "sf::CircleShape". to show the the error

i suspect it might be a bug with my compiler version. i'm using visual studio 2015 [v140] for window 8.1.

here my test code:
#include <SFML/Graphics.hpp>

int main()
        sf::RenderWindow window(sf::VideoMode(640, 480), "test!");

        std::vector<std::reference_wrapper<const sf::Drawable>> shapes_wrapper;

        sf::CircleShape shape(32);

        std::vector<sf::CircleShape> shapes;
        for (int i = 0; i < 2; i++) {
                if (i == 0) {
                        shapes.back().setPosition(window.getView().getCenter() / 4.0f);
                else {
                        shapes.back().setPosition(window.getView().getCenter() / 2.0f);
#if 0 // ugly error, it should accept it. <-- probably it's a bug

        sf::CircleShape test_shape(32);
        test_shape.setPosition(window.getView().getCenter() - window.getView().getCenter() / 4.0f);

        sf::CircleShape center_shape(32);

        while (window.isOpen()) {
                sf::Event event;
                while (window.pollEvent(event)) {
                        if (event.type == sf::Event::Closed)

                for (const auto& shape : shapes)
                for (const auto& shape : shapes_wrapper)

        return 0;

EDIT: it looks the std::vector of sf::CircleShape objects cause the problem, i replaced it with std::list and it works. also, i have test it with sf::CircleShape pointers ad it works as expected.
std::list<sf::CircleShape> shapes;

or with smart pointer
std::vector<std::unique_ptr<sf::CircleShape>> shapes;

both worked fine in my code.

alright, according to https://en.cppreference.com/w/cpp/container/vector/push_back

If the new size() is greater than capacity() then all iterators and references (including the past-the-end iterator) are invalidated. Otherwise only the past-the-end iterator is invalidated.

that means we have at least to use reserve() the vector to guarantee that no reallocation will happen by the subsequent of push_back()

fix: in my code it needs to add this:
std::vector<sf::CircleShape> shapes;
while in yours it needs to add this:
std::vector<Box> boxes;

General / Re: Sprite Pointer?
« on: January 09, 2020, 11:19:06 pm »
i agree with Rosme about reading a c++ book. pointers and references are most important features in c++ language. if you had difficulties to grasp these concepts then you may consider to switch to other programming language that don't use low level features like java or c#.

to solve the compiler warning in you code, just assign the memory address of your main sprite to the pointer sprite by using the address-of "operator(&)" like this:

Selected_Piece = &Piece_1;

and you can use the pointer by dereference it. if you were needed it, with "operator(*)", like this:

window.draw(*Selected_Piece );

SFML projects / Re: Intel 8080 Emulator-Space Invaders
« on: January 06, 2020, 09:51:34 am »
hello fallahn  :)

i'm so glad that you like it, i really appreciated.

i can't thank you enough for the tutorial, it really helpful. i get it where the problem is, according to the tutorial, it appears i have mapped the mirrored RAM location at wrong address location. i have fixed that and the bug seems has gone away  :D

SFML projects / Intel 8080 Emulator-Space Invaders
« on: January 03, 2020, 06:42:50 pm »
i have managed to make simple a `Intel 8080` 8-bit microprocessor emulator for Space Invaders. however, there is good news and bad news.

the good news is, the sound is working fine with emulator unlike my previous Space Invaders clone https://en.sfml-dev.org/forums/index.php?topic=26821.0
which is still can't get it to working correctly.

the bad news emulator has a bug for some reasons the Space Invaders game crushed when the startup game demo run longer. honestly i don't know what actually cause it, is it a multi-threading issues or memory-corruption, i have no idea.

the cpu runs fine i have tested it with COM test-files.

EDIT: bug is fixed, now the emulator's working fine.

here a Demo of Space Invaders game:


Graphics / Re: White rectangle issue
« on: December 27, 2019, 05:58:20 am »

it looks you passing textures container by value to player class constructor, this will make a new copy of passing objects. use reference or pointer to fix it like `Player(const std::vector<sf::Texture>& texturas)`

btw, since all textures have same file names except of its numbers, you can use `std::to_string()` with a for-loop.

std::vector<sf::Texture> texturas(5);
for (int i = 0; i < texturas.size(); i++) {
        texturas[i].loadFromFile("Idle (" + std::to_string(i+1) + ").png");

SFML projects / Space Invaders Clone
« on: December 26, 2019, 12:57:22 pm »
hello everybody

i just made simple Space Invaders clone that's mimic the original game as possible as i could. it uses the original ROM data of-course to achieve same game experience as playing the original except for cpu cycle time which's not effect the game-play itself but it effects the sound. the game currently has no sound. i'm working to solve this issue hopefully it does't take much time.

the game is not an emulator as what it seems to look like. it is different code made it with SFML/OpenGL.



yeah, that's what i suspected too, the erase to left character is a different input entity. now it's clear.

unfortunately, i haven't worked on any mobile platforms yet. soon i'm gonna delve in it.

sorry i can't help much on this issue.

General / Re: Getting intersection direction/side.
« on: December 17, 2019, 06:09:36 pm »
you most welcome  :)

my laptop support arabic alphabet. i tried to generate your error but no avail every things looks work fine from SFML side.

just to clarify things:
does this "erase to left character" means "BackSpace" on the keyboard?

i made minimal example by using `'\b'` and `'\r'` which is working fine as i said before. other wise you have to write your own minimal example which's cause the issue to let the others to test your code and solve the problem.

#include <SFML/Window.hpp>

int main()
        sf::Window window({ 640 ,480 }, "test arabic alphabet");

        std::wstring arabic_str;

        while (window.isOpen())
                sf::Event event;
                while (window.pollEvent(event))
                        if (event.type == sf::Event::Closed)
                        else if (event.type == sf::Event::TextEntered)
                                if (event.text.unicode == '\b')  // press backspace
                                        if (!arabic_str.empty())
                                else if (event.text.unicode == '\r') // press enter/return
                                        if (!arabic_str.empty())
                                else {
                                        arabic_str += event.text.unicode;


General / Re: Getting intersection direction/side.
« on: December 15, 2019, 10:54:05 pm »
you should use sf::Sprite::getGlobalbounds() instead of the local to test for intersects.
you may try manifold for detecting the collision from every directions up/down or left/right, here an excellent tutorial in this topic with examples:


Graphics / Re: Displaced bounding box of Node
« on: December 15, 2019, 10:42:43 pm »
i think you need to pass window to the `sf::Mouse::getPosition(window)` to get the relative mouse position to your app window.

SFML projects / Re: Screenshot Thread
« on: December 14, 2019, 03:16:54 pm »
Hi  :)

It's me again, still working on my opengl framework. It is a little bit getting mature to be as a regular game engine.

I’m currently studying/working on 3D primitive shapes and collision detection and learning the basics of 3D game physics.

I have made a demo showing what i have been implemented.It is again space invaders. Lol
It's my favourite arcade game and easy game to make.

I was concerned about performance and i had to have to test my opengl framework to its limit. It looks working fine. Even i haven’t done any kind of advanced optimization like multithreading or using SSE instructions or any thing similar.

here a 2.5D Space Invaders demo runs on regular and hell-bullets modes

Regular mode

Hell Bullets mode

General / Re: Help with basic fragment-shadered full-screen sprite
« on: February 12, 2019, 06:25:58 pm »

no need to use sprite and texture to draw fragment shader. just use sf::RectangleShape to get fullscreen to draw on it. also, no need to provide the vertex shader. like so:

#include <SFML/Graphics.hpp>

#define GLSL120(src) "#version 120 core\n" #src

static const char* frag = GLSL120(

uniform float time;
uniform vec2 resolution;

float h(float i) {
        return fract(pow(3., sqrt(i / 2.)));

void main(void) {

        vec2 p = gl_FragCoord.xy*2. - resolution;

        float a = floor(degrees(4. + atan(p.y, p.x))*2.) / 4.;

        float d = pow(2., -10.*fract(0.1*time*(h(a + .5)*-.1 - .1) - h(a)*1000.));

        if (abs(length(p) - d*length(resolution)) < d*35.) {
                gl_FragColor = vec4(d*(h(a + .5)*3.));
        else {
                gl_FragColor = vec4(0.);


int main()
        sf::RenderWindow window({ 800, 600 }, "SFML Shader Example");

        sf::RectangleShape fullscreen({ 800, 600 });
        sf::Shader shader;
        if (!shader.loadFromMemory(frag, sf::Shader::Fragment))
                return -1;

        shader.setUniform("resolution", sf::Vector2f({ 800, 600 }));

        sf::Clock clock;
        while (window.isOpen()) {
                sf::Event event;
                while (window.pollEvent(event)) {
                        if (event.type == sf::Event::Closed)

                shader.setUniform("time", clock.getElapsedTime().asSeconds());

                window.draw(fullscreen, &shader);

Pages: 1 2 [3] 4 5 ... 19