Hi everyone,
I am new to these forums, but have experience in programming in many languages, like C++ or Python, using Windows computers.
I am using the Castle Game Engine to develop video games because it is 100% free and works on the very old and slow machines from the 90s, whereas most so-called professional game engines like Unity or Unreal 5 cost money or don't run on old machines you will find in most schools or homes.
The Castle Game Engine uses Pascal for its language and Lazarus for its compiler, and is cross platform, but because I am using it on a Windows computer I decided Windows forums would be most appropriate compared to "Miscallenous" which seems to be about non-home computer electronics specifically, and not cross-platform software.
I am having trouble with this (link removed for security reasons) particular project, which I made free to download for everyone who has the Castle Game Engine downloaded on their computer - I made sure it actually opens on my copy correctly first obviously.
It is meant to be a third person game that is a platformer where you play as Sandy Cheeks from SpongeBob, like a kid friendly game.
I initially asked for help on this forum thread, but got called unhelpful responses like "being a hopeless idiot who doesn't pay attention" by the so-called helpers, even after I used examples to prove I was paying attention.
I understand that their point was that I would not include certain lines that made the code not work the way it does, like not including the correct amount of "begins" and "ends", but I pointed out how I understood conceptually how a begin and end block was supposed to work, or that a procedure is defined in a certain way always, I only needed help with the details.
This code snippet is what I need help with, in the line about gamemymesh.pas:
procedure CreateMesh;
begin
Mesh := TCastleRenderUnlitMesh.Create(true);
Mesh.SetVertexes([
Vector4(-1, -1, -1, 1),
Vector4( 1, -1, -1, 1),
Vector4( 1, 1, -1, 1),
Vector4(-1, 1, -1, 1),
Vector4(-1, -1, 1, 1),
Vector4( 1, -1, 1, 1),
Vector4( 1, 1, 1, 1),
Vector4(-1, 1, 1, 1)
], false);
Mesh.SetIndexes([
// line loop on Z = -1
0, 1,
1, 2,
2, 3,
3, 0,
// line loop on Z = 1
4, 5,
5, 6,
6, 7,
7, 4,
// connect Z = -1 with Z = 1
0, 4,
1, 5,
2, 6,
3, 7
]);
// Later on in the code
CreateMesh;
This is the relevant code snippets from the example I was using.
I learned that SetVertexes sets each point of the fesh, and SetIndices sets how the points are connected and in what order, like I initiailly guessed, when I asked.
However, when I asked for clarification on how to get custom inputs to "SetVertices", which I needed to do to get the player character's location precisely drawn down,
I wasn't given any response, so I assumed it was because they wanted me to figure things out for myself like they told me explicitly many times earlier, which is fine.
I did the resourceful thing and looked up if that particular procedure came pre-coded with a particular number of inputs/parameters in the manual's API, and fortunately it wasn't, so I made an educated guess that it was just a function customly made for that particular piece of code,
So I defined my own version of it with arguments for getting the player Transform object's properties, and made sure that each input of the Vector4's were all of the same type, so single precision singles, like the API says should happen right here:
Like so:
procedure CreateMesh(const AvatarTransform: TCastleTransform);
begin
Mesh := TCastleRenderUnlitMesh.Create(true);
Mesh.SetVertexes([
Vector4(0.0, AvatarTransform.Translation.Y, 0.0, 1.0),
Vector4(0.0, (AvatarTransform.Translation.Y - AvatarTransform.Direction.Y), 0.0, 1.0),
], false);
Mesh.SetIndexes([
// line loop on Z = -1
0, 1
]);
// Line somewhere later down the code; I guessed the problem was
// not having the correct amount of inputs to match the procedure
// definition above, but it still doesn't draw anything afterward
CreateMesh;
However, as mentioned in the comments in the code, even after I correctly specify the correct number of inputs when I call the newly made function, nothing happens at all, not even drawing small dots.
Again, if you want to test this yourself, simply open the Castle Game Engine and the project, copy and paste the code from the second snippet where appropriate in the first snippet, and witness for yourself how it compiles fine but doesn't actually do anything, when I was given that the first example worked perfectly as it was.
Does anyone with any expertise in Pascal Game Engine's Lazarus compiler in particular, know why the above code in the second snippet doesn't work?