Posts Tagged ‘game’

Posted by Tatyana at 2 March 2010

Category:

Tags: , , , , , ,

Templates in C++ are the way functions and classes operate with generic types. This allows a function or class to work on many different data types without being rewritten for each one [wiki].

Note that there is a difference between class template and a template class: class template is a template used to generate template classes. You cannot declare an object of a class template. Template class is an instance of a class template.

Here we are going to look at 3 main clas templates that are very useful in game and 3D design: Point, Vector and Matrix class templates.

Point and Point3D:

Here is how a simple Point template will look like in C++. This template is constructed to support multiple dimensions like Point2D, 3D and so on:

template <class T, int n> class Point {
protected:
	T mat[n];
	 void cp(const Point<T,n> &p)
    {
		memcpy(mat, p.mat, n*sizeof(T) );
	 }

    void cp(const T p[n])
    {
		memcpy(mat, p, n*sizeof(T) );
	}

    void cp(const T &val)
    {
		for (int i=0; i<n; i++)
			mat[i] = val;
    }

public:
	// new constructor
	Point(const T pt[n])
	{
		cp(pt);
	}

	// copy constructor
	Point(const Point<T,n> &cp)
	{
		this->cp(cp);
	}

	// default constructor
	Point()
	{
		for (int i=0; i<n; i++)
			mat[i] = 0;
	}
	virtual ~Point(void) {};
};

Templates are of great utility to programmers in C++, especially when combined with multiple inheritance and operator overloading. Here vi can add multiple operator overloading functions to our Point class template, for example addition:

        //Point + some value
	Point<T,n> &operator+=(const T &val)
    {
		for (int i=0; i<n; i++)
			mat[i] += val;

		return (*this);
    }

    //sum of two Points
    Point<T,n> &operator+=(Point<T,n> &pt)
    {
		for (int i=0; i<n; i++)
			mat[i] += pt[i];

		return (*this);
    }

A Point3D class template will look like this:

template <class T> class Point3D : public Point<T,3> {
public:
	Point3D() : Point<T,3>() {};

	Point3D(const Point3D<T> &p) : Point<T,3>(p) {
		for (int i=0; i<3; i++)
		mat[i] = p.mat[i];
	}
	Point3D( const T px, const T py, const T pz)
	{
		mat[0]=px; mat[1]=py; mat[2]=pz;
	}
};

An example of how we can use it is a motion programming:

	Point3D<float> EulerAngle(float sensitivity, double x, double y, double z) {
		return Point3D<float> (
				sensitivity*cos(z),
				sensitivity*sin(z),
				0
		);
	}

Posted by kent at 2 August 2009

Category: Game review

Tags: , , ,

It sucks.

That was my first impression.

Right from when I installed it and started it, it took me 30 minutes to get started. 15 minutes of shader generation and 15 minutes of clicking through every small little popup window with “helpful” hints. I got tired after the 2 first “hints”, so I rushed through them all. That was before I got started with actual gameplay.

When the game finally started and I was able to drive a vehicle, guess what! MORE FUCKING POPUPS AFTER MOVING THE VEHICLE 2 METERS[1]

When I got started it seemed like I needed some Games for Windows account to save my progress, and that I couldn’t save the progress without it. I don’t have an account and I don’t intend getting one either.

After about 20 minutes of uninterupted (wow!) playing, I had enough of metre wide pixels and crappy physics.
You see, it doesn’t look good at all with a game running in a default 640×480 resolution on a 26″ monitor – and without the ability to change resolution within the game, it starts to get real bad! And believe me, the graphics and physics in the original Monster Truck Madness from 1996 is miles ahead of FUEL!

And to be fair, I tried to do a second impression after changing the resolution to 1920×1200 pixels. The graphics was far better, but the physics were still crappy.

And to be fair the second time, the idea and concept was and is good. but the wrapping sucks big time! Codemasters might have forgotten that playing games is all about having fun and playing the game, not being able to select paintwork and colors and what the driver should look like. And you must be able to save the game without relying on internet access and Microsoft! And not to forget the ultra-annoying popups!

Sadly, there won’t be a third impression. I kind of liked FUEL after I got started, but without being able to save the game, the final nail in the coffin was nailed.

So, this was an utterly big fail! Its a shame though, the music was good!