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 / How can I assign texture to 3D buildings made with VertexArrays?
« on: December 18, 2019, 07:48:43 pm »
Hello ladies and guys!

I would like that Quads (that are the 2D parts of my 3D buildings) have a texture, so the 3D buildings look a bit more like buildings ... I tried this but they just show the same old Color but darker

        private void AssignVertices(VertexArray array, Color color, float[] coords)
        {
            int a;
            array.Clear();            
            for (a = 0; a < coords.Length / 2; a++)
                array.Append(new Vertex(new Vector2f(coords[a * 2], coords[a * 2 + 1] + this.ship.Scroll), color, new Vector2f(0, 0)));
            array.Append(new Vertex(new Vector2f(coords[0], coords[1]), color, new Vector2f(0, 0)));
            RenderStates states = new RenderStates(Graphics.building);  // this is the Texture
            this.window.Draw(array, states);
        }
 

Maybe those who remember my Massacre space shooter game will understand better ...

Thanks in advance
Pablo

17
General / Re: Space Invaders - Enemy Movement Logic
« on: November 21, 2019, 05:57:16 pm »
Sorry, I'm a C# programmer, I know very little C++

Maybe if I saw the entire code (and if I had the C++ compiler) I might find out ... but surely any C++ programmer here will tell you what is wrong

But check the array, or list, or vector's size ... did you allocate it for containing NUMBER_OF_ALIENS?



18
General / Re: Space Invaders - Enemy Movement Logic
« on: November 21, 2019, 12:46:19 am »
Hi firepro20

I called, in my "Massacre Space Shooter", XRadius and YRadius to half the width and height, respectively, of any ship. So then you can check collision, reaching the bounds, and also if bullets have touched a ship. As I saw in your code, your enemy's XRadius would be 24.

Yes! I'm sure it would be a good practise to make a class for each different enemy, and then a "collection" class for groups of them. Also you can write an abstract class to put there all enemies' common attributes and methods and then make all enemies inherit from it.

19
General / Re: Space Invaders - Enemy Movement Logic
« on: November 18, 2019, 01:18:39 am »
Hi firepro20

Basically it depends on how you want your enemies to move. They should have X and Y variables to set where they are, Sense (1 if going right, -1 left), Health, Points by destruction, some object list for weapon, maybe SenseY (for up/down), etc. If I understood well the movement you described, it would be like

//inside your enemy update code
X += 3f * Sense; // goes from side to side through the screen
if (X >= SCREEN_WIDTH - 24 || X < 0 + 24)  // you could use XRadius instead of 24
    Sense = -Sense;  // has reached bound, then goes oposite
Y += 1f; // just goes down screen

Then you would have to check if player (space ship) shoots have touched the enemy, if it collides with player, or if it goes off side and then disappears, etc ...

You can also make curve movements, for which you would have to use, generally, sine and cosine functions, and sometimes also arc tangent

Continue with it, your graphics are very good
And please come back here if you need any more help
Pablo


20
General / Why my SFML.Net 2.2 game makes Windows 10 restart?
« on: August 12, 2019, 09:39:04 pm »
Hi all

I'm trying to run my SFML.Net 2.2 game on Windows 10, but it makes system reboot.

What could be the causes? It doesn't seem to be the drivers. Neither the antivirus.

Thanks
Pablo

21
General / Re: Wrong Screen ratio
« on: July 17, 2019, 12:50:38 am »
Hi all

eXpl0it3r:
On my notebook's monitor I didn't have that issue, but as in other ones I did, I would like to have the same code in my project, and, supposedly it would work fine even on those monitors that don't distort the aspect ratio

I have just tested in a 1440x900 monitor and it doesn't work either

This is my translation of the function from C++ to C# ... maybe there's something wrong

        public static View getLetterboxView(View view, int windowWidth, int windowHeight)
        {
            // Compares the aspect ratio of the window to the aspect ratio of the view,
            // and sets the view's viewport accordingly in order to archieve a letterbox effect.
            // A new view (with a new viewport set) is returned.

            float windowRatio = windowWidth / (float) windowHeight;
            float viewRatio = view.Size.X / (float) view.Size.Y;
            float sizeX = 1;
            float sizeY = 1;
            float posX = 0;
            float posY = 0;

            bool horizontalSpacing = true;
            if (windowRatio < viewRatio)
                horizontalSpacing = false;

            // If horizontalSpacing is true, the black bars will appear on the left and right side.
            // Otherwise, the black bars will appear on the top and bottom.

            if (horizontalSpacing)
            {
                sizeX = viewRatio / windowRatio;
                posX = (1 - sizeX) / 2f;
            }
            else
            {
                sizeY = windowRatio / viewRatio;
                posY = (1 - sizeY) / 2f;
            }

            view.Reset(new FloatRect(posX, posY, sizeX, sizeY));

            return view;
        }
 

Thank you all for your help

22
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  :)

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

24
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

25
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

26
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

27
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

28
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

29
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

30
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

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