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

Pages: [1]
1
Graphics / Re: [Very Beginner] Need Help With Drawing Things
« on: November 26, 2020, 04:34:37 pm »
all the problem is solved, thankyou for helping! :D

2
Graphics / Re: [Very Beginner] Need Help With Drawing Things
« on: November 26, 2020, 01:45:22 pm »
You first need to figure out how you want to draw a snake, since they can have different lengths or directions.
If you just use shape, you'd need to calculate the correct rotation for a start and end point yourself or you could also check out the LineShape someone wrote once.

But if you then have different textures for the snake or ladder, you'll have to come up with a way to add more sections of the given texture.

after searching answers on the internet, i think that problem is solved, here's what i've done to my code, but i have a new problem and i don't know what to do, here's the code

void Board::render(RenderTarget& target) //<- this is RenderWindow from the main game.cpp
{
        node* temp = head;
        while (temp) {
                if (temp->jump->location > temp->location) {
                        float distance = pow(temp->locx - temp->jump->locx, 2) + pow(temp->locy - temp->jump->locy, 2);
                        distance = pow(distance, 1 / 2);
                        float scaley = distance / laddersprite.getTexture()->getSize().y;
                        laddersprite.setScale(5, scaley);
                        laddersprite.setOrigin(laddertexture.getSize().x / 2, laddertexture.getSize().y);
                        float angle = atan2(temp->jump->locy - temp->locy, temp->jump->locx - temp->locx);
                        laddersprite.setRotation(angle);
                        laddersprite.setPosition(temp->locx, temp->locy);
                        target.draw(laddersprite);//<--it triggers breakpoint here
                }
                else if (temp->jump->location < temp->location) {

                }
                temp = temp->next;
        }
}
 
i'm pretty new with SFML and i never encountered problems like that, i used linked list for the game and jump is snake/ladder target tile(as a node), locx and locy is basically the position of the tile

3
Graphics / Re: [Very Beginner] Need Help With Drawing Things
« on: November 26, 2020, 09:23:44 am »
You just apply some math. Calculate the position of the tile, then subtract half of the width of the snake or ladder. Best you take some pen and paper and figure out the math on paper, before trying to apply something in code.

i have the location of the every tile, but i dont know how to set the beginning and the end of the snake in tiles, what type of shape should i use and how to set the positions?

4
Graphics / [Very Beginner] Need Help With Drawing Things
« on: November 26, 2020, 07:41:36 am »
Hi!
I have a snake and ladder game project, I have to draw a snake / ladder of course, but I am confused about how I can set the snake or ladder so that the location can match the board tile, is there any way that i can set the start of the snake with Vector2f, and the other end with also Vector2f? sorry for my bad english, hope you understand and can fix my problem, Thanks!

Pages: [1]
anything