cnlohr / noeuclid

Non-euclidean GPU Raytraced Game
BSD 3-Clause "New" or "Revised" License
645 stars 48 forks source link

Level declaration syntax #12

Open phiresky opened 9 years ago

phiresky commented 9 years ago

Currently the levels are declared in a kind of DSL. I'm not sure if there is a better way / different syntax.

Also this means that the RunScript/InitScript parts have a different syntax because they are C.

The syntax of script and static things should be joined. Maybe put the static things back into normal C, not parsed extra?

Or maybe the other way around, preparse the C to make it more readable and easily allow things like Block Type aliases.

phiresky commented 9 years ago

I guess the best way would be to remove the lambda function parsing and executing as an array and instead preparse the declaration from e.g.

Cell (4 4 60) Goal to ChangeCell(4,4,60,GOAL); and then pass the whole thing as a single init function for each room into TCC. Thoughts, @cnlohr?

cnlohr commented 9 years ago

I am always a fan of c function-ifying things, and I do prefer the ChangeCell(4,4,60,GOAL); syntax - but this is only a mild preference! You have a much deeper understanding of these language constructs than I do, and have no reason to question your judgment on these sorts of things!!!

This is all that comes to mind:

(1) We could do our own preprocessor on the TCC to add language features not in TCC. For this sort of thing, lambda functions would be extremely useful.

(2) The only reasons I was/am using TCC are: (a) Binding to the rest of the engine is trivial - it is very easy to export a vast array of useful functions. (b) Object orientation doesn't really matter when it comes to a very flat environment. It's just an array of blocks. (c) It does not increase compile time. (d) Simply saving the file can reload-in-place. --- So, don't completely abandon the idea of using a scriptier thing.

phiresky commented 9 years ago

I just realized that using a syntax like Cell (4 4 60) Goal would give problems when having a loop and doing Cell (4 4 60 + i) Goal. I like it without commas but like it is it would definitely not work for non-static things.

  1. I'm still not sure about how to do this. I'd like a more clean syntax than pure C for declaring levels, but I'd also like the level scripts to have the same syntax as the rest.
  2. Yes.. ChaiScript also had very simple binding, but it's probably not the best choice. Maybe some more common language like lua but that seems to be more work. I think we can just keep it tcc for now (except if there are problems with windows/etc)

Maybe a better approach would be to first write a ingame/external level editor, that would make these things less important. but I don't think I have the energy for that right now ;)

cnlohr commented 9 years ago

I've compiled TCC manually for a number of platforms, I may be able to compile libtcc1.a into the project.

Actually, I'm going to have access to a Windows computer soon, so I can mess around on there.

Someone else on youtube asked about the level editor, and I don't think it would be that hard. I'll make an issue for that and think about doing it over the next few days.

erinzm commented 9 years ago

Lua is nice, that's pretty simple to interface. Maybe a better approach to loading levels would be to have a levels/ folder with multiple level scripts?

cnlohr commented 9 years ago

I have tried doing the LUA thing, but it never really panned out for me. If you want to take a stab at it again, I would be up for poking with that branch.