Contrast Devlog #1 - Setup & Movement
Tags: gamedev, programming, devjournal
Published: 2023-05-08 11:22:57


May 8th, 2023

This is a project that I've been slacking on for ages now, I decided to get back on it from scratch and actually write a devlog on it every once in a while and see if that motivates me enough to release it to the public when finished 😤😤

![Old repositories of the same project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gbj3259ny9ui86l0iezr.png)

## The Idea

![Shift (webgame)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqz5srsbfvlkdvk82ipx.png)

I'm taking the core concept of flipping the room from "Shift", an old webgame developed by Antony Lavelle, and expanding on it in terms of game mechanics and level design.

![Project Overview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uaxd7tdn1uwaz2cho2mt.png)

I've started up with an empty Godot project and immediately started working on player movement and controls.

## Player Movement

Using the very helpful template script that CharacterBody2D provides initially, I've expanded on it to add some variables that allow me to fine tune the movement to something that works for the game.

![Tweakable variables from the inspector](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0im2e2haujz8zs8t069r.png)

The movement logic looks like this, `_handle_movement` function is called inside the `_physics_process` callback, for the movement to actually happen, `move_and_slide` is called at the end of `_physics_process`.

![Movement logic](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bq06nsi22031yp7b372y.png)

And this is how it looks in game

![Player movement in action](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/suwvcbjfu2gpoc4geb5b.gif)

## Shifting Between Black & White

![Player shifting realms](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pwrgwb9mb6tyyq3go36y.gif)

To achieve this, I made use of the physics layers that can be attached to each tile individually in Godot's tilesets.

I first added two physics layers with each one having a different collision layer, and each representing a different realm.

![Physics layers for tilesets](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bsh4b3zblu2z8nlcrit6.png)

I can then switch the player to another realm (physically) by changing the `collision_mask` between `1` and `2`.

As for the transition between black and white for the player, I used an `AnimationPlayer` to animate the properties of two sprites carrying different colors and produce the following result.

![Player transitioning animation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pn2ast5g9ga06ds8dip6.gif)

After setting up the animation and the physics layer, all that's left is scripting the shifting logic by combining those two components together along with the offsetting actual position of the player (up or down).

## What's Next?

Having the movement and realm shifting logic done is great, but that has always been the easy part for me (keep in mind that I've done this 3 times in the past already 😅😅).

The hard part for me is level design and keeping the game juice up while progressing in levels, although the core mechanic is still the same, I've got a few ideas that I'm going to share for feedback in future devlogs once I advance further in the development.

---

Thanks for taking the time, until the next log 🫡