Jump to content
  • Advertisement
Sign in to follow this  
Diton9000

implementing puzzles in puzzle game

This topic is 4720 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I currently have it set up as a level, node, and game class and a game class. The node class contains 4 images, one for each of north, south, east, and west. It also contains the number of the node it connects to for each direction. The level class loads the nodes in. The game class processes input, and contains a level. My question is, how do I add puzzles and toggle-able items like doors to this? Forgot to add this - the level info is loaded in from a text file in this format: number of nodes north pic filename for node 1 number of node to north east pic node 1 node to east etc, looping through all the nodes.

Share this post


Link to post
Share on other sites
Advertisement
So ok, you got a node class, and that class has the ability to take the user north, south, east, or west right?

The first way would be to add some more code to the node class and give it the ability to have a puzzle within the node. Like when that node is active it takes the user into a puzzle, which would be a function within the node class.

Or better yet you could take advantage of some OOP and use your node class as a base class for different types of rooms.

class Node {
protected:
Node *northRoom;
Node *southRoom;
Node *eastRoom;
Node *westRoom;
public:
virtual int update();
};

class PuzzleNode : public Node {
private:
// some data for the puzzle
void runPuzzle();
public:
virtual int update();
};

Now whenever a Node is activated update can be called, and that class can do whatever it needs to do with it's data.

I hope this answered some of your questions.

EDIT: As for writing actual code for the puzzles, then you will have to be more specific on what kind of puzzles you would like you have.

Share this post


Link to post
Share on other sites
That will work for puzzles that don't have to do with player motion. However, this
doesn't work for doors, which would open when the player moves towards them, since
motion is controlled by the game class. I tried adding special door opening code directly into the game loop, but it requires a lot of logic statements for just one door. If there were more, it would be a very bad solution.

It would work if I could somehow feed the update function the movement event contained in the game class.

EDIT: The puzzles would all take place on one screen. 2 of this other are the gate puzzle on Haven in Myst IV and the mastermind puzzle in the journeyman project.

[Edited by - Diton9000 on June 21, 2005 9:38:46 AM]

Share this post


Link to post
Share on other sites
I'm working on something like that. I'm going to use a base class with a virtual function like checkPuzzle(); Before the program switches to the next scene, or some other main action, it does the checkPuzzle() override for that scene which can make it do something else or ignore the next action.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!