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 - Carlos Augusto Br Cpp

Pages: [1] 2 3
1
Wow man its so good to see that a game of my land is getting really good...

parabĂ©ns Tukimitzu, orgulho de br huehuehue  ;D

2
General / Re: Arkanoid game - move a ball
« on: June 05, 2017, 09:33:10 am »
You are welcome... good to know that it helps  :)

3
Animation also consists in update the frames...

so update the idle animation in game loop when are not updating the left or right animation...

4
Hey Elias... when will you give to us the grace of an demo?  :D

5
General / Re: Arkanoid game - move a ball
« on: June 03, 2017, 09:22:06 pm »
Sorry for dont reply quickly... btw... I have removed the paddle to focus on ball movement... so now its working... so you can check and study the code and put the paddle...

there goes:
#include <SFML/Graphics.hpp>
#include <random>
#include <functional>
#include <cstdlib>
#include <cmath>

int main(int argc, char* argv[])
{
    const int window_width = 800;
    const int window_height = 600;
    const float ball_radius = 16.f;

    sf::RenderWindow window(sf::VideoMode(window_width, window_height), "SFML Pong");
    window.setVerticalSyncEnabled(true);

    std::random_device seed_device;
    std::default_random_engine engine(seed_device());
    std::uniform_int_distribution<int> distribution(-16, 16);
    auto random = std::bind(distribution, std::ref(engine));

    sf::Vector2f direction(random(), random());
    const float velocity = 15;

    sf::CircleShape ball(ball_radius - 4);
    ball.setOutlineThickness(4);
    ball.setOutlineColor(sf::Color::Black);
    ball.setFillColor(sf::Color::White);
    ball.setOrigin(ball.getRadius(), ball.getRadius());
    ball.setPosition(window_width / 2, window_height / 2);

    sf::Clock clock;
    sf::Time elapsed = clock.restart();
    const sf::Time update_ms = sf::seconds(1.f / 30.f);
   
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if ((event.type == sf::Event::Closed) || ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
           {
                window.close();
                break;
            }
        }

        elapsed += clock.restart();

        while (elapsed >= update_ms)
        {
            const auto pos = ball.getPosition();
            const auto delta = update_ms.asSeconds() * velocity;
            sf::Vector2f ball_pos(pos.x + direction.x * delta * 2, pos.y + direction.y * delta * 2);

            if (new_pos.x - ball_radius < 0)
            { // left window edge
                direction.x *= -1;
                ball_pos.x = 0 + ball_radius;
            }
            else if (new_pos.x + ball_radius >= window_width)
            { // right window edge
                direction.x *= -1;
                ball_pos.x = window_width - ball_radius;
            }
           
            else if (new_pos.y - ball_radius < 0)
            { // top of window
                direction.y *= -1;
                ball_pos.y = 0 + ball_radius;
            }
   
            else if (new_pos.y + ball_radius >= window_height)
            { // bottom of window
                direction.y *= -1;
                ball_pos.y = window_height - ball_radius;
            }
           
            ball.setPosition(ball_pos);

            elapsed -= update_ms;
        }

        window.clear(sf::Color(50, 200, 50));
        window.draw(ball);
        window.display();
    }

    return EXIT_SUCCESS;
}
 

6
SFML projects / Re: Confluence - A Human Strategy Game
« on: June 01, 2017, 06:41:11 pm »
wow man... I enjoyed so much the art... its you that have draw it?  :o

7
SFML projects / Re: Snek Game!
« on: June 01, 2017, 06:35:50 pm »
haha so I will be watching for the next game...  ;)

8
SFML projects / Re: Snek Game!
« on: June 01, 2017, 05:48:54 pm »
Will you enhance the game? or is just for test and fun?  btw... good work :o

9
Graphics / Re: Simple Map Borders
« on: June 01, 2017, 05:41:25 pm »
You can make an if statement to check if the actual position of the object that you want to collide with walls, plus its own size, are greater or equal to the window side that you want...

I hope that it helps...

much love...

10
Graphics / Re: Rotate a Sprite centered
« on: June 01, 2017, 05:30:54 pm »
good... please put [SOLVED] on the name of this post, to help people know that you have get it... I was writing an answer when I see that you got it to works...  ;D

11
General / Re: Arkanoid game - move a ball
« on: June 01, 2017, 05:04:14 pm »
@EliasDaler you are right... and that is was exactly what I was trying to say it... putting one setPosition fuction in every collision check is no necessary... and move fuction work as well, since its code behind is a setPosition fuction getting the actual position of each axis and adding with a offset of our choice, doing the move... have a nice day  :)

12
General / Re: Arkanoid game - move a ball
« on: June 01, 2017, 07:17:02 am »
I recommend to you put the setPosition function on the game loop and when you check the collision you could just play with the values (x, y), so you will not need so many setPosition functions for each collision check...

13
SFML projects / Re: SimpleNES -- An NES emulator in SFML and C++!
« on: December 13, 2016, 07:57:10 pm »
humn... thanks... for sure I will give an try... but nice work bro...

14
SFML projects / Re: SimpleNES -- An NES emulator in SFML and C++!
« on: December 13, 2016, 12:05:58 am »
Hey bro... where did you have find material for 6502??  I have searched a lot... but only have find the "Easy 6502"...  :o

15
SFML projects / Re: Tic-Tac-Toe --My first SFML Game
« on: December 05, 2016, 01:05:04 am »
Congrats bro... every effort to make games in SFML is appreciated... I really have liked... I have made one tic-tac-toe with javascript in some past... and an fact is that even simple games like that is really good to code...

Pages: [1] 2 3