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

Pages: 1 [2] 3 4 ... 394
General / Re: Reason: Unable to open file
« on: July 04, 2021, 02:20:33 pm »
Probably your working directory is not correct.

IIRC, by default Visual Studio uses the output directory (where the .exe is created) and not the solution directory.
You can change the working directory in the project settings.

Have you looked at the compiler error messages and tried to resolve them one-by-one?

If you copy-paste GitHub code partially into your own project, don't expect everything to magically work. And if it doesn't, don't just dump the code here and ask others to resolve it...

An alternative approach is to start from the official source, change things only slowly, and make sure things still work after every change. Git can be very helpful here: commit each change, and find out where stuff breaks.

General discussions / Re: GUI Issue
« on: June 30, 2021, 08:35:41 pm »
It seems to me that you're designing the GUI library ahead of any project that uses it. While this can be nice to experiment with different scenarios, it is often more efficient to do Dogfooding, as it will make the use cases more clearer and also tell you how the API should look.

What I can also recommend is to look at one of the many existing UI libraries for SFML. Chances are that you might not need to reinvent the wheel, or at least draw inspiration from existing projects. There are of course also many UI libraries completely outside SFML; if you're not developing a game, that might be a better choice.

Btw, what is up with your font size? :D

General / Re: Entire game in single cpp file?
« on: April 21, 2021, 05:17:19 pm »
Youtube tutorials are often low-quality and gloss over lots of important topics. C++ is probably the most complex language (at least of those actually used in the industry), it's entirely impossible to learn it in a few days.

That being said, if you want to learn a new language in 2021, I'm not sure if C++ is still the best choice. I would rather recommend Rust (if you want to have the same level of control), which is significantly more modern and easier to use than C++, and does a lot of things better.

General / Re: About game states
« on: April 16, 2021, 08:15:53 am »
@AdrianHey: please follow the advice I gave you in my last answer.

It's not nice to ask a low-effort question without research, let people spend a big amount of time answering and then not even get back to them.

The only question that you replied to was this one, and interestingly it's exactly the one where you spent more time asking the question.
All the others are two-sentence questions and remain unanswered:

If you continue like this, soon people will stop helping you altogether.

General / Re: Problem using delta time
« on: April 15, 2021, 12:30:27 pm »
I am trying to make an int function withc return delta tiomme and It doesent work. Any ideawhat can I do?
Please read this thread first.
This concerns a lot of your posts here.

And please spend at least 10 seconds formulating a clear question without typos, if you expect people to spend several minutes answering.

General / Re: Change color when hovering over text
« on: April 15, 2021, 10:13:34 am »
By the way, this should just be a warning (maybe an error if you treat warnings as errors), you can still use setColor().

Network / Re: My Issue with TcpListener listen() method
« on: April 11, 2021, 04:56:53 pm »
A bit late, but the reason is not zero initialization -- both times, the same constructor is called, default-constructing the sf::TcpListener member variable.

As expl0it3r mentioned, initialization at startup (i.e. from global variables) is a big mess in C++, as there's no deterministic order. So better avoid global variables in general, good design almost always makes them obsolete.

General / Re: understand sf::Time
« on: April 11, 2021, 04:29:36 pm »
sf::Time is simply a value. It doesn't change on its own.

General / Re: Entire game in single cpp file?
« on: April 11, 2021, 04:27:25 pm »
Multiple files only decrease compile if you carefully check dependencies, and possibly use the PImpl idiom. If you have a #include <SFML/Graphics.hpp> + several standard includes in every header file, your code is almost guaranteed to compile slower than doing the same thing in a single header file. After all, the compiler needs to re-compile the same code over and over (unless you use precompiled headers).

You can definitely start with one file, C++ leaves it up to you how you organize your code. But once your code grows beyond a few hundred lines, it really gets harder to navigate. At some point, compile times do come into play, because that one file (and thus your entire code) needs to be recompiled on every change, no matter where.

Consider this: you have files Zombie.hpp and Zombie.cpp which implement a class. The header is simply the public interface + some member variables. The logic how the zombie moves is written in the .cpp file. Now if you want to modify something, e.g. make it faster to move or change how it interacts with certain objects, the compiler only has to recompile Zombie.cpp + all the headers it includes. But it does not have to recompile Player.cpp, Item.cpp and Orc.cpp. They are independent translation units.

General / Re: ld.exe cannot find -lsfml-graphics-d
« on: April 11, 2021, 03:34:34 pm »
All the search directories are added correctly still its giving this error.
Are you sure you added the library directory with sfml-graphics-d? Double-check, the error indicates that it is wrong.

How does the filesystem of that lib directory look?

General / Re: If an object is not drawn does it exist?
« on: April 09, 2021, 01:10:48 pm »
If an object is not drawn does it exist?
Quite a philosophical question!

See my answer in the other thread for an explanation. Collision with other objects will happen exactly when you program it, otherwise not. There is no "implicit" collision in SFML or anything like that.

Maybe also consider reading a good C++ book that explains the concept of objects and their lifetimes ;)

General / Re: Any way I can destroy objects?
« on: April 09, 2021, 10:40:04 am »
Even if you would call the destructor, the object would still be there, just in a destroyed state. But you'd still have a variable referring to it. Also it would be undefined behavior for stack/automatic objects, their destructor is called at the end of their scope, so don't invoke it manually.

What you typically want to do for things like bullets is a STL container, almost always std::vector (see cppreference.com). You can dynamically add and remove objects, and iterate over all existing objects. So whenever someone shoots a bullet, you add it, and when it hits something, you remove it from the vector.

"Static array" can also be understood as the counterpart to "dynamic array", i.e. an array with fixed size at compile time, or simply an array -- not a pointer allocated with new[]. I would try this.

Using the keyword static just so it's used really makes no sense. Maybe we're missing some context.

A few hundred draw calls should be OK, did you encounter any problems? I wouldn't make code more complicated than necessary.

Otherwise, can you tell us a bit more about how the effects/icons are drawn? Are they static? Are they part of a shared texture? Animated?

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