Jump to content

  • Log In with Google      Sign In   
  • Create Account


chryan

Member Since 03 Apr 2005
Offline Last Active Dec 18 2011 12:14 PM

Topics I've Started

Deity - Unique Stealth Action

16 December 2011 - 05:19 PM

I've been working on a game project, Deity, with a team of other students for the past 15 months and
it was released to the public this morning.

Here's the release announcement video:
http://www.youtube.com/watch?v=dVPIb1O9f2o


The game is now freely downloadable at our website.
Give it a try and let us know what you think!

Game Description:
Deity is a stealth action game developed by a team of students at DigiPen Institute of Technology.
Deity features unique gameplay mechanics, requiring only the mouse to play and was inspired by
games such as Diablo and Batman: Arkham Asylum, encompassing stealth action in an isometric view.

Chewable Framework (XNA For C++)

12 August 2009 - 09:49 AM


The Chewable Framework
Chewable is designed to make your life easier.

Inspired by XNA, it aims to provide a C++ component-based framework to make game development easier, providing the foundation for getting a game up and running.

It is intended to be a minimal library so it does NOT include features for windowing, input, graphics, audio. However, it is fairly easy to plug these systems into the game. As such, the project does not rely on any external libraries to compile (with the exception of Google Test for the unit tests project, which is not required), making it easy to setup.


Chewable Features
Chewable implements the following key features:
  • Fast Event/Delegates
  • Object/Object component management
  • Game state management
  • Object/Object component registry system
  • Component system
  • Services system
  • Math Utilities/Wrappers
  • High-Precision Timers
  • Logging & Profiling Tools
  • Custom assertion system
There are a number of other useful utilities included.


Currently, only MSVC2008/2010 on Windows is supported. Feel free to contact me if you're interested in implementing support for Linux or Mac.


Tutorials will be done over the course of the next few months.


Link: http://chewable.googlecode.com/
Last Updated: 29-Mar-2011


C++ Singleton Across DLLs

11 August 2009 - 12:32 AM

Hi, I've implemented a simple singleton solution as shown below:
// Singleton.h
template< typename T >
class Singleton
{
public:
    Singleton();
    ~Singleton();

    static T & Instance( void )
    {
        return mSingleton;
    }
    static T * InstancePtr( void )
    {
        return &mSingleton;
    }

protected:
    static T mSingleton;

private:
    Singleton( Singleton const & ); // Hide copy ctor
    Singleton & operator = ( Singleton const & ); // Hide assignment operator
};

template< typename T >
T Singleton< T >::mSingleton = T();


Using this solution, I'm curious about the implications of using this across DLLs, for example:
class __declspec( dllexport ) 
MyClass : public Singleton< MyClass >
{
public:
    void Print( void )
    { printf( "Hello!" ); }
};


If I were to compile the above code into a single library DLL, would external usage of the MyClass singleton access the library version or create it's own copy of the static variable?
#include "MyClass.h"
...
MyClass::Instance().Print();


Thanks in advance. EDIT: Changed the Singleton class code a little. [Edited by - auron777 on August 11, 2009 7:17:26 AM]

C++ Event/Delegate System

27 July 2009 - 09:29 PM

Here is a simple event/delegate system I've been working on as part of a framework I'm doing. I make use of a Fast Delegate which can be found at here (requires some boost headers).
/// Traits structure specialized for defined events using the event definition macros.
template< typename T >
struct ArgumentTraits
{
};

template< typename T >
class Event : Noncopyable // Cannot copy events.
{
public:

	/// Arguments typedef for convenience.
	typedef ArgumentTraits< T > Arguments;
	/// Listener function pointer type.
	typedef void ( * ListenerFunc )( Arguments const & );
	
	/// Get global event.
	static Event< T > & Global();

	/// Empty constructor.
	Event() {}

	/// Empty destructor.
	~Event() {}

	/// Raise an event with arguments.
	void Raise( Arguments const & args );

	/// Register a listener function to the event.
	void Register( ListenerFunc func );

	/// Increment operator used to register a listener function to the event.
	void operator += ( ListenerFunc func );

	/// Unregister a listener function from the event.
	void Unregister( ListenerFunc func );

	/// Decrement operator used to unregister a listener function from the event.
	void operator -= ( ListenerFunc func );

	/// Register a listener object to the event.
	template< typename O >
	void Register( O & obj );
	
	/// Increment operator used to register a listener object to the event.
	template< typename O >
	void operator += ( O & obj );

	/// Unregister a listener object from the event.
	template< typename O >
	void Unregister( O & obj );

	/// Decrement operator used to unregister a listener object from the event.
	template< typename O >
	void operator -= ( O & obj );

	/// Clears all registered event listeners.
	void Clear();

private:

	fd::delegate1< void, Arguments const & > mDelegate; ///< Event delegate.
};

template< typename T >
Event< T > & Event< T >::Global()
{
	static Event< T > global;
	return global;
}

template< typename T >
void Event< T >::Raise( Arguments const & args )
{
	if( mDelegate.count() )
		mDelegate( args );
}

template< typename T >
void Event< T >::operator += ( ListenerFunc func )
{
	Register( func );
}

template< typename T >
void Event< T >::operator -= ( ListenerFunc func )
{
	Unregister( func );
}

template< typename T >
void Event< T >::Register( ListenerFunc func )
{
	mDelegate.add( func );
}

template< typename T >
void Event< T >::Unregister( ListenerFunc func )
{
	mDelegate.remove( func );
}

template< typename T >
template< typename O >
void Event< T >::Register( O & obj )
{
	mDelegate.add( boost::ref( obj ) );
}

template< typename T >
template< typename O >
void Event< T >::operator += ( O & obj )
{
	Register( obj );
}

template< typename T >
template< typename O >
void Event< T >::Unregister( O & obj )
{
	mDelegate.remove( boost::ref( obj ) );
}

template< typename T >
template< typename O >
void Event< T >::operator -= ( O & obj )
{
	Unregister( obj );
}

/// Macro to define a new event.
/// Arguments is typedef-ed for convenience, as seen below.
#define BEGIN_EVENT_DEF( eventName ) 	struct eventName { typedef ::ArgumentTraits< eventName > Arguments; }; 	template<> struct ::ArgumentTraits< eventName > {

/// Close event definition.
#define END_EVENT_DEF };

For objects to register with the event, it must implement the () operator. Usage:
BEGIN_EVENT_DEF( OnTest )
	int x;
	int y;
END_EVENT_DEF

class TestListener
{
public:
	void operator () ( OnTest::Arguments const & args )
	{
		printf( "[Object] %d, %d", args.x, args.y );
	}
};

void TestFunction( OnTest::Arguments const & args )
{
	printf( "[Function] %d, %d", args.x, args.y );
}

Event< OnTest > evt;
TestListener listener;

evt.Register( listener );
evt.Register( TestFunction );
evt.Raise( data );
evt.Unregister( listener );
evt.Unregister( TestFunction );
evt.Raise( data );

// OR

evt += listener;
evt += TestFunction ;
evt.Raise( data );
evt -= listener;
evt -= TestFunction;
evt.Raise( data );

The Global() function is not needed but is useful for global events that need to be triggered. Feedback is appreciated. :)

PARTNERS