Re: Less verbose or at least "higher level" 2D game engines for Dlang.

2023-12-29 Thread evilrat via Digitalmars-d-learn

On Saturday, 30 December 2023 at 00:47:04 UTC, Agent P. wrote:

Hello everyone,

I'm looking for a 2D game engine for Dlang that offers 
flexibility but has a high-level interface, preferably less 
verbose. Although I've explored options on GitHub and in 
general, I haven't found something that exactly fits what I 
need.


Often the recommendations mention SFML, SDL or OpenGL (obvious 
links), but I would like to consider those options only after 
exploring engines with less verbose APIs.


I don't need much, I'm just looking for suggestions for engines 
that meet these criteria. Does anyone have any recommendations?


Thank you for your time.


There is godot-dlang, while it is not a D engine but just 
bindings, the Godot itself is a full featured engine including 
both 2D and 3D, it has UI framework and editor too.


I haven't even heard of any other D engines with editor btw, but 
unless you are need something minimal to make a basic one screen 
game with minimal build size it is a nice feature to have.





Re: Less verbose or at least "higher level" 2D game engines for Dlang.

2023-12-29 Thread monkyyy via Digitalmars-d-learn

On Saturday, 30 December 2023 at 00:47:04 UTC, Agent P. wrote:

Hello everyone,

I'm looking for a 2D game engine for Dlang that offers 
flexibility but has a high-level interface, preferably less 
verbose. Although I've explored options on GitHub and in 
general, I haven't found something that exactly fits what I 
need.


Often the recommendations mention SFML, SDL or OpenGL (obvious 
links), but I would like to consider those options only after 
exploring engines with less verbose APIs.


I don't need much, I'm just looking for suggestions for engines 
that meet these criteria. Does anyone have any recommendations?


Thank you for your time.


raylib, take your pick from 5 or so different bindings


Less verbose or at least "higher level" 2D game engines for Dlang, again.

2023-12-29 Thread Agent P. via Digitalmars-d-learn

Hello everyone,

I'm looking for a 2D game engine for Dlang that offers 
flexibility but has a high-level API, preferably less verbose. 
Although I've explored options on GitHub and in general, I 
haven't found something that exactly fits what I need.


Often the recommendations mention SFML, SDL or OpenGL (obvious 
links), but I would like to consider those options only after 
exploring engines with less verbose APIs.


I don't need much, I'm just looking for suggestions for engines 
that meet these criteria. Does anyone have any recommendations?


Thank you for your time.



Re: jsoniopipe - exaples?

2023-12-29 Thread Steven Schveighoffer via Digitalmars-d-learn

On Friday, 29 December 2023 at 08:09:58 UTC, Zz wrote:

Hi,

Here are some samples from the std.json documentation.
Any idea on how to do something similar using jsoniopipe?

Directly copied from https://dlang.org/phobos/std_json.html

import std.conv : to;

// parse a file or string of json into a usable structure
string s = `{ "language": "D", "rating": 3.5, "code": "42" }`;
JSONValue j = parseJSON(s);
// j and j["language"] return JSONValue,
// j["language"].str returns a string
writeln(j["language"].str); // "D"
writeln(j["rating"].floating); // 3.5

// check a type
long x;
if (const(JSONValue)* code = "code" in j)
{
if (code.type() == JSONType.integer)
x = code.integer;
else
x = to!int(code.str);
}

// create a json struct
JSONValue jj = [ "language": "D" ];
// rating doesnt exist yet, so use .object to assign
jj.object["rating"] = JSONValue(3.5);
// create an array to assign to list
jj.object["list"] = JSONValue( ["a", "b", "c"] );
// list already exists, so .object optional
jj["list"].array ~= JSONValue("D");

string jjStr = 
`{"language":"D","list":["a","b","c","D"],"rating":3.5}`;

writeln(jj.toString); // jjStr


jsoniopipe is not focused on the `JSONValue` 
[equivalent](https://github.com/schveiguy/jsoniopipe/blob/7d63a2e19ae46a1ae56ccab4c6c872bcce094286/source/iopipe/json/dom.d#L22)


You can see it's pretty basic and just serves as a "catch any 
type" thing.


It could easily be replaced with `std.json.JSONValue`, though I 
like the fact that it's templated on the string type.


The main focus of jsoniopipe is parsing and serialization -- I 
prefer to use real concrete structs/classes rather than variant 
types. In fact, the huge benefit from the library is that there 
is no intermediate type.


But yeah, I could ingest all the functionality from std.json 
there. Or maybe even just use `JSONValue` from std.json. Could 
you make an issue?


-Steve


Re: How to implement filterMap

2023-12-29 Thread Siarhei Siamashka via Digitalmars-d-learn
On Friday, 29 December 2023 at 23:10:47 UTC, Christian Köstlin 
wrote:
Is there a way to implement filterMap (meaning do mapping of a 
range, but if something happens during the map, leave this 
element out of the resulting range).


It's probably not a good idea to do this in general. Expecting a 
lot of exceptions handling happening during normal program 
execution (if you want to filter out roughly half of the input 
array) will result in a major performance loss. Exceptions are 
best left to just do error handling on a very rarely used code 
path for troubleshooting purposes.


Blues require to road for match versus Kings

2023-12-29 Thread JaimeShelby via Digitalmars-d-learn
The way the St Louis Blues have actually been carrying out when 
traveling this period, they need to be eagerly anticipating the 
begin of a six-game journey versus the Los Angeles Kings on 
Monday night. Whether the Kings make it back to Los Angeles in 
time for the video game is an additional story. The Kings were 
snowed in following their 4-1 loss to the Colorado Avalanche on 
Sunday mid-day, compeling them to spend the night in Denver. As 
of Sunday evening, the video game versus cry was still 
tentatively scheduled for Monday night, but might be moved to 
Tuesday given that St Louis is additionally set up to play in Los 
Angeles on Wednesday. The Blues have the best roadway document in 
the West Division this period at 10-2-2 They saw Staples Facility 
earlier this month for a two-game set and stole 3 of the 
available four factors against the Kings. St Louis should 
additionally be starving for a success after going winless in its 
past four, most recently dropping back-to-back games to the going 
to Vegas Golden Knights 
https://www.goldenknightsprostore.com/gage-quinney-jersey
. " We've reached obtain back to what we just did when driving," 
St Louis ahead Brayden Schenn stated of one of the most recent 
journey, which wrapped up with a 4-0-2 mark that maintained the 
Blues securely within the top 4 in the West. The Kings appear to 
have the finest chance of climbing up out of the lower 4 in the 
West, and St Louis seems one of the most likely group to be 
caught. The Kings will certainly require to play much better than 
they corrected the previous nine games, however. They are 2-4-3 
because span, most lately losing two straight versus the 
Avalanche by a combined rating of 6-1. " There's still some 
things we have to boost on," Kings instructor Todd McLellan said. 
The Kings put themselves in the playoff discussion by winning six 
straight games last month, a streak that culminated with 2 
straight victories in St Louis. Los Angeles is 4-1-1 overall 
against the Blues this season 
https://www.goldenknightsprostore.com/ivan-morozov-jersey
. The Kings played without leading goal marker Dustin Brown in 
the loss on Sunday Brown is day to day with an upper-body injury. 
His continued absence would leave a big opening on the power play 
for Los Angeles Brown has actually racked up 7 objectives with 
the man-advantage this season. Kings goalkeeper Jonathan Quick 
will be inaccessible once again on Monday, leaving Cal Petersen 
to perhaps start momentarily straight day. Injuries have been the 
biggest challenge for cry this period as well. They stay without 
Tyler Bozak, Colton Parayko and Jaden Schwartz, however recently 
invited back their leading goal scorer for 5 straight seasons 
from 2014-19, Vladimir Tarasenko, that underwent offseason 
shoulder surgical procedure and missed out on the very first 24 
games. Tarasenko has 4 factors in 4 games considering that his 
return. Berube will not use an irregular schedule as a reason for 
the Blues' current below-average play 
https://www.goldenknightsprostore.com/william-carrier-jersey
. " We don't have sufficient individuals that are drawing on the 
very same rope below and we need that, specifically with the 
injuries we have," he said. Berube indicated his team's recent 
play along the boards as one location that needs renovation. " 
You have actually reached be strong on the wall surfaces," he 
claimed "Some men were weak on walls and transformed pucks over 
and they obtain two goals this way. "


Re: Less verbose or at least "higher level" 2D game engines for Dlang.

2023-12-29 Thread Agent P. via Digitalmars-d-learn

On Saturday, 30 December 2023 at 00:47:04 UTC, Agent P. wrote:

Hello everyone,

I'm looking for a 2D game engine for Dlang that offers 
flexibility but has a high-level interface, preferably less 
verbose. Although I've explored options on GitHub and in 
general, I haven't found something that exactly fits what I 
need.


Often the recommendations mention SFML, SDL or OpenGL (obvious 
links), but I would like to consider those options only after 
exploring engines with less verbose APIs.


I don't need much, I'm just looking for suggestions for engines 
that meet these criteria. Does anyone have any recommendations?


Thank you for your time.


Sorry, ignore the "higher level interface" part, I was referring 
to a less verbose, higher level API.


Less verbose or at least "higher level" 2D game engines for Dlang.

2023-12-29 Thread Agent P. via Digitalmars-d-learn

Hello everyone,

I'm looking for a 2D game engine for Dlang that offers 
flexibility but has a high-level interface, preferably less 
verbose. Although I've explored options on GitHub and in general, 
I haven't found something that exactly fits what I need.


Often the recommendations mention SFML, SDL or OpenGL (obvious 
links), but I would like to consider those options only after 
exploring engines with less verbose APIs.


I don't need much, I'm just looking for suggestions for engines 
that meet these criteria. Does anyone have any recommendations?


Thank you for your time.


How to implement filterMap

2023-12-29 Thread Christian Köstlin via Digitalmars-d-learn
Is there a way to implement filterMap (meaning do mapping of a 
range, but if something happens during the map, leave this 
element out of the resulting range).
I have two solutions (one is with evaluating the mapping function 
several times), and one tries to store the result for the next 
front call like this.
Both do not seem very clean for all possible types. Here the 
version that tries to cache the mapping results.


```d
template filterMap(mapping...) if (mapping.length == 1)
{
auto filterMap(Range)(Range range)
{
import std.range : ElementType, empty;
import std.functional : unaryFun;

alias RangeElement = ElementType!Range;
alias mappingFunction = unaryFun!mapping;
typeof(mappingFunction(RangeElement.init)) result;

void findNext() {
while (!range.empty)
{
try
{
result = mappingFunction(range.front);
break;
}
catch (Exception e)
{
range.popFront;
}
}
}
findNext();
struct FilterMap
{
bool empty()
{
return range.empty;
}

auto ref front()
{
return result;
}

void popFront()
{
range.popFront;
findNext();
}
}

return FilterMap();
}
}

@("filterMap") unittest {
import std.conv : to;
import std.array : array;
["1", "2", "abc", ""].filterMap!(s => s.to!int * 
2).array.should == [2, 4];

}
```

Kind regards,
Christian



Re: Indirect access to variables.

2023-12-29 Thread user1234 via Digitalmars-d-learn

On Friday, 29 December 2023 at 17:11:49 UTC, DLearner wrote:

Compile-time:
[...]
Is there a 'foo1' that yields 1 from the snippet below?
[...]
Similarly, execution-time, is there a foo2 that wields 2 from 
the snippet below:

[...]


**compile-tome**

```d
void main() {

import std.stdio;

size_t var1 = 1;
size_t var2 = 8;

writeln(mixin(var1.stringof));
writeln(mixin(var2.stringof));
}
```

**run-tome**

Given the information you provide I'd say you can use an 
associative array:


```d
size_t*[string] registry;

void main() {

import std.stdio;

size_t var1 = 1;
size_t var2 = 8;

registry[var1.stringof] = &var1;
registry[var2.stringof] = &var2;

writeln(*registry[var1.stringof]);
writeln(*registry[var2.stringof]);
}
```

but take care to the entries lifetime, that's basically not safe 
as this escapes stack addresses.


Indirect access to variables.

2023-12-29 Thread DLearner via Digitalmars-d-learn

Compile-time:

Is there a 'foo1' that yields 1 from the snippet below?
```
void main() {

   import std.stdio;
   size_t var1 = 1;

   char[4] Txt = cast(char[4])("var1");
   writeln(foo1(Txt));
}
```

Similarly, execution-time, is there a foo2 that wields 2 from the 
snippet below:


```
void main() {

   import std.stdio;
   size_t var2 = 2;

   char[4] Txt;

// Txt = various things at run-time;
// But finally:
   Txt = cast(char[4])("var2");
   writeln(foo2(Txt));
}

```


jsoniopipe - exaples?

2023-12-29 Thread Zz via Digitalmars-d-learn

Hi,

Here are some samples from the std.json documentation.
Any idea on how to do something similar using jsoniopipe?

Directly copied from https://dlang.org/phobos/std_json.html

import std.conv : to;

// parse a file or string of json into a usable structure
string s = `{ "language": "D", "rating": 3.5, "code": "42" }`;
JSONValue j = parseJSON(s);
// j and j["language"] return JSONValue,
// j["language"].str returns a string
writeln(j["language"].str); // "D"
writeln(j["rating"].floating); // 3.5

// check a type
long x;
if (const(JSONValue)* code = "code" in j)
{
if (code.type() == JSONType.integer)
x = code.integer;
else
x = to!int(code.str);
}

// create a json struct
JSONValue jj = [ "language": "D" ];
// rating doesnt exist yet, so use .object to assign
jj.object["rating"] = JSONValue(3.5);
// create an array to assign to list
jj.object["list"] = JSONValue( ["a", "b", "c"] );
// list already exists, so .object optional
jj["list"].array ~= JSONValue("D");

string jjStr = 
`{"language":"D","list":["a","b","c","D"],"rating":3.5}`;

writeln(jj.toString); // jjStr


Regards,
Zz