Trying to plan out how to code this game before I start making it.

0 favourites
  • 7 posts
From the Asset Store
Make your own platformer for both the web and mobile easy with this Santas Platformer Template, FULLY DOCUMENTED
  • I am going to make a new game based on the four elements(fire,earth,water and air). It will be a top down survival shooter.

    The core mechanics are that the player has 4 types of attack. (bullet, bomb, nova and orbit)

    At certain points, the player can permanently infuse their attacks with one of the four elements. i.e. drag and drop FIRE onto your "bullet" slot and the bullet becomes a fire bullet.

    Each attack, can be modified by two elements. EARTH + FIRE = LAVA.

    This means 10 possible combinations (14 if I allow same element stacking)for each of the four attacks.

    That's 40-56 unique attacks for me to code, which isn't the problem. I can code all of the actual game mechanics, such as damage, choosing sprite, special effects etc.

    What I need is an elegant way to track which modifiers each attack has and then a way for the engine to determine which modified attack to start using. I wanted to have a menu that you place the elements onto. In a very simple setting, I would code this.

    FIRE is overlapping BULLET1 -> set firebullet boolean true.

    FIRE is overlapping BULLET1

    EARTH is overlapping BULLET2 -> set lavabullet boolean true

    Clearly, this will be quite cumbersome with 40+ attacks as well as having to account for two slots per attack. Unfortunately, I am a hopeless visionary, and not much of a coder...

    My friend suggested using an array, but I have no idea how to tie arrays to work with variables. Does anyone have a suggestion?

    Thanks

  • First of all, it was a wise decision to ask for advice before starting to develop the game! I've seen too many examples where people did the opposite.

    While you can create 40+ boolean variables and code each of the attacks separately, this won't be a good solution. Such code will be difficult to manage and worst of all - it won't be expandable. Imagine if you decide to introduce two new elements later, when the game is almost ready!

    So my suggestion is to use some data object to store all attacks and their properties. Here is a example with an array:

    I chose an array because it's easy to edit in C3, but there are other options - JSON, CSV (Excel), XML etc. In fact, I would probably use the array for entering and editing data, but convert it internally to JSON in runtime.

    With all the values configured, you will only need 3 variables to start an attack and your code can look something like this:

  • Alright, as a grade school teacher who is entirely self taught. This is mostly greek to me. I haven't used functions yet, or any string variables.

    This probably took you, what, five minutes to put together? Hah, it will likely take me hours to unpack these concepts, research them and implement them.

    I like the array you set up and I could easily expand it for all 10-14 bullet types.

    I was planning on doing most of my damage and modifier coding directly on each sprite. When certain variables are true, the player will instead spawn the fire bullet, or steam bullet etc. When that specific sprite collides with an enemy, damage occurs as well as the other element-specific effect.

    Would it be possible to use the first two columns to identify what the element will be and then use a third column to determine what the resulting projectile would be?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I was planning on doing most of my damage and modifier coding directly on each sprite.

    Actually, yes, you can do this instead of using the array. You can use a single Bullet sprite with multiple animations in it (bullet, bomb, nova). And add a bunch of instance variable to the sprite - "damage", "effect" etc.

    Then put 40 copies of this sprite on unused layout, set their animations, configure each copy for a specific attack, and set them as templates. For example, a bullet for fire+air attack may look like this:

    Then you can spawn a bullet from this template and it will be created with all the correct values and the correct animation. You will need a single action for all 40+ attacks!

  • Wow, this is so elegant. I love this. Thank you for sharing these ideas with me.

    I still come across the problem of being able to tell the engine which of those templates to select. And it needs to be changeable. If the player puts FIRE in my first slot, choose fire, but when the player puts air in the second slot, it must change to lightning.

    I am so ready to make this game and have all the mechanics ready to go, this single thing is really holding me up though.

  • Been thinking about it and I think I got it.

    Four global variables bullet, bomb, nova, orbit

    When FIRE is placed on bullet, add 1 to globalbullet

    When Air is place on bullet, add 50 to gloablbullet

    When EARTH is placed on bullet, add 150 to global bullet

    When WATER is placed on bullet and 400 to bullet.

    Then, every one of my 14 combinations will make globalbullet a unique integer. I can set the sprite accordingly when globalbullet = x.

  • Yeah, that's one way to do it. You can also use a binary value - see the documentation for setbit and getbit expressions.

    Another option is to use 4 variables: Fire, Earth, Water, Air. They can be boolean, but I prefer to use number variables with values 0 for false and 1 for true.

    Then when fire attack is placed in any slot, you set Fire variable to 1. When water attack is in any slot, set Water to 1.

    Then you can use them to build the name of the bullet template:

    Set TemplateName to BulletType
    
    If Fire=1 : Set TemplateName to (TemplateName&"_fire")
    If Earth=1 : Set TemplateName to (TemplateName&"_earth")
    If Water=1 : Set TemplateName to (TemplateName&"_water")
    If Air=1 : Set TemplateName to (TemplateName&"_air")
    

    Or a shorter method:

    Set TemplateName to BulletType & (Fire=1 ? "_fire" : "") & (Earth=1 "_earth": "") & (Water=1 "_water" : "") & (Air=1 : "_air": "")
    

    As a result you will have a string like "nova_fire_water", even if the water was added first in the first slot.

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