Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Castle Game Engine ...
 
Share:
Notifications
Clear all

[Solved] Castle Game Engine (Cross Platform) - Need Help with Programming a particular Task

17 Posts
2 Users
0 Likes
408 Views
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

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?

This topic was modified 2 months ago 2 times by Anonymous

   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

I did also catch that I most likely should have done "+" the Direction in the end of the vector and not "-" given the sign of the component, but left it as it was, mistakes and all, so I was being honest about them.

 

But either way, it should still stand that something yellow should have appeared that wasn't there earlier, as opposed to totally nothing at all, which is my problem.

This post was modified 2 months ago by Anonymous

   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2678
 

Welcome to the forum!

Well, I can see why you may not get any responses. I know Pascal pretty decent, but I have never used the Castle Game Engine. So I'm not familiar with the objects like TCastleRenderUnlitMesh. This fact alone would make me skip looking at the question, since I have zero experience with these object or the game engine for that matter.

As much as you may not like the responses in the forum (although the user "valterb" seems very much willing to help?), I'm afraid that would be the best place to seek assistance, since these are the people that actually have experience with it.

I'm leaving your message here, in hopes someone will chime in to help.
Sorry I cannot be more helpful 😞 


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

@hans Thank you for your response and time! Unfortunately, that user was the one calling me an idiot who doesn't pay attention, so I thought because this forum was dedicated to Pascal but not that particular game engine, I would get more professional respones here as that was certainly not the first time, but more like the millionth, he did that.


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

And if the people in charge of a software, even if it's free, are actually unwilling to help newcomers properly but tell them to RTFM and screw themselves for needing help with details (which is my complaint and you can see that in the forum thread),

I figured finding people who are more considerate and kinder in another community would be a great idea, even if it's not about that game engine or piece of code in particular, but just the language overall, because as you said others with the proper expertise in that field might step in, and it's more likely to happen than in a forum like Stack Overflow,

Where again I was given RTFM respones as well as told when I included the minimal code necessary to reproduce the problem like in my first post, my response was "too minimal" which doesn't even make sense - if you want the minimum amount, by definition, the minimum means the least possible, and you can't get lesser than that - on top of that why is not typing snu redundant and irrelevant code at all a bad thing? It helps make the reading easier, and so on.

Therefore, cause I already tried asking in communities that were less than helpful, I figured one dedicated to the Pascal language would help the best.


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2678
 

I can understand the frustration with things like this. It can be challenge for both parties involved, and sometimes people can be rude.

I wanted to suggest looking at the Lazarus Pascal forum, as there is a game development section there and I did see talk about the castle game engine. As well. You could give it a try (even though it looks like there is not much activity). Lazarus Pascal Forum - Game Development.

I did try looking at your question, but it would take me too much time to read up on the basics, unfortunately 😞 

Just one thing that may make a difference: In your code it looks like you have a type (not understanding what I'm looking at):

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;

On the 6th line you seem to have an extra comma (the 2nd line that starts with Vector4).
Possibly corrected:

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) // <-- removed comma here
    ], 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;

 Not sure if it helps, just noticed it. Hope it helps 😊 


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

@hans That could be why. That is a great suggestion and thank you for it! However, I will take your advice and post on Lazarus forums in the future, given how this is a problem to Lazarus in particular and not just Pascal in general. Is that your point as well?


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

Okay, I omitted the comma you suggested, and it still doesn't show up at all. Do you think I should just try the Lazarus forums, given this forum is not specailized to my kind of problem but is more general Pascal help?


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

Okay, now it's posted with the last comma omitted, on the Lazarus Game Development board. Hopefully it doesn't get deleted or marked spam, but you never know until you try with these things.


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2678
 

Sorry to hear that didn't fix the issue. Oh well. Worth a try 😊 

I agree that the Lazarus forum is not specialized in gaming engines, but they do have a section specifically for that and I think the original developer of the Castle Engine even posted there. So this may be a motivator for him/them to chime in. Or not. Either way: if you do no t give it a try, we will never know 😊 


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

@hans Oh, I was agreeing with your suggestion and not contradicting it; my point was this forum right here is not about Lazarus in particular, so I would get more professional responses on that one, as you were saying just now in your most recent post. I am very sorry for the misunderstanding :)


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

Although the "developer chiming in" doesn't seem like a good idea - given that on the forum thread, if you read it, he was telling me to RTFM as well and locking threads for asking legitimate questions, most likely because of his ego/"I am the boss so what I say goes", so I decided that I needed the help from other people.


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2678
 

You could also see it this way: Maybe he wants to be nice in the Lazarus Forum to keep a good reputation?

Note that I do not know the developer and that I prefer not to get involved in things like this, as you probably understand. 😊  


   
ReplyQuote
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

That makes sense - don't add drama to things that don't involve you directly - and my point was about the Castle Game Engine thread and not the Lazarus thread - I didn't get any responses as of yet.

 

Either way, it's a very great idea to post on that forum as well as this one, just in case I get legitimately helpful responses there. Thank you so so much for it again!


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2678
 

You're most welcme, wish I could have been more helpful.
Fingers crossed you get a response in the Lazarus Forum 😊 


   
ReplyQuote
Page 1 / 2
Share: