Resolved: Best practices for developing and merging prototype code?

0 favourites
  • 3 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • Some context: I have a family called enemies, which is pretty established, and I wanted to create a new enemy type called Wolf. Wolf is very different from the rest of the existing enemies, which are mostly human-based, so I needed to develop lots of new code to control and animate Wolf. But in the end I still want Wolf to be a member of the enemies family as there’s common enemies code that will apply to Wolf.

    I wanted to avoid the existing enemies family code being called on Wolf during prototyping, as it would potentially throw everything off in the game and make prototyping a lot harder. So I chose to create a standalone object called Wolf to prototype. Even though it’s not part of the enemies family, Wolf has several identical behaviors and instance variables, like ‘health’ and ‘hitStrength’, and the Platform behavior.

    Now that I’ve got Wolf working (yay!), I want to add it to the enemies family. But because it has the same instance variable names as enemies, I need to change them before C3 will let me add Wolf to the enemies family. I expect this will involve a) changing the names of those IV’s in Wolf (e.g., change ‘health’ to ‘health2’), b) adding Wolf to enemies, c) changing the Wolf logic to use the IV’s from enemies (e.g., change anything referencing ‘health2’ to ‘health’), and then d) deleting the Wolf-specific IV’s ((e.g., ‘health2’). I’m probably going to need to do something similar with the common behaviors as well.

    This is just an example but it’s making me think there may be a better way.

    My question is, what’s a good way to plan for such ‘merges’ of code, and is there something I should have done differently? C3’s editing logic is great because it checks for errors caused by duplicate IV and Platform names, and I wish there was an easier way to do this merge without having to pick through my code. Any suggestions?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • As I understand, Wolf sprite in the prototype project has the same instance variables and behaviors as the Enemies family in the main project? In this case you can create a new blank project, copy Wolf sprite to that project, remove all variables and behaviors from Wolf sprite, and then copy it to your main project. Add it to the Enemies family, and then you will be able to copy over all events from the prototype project.

    Also, check out this tutorial from Ashley:

    construct.net/en/tutorials/upgrade-object-family-319

  • dop2000 I get so pumped when I see you're responding to one of my questions, you are always spot on with your answers! This is exactly what I was looking for, and that tutorial from Ashley is gold. Thanks again!

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