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 - Esteban

Pages: [1]
1
Window / Re: Problem handling multiple key stroke
« on: May 13, 2024, 06:50:00 pm »
Thanks for your answer Kojack ! I looked up at this and this is my problem, i don't know how they set up the arcade so i will test on the battleground.
 Thanks for you fast and detail response.

2
Window / Re: Problem handling multiple key stroke
« on: May 13, 2024, 04:28:16 pm »
In my game the two players has keys  for deplacements and others for action, if one player hit two keys for shooting the other is stuck and cannot use any movement)
the key are the following  :

(thats a french keyboard tho) so instead of zqsd its wasd
The problem is that i want to put the game on an arcade born at my school and i cant decide which key is related to which joystick and neither for the button of each players.

3
Window / [SOLVED] Problem handling multiple key stroke
« on: May 13, 2024, 03:42:05 pm »
Hello everyone,
Its been a one year journey with SFML and everything has been great but i am facing a weird bug with inputs.
I am building a game so i have a HandleInput method in which i poll every event but when i am stroking 5 keys at the same time i get nothing (i tried to detect keyboard input using sf::Keyboard::isKeyPressed and by sf::Event.type and get the same bug)

Here is how i handle my event, this function is called by the main loop with 2 main functions, update and draw
sf::Event event;
while (data->window.pollEvent(event))
{
        if (sf::Event::Closed == event.type)
                data->window.close();
        else if (event.type == sf::Event::KeyPressed)
        {
                if (event.key.code == inputOfPlayers[0].moveUp)
                {
                        //do things
                }
                else if (event.key.code == inputOfPlayers[0].moveDown)
                {
                        //do other things
                }
        }
}

I am building a local multiplayer game so this error bother me a bit, i don't know how can i solve this ?
Thanks for reading this and lmk if i didnt make this clear enough

4
that the effect i want to get thanks for your answer ! And thanks for you work on sfml this is huge

5
Render textures need to have display() called on them after drawing on them for them to update correctly.
So after rendertexture.draw(myText); put a rendertexture.display(); and see if that helps.
Thanks for you answer,i did it previously but it dont change the behaviour (which is kinda weird because yes i didnt display anything on the screen yet) but it result on the same black background.

https://blog.rubenwardy.com/2020/05/12/sfml-drop-shadow/
I used this tutorial to help me use my shader on the text but i couldn't figure it out

6
Hello everyone,
i am working on a game project and i face difficulties understanding how to use shader on sf::Text.
What i wanted to do is in the title and i dont realize if this is possible or not. I wanted to spin a text to have a fake 3D rotation effect. I Found a shader that does the spin effect in shadertoy and adapt it  :
.frag
precision mediump float;

#define Mouse_Rotation ( Max_Rotation - Max_Rotation * 2.0 * (iMouse.xy / iResolution.xy) )
#define RotationCenter vec3(0.000, 0.000, 0.000)
#define Max_Rotation 0.65

/*
   A simple rotating effect of a textured plane in 3D space.
   I'm basically using a ray for each pixel that intersects the plane
   as drawn in a 2D view below.

   Created By Jaap Boerhof (Dec. 2017)
   Forked by yohjimane (Jul. 2023)

   Positioning                             Positioning at a certain angle:
   at zero degrees rotation:
   
   |------plane-----|  coords:                              __--|
   \                /  (-1.0..1.0, 0.0)                 __--   /  
    \              /                                __--      /  
     \            /                             __--         /
      \          /                         \ _--            /  
       \        /                          |\              /  
        \      /                             \            /    
         \    /                               \          /      
          \  /                                 \        /      
           \/          Camera                   \      /  
                       position                  \    /  
                       at (0.0, -1.0)             \  /
                                                   \/
*/

uniform vec2 u_resolution;
uniform float u_time;
uniform sampler2D texture;
vec2 rotate(vec2 v, vec2 o, float a) {
    float s = sin(a);
    float c = cos(a);
    mat2 m = mat2(c, -s, s, c);
    return m * (v-o) + o;
}

vec3 rotateZ(vec3 v, vec3 o, float a) {
    float s = sin(a);
    float c = cos(a);
    mat2 m = mat2(c, -s, s, c);
    return vec3(m * (v.xy - o.xy) + o.xy, v.z);
}

vec2 TransformPlane(vec2 uv, vec3 center, float XRot, float YRot, float ZRot) {
    // First Rotate around Y axis
    vec2 RayDirection =  vec2(uv.x, 0.0);
    vec2 A1 = vec2(0.0, -1.0);
    vec2 B1 = RayDirection - A1;
    vec2 C1 = rotate(vec2(-1.0, 0.0), vec2(center.x, 0.0), YRot);
    vec2 D1 = rotate(vec2(1.0, 0.0), vec2(center.x, 0.0), YRot) - C1;

    // calculate intersection point
    float u = ( (C1.y + 1.0) * D1.x - C1.x * D1.y ) / (D1.x*B1.y-D1.y*B1.x);

    // position on the XY plane after Y-axis rotation
    float sx = u * B1.x;
    float sy = u * uv.y;

    // Now Rotate around X axis
    RayDirection = vec2(sy, 0.0);
    vec2 B2 = RayDirection - A1;
    vec2 C2 = rotate(vec2(-1.0, 0.0), vec2(center.y, 0.0), XRot);
    vec2 D2 = rotate(vec2(1.0, 0.0), vec2(center.y, 0.0), XRot) - C2;

    // calculate intersection point
    float v = ( (C2.y + 1.0) * D2.x - C2.x * D2.y ) / (D2.x*B2.y-D2.y*B2.x);

    // the position after x and y rotations
    vec3 pos = vec3(v * sx, v * B2.x, 0.0 );
   
    // Now rotate the position around Z axis
    vec3 finalPos = rotateZ(pos, center, ZRot);

    // final position on the 3D plane after Z-axis rotation
    return finalPos.xy;
}

void main()
{
    vec2 uv = -1.0 + 2.0 * gl_FragCoord.xy / u_resolution.xy;
    float R_X = 0.;
    float R_Y =  u_time;
    float R_Z = 0.; // Adjust the value for Z-axis rotation
    vec3 MyCoords = vec3(TransformPlane(uv, RotationCenter, R_X, R_Y, R_Z), 0.0);
    vec2 MyTexCoord = (MyCoords.xy + vec2(1.0)) / 2.0;

    //vec4 image1 = texture2D(texture, MyTexCoord);
    //vec4 image2 = texture(iChannel1, MyTexCoord);
    //fragColor = mix(image1, image2, (sin(iTime * 0.5) + 1.0) / 2.0);
     gl_FragColor = texture2D(texture, MyTexCoord);
}

The shader looks fine and seems to work on a sprite but i don't know if i can use it to spin a text.
I tried to use a rendertexture and make a sprite out of it but with this i have a black background on my text
sf::RenderTexture rendertexture;
rendertexture.create(SCREEN_WIDTH,SCREEN_HEIGHT);
rendertexture.clear();
rendertexture.draw(myText);
sf::Sprite sprite(rendertexture.getTexture());
//window.draw(myText,&testRotation); This doesnt work
window.draw(sprite,&testRotation);
This doesnt work, i dont know if i need to use deeper things as vertex and stuff like that.
Thanks for reading this and let me know if you need sample of code or smthing else

Pages: [1]
anything