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 - Tigre Pablito

Pages: 1 [2] 3 4 ... 15
16
General / Re: Wrong Screen ratio
« on: July 16, 2019, 04:36:08 am »
Hi

In my notebook that had never had that problem it doesn't work.  :(

Everything runs fine but sprites are not drawn. I just see the screen in the color I Cleared()

This is my code (in C#)

GameLevel.GameView = new View(new Vector2f(400, 300), new Vector2f(800, 600));
GameLevel.GameView = Screen.GetLetterboxView(GameLevel.GameView, 800, 600);

Then I call

window.SetView(GameLevel.GameView);

after all calls to

window.Clear();

I didn't handle the Resized event because I'm using fullscreen mode.

Could you tell me what is wrong?
Thanks again  :)

17
General / Re: Wrong Screen ratio
« on: July 13, 2019, 12:19:51 am »

18
General / Wrong Screen ratio
« on: July 10, 2019, 10:51:50 pm »
Hi,

When I run my SFML games on some PCs which have screens whose width is more than 4/3 of its height, they are displayed with wrong ratio. I always use 800x600.

Is there a solution for this?

Thank you
Pablo

19
Graphics / Re: RenderImage doesn´t exist anymore in SFML.Net 2.2?
« on: April 02, 2019, 10:55:17 pm »
You should call rt.Texture.CopyToImage() once and store the result, it is an expensive call.

One always learns something new  :) ... but ... I should have guessed that. Thanks  :D

And I don't get why you're dividing XLIM and YLIM by 1000 and not 1024.

The image is 16000x3000, if I divide by 1024 an space on the image's right and bottom would remain not "painted", because (16000 / 1024) * 1024 = 15360, not 16000. Also it happens with 3000 / 1024.

So I had to divide by 1000 to get all the image "painted", ... or maybe I should have done this?

Math.Ceiling((double)XLIM / 1024.0)

but I didn't worry about that because that "image creating" won't happen on game release, and in this case it is the same

20
Graphics / Re: RenderImage doesn´t exist anymore in SFML.Net 2.2?
« on: April 01, 2019, 03:16:24 am »
Quote
Quote
Actually, my code, which before took several seconds on performing an "image building" with a lot of SetPixel() calls, now with the RenderTexture code added, it takes more or less the same.
Maybe this is because you're loading the same texture again and again for every single tile that you draw, instead of just once at init time.

I meant that other stuff my code did was the cause of the delay, and that adding the RenderTexture code didn´t extend it. The code I posted before was "abbreviated" ... I assumed you would assume that  ;), ... I am an "a bit old" programmer  8)
Actually my code is (now, with the fix of the Texture size)

        private void FillWithTile(int tile)
        {
            RenderTexture rt = new RenderTexture(1024, 1024);
            Texture img = new Texture(Images.bkgnds[tile]);
            Sprite spr = new Sprite(img);
            int a, b;

            rt.Clear();
            for (a = 0; a < 8; a++)
                for (b = 0; b < 8; b++)
                {
                    spr.Position = new Vector2f(a * 128, b * 128);
                    rt.Draw(spr);
                }
            rt.Display();

            for (a = 0; a < XLIM / 1000; a++)
                for (b = 0; b < YLIM / 1000; b++)
                    image.Copy(rt.Texture.CopyToImage(), (uint)(a * 1024), (uint)(b * 1024));
        }
 

Quote
Quote
what is 16000x3000 are the Image and the RenderTexture
As its name implies, a RenderTexture is (has) a Texture, so when you create a 16000x3000 RenderTexture you're also creating a 16000x3000 Texture.

Yes, I realized just now that, though it didn't throw an error, it wasn´t drawing the tiles (now it is)

Thank you

21
Graphics / Re: RenderImage doesn´t exist anymore in SFML.Net 2.2?
« on: March 26, 2019, 03:49:01 am »
Hi,

I would probably do it this way, yes. Is it too slow for you?

Actually, my code, which before took several seconds on performing an "image building" with a lot of SetPixel() calls, now with the RenderTexture code added, it takes more or less the same. So I assume it must be very fast  :)

Be aware that a texture size of 16000x3000 may not be supported by many GPUs.

My system supports only 1024x1024 Textures (so, I have to split the level image into several Textures, as you told me several years ago ... remember? ;D) ... what is 16000x3000 are the Image and the RenderTexture  ;)

Thanks a lot for your help

22
Graphics / Re: RenderImage doesn´t exist anymore in SFML.Net 2.2?
« on: March 22, 2019, 03:34:01 am »
Hi

How could I use the RenderTexture to make my tiles (Images) be drawn onto the bigger Image?

I tried this

// I need to "tile copy" Image tile (128x128) onto Image image (16000x3000)
RenderTexture rt;
Sprite spr;
rt = new RenderTexture(XLIM, YLIM);
rt.Clear();
for (a=0;a<XLIM/128;a++)
    for (b=0;b<YLIM/128;b++){
        spr = new Sprite(new Texture(tile))
        spr.Position=new Vector2f(a*128, b*128);       
        rt.Draw(spr);
}
rt.Display();

image.Copy(rt.Texture.CopyToImage());
//

Is this the fastest way?

Thank you very much

23
Graphics / Re: Problem with sf::Text in a custom class
« on: March 22, 2019, 03:19:21 am »
Hi Matfire

I saw this post casually. I don't know much c++ ... but it seems you are corrupting the memory with a buggy argument pass and Font object access

What you need is to list Names of Games and to enter a number to select one of them, isn't it?

Maybe you could try this: create a Text object (with its Font object just once passed in its argument list if possible) and when iterating through the Game Names list just change its "DisplayedString" and "Position" attributes, and Draw it ...

Obviously to learn to use the Debugger is a very good idea ... but if you don't understand very well the language internal stuff, I have some doubts that you understand it enough ...

Please let me know if I can help in something else
Pablo

24
Graphics / RenderImage doesn´t exist anymore in SFML.Net 2.2?
« on: March 19, 2019, 09:13:57 pm »
Hi,

I would like to be able to copy an Image onto another Image faster than with the Copy() function. A time ago I posted in the forum and I was told to use RenderTexture. I tried that, but without success. A few days ago I googled and found RenderImage class. But it seems it doesn´t  exist in SFML.Net 2.2 ... ? Why? Or am I wrong?

If RenderImage class is not available, could someone tell me the way to do this (if there is)?
Thanks
Pablo

25
General / Re: SFML cicrle movement
« on: December 24, 2018, 12:07:15 am »
Hi Guys

I have one doubt: shouldn't the rotation attribute be updated after that formula? Or it is automatically?


body.move( -sin(body.getRotation()*3.14159265 / 180)*-3, -cos(body.getRotation()*3.14159265 / 180) * 3);

If you don't do this

body.setRotation(body.getRotation() + rotation);

wouldn't it go like by a line (constant)?

26
Hi  8)

As eXpl0it3r said, you would have to set the mouse position (according to the joystick movement)  ;)

You don't need to translate the mouse event handling, but handling the joystick event to move the mouse cursor  :P

you would need to have an X and Y vars to store the current mouse position,

then when you move the joystick to your right, then increase X, when you move up, then decrease Y, etc, etc ... (I don't know the code for this, please query C++   ::))

and then, just set mouse position to (X, Y)

sf::Mouse::setPosition(X, Y);    // I'm not sure of this cos I don't know C++, query the correct syntax  ::)

Hope this helps  :)

27
General / Re: Adding shapes to vector
« on: November 07, 2018, 03:19:39 am »
Hi,

I'm sure that it works with an array, but I'm not sure if it works with a vector (List<T> in C#)

i.e. (in C#)

Parent[] array = new Parent[] { new Child1(), new Child2(), new Child1(), new Child4() };

Or maybe if you don't make the generic type "const" ... ?  ::)

........

What has happened with your Arkanoid clone project? Remember that Hapax and i tried to help you?  ;D
(sorry for the out of topic)

28
General / Re: How can i block sprite to outside screen ?
« on: October 28, 2018, 08:55:01 pm »
Just ask (with an if statement) if your sprite will step outside the screen before making it move, and if it will, then don't move it.
This is, if X is not lower than screen left, if Y is not lower than screen top, if X + WIDTH is not greater than screen left + screen width - 1, and if Y + HEIGHT is not greater that screen top + screen height - 1

If you can be more specific maybe you can get more and better replies

29
General / Re: Issue with collision
« on: September 21, 2018, 04:14:31 am »
Hi,

you gave this code,

else if (Collision::PixelPerfectTest(ball, paddle.getShape()))
{
   if (!ball.getGlobalBounds().contains(paddle.getShape().getPosition().x, paddle.getShape().getPosition().y))
        {
             y_ballSpeed = -y_ballSpeed;
        }
}

maybe if you add to the condition that the ball is going to the bottom of the screen, like this

   if (!ball.getGlobalBounds().contains(paddle.getShape().getPosition().x, paddle.getShape().getPosition().y)
&& y_ballSpeed > 0
)

to avoid the issue Hapax wrote about ... otherwise, when the ball hits the paddle on its very very edge, as the ball´s Y comes very low, the original condition would be true more than once, making the sentence:

y_ballSpeed = -y_ballSpeed;

execute a few times and getting a wrong behaviour of the ball

but if the condition requests the ball leading to the bottom, there won´t be a 2nd execution of that sentence because on the 2nd time the ball will be pointing to the screen top

Hope this helps

30
General / Re: Collision by differentiating colors
« on: September 01, 2018, 07:12:50 pm »
Hi

It's a run time error (no compiler error because the compiler can't guess that maybe the player will atempt to access out of the maze image bounds)  ;) . Usually they are the most difficult to detect because of that, there is no message.

I had thought about this possibility before, but then I believed that the maze image borderlines would be 'wall' color so that you would lose before step outside the image bounds

To prevent this you could check, before the player scrolls to another position, if it would step outside (for example, if the maze image is 800x600, no part of the player can be at (805, 347). No part, not only the (left, top),  because the collision function will be accessing the image's region that is occupied by all the player's area, and if in a call to GetPixel() X or Y are < 0 or > (800, 600) it will throw an "Out of range" Exception)

public bool CheckStepOutside(newPosX, newPosY)
{
    if (newPosX < 0 || newPosY < 0 || newPosX + 20 > 800 || newPosY + 20 > 600)
        return true;
    return false;
}
 

You can get the (x, y) where the player will be on next frame, and just allow it to scroll if the function (passing x and y to it) returns false.


Pages: 1 [2] 3 4 ... 15
anything