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.


Topics - CowNation

Pages: [1]
1
Graphics / Drawing a short line between Sprite & Mouse
« on: June 09, 2018, 11:31:09 pm »
I have figured out how to draw a line between a sprite and the mouse. I am trying to make the line shorter. I want to draw a bullet pointing towards the cursor. How would I do that?
The game is a top down game. I have tried dividing the mouse cursor's position, also I have tried subtracting it by 5.

Thanks in advance

2
Graphics / need help with bloom
« on: June 08, 2018, 11:29:36 am »
I have been trying to add a bloom effect for about 2 hours and 30 minutes going off of the SFML Game Development. I could not figure out the BloomEffect & PostEffect classes. If someone has a bloom tutorial/source/class and would like to share it to me, that would be greatly appreciated!

3
Graphics / How to check if a sprite is touching a line
« on: May 22, 2018, 07:59:55 pm »
As the title says, I am drawing a line between 2 verticies.. One is located at the local player sprite, the other goes to the mouse. How can I tell if a different sprite is touching the line in between local & my mouse?

4
Network / Port-Forwarding with LAN
« on: May 09, 2018, 04:31:26 pm »
I am making a program that only requires LAN connection.
Do I need to Port-Forward a port for UDP connection?
If not, how do I tell which port the client needs to connect to?
Or can I just pick a port at random?

5
Graphics / Need help with move function
« on: May 03, 2018, 02:50:23 am »
Can someone help me with my move function for my main sprite?
My code:
    void Move(RenderWindow* window, Vector2i UPDOWN, Vector2i LEFTRIGHT, Vector2f UPDOWNSPEED, Vector2f LEFTRIGHTSPEED, Sprite collider) {
        if (window->hasFocus()) {
            if (GetAsyncKeyState(UPDOWN.x) && collisionDir != Up) {
                if (collisionDir == None && Collision::PixelPerfectTest(sprite, collider)) { collisionDir = Up; }
                else {
                    sprite.move(0.0f, UPDOWNSPEED.x);
                    //Game::World::tileMap.setCamera(Game::World::tileMap.getCamera() + sf::Vector2f(0.0f, UPDOWNSPEED.x));
                }
            }
            if (GetAsyncKeyState(UPDOWN.y) && collisionDir != Down) {
                if (collisionDir == None && Collision::PixelPerfectTest(sprite, collider)) { collisionDir = Down; }
                else{
                    sprite.move(0.0f, UPDOWNSPEED.y);
                    //Game::World::tileMap.setCamera(Game::World::tileMap.getCamera() + sf::Vector2f(0.0f, UPDOWNSPEED.y));
                }
            }
            if (GetAsyncKeyState(LEFTRIGHT.x) && collisionDir != Left) {
                if (collisionDir == None && Collision::PixelPerfectTest(sprite, collider)) { collisionDir = Left; }
                else {
                    sprite.move(LEFTRIGHTSPEED.x, 0.0f);
                    //Game::World::tileMap.setCamera(Game::World::tileMap.getCamera() + sf::Vector2f(LEFTRIGHTSPEED.x, 0.0f));
                }
            }
            if (GetAsyncKeyState(LEFTRIGHT.y) && collisionDir != Right) {
                if (collisionDir == None && Collision::PixelPerfectTest(sprite, collider)) { collisionDir = Right; }
                else {
                    sprite.move(LEFTRIGHTSPEED.y, 0.0f);
                    //Game::World::tileMap.setCamera(Game::World::tileMap.getCamera() + sf::Vector2f(LEFTRIGHTSPEED.y, 0.0f));
                }
            }
            if (!Collision::PixelPerfectTest(sprite, collider)) { collisionDir = None; }
        }
    }
all of the collisionDir is for detecting which side the collider is at
if anyone has a better way i'd love to do it
if you switch positions quick enough, you can travel through a collider
and if you walk diagnally you can travel with them
any suggestions for better way to detect which side the collider is at?
or just a better way to do movement in general, i guess
here is proper use for calling Move func btw
Game::Entity::g_eLocal.Move(window, Vector2i(VK_UP, VK_DOWN), Vector2i(VK_LEFT, VK_RIGHT), Vector2f(-5.0f, 5.0f), Vector2f(-5.0f, 5.0f), Wall);

6
Graphics / Question about selbaward's tilemap
« on: May 02, 2018, 09:48:43 am »
Link to source used:
https://github.com/Hapaxia/SelbaWard/wiki/Tile-Map
My tilemap code:
        //TileMap Stuff
        Tiles = ENG::TextureFromFile(&MainWindow, "Data//Images//tileMap.png", "main", false, false, true);
        for (auto& tile : levelData) { tile = rand() % 3; } // pick one of the four available tiles at "random"
        tileMap.setLevel(levelData); // connect level data
        tileMap.setLevelWidth(Engine::windowSize.x); // width of 125 means that the level data gets processed as if it is 125 x 80
        tileMap.setSize({ 1280, 720 }); // size of tile map's rendered image
        tileMap.setGridSize({ 40, 24 }); // size of tile map grid (number of tiles)
        tileMap.setTexture(Tiles);
        tileMap.setNumberOfTextureTilesPerRow(3);
        tileMap.setTextureTileSize({ 64, 64 }); // actual size of tiles within the texture
        tileMap.setPosition(MainWindow.mapPixelToCoords(Vector2i(0, 0)));
        tileMap.update();
        window->draw(tileMap);
        //TileMap Stuff
what it draws:
https://i.imgur.com/LZiFJgB.png
it only randomly selects the first 7 rows
my tilemap:
https://imgur.com/a/lKJk3SX
I'm not understanding what setSize & setGridSize & setLevelWidth do.

7
Graphics / Question about drawing tilemaps on a modified view
« on: May 02, 2018, 12:10:58 am »
I can't figure out how to draw a tilemap centered at the origin of the window with a modified view.
Here is my modified view:
View view;
view.setCenter(Game::Entity::g_eLocal.sprite.getPosition());
view.setSize(((float)Engine::windowSize.x), ((float)Engine::windowSize.y));
view.zoom(0.75);
window->setView(view);
My TileMap class:
https://www.sfml-dev.org/tutorials/2.1/graphics-vertex-array.php#example-tile-map
Here is my tilemap:
TileMap TM;
if (!TM.load("Data//Images//64x64grass.png", sf::Vector2u(32, 32), level, 16, 8)) { return -1; }
When I draw the tilemap, it doesn't set it to the origin of the current view.

I have determined that the view zoom is messing it up:
zoom = 1 works perfectly:
https://i.imgur.com/0dSloIz.png
zoom = 0.75 does not:
https://i.imgur.com/KidZMNY.png
it does not update the origin of the window


Also, how do i set the top left corner of the tilemap to the origin of the window?

8
Graphics / TileMap collision
« on: May 01, 2018, 03:48:27 pm »
How would I do collision for a certain texture for my tilemap?
I already have a collision class.
Is there any way to do it without having to set a sprite on top of it?
Am using:
https://www.sfml-dev.org/tutorials/2.1/graphics-vertex-array.php#example-tile-map
for the tilemap
and am using:
https://github.com/SonarSystems/SFML-Box2D-Tutorials/tree/master/SFML/Tutorial%20013%20-%20Pixel%20Perfect%20Collision%20Detection
for collison class

Thanks in advance

9
Graphics / Question about drawing tilemaps off-screen
« on: May 01, 2018, 01:30:41 am »
I was able to figure out how to draw a tilemap but I have a few questions.
How would one draw a tilemap off-screen or generate it procedurally?
I'm using https://www.sfml-dev.org/tutorials/2.1/graphics-vertex-array.php#example-tile-map
for my tilemap class.
Or how would you draw anything off-screen for that matter?
My View is centered on my local sprite

      View view;
      view.setCenter(Game::Entity::g_eLocal.sprite.getPosition());
      view.setSize(((float)Engine::windowSize.x), ((float)Engine::windowSize.y));
      window->setView(view);

Maybe i'm just not understanding how Views work.
Also, how would you draw an infinite tilemap?

10
Graphics / Question about textures
« on: April 30, 2018, 05:46:02 pm »
Where do you guys get most of your textures for sprites & such?
What program do you use to make your texture?
Any link on a tutorial of how to make a texture.

Thanks in advance

Pages: [1]