Bonus:
Little warm up in making music, as I haven't for a while - hoping to nail down an aesthetic for the game, art and sound. This...will not be the aesthetic.
So, let's make the character move around in 3D space. Should be pretty easy. First, lets consider what we need.
This is a small scene - no need to jump or even move up and down at all.
There will only be one room - so no need to transition between scenes (only to the battle scene and then to return)
Let's fix that mouse-locking thing while we're at it. Also, might as well enable battling through some button.
First, we go to the _physics_process(delta) function. The physics process is constantly running (it counts ticks in delta, but we won't need the use it [delta is useful for gravity, as you want stuff to move downwards every tick in the physics engine]).
We grab two vector3s. A Vector3 is a set of coordinates and a velocity, I believe. Now, this could be done with 1 Vector, but I found using two makes it a lot simpler for the programmer, though may be more work for the computer. We designate them to be "zero", which is the same as (0, 0, 0) on the x, y, and z axis. I only designate an x and z vector. It is entirely possible that I could have used a Vector2 (only x and y) for this, but I don't really know how and don't want to find out.
This looks a bit odd, but it's rather simple, as the game engine makes handling movements rather easy.
Whenever Input (which is anything from a microphone to a mouse to a keyboard) is the ui_up button, we move forward. ui_up is a predetermined control set by Godot. We can change it, and will change this to be WASD controls. ui_up is the up arrow. When up is pressed, we grab the transformation that has happened to the player (the entire player rotates to follow the camera, so it is pointing forward.) We set that as the basis of our z value and send it to the Vector. That number, I believe, is a pure 1 or 0. We do the same for x and then add them together, giving us a new vector somewhere between (1, 0, 1) and (-1, 0, -1), as Y is never changed. That's good enough for movement!
Quite simply, you just tell godot to move with that info and it does. Super easy. The move_and_slide means we won't stop if we hit an object, we'll just slide off of it as much as possible. We also normalized() the vector so that we don't do the morrowind thing where if you run at a 45 degree angle, you move at twice the speed (again, taking out the best parts...). The character moves pretty slow, so I multiply the speed by a new variable - speed.
Just for fun I set this to 400 the first time and when I tapped forward, I instant transmissioned so far away I couldn't see the cube any more.
I included a signal called battle. Signals are useful for communicating to parent nodes. Player is a node in the gameshop scene, so to communicate directly with the gameshop scene, we send a signal up the ladder.
The gameshop scene looks like this:
Which is what the main scene looked like before.
We emit that signal by pressing enter, for now. We also can press escape to free the mouse.
I added the ability to free the mouse and
kill the player "free" the player when the battle scene opens because if I don't...
Things get silly.
Speaking of silly, this is an issue I have. My screenshot tool is in the taskbar - which means I end up looking at the floor when I go to try to get a screenshot... I set a new hotkey to open it up so I don't get this issue.
And here's a tour of the game shop!
I added collision to the cube to show that it is handled entirely by move_and_slide. Nifty and easy!