Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411490 Posts in 69371 Topics- by 58428 Members - Latest Member: shelton786

April 25, 2024, 12:21:23 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogs▲ Startron ▲ (The procedurally generated ASCII space sandbox)
Pages: 1 ... 3 4 [5] 6 7 ... 17
Print
Author Topic: ▲ Startron ▲ (The procedurally generated ASCII space sandbox)  (Read 28027 times)
vdapps
Level 5
*****


Head against wall since 2013


View Profile WWW
« Reply #80 on: October 15, 2020, 05:00:32 AM »

Yeah, but because you're pure .NET Core you should be able to compile Linux executable from same sources (I'm not sure about your music though). But whole logic and rendering in console should be compilable on Linux without any code change.

According to: https://stackoverflow.com/questions/41533592/how-to-compile-net-core-app-for-linux-on-a-windows-machine, you can compile Linux executable on Windows from command line. However to test it you must find someone. JobLeonard? Smiley
Logged

JobLeonard
Level 10
*****



View Profile
« Reply #81 on: October 15, 2020, 05:24:29 AM »

Happy to try Smiley
Logged
Rogod
Level 3
***



View Profile WWW
« Reply #82 on: October 15, 2020, 07:16:31 AM »

I'm afraid I am a few steps ahead here (and have omitted details for the sake of brevity); I've tried using dotnet to compile, but it gets caught up on ResolveCOMReference because I'm importing Windows DLLs to make the console work.

In order to make Startron work on Linux, I need to replace all the places where I'm using commands from user32.dll and kernel32.dll with Linux compatible commands and I just don't have the breadth of knowledge in this domain to do that.

(Most of these occurrences are simply to transform the console window around, but one key command allows the console to render all these ASCII characters in colour at such a high framerate - I have no idea if such a thing is even possible in a Linux window, let alone how to achieve this.)

(A simplified code snippet of how the rendering works can be found on this stack overflow link where I got stuck trying to get at the 437 codepage.)

In short, Startron is not pure .net Core because it just doesn't provide me enough freedom with the console to make anything more than a text adventure.
« Last Edit: October 15, 2020, 08:03:48 AM by Rogod » Logged

JobLeonard
Level 10
*****



View Profile
« Reply #83 on: October 15, 2020, 08:08:07 AM »

Hmm, and I suppose there isn't a platform-agnostic command line library for .net core that gives you what you're missing?
Logged
Rogod
Level 3
***



View Profile WWW
« Reply #84 on: October 15, 2020, 08:13:56 AM »

Well that's just what I mean: I wouldn't know Sad

It seems the rendering process I'm using is niche enough that few people could even assist with it on Windows - I highly doubt such a backdoor, hacky mechanism exists or is known about for Linux thereby.

I wouldn't be at all surprised to find that to achieve the same effect on Linux requires a complete rewrite of Startron or something.
« Last Edit: October 15, 2020, 08:23:34 AM by Rogod » Logged

JobLeonard
Level 10
*****



View Profile
« Reply #85 on: October 15, 2020, 10:04:20 AM »

Well, there's a very lively demoscene out there, for starters Shrug

I just looked, Notcurses (aside from being a bit too meme-y for my tastes) is Unix/BSD only as far as I can tell

https://nick-black.com/dankwiki/index.php/Notcurses

Seems to do what you have in mind though Wink






PDCurses maybe?

https://github.com/wmcbrine/PDCurses
Logged
Rogod
Level 3
***



View Profile WWW
« Reply #86 on: October 16, 2020, 12:09:45 AM »

Heh, while the first of these seems like a viable alternative, it's not exactly the lightweight solution I've been borrowing from user32.dll and kernel32.dll - more like a graphics API.
(Given I had half a mind to do this with OpenGL and little 16x16 quads anyway, I think I'd choose that route first over learning another paradigm.)

But I'd really rather just raw text access like the Windows console Sad - PDCurses does appear to provide this, so I think this is the way to go unless anyone figures out how to get the original to work on Linux (a friend of mine has had partial success, so maybe it's possible).
« Last Edit: October 16, 2020, 12:25:03 AM by Rogod » Logged

JobLeonard
Level 10
*****



View Profile
« Reply #87 on: October 16, 2020, 12:42:19 AM »

Yeah, I guess you need at least one abstraction layer to get things to work on all terminals  Shrug
Logged
Rogod
Level 3
***



View Profile WWW
« Reply #88 on: October 16, 2020, 12:44:32 AM »

Just really feels like false advertisement on the part of Microsoft here: "Use .net core and your applications will be cross compatible with anything that runs it, just like Java -> except not, because nothing you'd actually want to do will be cross compatible - hf"
 Cry
Logged

JobLeonard
Level 10
*****



View Profile
« Reply #89 on: October 16, 2020, 02:28:56 AM »

Eh, IO is always an edge case (literally, kinda) - same is true for any other language I'd say.

It works as long as you stay inside the .Net sandbox

Logged
Rogod
Level 3
***



View Profile WWW
« Reply #90 on: October 16, 2020, 11:06:08 AM »

So, fun story :D

I just spent 3 hours Googling & trying every conceivable way to get Startron to work on Linux, short of rewriting it all in Java.

And I have determined, it's just not possible :D - The world has just decided this :D


mono expects anyone who runs the Startron executable to have mono installed on their machine (a bit of an ask as I've already gotten people to install .Net Core under false pre-tenses by this point).

mkbundle (part of mono) apparently allows you to simply bundle an existing .Net application into a runtime for any OS of your choosing but after creating the simplest console application and doing just this, when I run it on a VM it just spits out an error that apparently got fixed a long time ago in mono's GitHub issue tracker. (Not to mention if I try the same process on the full version of Startron, the compiler spits out an equally unhelpful and orphaned error with no explanation to follow.)

PDCurses is a C++ library which provides no insight into how to get C# to interface with it and Google results direct you to any of a number of other C# curses libraries (some of which I tried below).

dotnet-curses seems unsupported and the example just didn't work (despite installing it through Visual Studio's NuGet package manager (so I felt it definitely ought to do something)).

curses-sharp provided a nice .zip file of examples I could try out to verify this library even did the kind of thing I was after, so I double clicked one and got an empty console window - not exactly the visual fidelity I was hoping for.

wolfcurses seems to be the closest thing to working - I did at least get it to start a fairly unimpressive example up in Windows but when converting to a Linux runtime with the dotnet command and running it on Linux, it complains about not being able to find .dlls or something because of the weird JSONified way Visual Studio likes to bundle its executables these days (why it can't just be 1 file I do not know...).


I have rather reached breaking point on not getting a single thing to work out of all of that, so I feel unless someone who's actually versed in writing cross-compatible .Net software comes along to solve this little problem, it's going to have to remain unsolved. (At least until I capitulate and decide to write it in Java or with a real graphics API - at which point some of the charm and simplicity of writing an extremely lightweight console game will be lost Sad )

The really awesome part about all of this is that this is just the visual output - I foresee the same trudge and ultimately unsolved problem for keyboard input and again for music output :D!

My, how far we've come in the year 2020 - we truly can now write our software once and deploy it anywhere, all thanks to things like .Net Core. :D!



Cry



EDIT:
I came back after giving up and throwing a wall at my monitor and started the hunt from scratch - it lead me to elwood's consoleframework which has lots of demos and things that I couldn't get working in Visual Studio. But what I was able to get working, and was quite impressed by, was the ManyControls demo which just fired up a full TUI in powershell with mouse interaction and everything. So after a minute or 10 of trying to figure out how to build it for Linux with the dotnet command (rather than just running it) I shipped it over to my VM and tried running it. On first attempt, it didn't run and complained about missing libncursesw.so.5 so I went about trying to install libncurses5 (could be a small ask for a Linux user) but it still didn't work, so I tried installing libncurses5-dev (not my favourite solution but might have pointed me in the right direction) and it still didn't work. - So I am once again stumped lol

Maybe next I'll dream up some other plan, or I'll go code the actual game - who knows :D!



EDIT2:
So after realising I was being a derp I installed a few more libraries and suddenly the same TUI demo I'd seen run in powershell & cmd.exe on Windows now works in the default terminal on the Ubuntu VM (mouse clicks and key input too). So I know this is all at least possible - all I have to do is figure out how to use that API in Startron, then figure out how to get both runtimes out of the build process and finally figure out the minimum requirements of the Linux side (presumably some of this can be packaged with it or I didn't need to install the *-dev versions of these libraries to get it to work).

At least these last 7 hours were not completely hopeless, but it's still an up-hill struggle to reach the end of the tunnel.  Screamy
« Last Edit: October 18, 2020, 04:21:00 AM by Rogod » Logged

JobLeonard
Level 10
*****



View Profile
« Reply #91 on: October 17, 2020, 02:02:25 AM »

OTOH, if you ever land a dev job that involves cross-platform CLI apps you're well prepared!  Grin

And the effort is appreciated Smiley
Logged
Rogod
Level 3
***



View Profile WWW
« Reply #92 on: October 17, 2020, 03:03:43 AM »

Amusingly I'm well versed in getting things to work between operating systems in Java and Unity - just not .Net Sad

(We work on Windows and deploy on Linux at work for example :D)
Logged

vdapps
Level 5
*****


Head against wall since 2013


View Profile WWW
« Reply #93 on: October 17, 2020, 02:08:39 PM »

Uuuuf, console troubles. I'm having impression that writing wrapper in OGL or Vulkan to simulate console would be faster. Undecided Crossing my fingers, you'll crack this nut. Don't give up, .NET Core is definitely well portable. It's just pity you have to make those Win specific hacky calls. Tired
Logged

Rogod
Level 3
***



View Profile WWW
« Reply #94 on: October 17, 2020, 03:15:04 PM »

So I thought I was on a role when I got to this point:

I had successfully butchered the consoleframework library and managed to nab a C# wrapper for NCurses which I was chopping up and adding to as needed. (I could put a character anywhere on screen.)

But sadly that's as far as I can get without more specific C/NCurses knowledge. - The hurdles here are that I can't see a way to get C# to play nicely with the colours (and fear it would be slow and clunky anyway with lots of pre-calculated combinations of background and foreground) and I can't get it to display codepage 437 or any UTF8 characters even when going down the suggested route of using ncursesw (the W apparently stands for wide-characters (longer than 8 bit)).

You can see the simplicity of the program I was trying to test out (left) and the monstrosity I was attempting to interface with (right) here:


I just feel this is out of my reach; we made all these innovations in cross-compatible game engines, but left out cross-compatible consoles by the looks of it. (The suggested solution is to go one layer higher than this and use CursesSharp - but this seems to expect the Windows user to have PDCurses installed and the Linux user to have NCurses installed - a tall ask for a simple text game: it's not exactly Crysis) (Not to mention the CursesSharp documentation suggests the Windows PDCurses integration doesn't even work yet and the library hasn't been updated in 5 years or so.)



I once again retire in vain hopes someone says something like "Oh, this is easy - I do this all the time - just do X,Y,Z and boom, addressable Linux terminal characters Gentleman"

Concerned </deflated>



EDIT:
I stumbled around last night coming to terms with having to just make my own terminal using something like MonoGame (a whole project in itself but well within my abilities) but then as I was turning in for the night I realised the example I'd tried for consoleframework had been using cyrillic characters and colours so there must be a way to do it - plus, I had all the source code.

Setting out this morning, I managed to track down exactly the point in their code where they're pushing characters and colours to the screen in a nice O(n²) just like me :D. This showed me what I needed to do in order to display UTF-8 characters, so that's one hurdle overcome, however the colours just seem to emanate from a black box (despite me thinking I'd laid eyes on the code to do this yesterday).

One final problem I did not anticipate was that the default terminal in the Ubuntu VM I'm using is not automatically set to a monospace font. I can't seem to find a way to set this programmatically online but sure enough if the user sets it themselves, it is at least possible to get this output now: (notice the smiley faces)


So there is still the matter of colour, input and music to overcome, but I fear this may reach a point where the best solution is to simply say to any Linux user: "Set your console font to monospace when playing Startron or it's gona look odd."
Shrug

The battle rages on...



EDIT2:

Ok I've worked out how colour works - sadly this seems to be done by pushing pairs of foreground and background colour into memory (which I suspect is costly to perform on the fly) so I'm going to need some big table of precalculated pairs for all the combinations by the looks of it.

I also need to figure out how one is to get to all 16 colours afforded by the Windows console (NCurses only seems to have 8 presets). I'm hoping this is controlled with the A_STANDOUT or the A_DIM attributes I've been seeing in demos. But failing that, there does appear to be a handle for providing custom RGB values which I would just match to the Windows 10 console if it came to that.

(Oh and good news, it appears once the terminal has been set to a monospaced font, it keeps that setting, so Linux users need only apply this the first time they run Startron.)

The battle rages slightly less fiercely now...



EDIT3:
Accessing all 16 colours for foreground is not a problem - the A_DIM attribute affords me this palette swap nicely - I am attempting to find a way to do the same for background colour. :S



EDIT4:
Apparently just going beyond the original 8 colours defined in the NCurses library allows me to specify bright and dark without needing the A_DIM attribute (which is good because it was refusing to work simultaneously on foreground and background which would have been a severe limitation for Startron.

So having cracked that one as well, with the exception of a black character on a black background (top left), I've not only got access to all 256 combinations (precalculated and ready for Strartron when I need it) but also copied all their RGB values from cmd.exe which is a bonus I was not expecting when embarking on this journey. (It is highly likely I will be making an entire API available for this cmd.exe -> Linux parity work so others can benefit from this if they so wish.)




EDIT5:
I have input working!

My next port of call here is to tidy all this up into some kind of a wrapper and then swap to the Startron source to go about implementing an OS switcher and dealing with any dotnet problems.

(I'll deal with the music another day once I've established I can get Startron to actually run on Linux ... finally Big Laff)
« Last Edit: October 18, 2020, 06:33:29 AM by Rogod » Logged

JobLeonard
Level 10
*****



View Profile
« Reply #95 on: October 18, 2020, 04:30:53 AM »

... there are people who use non-monospace fonts in their console? Who, Me?
Logged
Rogod
Level 3
***



View Profile WWW
« Reply #96 on: October 18, 2020, 04:32:12 AM »

Apparently so xD

This is the default setting for the terminal in Ubuntu 20.04 so some maniac must want it for some reason :D
Logged

JobLeonard
Level 10
*****



View Profile
« Reply #97 on: October 18, 2020, 08:40:02 AM »

 No No NO
Logged
Rogod
Level 3
***



View Profile WWW
« Reply #98 on: October 18, 2020, 11:44:25 AM »

Something's definitely brewing...

It's not perfect yet, but this is the first time I've seen something vaguely recognisable onscreen in Linux-land.

I've had to disable the music (I'll likely need to find a new library eventually or do something complicated to disable it just for Linux) and the input doesn't work yet (it needs wired up slightly differently to the Windows input) but I would have basically been willing to pay somebody to get the project this far a couple of days ago. xD

</calm>
« Last Edit: October 18, 2020, 12:12:56 PM by Rogod » Logged

vdapps
Level 5
*****


Head against wall since 2013


View Profile WWW
« Reply #99 on: October 18, 2020, 12:03:32 PM »

That's real magic man this console adventures! Wizard
Congrats to first results on Linux. Gentleman
Logged

Pages: 1 ... 3 4 [5] 6 7 ... 17
Print
Jump to:  

Theme orange-lt created by panic