DEV Community

Zoppatorsk
Zoppatorsk

Posted on

Let's build a multiplayer movie trivia/quiz game with socket.io, svelte and node. devlog #12

Going back!!

Last time I talked about the implementation of a "back button" so always can get out of the game and back to the start.

The server side code is still the same, just added a if-statement so don't have to run any code if not currently in a game, so if in settings and choose to go back there is no need to do any checks as player can not be in a game.

The Svelte component is simply a button saying back, will probably put in an icon or something later.. for now good enough.

The component is directly in app and is shown if not on the "start screen"

<script>
    export let socket;
    import { activeComponent, gameProps } from '../lib/stores';

    const back = () => {
        if ($gameProps?.id) {
            socket.emit('leave-room', $gameProps.id);
            $gameProps.id = '';
        }
        activeComponent.set('Start');
    };
</script>

<button class="back" on:click={back}>Back</button>

<style>
    button {
        position: absolute;
        top: 10px;
        left: 10px;
        width: 100px;
        padding: 10px;
    }
</style>
Enter fullscreen mode Exit fullscreen mode

Got a can of inspiration?

So I finally got some inspiration to how the UI should be, or well, at least the end game component.

At first I tried using a table, but it did not feel right so I just made it like a list instead

This is how it looks like now:
game_results

Made it responsive so text n images shrink on mobile. This way of displaying the results as a list is so obvious I did not even think about it before.. haha.. yeah, I suck at UI stuff.

Will also put in the the last round results later.

Also think I will add something similar to the round results so can see who is in the lead of the game, but yeah, that will be for later.

Still need to figure out where to put the chat.. think will just put it on the right side of the screen and if using mobile will add some toggle to bring it on screen.

Yeah, not much happened since last time, but some, and it is progress...

The AI era means ongoing career reinvention. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

πŸ‘‹ Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay