Archive

Archive for the ‘game engine’ Category

More on Python

December 18th, 2004 zeraien No comments

How about this idea…. Python is a pilot, and C++ is the ship.

Basicly I figure that I still want to keep most of the object infrastructure in C++ but let python control some objects such as ships.

I did come up with the idea of sending extensive data back and forth via lists rather then separate methods for everything… this will surely save time and code, since I wont have to have a method for every little detail that python or C might need to know about a ship.

In any case, I am still working on this whole integration thingie.

Categories: c++, game engine, python Tags:

Enter: XML

December 18th, 2004 zeraien No comments

Today I realised that perhaps the best way to store data about graphics, sounds, objects and actions would probably be XML.

After creating some basic XML files containing the data for my meager game, I have come to realise that I was correct. Using XML files might create a larger file, but in the end I believe it to be worth it.

XML makes it easy to store the data about all kinds of shit, and by using DTDs I can even set default values for rarely used fields and all that kind of stuff.

In other words, the ambiguity of ["ship-01","ship.png",12,5,1] was replaced with

<ship type="ship-01">
    <action name="default">
        <animation name="ship-01-default"/>
    </action>
</ship>

With the animation itself being in a different place. Basically I believe this will allow me to easily create lots of versatile templates for my game without having to wonder down the road what the hell it all means.

I am currently working on parsing the XML files with libxml so I can start using the data from the XML files. It has taken me some time to figure out how the stuff works, but I think I got a grasp on it now and tomorrow I should be able to shun the python data files and just use XML. I hope.

Categories: game engine, xml Tags:

Python is just a figurehead…

December 16th, 2004 zeraien No comments

An important thing to consider:

At the moment, most default values for speed, names, hitpoints and such are all set inside unchangeable C code.

And python has no way to change it. This is bad, simply because python should be the one dictating how many hitpoints the Player ship has and what the speed of torpedoes is.

Tomorrow (or whenever i get time to continue with this), I shall thoroughly look over the control that python has over the objects, and try to decide how to give it more control, as well as get the communication between python and C++ code improved.

I believe that C++ should keep track of objects collisions and such, their life or death state etc, and report any change back into python, while python will be the one to set the values.

Still hungry, and tired.

Categories: c++, game engine, python Tags:

Actions followup

December 16th, 2004 zeraien No comments

After coding for a few hours, I’ve come to a pretty decent idea of what I am dealing with.

At the moment, sprites and sounds are completely separated from actual objects.

Well, sounds are actually extensions of the base Object, and sprites are stored in a MAP with the object id being the key.

The issue right now is that there is no way for the object to inform the sprite as to what graphic it wants to have.

Earlier this was done with the object type string, however the object type is now an integer and is more a generic type to help with the creation of the correct class in python.

I realise now however, that the reason python was using strings for object type was simply because the strings were equal to the class names inside the C++ code. I think I will go back to that for simplicity.

Also, the whole object type thing, while very useful for torpedoes, still needs some clarification as to it’s role in other instances.

As for which sprite will be assigned to which object, perhaps the addObject method can simply accept the name of the sprite that is needed, or even better, the python code will use it’s newly created Action code to assign a sprite to an object, until such a time, the object will simply be a floating piece of nothing.

However upon first creation of the object the action code will assign a sprite by default so we dont have to do too many method calls for creation of every object.

Basically this post if full of random thoughts, so i can remember this stuff tomorrow.

Categories: c++, game engine, python Tags:

Orphans and Parents

December 16th, 2004 zeraien No comments

I added a new method to the base object called destroyAllChildren. This one not only makes children into orphans, but also kills them, meaning they are garbage collected and removed from the object manager upon the next loop.

This has proven useful when we add sounds as children to objects. Because as the object is destroyed, so are the sounds and any other children that are associated with it. However it is also a problem because even though a ship is destroyed, it’s torpedoes live on. So I think this method will surely not live inside the constructor. I think the best way to get rid of all useless sounds is to make their isAlive method return false when the sound is done playing.

Also I just noticed how cleverly (I think) I handled the sound issue. By making sounds into extensions of object class, I have simply been able to add sounds into the very same object container that holds all the other objects. Making sounds into children of objects, I am able to give sounds position data from their parents without relying on specific functionality in the object manager.

This seems to work extremely well, and the only downside is that right now sounds are not automatically garbage collected because their isAlive method always returns true. If I could simply make it return false when the sound is finished, garbage collecting sounds will be a piece of cake. Or rather, it will be done automatically since the function is already there.

Perhaps a similar method could be used for graphics. To create a Graphic or Animation extension of the object class, and assign this graphic as a child to whatever object it should be assigned to. Then make it’s obey parent obey the parents every move (not just match velocity), and we’re good to go. This might be the best idea I’ve had yet.

The cool thing is that with this method, we don’t need too much special functionality in the object manager, and we can also extend the Graphic object with more details such as multiple layers and whatnot.

Hungry. Must eat.

Object actions and sound

December 16th, 2004 zeraien No comments

I am just sitting here thinking about how to handle various actions that an object can perform and how those actions will affect the object, as well deal with sound.

A thought did occur to me that perhaps a good way would be to have a bunch of action objects, and each of those would in turn have its own sound, graphic and other stuff.

This means that we would in essence be free to choose which actions an object can perform, and simply change to a different action library if we wanted to use a different type of engine for the game.

For example, a text action library might perform actions by returning or printing text, while a 2D action library might use sprites and sounds for different actions.

Now, the trick is to decide how far the actions extend and what kind of default actions each object normally has anyway. Also, where exactly the actions will live, in C++ or in Python?

I will attempt to discuss this topic now.

Now Playing: Gamma Ray - Voice In My Head

Read more…

Collisions, Hierarchies and Shield Frequencies

July 11th, 2004 zeraien Comments off

As I talked yesterday about hierarchies and sounds, all of these things are implemented here.
Hierarchies will be useful for ship formations and large bosses.

Another previously (by me) unseen use of hierarchies is of course for collision detection.
Although it’s probably best to generally let small one piece objects deal with their own collision detection, larger more complex objects will certainly need several bounding boxes or spheres, and they will obviously be children to the object in question. They will pass down collision events to their father.

Right now I am struggling with a little issue here. Torpedoes from my own ship should not be able to hit other torpedoes fired from my own ship. Well torpedoes should not hit torpedoes at all, but if my ship has children, a torpedo fired by me should not be able to hit it (unless otherwise specified of course!)

So far, a child can never harm a parent and vice versa (what a beautiful world!), however a child can harm another child without any trouble (more realistic, less desirable). Of course, one can always go down the tree checking to make sure that both children do not have the same parent, but this might prove troublesome.

One idea might be to provide each object with unique shield frequency. Object that should not hit eachother would have the same frequency. This is a pretty bad idea I think, because torpedoes should not hit other torpedoes, but they should certainly be able to hit other ships.
So that idea falls short. It is a cool idea tho, I might use it for something.

Also, in an ideal hierarchy, each object should be a child of the SUPER OBJECT (in this case, the game world. This would serve a good purpose, such as if the world is moving, it would move all of it’s children. So just because things inherit from the same world, if they can not collide, this is a problem.

An alternative sollution is required.

Here are the variables that need to be considered:
1. Any object should be able to collide with another object
2. Any parent or child should decide if it should collide with its filials.
3. Same as above should decide if the collision will cause damage or do something else
4. Any object should be able to decide whom it can and can not collide with
5. Any object should be able to be out of phase, and thus not collide with anyone.

Solutions to the points:
1. This already works, but might need to be redesigned to accomodate new collision rules.
5. An invisible flag should exist, invisible objects can not collide with anything. Sounds will be invisible.

The other aspects are as of yet unsolved, but they will be in due time. I shall return when I have found a good solution.

Categories: game engine Tags:

SpaceShooter - The testing ground

July 11th, 2004 zeraien Comments off

Right now I branched my isometric game engine into a sidescrolling spaceshooter ala r-type or ikaruga (you could rotate it to become a sideshooter!).
I am obviously not abandonning the game engine, but at some point I felt that it was getting a bit huge and out of my control, so I had trouble testing new ideas and implementing new features.

Since everything I do in game development and C++ programming is currently my first time, I thought I needed a smaller project to complete, and also a project where I could implement all the features that a game might need. My SpaceShooter is this.

Basicly I need to try tons of different stuff in order to learn it, and the best way to go is to do a few different projects. The SpaceShooter seems simple enough to implement at least on a feature level.

So far I have a ship, which can fire torpedoes, making noises when torpedoes are fired. The torpedoes can hit the computer “controlled” opponent which is flying around the screen and shooting it’s own torpedoes. They can kill it. It also dies if it crashes into you.

Later I will discuss hierarchies and collisions.

Categories: game engine Tags:

Sound dilemma

July 11th, 2004 zeraien Comments off

I think I got the whole sound thing under control.

I am using OpenAL to play sounds, which means sounds can have vectors to specify velocity and position. This isnt too imporant really since I will probably add the ability to turn off environmental audio. The point is, sounds are now ordinary objects just like you and me. They are labeled not solid so they can never collide with anything, and in order for me to deal with them properly, they are added as children to whatever object produces them.

The only problem I believe I currently have is that the sound objects do not die when the sound is finished, which is not a very nice way to deal with memory ;)

However I am working on that, now that I have dealt with hierarchies. The cool thing about hierarchies is that I can now easily create formations of enemy ships!

I also implemented that thing I talked about in my previous post. There is a method called obeyParent(), which can be overridden by any class inheriting from object, and this method basically takes whatever data the current objects needs to inherit from its father and applies it to itself.

So for a torpedo, this is nothing, and thus the method is empty. The ship uses the default, which is to apply the fathers velocity to the childs position. For the sound, I have not figured it out to 100% yet, but one of the aspects is to set the sounds position to that of its father. I believe i might need to mess with some other stuff because the sound is still not perfect when you move around.

In any case, now its time for bed.

Categories: c++, game engine, sound Tags:

Building object hierarchies

July 11th, 2004 zeraien Comments off

I am now working on building object hierarchies.

First of all, if an object plays a sound, that sound should follow the object’s position (especially when dealing with environmental audio), for this I want to make the sound a part of the object.
But there can be several sounds, and if the object is a robot with 3 arms, you should be able to destroy each arm separately.

The children should inherit properties of their parent, however what properties should be inherited, and which should not?

Obviously the velocity of the father should be the same for all children. Of course, each child can also have its own velocity, and the father’s velocity is simply added to the child’s.

What about hitpoints, and other attributes? The question is if any of these variables should be passed onto the children, and also for example, if the children can survive without their parents. Should this stuff be decided on an object level, or during the joining itself?
Also some children such as torpedoes should certainly not inherit the ship’s velocity.

So this leads me to the conclusion that polymorphism, as always, is the answer.
Each object will have a virtual method for hierarchies, this method will grab whatever attributes the current object wants from its parent. I love coming up with cool ideas out of the blue heh.

There is also the question if children should be part of the object manager or if every father should take responsibility for his children. At this point, I think centralizing basic object management is probably easiest. There is one thing that is important tho, and that is that when a father dies, something has to be done about the children, and the question is if the children can survive without their father or not. I’ll need another lightning bolt to hit me to come up with the solution to that one.

For now, signing off.