Coding a Point-Click Adventure Game Engine from Scratch

Started by
17 comments, last by Khaiy 10 years, 4 months ago

Hello Everyone,

I haven't coded for a long time now(used to do it as a hobby when I was younger) but recently got the urge to create a point and click adventure game engine. I would like some info about getting articles and documentation on how to go about this.

My concept of a game engine is some form based IDE that lets you specify rooms, sprites, backgrounds, events. I assume the events would be scripted somehow but have no clue how to work on a scripting engine and how a custom script becomes compiled code. For the graphics I would use one of the free graphics libraries for Windows C# out there.

The functionality of the game I would want to create with my engine would be pretty limited at first. Just want 2 rooms, objects you can look at and add to your inventory and a defined screen region for walking.

Can anyone help? Thanks....

Advertisement
Ah, yes. A point and click adventure. That has been on my list of games I want to make for quite some time. Unfortunately it has never been at the top of that list.

Having not had experience making such a game I cannot give a lot of detail on how to make that but as for general game making my first piece of advice is to not make a game engine. Make a game. I have tried in the past to make a game engine and you end up burning out pretty quickly because you are trying to come up with solutions to hypothetical problems. Instead of having a specific need to be met by a game I was coming up with lots of different possible uses for a game engine and ended up coding up many different features that I never used. Mostly because the engine project died out. Later, I made a game and the engine kinda built itself around the game. While the game isn't perfect I at least have something working that can be considered finished and the core of the game is reusable. So I could use it to create more game projects.

So decide on a game you want to make and start to work on the game. My advice is to keep it as simple as you can. Don't try and add too many features. Focus on only what is necessary at first. Then work your way up from there. This means you will probably have to let go of the IDE style game maker for now. You will probably have to have your levels be created by writing json or xml files by hand. Having some sort of game editor with a WYSIWYG interface will have to come much later. Keep your focus on the game. Your tools should simplify making the game, not get in the way of it.

Also, if you really haven't make a 2D game before I would recommend starting with something simpler. Recreate a classic game such as pacman or tetris. Pick something that will challenge you but that you can complete. This will give a firm grasp on how to manipulate game objects on the screen and their interactions with each other.

If you already have some experience with 2D and think you are up to the challenge then I would start to study good oop practices such as cohesion and coupling. Look up component based game architecture.
My current game project Platform RPG

Point and click should give you a hint that this application would be very "GUI-based":

Get your feet wet with GUIs, 2D Graphics, Events(Interactions with the User with the mouse, keyboard or any button components) in the context of C#.

Agreed with the above post. I would say just go start implementing. Just start with one feature. Once that is done, move on to the next one.

Do not get blogged down with a huge design.

Ah yes. I have read a lot of the posts re Beginning Game Engines on the forum and I think all the ones I read have suggested starting with a game instead. Maybe I shall attempt to do just that. I assume the elements of the game would be hard coded? Objects for the graphics through XNA or OpenTK? Event handlers to respond to the interface? Maybe IronPython to incorporate some scripting? Or would that even be needed since this is hardcoded so I can write everything in c#?

I realize a lot of the code between an engine and a game are interchangeable but since I've already written graphics and input code for games I wanted to see how one would implement creation of a game through an interface. I know I can create a game in 2D. I've not made a point-and-click adventure but have made smaller scale 2D games like Snake, Breakout and a text adventure with graphics for the rooms. It was trying to understand how not to create a hardcoded version of a game but a scripted one thru an interface that appealed to me.

So, I ask again: Can anyone on this board please recommend books or websites with open source code for the kind of software I'm looking for? After all if you see from my first post I dont want my engine to implement sound, conversation trees, Z-buffering etc. at this stage The most complex part would be the event handler. I've even decided to delegate scripting(if i need it) to IronPython. I just don't understand how a form based interface would be used to create a game. Do we use use the variables from the form to generate a script that will be parsed? Or do we create a runtime handler that accesses the necessary variables and calls functions as needed? Or something else entirely?

The core of a point and click adventure should be simpler than a gui. Just draw a fullscreen picture of your background art; maybe just part of the texture that can be moved, if the texture is larger than the screen/window. Maybe add some extra sprites for changeable items.

Then wait for mouse click events and if one is inside a rectangle (or other shape) above some clickable thing make the game do something with it.

The hard part will be drawing all those art pieces for the game and writing intelligent messages telling a good story.

I agree with wintertime. A point and click adventure game shouldn't be any different than the casual "find the hidden object" games that have been so successful in the last few years.

This type of game is a picture on a screen, with various items in the picture producing some reaction when clicked. That's it. The "game" elements come in by connecting various pictures (the scenes of the game) to each other and a story to guide the player from one to the next. Plus some "triggers" to activate some objects in pictures or cause certain objects to have different effects.

I think you may be overthinking this. I don't know of any open source software, books, or guides tailored to making this kind of game. The golden era of adventure games was in a time when only professional studios would be making them. Today, they are minimally popular (though I still like them) and also not very complex as compared with other software. These two factors make it unlikely that there's much out there like what you're looking for, but the fact that they aren't so complicated also means that you shouldn't need them too much.

For an exercise, try this:

Have a screen with a blue background and a few red squares in it. Define events for the squares so that when they're clicked they change to a different color. Have one square cause a transition to a new screen, with a green background and blue squares and a similar click-and-change design.

Once you've done that, you've demonstrated all the basic skills you need to make this kind of game. Seriously. The rest (from a programming perspective) is basic game loop kind of stuff, which you say you've done so that shouldn't be an issue. The rest (from a polished game perspective) is better art and a story that determines the screens a player can visit, and under what circumstances.

-------R.I.P.-------

Selective Quote

~Too Late - Too Soon~

Fine. I won't post again until I work out Khaiy's suggestion. My problem is that C# seems to have changed a bit since I last used it several years back. I am currently reading C# Game Programming for Serious Game Creation by Schuller to get back on track so I wont post for a while. Schuller is using elements like delegates for game loops. I'm currently reading about them online. Seem to be some way to pass functions as arguments.

And I've pretty much scrapped the engine idea until I can first recreate my two room goal as a game first.

This is my first Windows game so I'm somewhat confused. I'm using xna 4.0. I can create clickable Rectangle objects that change color but am not sure how to create separate screens. Do I define each screen as a GameComponent with its individual Draw and Update logic? If I want to exit one screen and go to another is there some event I can create like ChangeScreen where the current screen is removed as a Component and replaced with the new screen (maybe in GameComponentCollection)?


Do I define each screen as a GameComponent with its individual Draw and Update logic?

You can, but you don't need to have screen inherit from GameComponent just for this functionality. It's a valid approach, but make sure that you know why you want Screen to inherit from GameComponent. (I'm mentioning this because a lot of people do this sort of thing only because they saw something in a tutorial, which is a bad way to practice using inheritance).


If I want to exit one screen and go to another is there some event I can create like ChangeScreen where the current screen is removed as a Component and replaced with the new screen (maybe in GameComponentCollection)?

That would work. However, I would suggest doing something that is a little bit simpler and clearer than relying on under-the-hood XNA stuff. If your Game class has a Screen field called currentScreen, you can assign whatever screen should be displayed to that variable and then, in your Draw method, call something like currentScreen.Draw(). It'll be easier to define your own events, event handlers, and keep your program flow straight if all of the objects and methods you're working with are easy to look at and review at need.

-------R.I.P.-------

Selective Quote

~Too Late - Too Soon~

Here is the code I have in Game1.cs:


namespace Reflection
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        DrawableGameComponent room;
        GameComponentCollection complist;
        GameTime gt;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            room = new Level1(this);
            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            base.Update(gameTime);
            
        }

        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
        }

        public void ChangeScreen(DrawableGameComponent curroom, Type type)
        {
            room = (DrawableGameComponent)Activator.CreateInstance(type,this);
            this.Components.Remove(curroom);
            this.Components.Add(room);
            //room.Draw(gt);
        }
    }
}

Then, the modified DrawableGameComponent class in Level1.cs:


   public class Level1 : Microsoft.Xna.Framework.DrawableGameComponent
    {
        Game1 game;
        public Level1(Game1 game): base(game)
        {
            this.game = game;
        }

       public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here
            game.ChangeScreen(this, Type.GetType("Reflection.Level2"));
            base.Update(gameTime);
        }

And the screen color changing code in DrawableGameComponet class Level2.cs:


       public override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Red);
            base.Draw(gameTime);
        }

I want this code to initially load the room Level1 class in Game1 which then immediately changes the screen to Level2 . However, it only seems to run the Update and Draw loops in Game1. I want the DrawableGameComponent room variable to load the component specified in it and then loop that component's Update and Draw functions until changeScreen is called for new component(room) again. Each time only one room should be displayed but each room should be able to store multiple sub-components of sprites etc. That way you could set a current room to loop with its eventhandlers and sprites until a new room need to be load after exiting the current one.

This topic is closed to new replies.

Advertisement