1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  4. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  5. The Secrets of Warcraft 3 have revealed interesting works. The RESULTS for Abelhawk's Mini-Mapping Contest #15 have come out!
    Dismiss Notice
  6. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  8. Night Rider gained several songs for his journey. The poll for the 12th Music Contest has started. Check it out!
    Dismiss Notice
  9. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  10. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Development] 2D Platform game

Discussion in 'Game Development' started by -Kobas-, Jan 7, 2015.

  1. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,895
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    Sup guys, it's been a while. :)

    I'm working on something new these days, and I made huge progress in my game developing "carrier".

    https://www.youtube.com/watch?v=hXVKZGYNaMA

    As you can see on screenshot (attachment down below), it's 2D platform game in really early stage and so far I finished with things like:
    - Movement and jump system
    - Animation
    - Gravity
    - Collision

    There are screens (for example main menu) and few more things worth mentioning like map-generating scrips that load levels from different files and so on.

    I'm pretty much done with basic stuff, core things still missing are enemy units, items (coins and such) and object you can interact with (doors, keys, chests etc).

    I have very nice ideas, terrain and whole design support multi-layer patter (not shown right now) that will add depth into the game view. There will be UI as well (need to hide blue text :p ).

    I'm open for suggestions, critics, new ideas.

    Have a nice day.

    Update (10-Jan-15): Added Editor and Editor1 image.
    Update (15-Jan-15): Added Youtube video.
     

    Attached Files:

    Last edited: Jan 15, 2015
  2. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    How are you planning to support (or if you already do) slopes?
    That's where the code becomes messy.

    I am also making a 2D platformer, so we could share information if you want.

    And just out of interest, are you using SDL/SFML/whatever for graphics, or OpenGL?
     
  3. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,430
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Does he not support them already? I mean he does not seem that racist...

    Joking aside angular terrain would fall under variable collision shapes. This would mean some form of vector based collision geometry instead of a simple bitmap.
    Who says he is going cross platform? He could simply be using Direct2D or 3D seeing how it is for Windows. That said it is a good idea to abstract the graphics enough that a new front end could be written if porting is required.
     
  4. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,895
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    Right now I use grid like structure (so no slopes) to handle collision.
    It's somewhat messy but I'm still learning. And yes there is a way (so far I can think about this one), usually called perfect pixel collision, where you basically check specific pixels intersecting objects.

    I'm codding this in C# using XNA tools. Right now it's easier for me to work on Windows, but I will switch to mono easy, when I make some huge progress worth distributing it on other operating systems.

    @GhostWolf, I will gladly check your project. In fact, health competition can't hurt right.
     
  5. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Having a uniform grid doesn't mean you can't support slopes, they just need different handling.
    I myself have slopes implemented such that they have two Y offsets, one at each end, where 0 means the top of the tile, and 1 the bottom. So, [0,0] is a normal tile, [1,0] is a 45 degree / slope, and so on.
    This supports any angle between 0 and 45 (didn't bother with slopes that end mid-tile, although supporting them isn't hard either).
    Of course, the logic of the collision detection needs to be changed, because slopes are tiles that you can get into without colliding, while also needing to collide with them under some conditions.

    A bonus of having semi-generic slopes like this (instead of say fixed low/high slope), is that you can query pathing for walking enemies quite easily, by just checking if the offsets of two adjacent tiles match where they connect.
    So if you have a 45 degree / slope, and then a regular tile, you know that the offsets where they meet are both 0, and so it's the same floor level.
    But I don't know if you'll actually need this (probably you will though).

    My project isn't open source, but I wouldn't mind talking about implementing different entity types, and having them dynamically configured in a level file.
    For me, everything beside the players is just a normal entity object, whether it's a key, button, door, moving platform, melee enemy, ranged enemy, and so on (and in fact you could mix and match to have a moving button, or an enemy that you can grab and use as a key, or any weird thing like that too, if you so desire).
    Each entity is just a set of attributes and components that tells it what to do, and which you can define dynamically in the level file.
     
  6. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,895
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    I load pathing from separate data container and it's grid based. It works right now and I won't bother improving it before I finish with other stuff.

    My current goal is to make this game working for level 1 only. Then I will see what can be dynamically handled so I can load that from file. Once I got into that stage, I will create Map Editor for my game (Windows Form Application) and I will handle maps (levels) from there.

    I already gathered tutorials and resources needed, all I need is time and devotion.
     
  7. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    So based on what you wrote, I assume your grid is made of indices to a texture array?

    My grid is made of indices to a tile type array, where each tile type defines not only the texture used by it, but also whether it is solid, sloped (using the aforementioned offsets), and all sorts of other properties.

    In case you are interested, here's an excerpt of my JSON demo level, though it's a bit messy (I keep making it neater with time, though):
    Code (Javascript):

    {
        "LevelName":"Demo",
        "ViewSize":[42,18],
        "Gravity":[0, 25],
        "Samplers":[
            {"File":"tile.png"},
            {"File":"ltt.png"},
            {"File":"lts.png"},
            {"File":"rts.png"},
            {"File":"rtt.png"},
            {"File":"lbt.png"},
            {"File":"lbs.png"},
            {"File":"rbs.png"},
            {"File":"rbt.png"},
            {"File":"ltn.png"},
            {"File":"rtn.png"},
            {"File":"lbn.png"},
            {"File":"rbn.png"},
            {"File":"water.png"},
            {"File":"lava.png"},
            {"File":"acid.png"},
            {"File":"ladder.png"},
            {"File":"rockwall.png"},
            {"File":"end.png"},
            {"File":"yellowkey.png"},
            {"File":"pinkkey.png"},
            {"File":"yellowdoor.png"},
            {"File":"pinkdoor.png"},
            {"File":"yellowlock.png"},
            {"File":"pinklock.png"},
            {"File":"wood.png"},
            {"File":"button.png"},
            {"File":"teleporter.png"},
            {"File":"smoke.png"},
            {"File":"lavaspecial.png"},
            {"File":"fireball.png"},
            {"File":"atlas.png"}
        ],
        "TileTypes":[
            {"Sampler":1, "Solid":1},
            {"Sampler":2, "Solid":1, "VerticalDirection":3, "YOffsets":[1,0.5]},
            {"Sampler":3, "Solid":1, "VerticalDirection":3, "YOffsets":[0.5,0]},
            {"Sampler":4, "Solid":1, "VerticalDirection":3, "YOffsets":[0,0.5]},
            {"Sampler":5, "Solid":1, "VerticalDirection":3, "YOffsets":[0.5,1]},
            {"Sampler":6, "Solid":1, "VerticalDirection":4, "YOffsets":[0,0.5]},
            {"Sampler":7, "Solid":1, "VerticalDirection":4, "YOffsets":[0.5,1]},
            {"Sampler":8, "Solid":1, "VerticalDirection":4, "YOffsets":[1,0.5]},
            {"Sampler":9, "Solid":1, "VerticalDirection":4, "YOffsets":[0.5,0]},
            {"Sampler":10, "Solid":1, "VerticalDirection":3, "YOffsets":[1,0]},
            {"Sampler":11, "Solid":1, "VerticalDirection":3, "YOffsets":[0,1]},
            {"Sampler":12, "Solid":1, "VerticalDirection":4, "YOffsets":[0,1]},
            {"Sampler":13, "Solid":1, "VerticalDirection":4, "YOffsets":[1,0]},
            {"Extends":"Water", "Sampler":14},
            {"Extends":"Lava", "Sampler":15},
            {"Extends":"Acid", "Sampler":16},
            {"Sampler":30, "Solid":1, "VerticalDirection":4, "YOffsets":[1,0], "Collidable":1}
        ],
        "EntityTypes":[
            {"Extends":"Ladder", "Sampler":17},
            {"Extends":"RockWall", "Sampler":18},
            {"Extends":"Teleporter", "Sampler":28, "Size":[2,3]},
            {"Extends":"EnemyShot", "Sampler":31},
            {"Solid":1, "Spawn":4, "SpawnSide":2, "SpawnDelay":2, "Size":[2,3], "Sampler":32},
            {"Solid":1, "Spawn":4, "SpawnSide":1, "SpawnDelay":2, "Size":[2,3], "Sampler":32},
            {"Extends":"Ladder", "Sampler":32, "AutoClimb":1}
        ],
        "Layers":[
            {
                "Depth":1,
                "Border":1,
                "Map""Entities": [
                    {"Extends":1, "Position":[19,29], "Size":[2,6]},
                    {"Extends":1, "Position":[42,25], "Size":[2,14]},
                    {"Extends":1, "Position":[45,39], "Size":[2,6]},
                    {"Extends":1, "Position":[53,33], "Size":[2,5]},
                    {"Extends":2, "Position":[54,9], "Size":[1,3]},
                    {"Extends":2, "Position":[5,10], "Size":[1,5]},
                    {"Extends":2, "Position":[11,42], "Size":[1,4]},
                    {"Extends":2, "Position":[44,36], "Size":[1,3]},
                    {"Extends":"End", "Sampler":19, "Position":[51,28], "Size":[4,5]},
                    {"Extends":"Item", "Sampler":20, "Position":[13,21]},
                    {"Extends":"Item", "Sampler":21, "Position":[62,45]},
                    {"Solid":1, "Sampler":22, "Position":[28,34], "Size":[1,2]},
                    {"Solid":1, "Sampler":23, "Position":[44,22], "Size":[1,3]},
                    {"Extends":"Button", "Sampler":24, "Position":[27,34], "Require":10, "Target":12, "Action":"Disable Solid"},
                    {"Extends":"Button", "Sampler":25, "Position":[41,37], "Require":11, "Target":13, "Action":"Disable Solid"},
                    {"Solid":1, "Sampler":26, "Position":[14,18], "Size":[5,0.7], "Keyframes":[[18.5,18]], "Speed":8, "KeyframesMode":0},
                    {"Solid":1, "Sampler":26, "Position":[50,27], "Size":[6,0.7], "Keyframes":[[44.5,27]], "Speed":8, "KeyframesMode":0},
                    {"Extends":"Button", "Sampler":27, "Position":[31,34], "Target":16, "Action":"Enable Keyframes"},
                    {"Extends":"Button", "Sampler":27, "Position":[49,37], "Target":17, "Action":"Enable Keyframes"},
                    {"Extends":3, "Position":[24,15], "Target":21},
                    {"Extends":3, "Position":[30,27], "Target":20},
                    {"Extends":3, "Position":[1,43], "Target":23},
                    {"Extends":3, "Position":[60,41], "Target":22},
                    {"Sampler":29, "Position":[36,17], "Size":[3,29], "ApplyForce":[0, -30], "ForceCutoff":[0,-5]},
                    {"Extends":5, "Position":[9,26]},
                    {"Extends":6, "Position":[62,14]},
                    {"Extends":7, "Position":[36,25], "Size":[0.1,14]},
                    {"Extends":7, "Position":[38.9,25], "Size":[0.1,17]},
                    {"Extends":"EnemyChaser", "Sampler":32, "Position":[23,42]},
                    {"Extends":"EnemyChaser", "Sampler":32, "Position":[57,35]},
                    {"Extends":"EnemyShooter", "Sampler":32, "Position":[40,43], "LineOfSight":20}
                ]
            }
        ]
    }
     

    For reference, a sampler is a layer above texture, and it can define all sorts of properties not shown in this level (mirroring, rotating, scaling, texture atlases, etc.)

    When something extends something else, it copies it's properties. In the case that it extends a string, it means that it's a predefined object created by the code, rather than the level file.
     
  8. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,895
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    Exactly, I split tiles into texture arrays so I can display multiple layers, same for pathing, just like in WE, totally different array handles collision.

    Right now I use txt file to store all this data, but C# allows me to easily use XML files with my project, that way I can handle attributes and/or properties of classes easy. I will try to make it simple as I said for now. Because it's easy to handle 10x10 grid with 5 different textures, try 100x100 + few layers + 20 textures etc. That's why I need working editor first, when I manage to generate map automatically, I won't care about readable txt files or whatever, I will let code do work for me.

    I was working like 4-5 hours on Map Editor now, it's really simple at this point, I can move map freely, draw basic rectangles on it and it handles basic menu options (save, load...). I still have a lot of work in front of me. For start it will be somewhat hard coded, but in future I may made few changes to allow people to use their own data.

    I will work on it tomorrow and hopefully create first level with it to show you guys some progress. Maybe even upload youtube video.
     
  9. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,895
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    Finally after hours and hours of work I made progress.
    As you can see on images:
    http://www.hiveworkshop.com/forums/...142321d1420908646-2d-platform-game-editor.png
    and
    http://www.hiveworkshop.com/forums/...42322d1420909300-2d-platform-game-editor2.png
    Editor allows me to easy "paint" maps for 2D games.

    You can move whole drawing board, set tiles dimensions and much more.

    I will now work on splitting map into layers that will allow me to use options like undo, delete tile and so on.
    Then things left will be "new map" button setup, "options" buttons and such to handle different map sizes and configurations.
    And finally saving (generating) files in specific formats that my game can read and load content from.
     
  10. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Looks neat so far.
     
  11. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,895
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    Done.
    Editor now supports multi-layer drawing.
    It's also possible to delete textures from grid.
    Drawing different textures on same layer will redraw existing texture with new one.
    Add View menu with setup to turn on/off layers.

    EDIT:

    Save/Load is now completed as well.
    Fuck yeah!

    EDIT:

    I have uploaded video, there you go.
     
    Last edited: Jan 15, 2015
  12. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    The only weird thing for me is that layers are selected in the spritesheet selector, rather than in the editor.

    On my game, I am at the point where I want to implement an in-game scripting language, and I am really not sure how extensive I want it to be.
    Even with very simple things, I am starting to see how easy it is to have the same bugs and issues that Warcraft 3 has with globals and waits.
     
  13. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,895
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    I added some properties to right click mouse button, so you can quickly select desired pointer and/or layer. But thanks for suggestion, will implement that into tool-bar on main window as well.

    Hmmm I can see scripting coming probably, in some way at least (probably GUI like interface for start), but I'm still way behind you. Horrible collision system I use must be fixed asap, and I'm working on it right now. Then I will be finally able to move to entities such as enemy units and items like weapons, power ups etc etc.

    I'm really interested in your project. Could you share some pictures, or at least part of story-line if any. :)
     
  14. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    There's not much to show, my only sprites are random stuff I got from google in 5 minutes, and there's the debug layer above everything (transparent blue overlay), but...here goes.

    What can be seen there is ladders, entities spawning fire balls, teleporters, external forces (big and long thing in the middle pushes you upwards), climbable entities which you can wall-jump from (actually overlaying the walls on each side of that same big upwards force), keys (items), locks (open doors if you have the keys), buttons, entities with keyframes that start moving when the buttons are pressed, and two enemy types - one patrols from side to side, and chases the player if he can see and reach him, in order to melee attack, and the other shoots fireballs when he can see the player on an height level that will get the fire ball to hit him.

    The nice thing is that literally all of this is defined in the level file itself.
    The chasing enemies are merely entities with the Patrol, Chase and MeleeAttack components.
    The spawners are similarity entities with the Spawn component.
    The locks are entities with an action that is triggered when the player uses the use button, and it requires the player to have the matching key, and in that case, disables the target door's solid state.
    And so on.

    Even with this, a lot of the stuff can actually be implemented in scripting and be even less hardcoded, if I'll choose to go that way (especially spawning).

    There is of course support for any number of layers, and a parallax effect, and even more obvious stuff like camera-centering which isn't seen, because the camera view (specified in the level file like all the rest) is set to the size of the level.

    Right now I am in the process of changing everything collision-related to work with bitwise categories (much like Box2D if you ever used it).
    That is, every entity has a category (I am a ...) and a mask (I can interact with ...), and I added also category based solid state (I can have solid collisions with ...) and category based one-sided state (I act as a one-sided platform with ...).
    This means that many things become configurable, such as walls being passthrough for specific entities, specific entities being able to stand on other specific entities, and lots of other neat stuff.

    This is all still in JavaScript though. Once I stop destroying half the code base every day in order to improve it, I'll probably transition to C++ and OpenGL.
     

    Attached Files:

  15. gorillabull

    gorillabull

    Joined:
    Jul 17, 2011
    Messages:
    1,368
    Resources:
    2
    Spells:
    2
    Resources:
    2
  16. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Possibly because making that is super easy and completely boring?
     
  17. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,895
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    GhostWolf you made quite a wonderful job so far. Are you using HTML5 Canvas to draw that?

    I can see how your objects can be converted into anything needed and interacted with in any way, cool. :D

    However, I have been busy with exams and school work these days, but I think, I managed to improve collision system, and added few more features to Map Editor, making it easier for use.

    Having a little different idea, my game won't be, let say, static, in a why that each level is always the same (mario game as example), instead I will try to make it a little more dynamic with things like, monster spawns, different loot to collect and so on, making it different for every new run. Something like RPG games but on 2D surface. As I said before, have many ideas, just not enough time. That's being said, after collision my next field of work will be UI, and that include, HP, Mana, Exp bars, buttons and other shit needed.
     
  18. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Yeah, it's just the normal 2D context of the Canvas element.
     
  19. Remixer

    Remixer

    Joined:
    Feb 19, 2011
    Messages:
    1,593
    Resources:
    52
    Models:
    19
    Packs:
    1
    Maps:
    31
    Template:
    1
    Resources:
    52
    This was so cute :3

    So cuuuteee!

    Years of thinking highly of you, thinking you are great sensei (which you are) and then I watch the video "first time using my voice so I am little... nervous" =D aaaaaaw ;P

    Didn't think you could be =D but you did fine :)