• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
afflicto

C++ & SFML?

23 posts in this topic

I'm new to C++ and I wanted to try SFML.

 

So I downloaded visual studio 2012 and the SFML 2.1 zip file. Extracted it to C:/sfml2.1

 

And I followed the instructions. I also disabled the 'Precompiled header' option in  'configuration -> C/C++ -> Precompiled headers' as suggested by another thread here on gamedev.

 

But I'm getting this error:

The program can't start because sfml-system-d-2.dll is missing from your computer. Try reinstall...

Any ideas?

 

Thanks in advance!

0

Share this post


Link to post
Share on other sites

You are welcome. Glad I could help. I think there is mention somewhere on the site about the DLLs.

By the way, from the Visual Studio tutorial page:

 

 

Now compile the project, and if you linked to the dynamic version of SFML, don't forget to copy the SFML DLLs (they are in <sfml-install-path/bin>) to the directory where your compiled executable is. Then run it, and if everything is ok you should see this:
Edited by Dragonsoulj
1

Share this post


Link to post
Share on other sites

Or just add the bin directory of SFML to the path, then you dont need to copy the dll files every time you make a new project. Just remember users of your program need them.

1

Share this post


Link to post
Share on other sites

You can get SFML liked statically to remove the need for dll. Static linking reduces the final size of the program, but possibly makes updates bigger.

I use static linking for convenience.

0

Share this post


Link to post
Share on other sites

I see. I did some stuff with the words 'linking' and 'sfml_static' I dno if that was linking.

0

Share this post


Link to post
Share on other sites

I have a question. What's going on in the Dog::Dog() constructor there?

Class Dog {
    private:
        Pig pig;
        Cat cat;
}

Dog::Dog()
    : pig(1)
    , cat()
{
}

Coming from other OOP languages, I find this strange tongue.png

Edited by afflicto
0

Share this post


Link to post
Share on other sites

I have another question. in SFML there is a templated Vector2 class.

 

I've been trying to extend it for the past few hours but damn...

 

Here's my code:

#pragma once
#include <SFML/Graphics.hpp>
#include <cmath>

template <typename T>
class Vector2 : sf::Vector2 {

public:
	T mag();
	void normalize();
	void invert();
	void decrease(T i);
	void reset();
	void limit(int i);
};

template <typename T>
T Vector2<T>::mag() {
	return sqrt(this->x*2 + this->y*2);
}
Edited by afflicto
0

Share this post


Link to post
Share on other sites

I would not do it that way. By deriving from that class that is not much more than a struct with a constructor, you are overcomplicating this and you will have to copy the vectors you get from sfml into your new type before you can use those methods. You better just make some free functions in the same way most of the functionality for using sf::Vector2 is done.

Though you should think again before doing that, the SFML vectors are just a tiny thing for communicating with that library and you may be much better off with using a real vector/matrix library like GLM: http://glm.g-truc.net

1

Share this post


Link to post
Share on other sites

I run into another issue.

 

I have a class 'Game'. and when instantiated, I want to store the instance on a static member of the 'Game' class but some code in SFML complains about NonCopyable.

 

I tried storing a reference, reference to a pointer and a the dereferenced object to no avail.

 

Here's the class:

class Game
{
	private:
		sf::RenderWindow mWindow;
		
	protected:
		std::vector<Entity> entities;

	public:
		static Game instance;
}

and the implementation:

Game::Game()
	: mWindow(sf::VideoMode(640, 480), "SFML!")
{
	//set the game instance
	Game::instance = *this;
}

Here's the full error:

error C2248: 'sf::NonCopyable::operator =' : cannot access private member declared in class 'sf::NonCopyable'	c:\sfml2.1\include\sfml\window\window.hpp	477	1	sfmltest2

What's going on here?

Edited by afflicto
0

Share this post


Link to post
Share on other sites

That means you should not do that with the RenderWindow as it was intentionally made not copyable to prevent errors.

Also singletons should be avoided as much as possible. Just create your objects somewhere and only pass a reference to as little functions through their arguments as possible and needed, to not get into the trap of creating spaghetti code.

0

Share this post


Link to post
Share on other sites

I was able to make it work.

 

It's not exactly a singleton. I just need my input object, sound object, gui object etc to access each other.

 

I think passing things around all the time is more like spaghetti code than to have 1 single place to store a reference to something. Less typing as well.

0

Share this post


Link to post
Share on other sites

That sounds like you want everything to access everything, when it would be safer to only have the higher level logic know about all those systems.

0

Share this post


Link to post
Share on other sites

If you want to have a private variable that stores the window, change it to a pointer and create a window with new:

 

In declaration:

sf::RenderWindow * mWindow;

 

In constructor:

mWindow = new sf::RenderWindow(sf::VideoMode(640, 480), "SFML!");

 

In destructor:

delete mWindow;
0

Share this post


Link to post
Share on other sites

It's not exactly a singleton. I just need my input object, sound object, gui object etc to access each other.

Which works fine if you pass references between things or have a container object to access them, if code was "just better" to have everything public and visible to each other we wouldn't have access modifiers at all.

I think passing things around all the time is more like spaghetti code than to have 1 single place to store a reference to something. Less typing as well.

I could argue against this but frankly there's at least a couple hundred live or half-dead threads on these forums going over this topic so I'm not going to bother, needless to say most people here are going to suggest you not just make everything global, public, or a singleton just because you think it makes it easier to type/deal with.

Hint: It doesn't. Definitely not in the long term.
0

Share this post


Link to post
Share on other sites

I was able to make it work.

 

It's not exactly a singleton. I just need my input object, sound object, gui object etc to access each other.

 

I think passing things around all the time is more like spaghetti code than to have 1 single place to store a reference to something. Less typing as well.

 

There is a lot of hidden dangers with using globally accessible variables. For one thing, it's hard to keep track of all the points of access. Because the objects can be accessed at any time, there is little options for the code to tell you that you need to initialize some global variable before the code can work correctly. At some point you'll forget that one of the classes in your code depends on a global variable and you'll forget to initialize it. Now you're wasting time fixing something that could have been prevented had you declared it as an input argument in your constructor. Sure, you can declare everything global, but you should keep in mind that scoping and proper class interfaces are there to tell you what information you need and hide information that should not be accessed elsewhere. It limits how many things you'll have to focus on and will keep you from creating functions that have hidden side effects.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0