First, I am building a little 3D engine in c++, just for fun. This is said to me quite often:
You should have your game use the engine as a library. But I thought
it would be better the other way around, like here. Thus have the
engine being the executable, and have it just call the game classes
loop functions in order(classes either compiled with the engine exe,
or loaded from a dll/so).
This because in my game engine, the engine has an editor, and you create game classes(eg. a player controller) by creating a class derived from GameObject.
And have the engine being the game executable, and have it call the Loop function of that class every frame.
This seems better to me, as it only needs an engine that calls the game classes.
So what would you recommend based on what I said and the link?
Thanks!
Both have their pros & cons:
LIBRARY:
You can have things and size compact use the part of engines you want
You can make high end compatible games a bit ported to the low end ones.
GAME ENGINE:
Things will get easier.
Less time consuming
Related
I'm using the Marmalade SDK, my question is, can I use only cocos2d-x and Box2d, and not use Iw2d, IwGx, IwGL altogether (or vice versa)?
And what factors will my choice depend on regarding if I want to use cocos2d-x and Box2d, and not all the others (or vice versa)?
P.S I'm developing a 2d game that will need minimal physics
you can use Cocos2d-x without using Iw2D, IwGX, etc. Cocos2d should abstract these things for you. Cocos2D-x is a complete game engine, where Iw2d is only a rendering system that renders 2d sprites für you.
What systems you want to use depend on how much low-level work you want to do yourself.
If you use Cocos2D-X it will have support for a lot of features out of the box. Like scenes, sprite-rendering, skeleton-animation, effects, particles etc..
Iw2D just abstracts the low level OpenGL-API so that you can render sprites with just one function call. But it does not support animations and other features. So you would have to include other projects or write the functionality yourself.
IwGx is a wrapper for OpenGL which introduces states so that the OpenGL-API is easier to handle.
IwGl is just plain OpenGL and you would have to implement even the rendering yourself.
Which one to use depends on the project. When you just want to make a 2d game cocos-2d or Iw2D should give you enough control to succeed doing so and also you will save time because you can use already tested systems.
Box2d is only used to drive the physics simulation of your game world. You can use it with all of these systems.
Depending on your C++ and game programming experience i suggest to first use a game engine (like cocos2d-x) or Iw2D to learn the basics. For your second game you can still switch to a more low level api if you want to.
Sounds like you can focus on the Quick flavor of Marmalade, which has cocos2d and box2d bundled up with Lua. That will make for easy start and development.
Yes, I admit this is the same old question, but I used to apply this pattern heavily in my game engine (if it counts one) design.
I noticed in this question http://stackoverflow.com/questions/137975/what-is-so-bad-about-singletons , Jim Burger has given his answer, yes it's true that my codes are tightly coupled, but where I apply singletons are managers used in my engine, for instance, resource manager which manages all sorts of images, audios and data. I can ask for resource anywhere in my code "ResourceManager.getInstance().getImageAndCacheIt("someimage"); ", so on top of my engine, the game logic codes are coupled tightly with it.
It is common your codes? Is there a better solution?
And I used to think that some of the Classes which Android Activity uses are singletons, however after digging into the source code, I found that they are surprisingly not, they are lazily instantiated with some configuration, should I use this approach instead?
And would you be so kind as to tell me some of your engine design experiences, what subsystems do I need, do you use a visual tree or draw your elements directly line by line?
By the way, what language do you use to make 3d video games, java or c++ or something else, now I'm working on java/opengl es
A common alternative to singletons is to use Dependency Injection.
With these programs, it seems like every aspect of the game is done through the GUI. Is there any coding when making games through these programs? Like would you code in collision detection, or would that be done through the GUI?
I don't know the Unreal engine but Unity3D and SIO2 but the situation should be similar. Basically a lot of programming is taken from you and can be done through setting properties like in a Blender material. But at the end you have to do at least a little bit of coding.
The process of collision detection for example involves attaching a collider to your player character and another one to your obstacle. Then you have to attach a small script to your player like this.
void OnTriggerEnter (Collider collider) {
if (collider.material.name.Equals ("ObstaclePhysicMaterial")) {
player.PlayAnimation ("Die");
// your code snippet to game over or whatever
}
}
Not too abstract but it has to be done and of course your game over logic will include some more code to reset all objects to their initial position. So at the end you cannot avoid coding but when I started learning Blender I made the experience that more complex Blender scenes have indeed similarities to programming. You have to plan your scene and find the most efficient structure to avoid unnecessary work i.e. thinking in terms of logic is slightly analogue.
So if you plan a game with heavy graphics and not too sophisticated logic I like to encourage you to give scripting a try. Start with studying sample projects.
With development kits you usually get. The most important part the engine. Sometimes materials and land scape tools. All you do really is the scripting part. Events, environmental variables, usually in LUA or python. Not the actual engine and physics.... the hard part.
I need a 3D engine for a very specific task in Artificial Intelligence, and I'd like some input.
The first part is the trivial one - basically, all I need is a FPS engine (3rd person would be good, too), such that it allows me to navigate a room and interact with objects (if you have Java and Windows, I'm looking for something similar to the Give Challenge, but a little more up-to-date). Physics would be nice, but is not a must.
Now, the non-trivial part would be: I need to impose a virtual grid over this room, such that at any moment I can say "the player is located at B5 - now he moved to B6", and so on. I need to redirect this information to another system (namely, one which will give the player instructions about what to do) and, at the same time, send messages to the player, so I must be able to have a single point through which the game logic passes through; also, I'd love not having to write my own collision detection and such.
So far, I've tried:
the Source SDK: it seems a little overkill (since I'm not really planning to shoot anyone, at least half the code base is useless to the task), and since I'm not really a Windows developer, I'm spending too much time with the "easy" stuff (such as getting VS up and running). Plus, cross-platform would be really nice.
Blender game engine: while this worked decently, the interaction model seems a little weird, and some easy stuff (such as making sure the camera stays inside the scene or showing the mouse on screen) gets too weird too soon.
Crystalspace 3D: I've tried their demos, but it looks a little old-fashioned, and since that was one of the problems of previous engines (it's easier to get volunteers when your game looks nice) I'd like to try something else.
Now, maybe I'm asking a little too much for a single software, but I'd love some input. Can anyone suggest me an alternative? Or should I give one of the previous ones a second chance?
Try the UDK. All of the things you request are present, and it's free for personal/noncommercial projects. Here are some highlights:
Modern looking. The UDK features an intuitive-ish visual material design system, post-processing effects, Scaleform Gfx UIs from Autodesk, and more.
A visual scripting interface called Kismet that can control gameplay elements, the camera, and more.
UnrealScript, a scripting language similar in syntax to C, C++, Java, that gives you the ability to extend existing functionality or create your own.
Comprehensive documentation available on UDN.
Lots of community support outside of Epic, in places such as Polycount, Eat3d, 3dbuzz, and more.
Basically, "and more".
If what you're looking for is a professional, free (as in beer) engine that will allow you to focus primarily or solely on your differentiating gameplay features, Epic has set the bar high.
I know this is a pretty open question but I was wondering how people go about writing scripts that will "play" a game, or manipulate it in some way. I had been thinking that I'd try to get a working AI to play a game for fun, but don't even really know where to start. Are there any good resources to learn this? What are good languages to use? Once I have the language, how do I get my script hooked into the game? I was thinking of just trying simple flash games, if that helps.
Thanks a bunch!
Are you looking to "play" an existing game, or write some sort of a game that can then be scripted?
If the former, you find that game's API and start writing code in the appropriate language. E.g. Unreal-powered games use UnrealScript and ship with the tools so you can embed new functionality. You're pretty much dependent on the game creators leaving an "in" such as this...
...unless you want to get totally nutty and hack the executable itself to execute your own code somehow. For information on how to do this, search for information on game "trainers". I'm not sure what a great set of search terms would be, but I know a lot of games do have trainers released, so type in "trainer <my_favorite_game>" and see what you get?
You can do this quite simply in Java 6.
expose your objects/functions in your Java app into the scripting environment
For example you can expose your character or the game world into the scripting environment and allow the script to control it.
invoke script functions/methods from Java environment
Allow the script to customize behaviours, add new actions, etc. Another use of this is to override the default build in game rules and load your own house rules. Another use is as a macro facility. Typically this would be part of the main game loop
use the script as a data/level file
For example, in a game likes SpaceHulk where it is mission based, you can use a script to define a game specific DSL, and us this DSL to define new missions. When the game starts up, it evaluates the data file and create a model of the game.
To integrate a scripting engine into Java, simply do this
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine jsEngine = mgr.getEngineByExtension("js");
jsEngine.eval("print('Hello world!');
To expose an object into the script environment
jsEngine.put("avatar", avatarObject);
//An avatar object is now available in myscript.js
jsEngine.eval(new FileReader("myscript.js");
To invoke a function in the script
jsEngine.eval("function hello(name) ... ");
Invocable inv = (Invocable)jsEngine;
inv.invokeFunction("hello", "Fred");
One of the problem with scripting is that, the script has access to your entire application. You can restrict what the script can 'see' by setting a classloader when you create the ScriptEngineManager instance.
Java 6 comes with a bundled JavaScript engine. However I prefer Groovy and loading Groovy basically mean changing 'js' in getEngineByExtension() to 'groovy'.
I know that a lot of people say that Java is not fast for games, but if you are writing turn based games or social games like Farmville then I think it is more than adequate.
For C/C++ based games, I think the preferred script engine is Lua. I've not used it so I cannot comment on it.
The best way to do that is to use the API provided by the game, if there is one. The Civilization games, for example, come with a very complete modding engine that allows you to script whatever you want. The same can be said for Age of Empires and a variety of other games.
Simple flash games, though? That'll be tough. Those don't generally provide any supported way to script, so you'll be left with simulating input. It'll be tough.
The easy way is to control mouse and keyboard functions with autoit. You can also read out information from your screen, but it is a bit limited It is good to just check if things changed or check whats on a certain area of the screen if you know there are a limited amount of possibilities. Not so easy to read and interpret text. Autoit is excelent to automate games like farmvile. I have also made blackjack bots for online casinos. And use it for small but mundane and repeating (manufacturing) tasks in RPGs. Dont expect to build an AI for an RTS or FPS though.
Autoit is easy to find with google. A fast and small download. Excelent documentation and you can learn it in days.
The hard way is what people wrote about above here i guess. Interacting with the game data. Searching information on that is what brought me here. I see its with C++ or Java. While the languages are all similar and you can use them all after learning 1, these come with complicated software environments that take lots of time to learn. The possibilities and chances to make something really reliable are much much greater though.