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

Pages: [1]
1
General / Re: How to heck if key is double-tapped?
« on: April 10, 2017, 03:50:22 pm »
Hi! To make it work the way you want you gotta store last time the key was pressed somewhere. Then on the event KeyPressed for that same key, check elapsed time. Maybe you can use unix time?

What I would probably do is make a two key command. WADS to move, and Shift to run.

Good luck!

2
SFML projects / Re: First SFML/C++ project - Need feedback
« on: March 30, 2017, 09:27:53 am »
Thanks for the link on the tutorial. Really helpful. And I'll try to adapt to the C++ member variable style then. Thanks again for thr tips!

3
SFML projects / Re: First SFML/C++ project - Need feedback
« on: March 27, 2017, 08:13:36 pm »
I'm starting to feel like there is so much meat when it comes to constructors that I thought at first.

Yep, I know about the fact that 'this' is a pointer (for this reason we use the -> notation i guess). Thanks for the headsup anyways.

Then there is one quirk that I couldn't get my head around. When I created a class, and I added a constructor with arguments, omitting the argless one, the compilation failed   :-\

Thanks again!

4
SFML projects / Re: First SFML/C++ project - Need feedback
« on: March 27, 2017, 03:42:29 pm »
Hi! Thanks for that huge post! It was really helpful. Coming from a Java OOP background there are quite a few quirks from basic C++ that I'm not used to (such as not calling constructor). Then the constructor is only called to create pointers with the new operand?

About the use of constexpr, I didn't quite grasp the usage of it when was doing the game, but now I've read what it's useful for.

On using this->; it was intentional. I don't quite like the underscore name styling for member class variables, so I opted for the this-> option.

Yep, now I see that it's better to put public on top. It makes sense. Will do the inerhitance par for drawable. also makes more sense.

The up and down part of the paddles was intentionar, yet an 'or' check won't hurt too much. Will do too.

Last but not least the player part is also very true. The thing is I started working with the paddle, and only when it was working, added the player, with the least number of lines, which led to this "mess".

Just to wrap it up, I noticed that SFML scales up the graphics by default when resizing the window. Do you know if mouse posituon is also scaled? And does it scale everything? Sprites and all?

Thanks a lot it really means much.

5
SFML projects / First SFML/C++ project - Need feedback
« on: March 27, 2017, 12:03:16 am »
This week I've taken upon myself to learn C++, and given that I like very much anything related to video games, what best to make a game to learn the language  ;D

My first game is a PONG clone. Gameplay aspects are more or less covered. As a list of things to implement/improve could be as follows:
  • Make the rebound true to angle and velocity.
  • Display players scores.
  • Make a menu
yet I wanted to focus on learning C++ so didn't pay much attention to details.

I would be very glad to read any and all feedback. From code styling to best and worst practices or project structure... anything is good.
A good sir from the forums already told me that I overuse passing arguments by reference when maybe it´s not due (on small objects and such).

Thanks for the awesome community!

Edit: This is the repo: https://git.albertdev.com/NexusBattle/sfml-pong/tree/develop

6
Thanks for the tips to the both of you. I'll keep that in mind then! Truth is I still don't have thr hang of it yet, and probably will remain like this for a while. Got some books to check out!

7
Sorry to bother again. But I'm having trouble with the class Rect, which is given a template. In my case it would be FloatRect (https://www.sfml-dev.org/documentation/2.4.2/classsf_1_1Rect.php). I've tried:

namespace sf {
    class Rect<float>;
}
 

but without luck  :-\

Edit: Sorry to miss inform. Not without luck but with the follwoing error:

error: specialization of ‘sf::Rect<float>’ after instantiation
     class Rect<float>;

8
Thanks a lot!!! Now that's working fine, let's solve more problems :D

9
General / Having problems with forward declarations of SFML classes
« on: March 24, 2017, 06:36:31 pm »
Hi all! TBH I'm a newbie when it comes to C++, also SFML is the first attempt at a C++ framework for games (have used LibGDX and Love2D before thought). Have been using them for 2 days :D just recently.

Then, right now I'm making a Pong clone, and while trying to make custom classes, right now Game, Ball and Paddle, I try to forward declare classes from SFML, but the thing is I don't exactly know how to  :-\. As an example here is the PongGame class definition and implementation:

PongGame.hpp
#ifndef PONGGAME_H
#define PONGGAME_H

// INCLUDES
#include "PongBall.hpp"
#include "PongPaddle.hpp"


//FORWARD DECLARE
class Event;
class Time;
class RenderWindow;

// CLASS
class PongGame
{
    private:
        /* fields */
        PongBall ball;
        PongPaddle paddle_left;
        PongPaddle paddle_right;

    public:
        PongGame();
        void processEvent(const sf::Event& event);
        void update(const sf::Time& elapsed);
        void draw(const sf::RenderWindow& window);
};

#endif
 

PongGame.cpp:
#include "PongGame.hpp"

#include <SFML/System/Time.hpp>
#include <SFML/Window/Event.hpp>
#include <SFML/Graphics/RenderWindow.hpp>

PongGame::PongGame()
{
    this->ball = PongBall();
    this->paddle_left = PongPaddle(/*PongPaddle::Player::Left*/);
    this->paddle_right = PongPaddle(/*PongPaddle::Player::Right*/);
}

void PongGame::processEvent(const sf::Event& event)
{
}

void PongGame::update(const sf::Time& elapsed)
{
}

void PongGame::draw(const sf::RenderWindow& window)
{
}
 

Thanks for any help!

P.S: And yep... I regret preceding each custom class with the word Pong.

10
General / Re: Window resize and world coordinates
« on: March 22, 2017, 06:24:29 pm »
Hi! I'm very very new to SFML (just started today looking into it) but here are some thoughts: Why don't you scale up (or down) you rendered graphics? If you scale proportionally (aka, keeping the same aspect ratio) wouldn't it solve the problem?

Pages: [1]