How to make a simple in-game constructor?

0 favourites
  • 4 posts
From the Asset Store
Quickly and easily add a Quake-like console to your games
  • I'm trying to create a simple in-game constructor that will allow players to build a certain object from parts. Some parts can only sit at the bottom and some parts can be only at the top of the constructed object. And all other parts can be in any place except bottom and top.

    The player may want to build an object using random parts quantity, but minimum 2 parts is required for the object to functioning (the bottom one and any other part) and a maximum of 5 parts can be used. Then the data will be saved to array to build actual object during gameplay.

    The first thing that came to my mind is to place an invisible sprite with several image points as "slots" for the parts. It works, and I've attached a project file below. But there are some problems I can't figure out how to solve.

    Main Problem #1:

    If the player takes a bottom part and a top part, they goes to the bottom image point and the top image point, and there is a gap between them because bottom/top parts can sit only at the bottom or at the top. So these parts doesn't connect with each other because of "image points" approach.

    Main Problem #2:

    If I abandon this "image points" approach since it doesn't work as I want it, so, how to "sort" parts? I mean how to place them depending of it's type (bottom / top / others). For example if I place a non-bottom or non-top part first, then place a bottom part - the bottom part must go below any other part. And same for the top part. Any other parts can go in any order between bottom and top parts.

    Little Problem #3

    When a part has been placed I still can replace it with another part of same type (e.g. just changing its animation frame), and I need to recalculate the cost of the each parts used and a total cost of the whole construction. Is there a way to do this without using a bunch of variables?

    There is a C3P file of what I did (dropbox).

    Any help or advice would be greatly appreciated!

    Denis.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Your file was unavailble when I tried to download it so I didn't have it to work with. I built a simple concept that I think should have all the things you asked for though:

    drive.google.com/file/d/1g34uTHMpVszjBiE4HmWTWv3dUqlFnyoB/view

    Problem #1 & #2

    I get around this by, rebuilding the object every time a change is made. I don't rely on the image points. I just place them above the base object the height of the image * the position in the array.

    Problem #3

    (Modifying) - This part is taken care of by rebuilding on change.

    (Changing Cost) - For this, I store the price in the array and update it when I update the image selected.

    Hopefully this little project gets you what you need to complete your project. Good luck.

  • I built a simple concept...

    Thank you, bro! A very interesting example and that's what I'm trying to achieve. You're awesome! :)

  • You're welcome. Glad I could help and good luck with your project.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)