Subscribe to gabehabe's on-topic ramblings        RSS Feed
-----

Creating a Game Engine!

Icon 1 Comments
So I've finally decided to work on a pretty big project. Doing it all by myself, the best way to do it IMO.

This new project is a 2D game engine. It'll be sooooo easy to use, and it'll be for creating games with a similar gameplay to the early Final Fantasy games. Nothing flashy, but fun all the same.

It could also expand into a game maker, something like RPG Maker if I ever get around to it. I have a habit of getting distracted from my side projects.

So, this engine. It's written in C++ using SDL for graphics. I've been working on it for a total of about 10 hours (maybe more, maybe less... I haven't been keeping track)

So far, there's sprite animation, and the player can walk around on a map. Objects can be loaded, and the player will collide with them when they try to walk into them. You can also load NPCs and talk to them. (Old FF style dialog boxes)

The map is loaded from an image, and images (objects) can be loaded onto that. I just finished figuring out some nasty looking function callbacks to "add an action" to an object, ie, when the player inspects the object, they could find an item, it could say something, could trigger an event. These events are in user-defined functions, and a pointer to these functions is passed to the object.

For those of you interested, here is your typical "gabehabe's test thingy" before it gets added to the project:

#include <iostream>
//#include<sdl/sdl.h>

using namespace std;

void a() {cout << "a";}
int b() {return 2;}

// experimentation
// template<class T>T exec(T(*f)()){return f();}

template <class T>
class object {
	public:
		void set_special_action(T(*f)());
		T perform_special_action();
	private:
		void* action;
		//SDL_Surface* img;
		//SDL_Rect offset;
		//int times_to_perform;
};

template <class T>
void object<T>::set_special_action(T(*f)()) {
	this->action = (void*)f;
}

template <class T>
T object<T>::perform_special_action() {
	return ((T(*)())this->action)();
}


int main(int argc, char* argv[]) {
	object<int> p;
	p.set_special_action(&B)/>; // add b() as the action
	cout << p.perform_special_action(); // outputs b() (which is 2)
	cin.get();
	return 0;
}


More news as this engine develops, but it's looking to be quite an ongoing project.

Future developments include exits to move from one screen to another (obviously a necessity), ability to add "second level" objects, that the player can walk behind (creates a slightly more 3D interaction) and weather. (Stuff like snow, with the ability to settle on surrounding objects)

Any special feature suggestions are greatly appreciated~! :D

1 Comments On This Entry

Page 1 of 1

Noldona Icon

01 April 2009 - 12:28 PM
Sounds like fun. I am planning on doing a game engine myself after I get this Toolkit project done. My plan is to make the game engine itself generic enough that it will work for any style of game and cross-platform. I, of course, will be using SDL and OpenGL for mine. I will definitely be interested in seeing how this turns out.
0
Page 1 of 1

December 2014

S M T W T F S
 123456
78910111213
14151617181920
21222324 25 2627
28293031   

Request A Topic!

Want me to blog about something? Perhaps a language? A piece of software? A specific topic? Let me know! Even guests can post here on my blog!

If you would like to request a topic, please post a comment here and I'll get on it right away! smile.gif

Search My Blog

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)

gabehabe's off-topic ramblings

Follow me on Twitter!
lol, my other blog died a horrible lonely death. Ah well.

Smiley of the [however often I change it]

IPB Image

Contact Me

e-mail: gabehabe@gmail.com

Google Talk: gabehabe@gmail.com
MSN: gabehabe@hotmail.com
Yahoo: gabehabe (rarely used)
AIM: gabehabe (rarely used)

Skype: gabehabe

Want me to work for you? [click]