www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Titanion 0.4

reply Moritz Warning <moritzwarning web.de> writes:
Titanion is a 2.5D shooter game for Windows, *nix and MacOSX.

The original code by Kenta Cho was ported to use Tango and Derelict.
This made it possible to create binaries for different platforms
and is what this 0.4 release is about.

The code was also put on sourceforge.net to make it easier for 
contributers to participate.


http://titanion.sourceforge.net


Have fun,
Moritz Warning
Apr 27 2009
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Moritz Warning:
 Titanion is a 2.5D shooter game for Windows, *nix and MacOSX.
 The original code by Kenta Cho was ported to use Tango and Derelict.

Lot of fireworks and the code looks clean. Most D games I see have inside a 2D and/or 3D vector struct, and the code is generally essentially the same. To avoid such duplication I think such struct deserves to be in Phobos/Tango. Bye, bearophile
Apr 27 2009
next sibling parent reply "Robert Jacques" <sandford jhu.edu> writes:
On Mon, 27 Apr 2009 17:29:49 -0400, bearophile <bearophileHUGS lycos.com>  
wrote:

 Moritz Warning:
 Titanion is a 2.5D shooter game for Windows, *nix and MacOSX.
 The original code by Kenta Cho was ported to use Tango and Derelict.

Lot of fireworks and the code looks clean. Most D games I see have inside a 2D and/or 3D vector struct, and the code is generally essentially the same. To avoid such duplication I think such struct deserves to be in Phobos/Tango. Bye, bearophile

I agree. Actually, it would be really nice if functions were able to return static arrays. (See http://d.puremagic.com/issues/show_bug.cgi?id=1869) In the mean time there's struct Vec(T = float,size_t N = 3) { T[N] _data; alias _data this; string toString() { std.conv.return text(_data); } } plus functions as array properties which apparently got upgraded at some point to the extra () isn't needed anymore. ( i.e. vec.x instead of vec.x() ) i.e. T x(T, size_t N)(T[N] v) { return v[0]; } And it works pretty well: Vec!(T,N) foo(T,size_t N)(T[N] v) { Vec!(T,N) r = v; return r; } float bar(float[3] b) { return b[0]; } void main() { float[3] x = [1,2,3]; float[3] y = foo(x); Vec!(float,3) z = x; writeln(foo(y).x); writeln(bar(z)); writeln(x); writeln(y); // writeln(foo(z).x); // Issues with being passed to a template // writeln(z); // error in format.d, goes away with when alias this is commented out writeln(z.toString); } hmm...
Apr 27 2009
parent reply bearophile <bearophileHUGS lycos.com> writes:
Robert Jacques:

 struct Vec(T = float,size_t N = 3) {
      T[N] _data;
      alias _data this;
      string toString() { std.conv.return text(_data); }
 }

Very nice.
 plus functions as array properties which apparently got upgraded at some  
 point to the extra () isn't needed anymore. ( i.e. vec.x instead of  
 vec.x() )
 
 i.e.
 
 T x(T, size_t N)(T[N] v) {
      return v[0];
 }

A name like "x" is too much common, I don't like that as free function. I like this better (I have borrowed SeriesGen2 from my D1 dlibs): import std.string: toString, writeln; import std.conv: to; import std.metastrings: Format, ToString; template SeriesGen2(string txt, string separator, int max, int min=0) { static if (min > max) const SeriesGen2 = ""; else static if (min == max) const SeriesGen2 = Format!(txt, ToString!(max), ToString!(max)); else const SeriesGen2 = SeriesGen2!(txt, separator, max-1, min) ~ separator ~ Format!(txt, ToString!(max), ToString!(max)); } struct Vec(T=float, size_t N=3) { static assert(N > 0); T[N] _data; alias _data this; string toString() { return to!string(this._data); } // You may also use SeriesGen4 here mixin(SeriesGen2!("T d%s(size_t i){ return this._data[%s]; }", "\n", N-1)); mixin(SeriesGen2!("void d%s(T value){ this._data[%s] = value; }", "\n", N-1)); } Vec!(T, N) foo(T, size_t N)(T[N] v) { Vec!(T,N) r = v; return r; } void main() { float[3] a = [1,2,3]; auto v = foo(a); writeln(v, " ", a[2], " ", v.d1); v.d0 = 5; writeln(v); } Unfortunately I think I have found another bug. If I run: import std.metastrings: Format; pragma(msg, Format!("good %s test", 5)); void main() {} D1 outputs correctly: good 5 test But D2 outputs the wrong: good %s test5 This also may mean that std.metastrings module lacks compile-time unittests (some static asserts suffice). Bye, bearophile
Apr 28 2009
parent bearophile <bearophileHUGS lycos.com> writes:
bearophile:
 struct Vec(T=float, size_t N=3) {
     static assert(N > 0);

Sorry. Better to use:
 struct Vec(T=float, int N=3) {
     static assert(N > 0);

From experience using D I have seen that using unsigned types is very unsafe in the current D language. In Delphi using unsigned types increases safety, in D actually decreases it. So in D it's better avoid unsigned type every time they aren't strictly necessary. Bye, bearophile
Apr 28 2009
prev sibling parent "Robert Jacques" <sandford jhu.edu> writes:
On Tue, 28 Apr 2009 05:06:23 -0400, bearophile <bearophileHUGS lycos.com>  
wrote:

 bearophile:
 struct Vec(T=float, size_t N=3) {
     static assert(N > 0);

Sorry. Better to use:
 struct Vec(T=float, int N=3) {
     static assert(N > 0);

From experience using D I have seen that using unsigned types is very unsafe in the current D language. In Delphi using unsigned types increases safety, in D actually decreases it. So in D it's better avoid unsigned type every time they aren't strictly necessary. Bye, bearophile

Well, in this case, N=-1 is both a compile time constant and doesn't compile (static arrays have a max size of 16kb). Anyways, here's an alternate version: import std.conv: text; struct _Vec(T:U[N],U,size_t N) { T _data; alias _data this; string toString() { return text(_data); } } _Vec!(T) Vec(T)(T val) if( is(_Vec!(T)) ) { _Vec!(T) r = val; return r; } Which simplifies use: auto foo(T,size_t N)(T[N] v) { // do stuff with v return Vec(v); } although functions as array parameters doesn't allow setters, i.e.: pos.x; // okay pos.x = 5; // error
Apr 28 2009
prev sibling next sibling parent Christopher Wright <dhasenan gmail.com> writes:
Moritz Warning wrote:
 Titanion is a 2.5D shooter game for Windows, *nix and MacOSX.
 
 The original code by Kenta Cho was ported to use Tango and Derelict.
 This made it possible to create binaries for different platforms
 and is what this 0.4 release is about.
 
 The code was also put on sourceforge.net to make it easier for 
 contributers to participate.
 
 
 http://titanion.sourceforge.net
 
 
 Have fun,
 Moritz Warning

I played it a bit, and it's fun. Though I'd like changing scenery and ship upgrades :)
Apr 28 2009
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
Moritz Warning wrote:
 Titanion is a 2.5D shooter game for Windows, *nix and MacOSX.
 
 The original code by Kenta Cho was ported to use Tango and Derelict.
 This made it possible to create binaries for different platforms
 and is what this 0.4 release is about.
 
 The code was also put on sourceforge.net to make it easier for 
 contributers to participate.
 
 
 http://titanion.sourceforge.net
 
 
 Have fun,
 Moritz Warning

Very nice, especially the mac support.
Apr 28 2009
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Mon, 27 Apr 2009 16:14:40 -0400, Moritz Warning <moritzwarning web.de>  
wrote:

 Titanion is a 2.5D shooter game for Windows, *nix and MacOSX.

 The original code by Kenta Cho was ported to use Tango and Derelict.
 This made it possible to create binaries for different platforms
 and is what this 0.4 release is about.

 The code was also put on sourceforge.net to make it easier for
 contributers to participate.


 http://titanion.sourceforge.net

I did, it was fun. :) I was especially interested in how the memory usage fared. I noticed it was quite small (12MB), are you using the GC at all? -Steve
Apr 28 2009
prev sibling parent Moritz Warning <moritzwarning web.de> writes:
On Tue, 28 Apr 2009 12:44:48 -0400, Steven Schveighoffer wrote:

 On Mon, 27 Apr 2009 16:14:40 -0400, Moritz Warning
 <moritzwarning web.de> wrote:
 
 Titanion is a 2.5D shooter game for Windows, *nix and MacOSX.

 The original code by Kenta Cho was ported to use Tango and Derelict.
 This made it possible to create binaries for different platforms and is
 what this 0.4 release is about.

 The code was also put on sourceforge.net to make it easier for
 contributers to participate.


 http://titanion.sourceforge.net

:) I was especially interested in how the memory usage fared. I noticed it was quite small (12MB), are you using the GC at all? -Steve

The GC is used. But I haven't made any benchmarks.
Apr 28 2009