Search dub via duckduckgo
For those that use duckduckgo as their search engine, you can now search the dub package registry with the '!dub' bang. I submitted this a while ago on a whim and it just got approved.
Re: D bindings to Chipmunk2D 7.0.1
On Wednesday, 2 March 2016 at 15:06:26 UTC, Andrej Mitrovic wrote: I ported it to D as I'm interested if it could improve performance since you could theoretically inline code. I haven't touched the code in a long time, though. Nice to see bindings too however! Thanks! Porting is an admirable goal, but the thought of keeping a full port up to date scared me :) Then again, Chipmunk has so many functions inlined in it's headers I had to do a fair bit of porting anyways, and most of it doesn't have to change too much to be valid D.
D bindings to Chipmunk2D 7.0.1
chipmunkd [1] provides D bindings for the most recent version (7.0.1) of Chipmunk2D [2], a 2D physics library. Note that there is also DChip [3], which provides a full source port and is currently targeting the 6.X branch. I figured bindings would be easier to keep up to date with upstream releases than a full source port, though DChip has the advantage of not requiring another dependency (and of having nicer-to-look at source code?). The ported demos seem to be working, but they depend on the rather outdated glfw2. If you have glew and glfw2, you should be able to run the demos with dub. Some of them look pretty cool. The demo directory contains some hacked-together glfw2/glew bindings that were just enough to get it working. I also just realized Jakob Orvum already had some bindings [4], though they are a few years out of date. In retrospect, I probably should have based my work on that. I really should research these things more thouroughly before I dive in. Oops. The bindings were created with the help of dstep [5] (and a fair bit of manual post-processing). [1] https://github.com/rcorre/chipmunkd [2] http://chipmunk-physics.net/ [3] https://github.com/d-gamedev-team/dchip [4] https://github.com/JakobOvrum/ChipmunkD [5] https://github.com/jacob-carlborg/dstep
Re: Damage Control: An homage to Rampart (Alpha)
On Tuesday, 5 January 2016 at 17:41:41 UTC, burjui wrote: Cursor speed is pretty low, so you can't react quickly and in the 3rd round your base always looks like Swiss cheese. You can hold the turbo key (shift by default) to move it faster. Again, something I should probably explain in-game :) Also, it would be really nice to use Enter for confirmation and Escape for going back by default, since these are standard. I cannot reassign the "cancel" action, because app crashes if I press Escape. Maybe its just being a vim user, but j/k seemed more comfortable to me :) The escape crash should be fixed (though I haven't cut another release yet). Found some minor issues: - On Windows, it shows a console window on launch. It may be useful for debugging, but since game doesn't output anything, it's useless and should be shown only in debug builds anyway I'll have to look into that. If you're saying D does that by default for debug builds -- the alpha release _is_ a debug build - On the title screen, it says "v0.0 (alpha)", but I'm actually using v0.2 - A typo: Options -> Shake: "Taseteful" Fixed and fixed. Thanks! Anyway, I played the game for an hour and enjoyed it. It needs some tuning and some kind of an introductory tutorial mode, but it's playable and fun. Also, kudos for composing music in LMMS :) Thanks! LMMS is a great tool. I actually contributed a little to it, but I've gotten too spoiled by D to write much C++.
Re: Damage Control: An homage to Rampart (Alpha)
On Sunday, 3 January 2016 at 19:53:25 UTC, Ivan Kazmenko wrote: "If, at the end of a round, you have no territory, you are defeated." I'm almost sure this is currently not true for the last round: the "completed" message showed up for me instead of "defeated". Huh, I couldn't repro that. Maybe you had some territory you didn't notice? Right now even having a single tile enclosed counts -- which actually may be too lenient. Its also possible there's a bug in the detection of enclosed areas.
Re: Damage Control: An homage to Rampart (Alpha)
On Saturday, 2 January 2016 at 23:43:48 UTC, thedeemon wrote: On Thursday, 31 December 2015 at 16:43:53 UTC, rcorre wrote: It works fine for me on Win 8.1. But I have no idea what's going on in the game, gameplay is totally unknown to me. ;) I added some instructions on the readme: https://github.com/rcorre/damage_control#how-to-play However, I'm getting the impression that I need to include some better explanations in-game. I guess the gameplay only seemed obvious to me because I made it :) Thanks for trying it out!
Re: Damage Control: An homage to Rampart (Alpha)
On Friday, 1 January 2016 at 13:15:02 UTC, MrSmith wrote: For me window is not shown. Windows 7 64bit. I see console and graphics windows in taskbar, but no actual window on the screen. Used release v0.2. Hmm, don't have a windows 7 machine, but maybe I can spin up a VM. Thanks for letting me know.
Damage Control: An homage to Rampart (Alpha)
"Damage Control" is a game inspired by one of my old favorite SNES games, Rampart (ok, technically an arcade game, but I had it on SNES). The project is on Github: https://github.com/rcorre/damage_control Its very incomplete, but if you don't mind spending a few minutes trying it out I'd really appreciate it. You can grab a binary from the Github releases page or try to build it yourself. The content building is a bit involved, but if you just want to build the source you can copy the content folder from a release package. It is made with Allegro using the DAllegro bindings. The linux build is statically linked to Allegro so you shouldn't to install it, but the rest of the dependencies are shared. Let me know if any are problematic. The Windows build just comes packaged with a few dlls, including allegro-monolith. Any feedback is appreciated -- either drop a comment here or file an issue on Github. It will write save data and settings to "~/.config/damage_control" or "%APPDATA%\local\damage_control". You can change this using the --savedir flag. There's no included tutorial as I'm hoping the gameplay will be pretty self-evident (let me know if it isn't!).
Re: Damage Control: An homage to Rampart (Alpha)
On Thursday, 31 December 2015 at 17:16:32 UTC, Ivan Kazmenko wrote: The game flow is not obvious in multiple respects: 1. Shoot: why only six bullets? 2. Rebuild: huh, what's the plan? 3. If the base is not completely enclosed by walls after rebuild, the game ends, giving a ?!?!? impression. Took me a few attempts to guess the requirement to proceed. 1. I was hoping the animation of sending ammo from the bases to turrets would make it obvious that bases grant 6 ammo each. In Rampart, enclosing bases just let you place more turrets, and there was no concept of ammo, which is probably easier to understand. 2. Yeah, this is probably what needs the most explaining, because... 3. It's probably not obvious why you lose the first few times. I guess a 'you have no enclosed territory' message on the failure screen might help a lot. I'll probably try to include some sort of quick tutorial. Thanks for the feedback! Crashed it :) with S-S-J-J-J-Esc pressed at start (controls -> keyboard -> make an action with an unassigned key and press Esc). Yup, that sure does crash it :) Whenever you map a key that's already assigned, its supposed to jump to the previously assigned action so you can reassign it. Esc was actually mapped to 'menu' (opens the pause menu in-game), but I forgot to include that in the controls menu (so maybe it wasn't even obvious there _was_ a pause menu). Thanks!
SuperStruct v0.2.0
For those that missed the first announcement (http://forum.dlang.org/thread/jiucsrcvkfdzwinqp...@forum.dlang.org?page=1), SuperStruct is a struct that acts like a class; basically, a value type that exposes a common interface from its 'subtypes'. Code on github: https://github.com/rcorre/superstruct Anyways, I was having enough fun with this slightly ridiculous idea to make a v0.20, so with no further ado, here's whats new: Operators get passed through just like any other common members. You can try to cast a SuperStruct to a subtype (throws on failure). If members have a common signature but uncommon return types, the member _is_ forwarded and the return type is a SuperStruct of the possible return types (this means it has any behavior common to the return types). Thanks to Timon Gehr for the suggestion! (http://forum.dlang.org/thread/jiucsrcvkfdzwinqp...@forum.dlang.org?page=2#post-n09600:241gel:241:40digitalmars.com) A SuperStruct can now satisfy a range interface (this required using mixed-in members instead of opDispatch). Create a SuperStruct on the fly with pick or pickAmong (similar to std.range's choose/chooseAmong, but works for any types, not just ranges). Example: unittest { import std.range, std.algorithm, std.container; alias Container(T) = SuperStruct!(SList!T, Array!T); Container!int slist = SList!int(); // We can call any members that are common among containers slist.insert([1,2,3,4]); assert(slist.front == 1); // opSlice is supported on all the subtypes, but each returns a different type // Container.opSlice will return a SuperStruct of these types auto slice = slist[]; // [1,2,3,4] assert(slice.front == 1); slice.popFront(); // [2,3,4] assert(slice.front == 2); // as slice is a SuperStruct of range types, it still works as a range slist.insert(slice); // [2,3,4] ~ [1,2,3,4] assert(slist[].equal([2,3,4,1,2,3,4])); }
Re: It's a class! It's a struct! It's ... SuperStruct!
On Thursday, 22 October 2015 at 02:35:34 UTC, rcorre wrote: Come to think of it, SuperStruct actually sounds pretty similar to std.range.chooseAmong (which I just realized exists). It seems to work quite nicely as an alternative to choose that works with any types as opposed to just ranges: auto pick(T...)(size_t index, T values) { foreach(idx, val ; values) if (idx == index) return SuperStruct!T(val); assert(0, "index not in range of provided values"); } /// `pick` is useful for something that is a floor wax _and_ a dessert topping: unittest { struct FloorWax { string itIs() { return "a floor wax!"; } } struct DessertTopping { string itIs() { return "a dessert topping!"; } } auto shimmer(bool hungry) { return pick(hungry, FloorWax(), DessertTopping()); } assert(shimmer(false).itIs == "a floor wax!"); assert(shimmer(true ).itIs == "a dessert topping!"); } I can't think of a time I've wanted to do this with something _other_ than a range, but hey, its there.
Re: It's a class! It's a struct! It's ... SuperStruct!
On Wednesday, 21 October 2015 at 23:09:52 UTC, Timon Gehr wrote: "A call signature for a given member is 'compatible' * if, for an instance of any one of `SubTypes`, that member can be called with * the provided set of arguments _and_ all such calls have a common return type." Probably you could/should return your SuperStruct instead of the/when there is no common return type. Interesting idea! At first I thought you meant returning the original SuperStruct, but then I realized it could be a SuperStruct of the return types. That could be really nice for functions that return different types of ranges, as your return type would just be 'something' that has 'front, top, empty, ect.'. Come to think of it, SuperStruct actually sounds pretty similar to std.range.chooseAmong (which I just realized exists).
Re: It's a class! It's a struct! It's ... SuperStruct!
On Sunday, 18 October 2015 at 21:26:55 UTC, rcorre wrote: And at the risk of going a little overboard, I think the answer to supporting arbitrary templated functions is to wrap visitor/project itself in a template, that then returns a variadic function while passing along other compile-time args. Maybe. I haven't thought it through too carefully... Proof of concept for passing through compile-time args: https://github.com/rcorre/superstruct/commit/27b99fae5eb1242ffcde31a7546771f35f8221f1 If at first you don't succeed, wrap everything in a template!
Re: It's a class! It's a struct! It's ... SuperStruct!
On Sunday, 18 October 2015 at 21:18:52 UTC, rcorre wrote: On Sunday, 18 October 2015 at 21:00:32 UTC, Meta wrote: On Sunday, 18 October 2015 at 19:00:16 UTC, rcorre wrote: You might find this interesting. It's an "outside-in" approach to the same problem as opposed to your "inside-out" approach. Not finished, but the general idea is there. https://github.com/MetaLang/phobos/commit/c8132f53b791ed4a134dd456c8fd20d0d201731d That's just the kind of thing I was looking for! I actually started with a 'visitor' function that works similar to project: https://github.com/rcorre/superstruct/blob/master/src/superstruct.d#L153-L166 then decided to wrap the whole thing in a struct to expose the members more 'naturally'. I think having something like project in phobos would be pretty useful though. And at the risk of going a little overboard, I think the answer to supporting arbitrary templated functions is to wrap visitor/project itself in a template, that then returns a variadic function while passing along other compile-time args. Maybe. I haven't thought it through too carefully...
Re: It's a class! It's a struct! It's ... SuperStruct!
On Sunday, 18 October 2015 at 21:00:32 UTC, Meta wrote: On Sunday, 18 October 2015 at 19:00:16 UTC, rcorre wrote: You might find this interesting. It's an "outside-in" approach to the same problem as opposed to your "inside-out" approach. Not finished, but the general idea is there. https://github.com/MetaLang/phobos/commit/c8132f53b791ed4a134dd456c8fd20d0d201731d That's just the kind of thing I was looking for! I actually started with a 'visitor' function that works similar to project: https://github.com/rcorre/superstruct/blob/master/src/superstruct.d#L153-L166 then decided to wrap the whole thing in a struct to expose the members more 'naturally'. I think having something like project in phobos would be pretty useful though.
It's a class! It's a struct! It's ... SuperStruct!
SuperStruct is a struct that acts like a class: --- struct Square { float size; float area() { return size * size; } } struct Circle { float r; float area() { return r * r * PI; } } alias Shape = SuperStruct!(Square, Circle); // look! polymorphism! Shape sqr = Square(2); Shape cir = Circle(4); Shape[] shapes = [ sqr, cir ]; // call functions that are shared between the source types! assert(shapes.map!(x => x.area).sum.approxEqual(2 * 2 + 4 * 4 * PI)); --- SuperStruct is basically a Variant that exposes the common members of its source types. You can check it out here: https://github.com/rcorre/superstruct I'm not quite sure if this is a good idea (or if it already exists in some form that I haven't seen), but it was fun to work on. There's a lot more info on the README if you're curious. Let me know what you think! If you're wondering why I even wanted to do something like this: I had this Variant that stored either a SpriteBatch, a TextBatch, or a Primitive batch. The thing is, I had a group of them that had to be sorted by depth. Each one of those types _had_ a depth, but it just wasn't accessible through the variant. Not a big deal, of course: --- struct Batch { Algebraic!(SpriteBatch, TextBatch, PrimitiveBatch) _batch; auto depth() { return _batch.visit!( (SpriteBatchb) => b.depth, (TextBatch b) => b.depth, (PrimitiveBatch b) => b.depth); } } --- And that worked fine for a bit. Then each of them got a blender too: --- auto blender() { return _batch.visit!( (SpriteBatchb) => b.blender, (TextBatch b) => b.blender, (PrimitiveBatch b) => b.blender); } --- Later, I thought it might be nice if a batch had a global transform. You can probably guess what that looked like... I started to think maybe Batch should be a class ... but these were value types, dammit! All I wanted was a little polymorphism! Sure, theres std.typecons.wrap, but that doesn't (yet) work on structs, and besides, it's really a class on the inside! Instead of (logically?) just using classes, I decided to go nuts with templates, and so SuperStruct was born.
Re: Vibemail - extensions for vibe's Mail class to send multi-part emails with attachments
On Tuesday, 29 September 2015 at 16:22:43 UTC, Adam D. Ruppe wrote: characterencodings is only needed if you call one of the character conversion functions; it is a lazy local import inside a template. Neat! I knew local imports were useful for keeping symbols in a smaller scope, but didn't think about it as a way to control dependencies.
Re: Enumap -- a lightweight AA alternative when your keys are enums
On Wednesday, 16 September 2015 at 03:20:28 UTC, SimonN wrote: Yes, the 0.4.x version works with my examples perfectly. Thanks for adding const support! (I haven't tested yet every combination of const/mutable Enumap, const/mutable foraech-value, and direct/ref foreach-value. My examples are exactly what I'd do in normal projects anyway, mapping enum-values to ints.) -- Simon Good to hear! I have a pretty long set of static asserts that tries every (?) operation between mutable/const/immutable enumaps to verify that they do/don't compile as expected, so hopefully that has most situations covered.
Re: Enumap -- a lightweight AA alternative when your keys are enums
On Friday, 11 September 2015 at 03:25:58 UTC, SimonN wrote: It doesn't seem to matter whether I put const int, or int, in the foreach statement. What's the idiomatic way to loop over a const Enumap? :-) -- Simon I've released v0.4.0, which implements foreach with ref, and (hopefully) atones for my crimes against const-correctness. You should be able to modify values in a loop and work with const/immutable Enumaps. Thanks for the feedback!
Re: Enumap -- a lightweight AA alternative when your keys are enums
On Friday, 11 September 2015 at 08:22:20 UTC, Kagamin wrote: On Friday, 11 September 2015 at 02:17:25 UTC, rcorre wrote: @nogc void donFancyHat(Enumap!(Attribute, int) map) { map.charisma += 1; } BTW, what this means? Isn't Enumap a value type? Correct, the parameter should be passed by ref in that example. Good catch!
Re: Enumap -- a lightweight AA alternative when your keys are enums
On Friday, 11 September 2015 at 04:30:31 UTC, SimonN wrote: Since I have been using "ref val" in the first loop, I expected the output to be instead: e1: 101 e2: 102 e3: 103 e1: 104 e2: 105 e3: 106 -- Simon Yep, as I was looking at the constness thing, I realized that ref parameters in foreach are totally broken. I may just have to use opApply instead of opSlice.
Re: Enumap -- a lightweight AA alternative when your keys are enums
On Friday, 11 September 2015 at 03:25:58 UTC, SimonN wrote: Hi, this looks excellent! I've been playing around with it, and am looking forward to using it regularly. I've ran into a compilation error when iterating over a const Enumap. In the following code: import std.stdio; import std.conv; import enumap; enum MyEnum { e1, e2, e3 } struct A { Enumap!(MyEnum, int) map; void mutable_output() { foreach (MyEnum e, int i; map) writefln("%s: %d", e.to!string, i); } void const_output() const { foreach (MyEnum e, const int i; map) writefln("%s: %d", e.to!string, i); } } ...the first method (mutable_output) compiles and works with no errors. The const method, however, gives: source/app.d(19,13): Error: invalid foreach aggregate this.map, define opApply(), range primitives, or use .tupleof". It doesn't seem to matter whether I put const int, or int, in the foreach statement. What's the idiomatic way to loop over a const Enumap? :-) -- Simon Interesting, thanks for pointing that out. I don't think I did a great job with const-correctness here, I'll take a look tomorrow. It should definitely be possible to iterate over (and index, etc...) a const/immutable Enumset, though you're right that it doesn't work right now.
Enumap -- a lightweight AA alternative when your keys are enums
I frequently find myself needing a data structure that maps each member of an enum to a value; something similar what Java calls an EnumMap (http://docs.oracle.com/javase/7/docs/api/java/util/EnumMap.html). I couldn't find any D implementation out there, so I wrote a little module for it. Enumap is available on Github (https://github.com/rcorre/enumap) and via dub (http://code.dlang.org/packages/enumap). Docs are hosted at http://rcorre.github.io/enumap/. An Enumap is basically a thin wrapper that makes a static array look like an associative array: --- enum Attribute { strength, dexterity, constitution, wisdom, intellect, charisma } Enumap!(Attribute,int) attributes; attributes[Attribute.strength] = 10; --- However, you might prefer an Enumap to an associative array if: You like syntactic sugar: --- // Boring! if (hero.attributes[Attribute.wisdom] < 5) hero.drink(unidentifiedPotion); // Fun! And Concise! if (hero.attributes.wisdom < 5) hero.drink(unidentifiedPotion); --- You like ranges: --- // roll for stats! attributes = generate!(() => uniform!"[]"(1, 20)).take(6); --- You like default values: --- int[Attribute] aa; Enumap!(Attribute, int) em; aa[Attribute.strength]; // Range violation! em.strength;// 0 --- You like array-wise operations: --- // note the convenient constructor function: auto bonus = enumap(Attribute.charisma, 2, Attribute.wisdom, 1); // level up! adds 2 to charisma and 1 to wisdom. hero.attributes += bonus; --- You dislike garbage day: --- void donFancyHat(int[Attribute] aa) { aa[Attribute.charisma] += 1; } @nogc void donFancyHat(Enumap!(Attribute, int) map) { map.charisma += 1; } --- Check it out, report bugs and all that! P.S. The above example used to read: attributes = sequence!((a,n) => uniform!"[]"(1, 20)).take(6); before Gary's recently posted article at http://nomad.so/2015/08/more-hidden-treasure-in-the-d-standard-library/ made me realize generate existed.
Re: Article: More hidden treasure in the D standard library
On Monday, 31 August 2015 at 16:09:02 UTC, Gary Willoughby wrote: I've written a new article on D here: http://nomad.so/2015/08/more-hidden-treasure-in-the-d-standard-library/ Hopefully to drive other programmers to investigate D. It's a continuation of a similar one I wrote a few months ago which attracted over 60k readers. It's a simple overview of some cool features in the D standard library hopefully to fuel curiosity. Nice article! I've been using 'sequence' and just ignoring the state variables because I didn't realize that 'generate' existed. predSwitch is one that I know exists, but can never remember when I need it. And when I remember it exists, I've already forgotton where I last needed it...
Re: dtiled v0.2 - a library for tilemapped games
On Wednesday, 24 June 2015 at 12:16:56 UTC, Suliman wrote: Is it's possible to use this lib for tiling jpg? I am planing to try to create online service that will load tiles depending on scale (zoom). Front and is js, but I think backend should be based on lib like this. Hmm... I'm not sure. Its hard to tell from your description. The readme and docs should make it clear what this library can do -- if not, let me know!
Re: dtiled v0.2 - a library for tilemapped games
On Monday, 22 June 2015 at 11:05:28 UTC, Manu wrote: Hey cool. I haven't thought about tiled for years! I contributed the terrain painting system years ago ;) Nice to see a lib in D! Nice! I make use of Tiled's terrain tool regularly, its a huge time saver. I've considered adding some terrain functionality to dtiled for situations where the terrain can change in-game (e.g. the player can place walls, which affect how nearby walls are drawn). I may have to ask you about the implementation if I ever get around to that :)
dtiled v0.2 - a library for tilemapped games
dtiled v0.2 is out, and for better or worse, it got hit by a serious case of feature creep. v0.1 was simply an easy way to load maps created with Tiled (http://mapeditor.org). v0.2 attempts to provide much of the functionality commonly needed by tilemapped games. I like to hack around on tilemapped rpg/strategy games, and noticed I was copying a lot of the same map-handling code everywhere, so I took a shot at lib-ifying it. The new tilemap modules (dtiled.grid and dtiled.map) are independent of the Tiled map-loading module (now called dtiled.data). You don't _have_ to load your map from a Tiled json file, any 2D array will work. However, as a whole, these modules should provide a nice road from creating a map in Tiled to working with it in a game. You can check out: The source: https://github.com/rcorre/dtiled The dub package: http://code.dlang.org/packages/dtiled The docs: http://rcorre.github.io/dtiled/index.html The demo: https://github.com/rcorre/dtiled-example dtiled is intended to be game-engine independent; the demo can currently be run using either DAllegro (requires allegro5) or DGame (requires sdl2) as a backend. My next goals are pathfinding and a more interesting demo. I've considered adding support for other Tiled map formats (tmx and csv), but I'm not sure that is valuable as anyone using Tiled has the option to export to json, which should contain all of the necessary data. Eventually, I may add support for isometric and hexagonal maps.
Re: DerelictAllegro5
On Sunday, 1 February 2015 at 12:32:46 UTC, Mike Parker wrote: I've finally dusted off and finished up the new Allegro 5 binding I started on over a year ago. SeigeLord already maintains a static binding at [1]. It has support for the WIP 5.1 branch of Allegro. DerelictAllegro5 is, like all Derelict packages, a dynamic binding and only supports 5.0 for now. Read my blog post [2] about it for some important info you need to know if you intend to use it. [1] https://github.com/SiegeLord/DAllegro5 [2] http://dblog.aldacron.net/derelictallegro5/ Link [2] appears to be dead.
Re: Arch Linux D package update
Awesome, thanks for all your work here! The DCD package is a nice addition.
DTiled: Tiled map loader
Any D game developers out there looking to create a tile-based game? DTiled aims to provide a quick and easy way to load maps created with Tiled (http://www.mapeditor.org). For those that don't know, Tiled is an open-source 2D tilemap editor that is a great tool for indie developers. At the moment, DTiled is a pretty thin wrapper around Tiled's JSON map format, though it provides a few useful helper functions and may expand to provide a higher-level API for inspecting tilemap data. DUB:http://code.dlang.org/packages/dtiled Docs: http://rcorre.github.io/dtiled/dtiled.html Github: https://github.com/rcorre/dtiled DTiled is focused on loading and inspecting tilemap data rather than rendering it, as I do not want to tie DTiled to a particular rendering engine. The idea is that a developer can use DTiled to inspect the information exported from tiled and populate their own in-game map data. Want to see it in action? Check out this example, which uses DTiled to load a map and Allegro to render it: https://github.com/rcorre/dtiled-example Other than that example and some unit tests on the loaded data, DTiled is not yet well-proven. However, I am trying to get back into gamedev and intend on developing DTiled further as I use it. If you give it a try, let me know what you think!
Re: DTiled: Tiled map loader
hmm ... apparently copy-pasting out of a vim buffer was not a good idea. Sorry about the weird line breaks.