M
M
Mimocodil2021-05-23 20:11:32
css
Mimocodil, 2021-05-23 20:11:32

How to make a temporary reverse of the control keys?

Essence: 2D platformer with a side view. The player enters a trap, after which the control keys are swapped for N seconds. The functions of WASD (and arrows) are transferred to SDWA (and arrows, respectively).
How to implement it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2018-12-24
@VladikLinnik

Sketched quickly, but I think you get the point.
https://codepen.io/AlexandrDev/pen/jXmXrd
If in words, then add a before pseudo-element to the columns with absolute positioning and a length of 100vw.

.column::before {
  content: '';
  display: block;
  background: green;
  width: 100vw;
  height: 20px;
  position: absolute;
  top: -20px;
  right: 15px;  /* для bootstrap (прибавляем padding) */
}

M
mcrack25, 2018-12-23
@mcrack25

If you are talking about the top grass, then make it a picture, or rather a small pattern with bacground repeat-x.
If about the lines to the block on the left, then you can make a regular cap on the block, make it position relative, then style the before pseudo-class, make it block stretched and absolute and just press it to the edge of the cap

I
IDzone-x, 2021-05-24
@IDzone-x

Well, there can be many options here, for example, a fairly simple crutch:

if(revers)
{
    ReversControl();
}
else
{
    NormalControl();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question