New Map and Water Trap!

posted in JWColeman for project Gogger
Published November 24, 2018
Advertisement

Wow, this last couple weeks has been quite a journey. As soon as I updated my map and added a water feature obstacle, I realized I had no obvious way built into my code to make it behave like it should for a frogger-esque type game. The water had to kill me, but, not if I was standing on a platform. This led to the addition of some features in the engine that I hadn't thought of initially. Namely, a collision mask. What I decided to do was make it so if I was colliding with water, it would decrease the Z axis up until a certain point. Once that point is met on the Z axis, then call the game logic to do its thing. It looks like this:


	else if (collidedObjectB->getCollisionType() == CollisionResponseType::SINK)
	{
		if (collidedObjectA->getPosition().z >= -1)
		{
			collidedObjectA->getPosition().z -= .1f;
		}
		else
		{
			if (collidedObjectA->userData != nullptr && collidedObjectB->userData != nullptr)
				gameCollisionResponse(*collidedObjectA, *collidedObjectB);
		}

	}

 

So, naturally, the physical object connected to water has the "SINK" collision response, which causes whatever is colliding with it to sink at a rate of -.1f per frame. If we find that we exceed the threshold for Z we call the game logic response gameCollisionResponse:


		// if the player runs into water
		else if (objectA->Type == GameObjectType::PLAYER && objectB->Type == GameObjectType::WATER)
		{
			objectA->resetPosition();
		}

This response is gated so that it only works on the player, after posting this code I realize my platforms could be sinking in Z perpetually, but this can't be perceived in the rendering (adds to fix list).

Now, all this works great for killing the player, but now I needed a way to make it so if the player was standing on a platform, it nullified the sinking effect. So, I set up a new game object called platform and gave its physical component a "FLOAT" mask, enter logic:


	else if (collidedObjectA->getCollisionType() == CollisionResponseType::STOP && collidedObjectB->getCollisionType() == CollisionResponseType::FLOAT)
	{
		collidedObjectA->getPosition().z = 0;
	}

Now, this will reset the Z of the player so that he doesn't reach the threshold we talked about earlier. I'm not certain that I need the other condition here (if objectA = type "STOP"), I'll mess with that sometime.

 

As you can probably imagine, the changes that were required in order to get this working properly were a lot further reaching than just this obvious code, but the end result is looking great! Also, I'd like to mention that I've updated the map with new sprites! It's looking pretty good now I think. No new enemies yet, I need to figure out how to pack the separated sprites into atlases so I can animate them properly. 

Just a few more things to do, need to have a victory trigger, and then some kind of menu! Oh, and a score system, ugh... Definitely a bit more work to do! I'm not certain if I will make the deadline, but participation has been a blast so far!

 

2018-11-24_12-36-11.mp4
6 likes 0 comments

Comments

lawnjelly

Wow this is really looking fantastic! I think that humblebundle artwork looks really good in the game very professional and saves you spending ages making tiles. I am sure you will make it, looks like you are most of the way there! :D 

November 24, 2018 07:59 PM
Rutin

Nice job on the water part. Everyone is coming along well, and looks good!

November 24, 2018 11:27 PM
DexterZ101

Cool But I can't seem to find the download link in your download page T_ T

November 30, 2018 04:16 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement