Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (746)
Games in Android Showcase (226)
games submitted by our members
Games in WIP (827)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Nine Levels  (Read 1726 times)
0 Members and 1 Guest are viewing this topic.
Offline bornander
« Posted 2017-12-09 19:39:00 »

I have decided to build a platformer game for Android.


In past posts here on JGO I've stated multiple times  (like this, this or even this) that I will never do another game that requires me to design levels but I think that if I limit the number of levels to a ridiculously low number, like nine, I should be fine.

So I'm going to call this game Nine Levels, it will be a 2D platformer where the objective is to collect all the collectables (most likely gems or coins) as fast as possible. To add replay-value I'll keep track of the best times and the plan is to also include Google Play leaderboards so that the players can compare their time to other players.

Right now the game is a very early stage and I am trying out some core mechanics that I would like to implement:
  • Basic jumping (obviously)
  • Enemies patrolling between two points
  • Enemies that walk until they hit an obstacle and then turn
  • Enemies that fly and attack when spotting the player
  • Enemies that can be killed by jumping on them
  • Enemies that can be hurt by jumping on them
  • Two way platforms (i.e. platforms that you can jump up through them, but down fall through them)
Additional things
  • Google Play leader board integration
  • Google Play achievements (not sure if this really adds anything)

I am using libGDX for the game library and  Box2D for the physics, not because it is necessarily a good fit for platform physics but becuase I really like it and want to get better at it.
Rendered using the debug renderer it right now looks like this:
Click to Play


For graphics and audio I'll try to find some CC0 licensed assets, which likely will mean I'll turn to Kenney again as he is awesome.

I'll try to post somewhat regular updates on my progress here and any comments you guys might have is greatly appreciated.

Thanks.

Try my Android games: Grapple | Hovercraft | Lala
Offline bornander
« Reply #1 - Posted 2017-12-14 21:59:21 »

To implement one-way platforms (that is a platform the player can jump up through, but will not fall down through) I hook into the Box2D contact listener.
My game entities can be either Contactable or Collidable, they're both sort of similar but have slightly different capabilities:
  • Contactable
    The entities are notified when a contact occurs, at which point they're given the other object and their Fixture that was involved in the contact.
  • Collidable
    The entities are notified when a collision occurs and can tell Box2D to cancel the collision before any collision response have been applied.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
      world.setContactListener(new ContactListener() {
         @Override
         public void preSolve(Contact contact, Manifold oldManifold) {
            Fixture fixtureA = contact.getFixtureA();
            Fixture fixtureB = contact.getFixtureB();
           
            Object userObjectA = fixtureA.getUserData();
            Object userObjectB = fixtureB.getUserData();
           
            boolean disableContact = false;
            if (userObjectA instanceof Collidable)
               disableContact |= ((Collidable)userObjectA).collides(userObjectB);

            if (userObjectB instanceof Collidable)
               disableContact |= ((Collidable)userObjectB).collides(userObjectA);
           
            contact.setEnabled(contact.isEnabled() && !disableContact);
         }
         
         @Override
         public void postSolve(Contact contact, ContactImpulse impulse) {
            contact.setEnabled(true);
         }
         
         @Override
         public void endContact(Contact contact) {
         }
         
         @Override
         public void beginContact(Contact contact) {
            Fixture fixtureA = contact.getFixtureA();
            Fixture fixtureB = contact.getFixtureB();
            Object userObjectA = fixtureA.getUserData();
            Object userObjectB = fixtureB.getUserData();
           
            if (userObjectA instanceof Contactable)
               ((Contactable)userObjectA).handleContact(fixtureA, userObjectB);

            if (userObjectB instanceof Contactable)
               ((Contactable)userObjectB).handleContact(fixtureB, userObjectA);        
         }
      });


Using these interfaces the Player entity can check when the collision occurs if it is with a part of the terrain that has been marked as one-way, and if it is, cancel it.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
         if (terrain.isOneWay()) {
            if (isFallThroughOneWayPlatformsEnabled())
               return true;
           
            if (isMovingUp())
               return true;
            else {
               float py = body.getPosition().y;
               float ty = terrain.getVerticalPosition();
               boolean playerCenterIsBelowTerrain = py < ty;
               
               if (playerCenterIsBelowTerrain)
                  return true;
               else {
                  boolean playerCenterIsMostlyAboveTerrain = py - ty < Player.bodyRadius * 0.975f;
                  if (playerCenterIsMostlyAboveTerrain)
                     return true;
               }
            }
         }


It requires a bit of logic to determine if the Player is sufficiently above the platform (in my case 2.5% of the size radius of the player)  to enable it, also to allow the player to drop down through a platform on command.

I thought it would be tricky to-get one-way platforms to work but it turned out to be a lot easier than dealing with other edge-cases of the implementation.

Try my Android games: Grapple | Hovercraft | Lala
Offline bornander
« Reply #2 - Posted 2017-12-16 20:57:29 »

So I am using TileD to create the levels and for past project I've built the visual parts as tiles and the physics world as geometric shapes in a object layer rather than a tile layer. That approach give great flexibility but it also means that the world has to be defined twice, first visually then physically, it can get a bit messy if the levels have many things going on as can be seen in this gif from a previous project of mine:
Click to Play


For this project I've opted for a different approach, this time I've applied metadata to the tiles in the tile set used in TileD, and then my level loader reads that and build the physical world from the visual parts.
I'm not sure it's a better approach yet but so far it seems to be working Ok and I am getting levels built and tested faster than before.

The gif below shows what the first test level looks like with and without the visual parts on top of the physical Box2D world:
Click to Play


I am using a tile set from an artist called GrafxKid, I think it looks cool and it'll probably be the one I use for the final version.

Try my Android games: Grapple | Hovercraft | Lala
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline bornander
« Reply #3 - Posted 2017-12-20 22:42:12 »

So I playing around implementingan an enemy, if it walks into the player then the player dies:
Click to Play


Initially I thought I was going to use a Kenney sprite-sheet and my plan was to make the player jump twice on the little alien guys that Kenney has so many of, first jump to knock off their helmet and the second jump to kill them.
I am now leaning towards using this sprite-sheet from GrafxKid instead and as luck would have it he has a character that can be dispatched using two jumps as well:
Click to Play


I am not sure it's clever to have an NPC that is taller than one tile, but I guess if I design the levels so that they never occupy an area where the available height is just one tile it should be ok.

Try my Android games: Grapple | Hovercraft | Lala
Offline bornander
« Reply #4 - Posted 2017-12-23 15:39:56 »

As this game uses an on-screen joystick and the feel of it is important I wanted to give the player the ability to customize the size a bit.
I've added a settings screen where this can be configured and the way it is previewed is by showing the controls as they would appear in game when the user change the size, and then fade them out to avoid them cluttering and making the settings screen confusing:

Click to Play



Update!

I've added a HUD showing the number of coins left to collect and the elapsed time (the font used was part of the graphics pack I am using for the levels).

I've also fixed it so that spinning coins are displayed and there's a new type of enemy, a blue slime thingie that right now cannot be destroyed but I am thinking I'll probably make it so it can be jumped on and squashed or something.

Click to Play


Next task will probably be different materials for the ground as the tile-set comes with this cool winter theme and I want to have slippery ice in the game.

Another update!

I've added breakable brick blocks that can be destroyed in a very Marioesq manner by jumping into them from below, each consecutive hit earns one coin and after 4 coins the brick breaks, the idea being that it will provide a choice in some situations; either break the brick as soon as it's encountered or use is as a step to reach another place first, then come back and break it.

I've also added a new enemy, a bird that sits perched until the player gets close then it starts chasing the player, if it gets really close it dashes towards the player at a slightly higher speed.

Click to Play


Next update will be adding music and completing all the levels, after that it's really only Google Play integration for the leaderboards that remain.




Try my Android games: Grapple | Hovercraft | Lala
Offline Apo
« Reply #5 - Posted 2018-01-06 15:33:39 »

It looks really nice. Can't wait to play it. =)
Offline bornander
« Reply #6 - Posted 2018-01-10 19:41:45 »

It looks really nice. Can't wait to play it. =)
Thank you, hopefully it shouldn't be that much longer until it's finished.

In the meantime; I've added another enemy, this time an exploding pumpkin because what game is complete without one of those:
Click to Play

They drop at a configured interval and walk until they hit another Box2D body, they have a set life-span and at the end they stop and explode.
The explosion causes a small shockwave that might push the player off a ledge if he/she is close enough.

The pumpkins cannot be killed.

Also, posting this gif I realize that the parallax background for this level is wrong, it should be a snowy one instead of grassy hills  Emo

Try my Android games: Grapple | Hovercraft | Lala
Offline Gornova
« Reply #7 - Posted 2018-01-10 21:43:39 »

Good work so far, I like it! I've made some platformers in the past and found really fun to do and to play Cheesy

Hope you will release soon as desktop/web too so I can try it Cheesy

Idea: add some mid/final bosses and some puzzles, my 2 requests Tongue

Blog | Last game Drone Swarm
Offline bornander
« Reply #8 - Posted 2018-01-13 22:48:52 »

Good work so far, I like it!
Thank you for the feedback @Gornova, it's very much appreciated!

I've made some platformers in the past and found really fun to do and to play Cheesy
Are any of them available somewhere where I can try them?

Hope you will release soon as desktop/web too so I can try it Cheesy

Idea: add some mid/final bosses and some puzzles, my 2 requests Tongue
It's very likely I'll disappoint you on both requests I am afraid.  Cry

When I did Grapple, I found out that I am not very good at creating platform puzzles. In Nine Levels the only puzzle will be figuring out the fastest way to beat the level.

As for bosses, initially I hadn't planned on adding any since the game doesn't really progress like a platformer with an over-arching goal (like saving the Princess in Super Mario Brothers).
Having said that; I also like to incorporate feedback I get as I post the progress here (which is part of the reason I post about my games), so let me get back to you on that one. I just might add some sort of boss  Smiley .


Try my Android games: Grapple | Hovercraft | Lala
Offline Gornova
« Reply #9 - Posted 2018-01-14 16:50:35 »

Sure, feel free do give us a demo too Tongue

You can find my games on my blog:

- Zombie employee
- Fuzzy
- Childhood toys
- Gravity duck tribute

Blog | Last game Drone Swarm
Pages: [1]
  ignore  |  Print  
 
 

 
xxMrPHDxx (70 views)
2017-12-31 17:17:51

xxMrPHDxx (35 views)
2017-12-31 17:15:51

xxMrPHDxx (41 views)
2017-12-28 18:11:33

Ecumene (212 views)
2017-09-30 02:57:34

theagentd (310 views)
2017-09-26 18:23:31

cybrmynd (356 views)
2017-08-02 12:28:51

cybrmynd (399 views)
2017-08-02 12:19:43

cybrmynd (367 views)
2017-08-02 12:18:09

Sralse (335 views)
2017-07-25 17:13:48

Archive (1083 views)
2017-04-27 17:45:51
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!