Log In  
Follow
Saint_Modo
[ :: Read More :: ]

Cart #rubikscube-1 | 2023-04-25 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
13

RUBIK'S CUBE

CONTROLS :

Moving Around !

Use the (↑) (↓) (←) (→) Arrow Key to move around the cube.
you can invert the control in the option menu.

Selecting / Unselecting faces !

Use (O) to select a face, the selected face will be Highlighted and
3 move option will appear.
Use (O) again to unselect the face.

Rotate faces !

Once you have selected a face, Use the Arrow Key to rotate the face.
Use the (←) Arrow Key to turn 90° counter clockwise
Use the (→) Arrow Key to turn 90° clockwise
Use the (↑) and (↓) Arrow Key to turn 180°

Option Menu !

Press (X) to open the option menu in-game.
the option menu will also appear at the start of the game.
Use the (↑) and (↓) Arrow Key to navigate in the menu.
(←) (→) (X) and (O) will interact with what's in the menu.

RUBIKS'S CUBE RULES :

Rubik's Cube is a popular 3D puzzle game that was invented by Ernő Rubik, in 1974.
The cube consists of six faces, each with nine colored squares, which can be twisted and turned to create different combinations.
The goal of the game is to solve the puzzle by aligning all the squares of each face with the same color.
The Rubik's Cube has become a worldwide phenomenon and is enjoyed by people of all ages and skill levels.

BEHIND THE SCENES :

/!\ English not my first language, grammar difficult, sorry sorry /!\

Did you know ?

I am not a programer.
I do not know how to solve a rubik's cube.

"Then, Why did you make one?" I hear you ask, well, i saw this video on youtube.
I already knew about cos and sin doing circles and stuff.
and I thought I could push the concept further with fake perspective.

So what simple puzzle game can I make with just a cube?
A Rubik's Cube, that's the game plan.

Making a "3D" cube

Doing the base cube wasn't that difficult,
it follows what there is in the video, but scale down the X and Y axis with of the circle with another cos controlling all of that.
Then I just keep the top and bottom part far away from one another when the cube is on front of us.
And bring the top and bottom part close to the middle of the screen for the top and bottom view.

BUT THEN !!!
Doing the nine squares on each face was more difficult
a naïve way to think of it would be to take the distance between each corner and divided by 3, repeat and multiply by 2 and you would have the coordinate, but this does not account for perspective.
The result of this was an "indent effect", it felt like the further away the squares where, the bigger they get.
We want the opposite of that.

The solution was to take shift we calculated by doing the naïve method, and adding it again to the result, and multiply this shift by a cos or a sin of the rotation of the cube.
This makes the position of the pieces in between the corner shifts away from the "camera."
and with that, we have x and y coordinate for every square on the cube that fake perspective
Is it accurate? No.
Is it good enough? ? I believe so.

Selecting and Rotating faces

Gettings the face was simple and straight to the point.
Get the inclination of the cube.
Is the camera high?Select the top face.
Is the camera low?Select the bottom face.
Else just get the rotation of the cube, and you select one of the vertical face.

But again, moving them was way more difficult,
I don't have a clear way to do it and would love to have your feedback on it.

I separated the problems on two categories, the top and bottom face, and the vertical face.
The top and bottom face wasn't so difficult, first copy all the flat faces on a table, then copy them back to the cube with the appropriated transformation, the side face of the flat face was juster a shift in their position, it works the same for the top and bottom faces.

The vertical faces were a nightmare.
Just rotating the face in front of the camera was fine and works pretty much the same as above.
But the side face was horrible.

Let me tell you first how the faces are made.
I have a table witch store each face from 1 to 6, 1 is the top, 6 the bottom and 2 to 5 the side face.
Then for each face a have 3 tables other table, for the faces X data,
And in those tables have the 3 y coordinate making a table like this:

CUBE[FACE][POSITION X][POSITION Y]

this gave me quitea headache because
you would think that for getting the side ofan another vertical face you would just move the CUBE[face] by +1 or -1,
but if you are face 2 or 5, you would get the face top and bottom, but we want to stay on the vertical face...

And when we want to get the side of the top and bottom from a verticale face, well, each verticale face are neightbore with different position X and y from the top and bottom face.
it created too many edge case.
I ended up doing a long table (or a truth table?, i don't know of those things are called) that would give the order of every x and y coordinate to take for every vertical face, and after all of that it finally work.

The Token probleme

I ran out of token.
I needed to make the menu, a scramble system for the cube, have quality of life option, and a congratulation message for when the player solve the cube, and I have 70 tokens left.

i did a Majeur rewrite off many thing to save a few token, in the finish game, i have 2 token left.
i am not a programer, i pretty much learn by doing and falling, and so i don't know any optimisation technique.
in the end, i was able to save enouph token to finish the game,
There are a few micro details in the menu I wish I could have fixed, and I wish I would have been able to do a better congratulation message... But in the end, I made it!

Congrats! you made it!

That was a fun project to make, a quick one week, one shot.
I wanted to go back to another project I was making, way bigger, a game I already put 6 months in, that I am doing on love2d.
But this is a nice break, and I wanted to have to criticism on my way of programing.
So that's it, I hope you enjoy the game!

~Savary Benjamin

CREDITS :

@Gruber Pico-8 Tunes Vol.1
@p01 Triangle rasterizer
@freds72 thick line routine
@drakeblue Printing Outlined Text
Lua easing Library

P#128992 2023-04-25 13:47 ( Edited 2023-04-25 14:10)

[ :: Read More :: ]

First test of motorbike V0.1

Cart #motorbikedemo-0 | 2021-01-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

Her is my work in progresse little project, motorbike
at the beginning i just wanted to learn how to make paralax
there is barely anything, just a few sprit and a very basique hitbox system
that's it.

P#86036 2021-01-01 21:15 ( Edited 2021-01-01 21:17)

[ :: Read More :: ]

Rock Paper Scissors / my first game !

Cart #rockpaperscissorsmyfirstgame-0 | 2020-12-30 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

Her is my first game !
Its just rock paper scissors, press left/up/right to select your choice.
It took me 4 day to make it, its slow, but i was abel to understande code logic !
The IA is very simple, it just chose at random when you select something.

P#85927 2020-12-30 14:48

Follow Lexaloffle:          
Generated 2024-04-20 03:19:06 | 0.123s | Q:21