Insert an element into an Associative Array ?

2012-04-04 Thread Chris Pons
I'm playing around with associative arrays right now and I can't seem to figure out how to add additional objects to the array. I tried insert but it doesn't recognize both arguments. Also, if I do this it produces an error: Node[bool] test; Node node; Node[bool] temp = [ false:node ]; test

Re: Insert an element into an Associative Array ?

2012-04-04 Thread Chris Pons
Ok, thanks for the help, much appreciated. On Wednesday, 4 April 2012 at 19:57:40 UTC, ixid wrote: Oops, the comment should read as follows, and test[bool] should not be on the next line. //Conceptually maybe clearer as Node[] test[bool]

Binary Heap Errors Class level vs function level

2012-04-04 Thread Chris Pons
I'm still messing around with binary heaps. I've successfully created and used it on the function level but for some reason when I move it to the class level I get an error. Furthermore, i'm not entirely sure how to use a binary heap without auto as the type. class AStar { ReferenceNode[]

Re: Min-Heap and Hash Table help

2012-04-03 Thread Chris Pons
at 11:28:06 UTC, Timon Gehr wrote: On 04/03/2012 05:17 AM, Chris Pons wrote: I'm still having troubles with the min-heap. Node[] a; auto b = BinaryHeap!a.fScore b.fScore( a[] ); Error 1 Error: template instance BinaryHeap!(a.fScore b.fScore) BinaryHeap!(a.fScore b.fScore) does not match template

Re: Min-Heap and Hash Table help

2012-04-03 Thread Chris Pons
Thanks! This clears up that part very well. I'm a lot closer to having a decent path finding algorithm now. On Tuesday, 3 April 2012 at 21:24:24 UTC, Chris Cain wrote: On Tuesday, 3 April 2012 at 19:38:12 UTC, Chris Pons wrote: Thanks, yes, that did work. However now when trying to insert

Re: Add Element to list not Working

2012-04-02 Thread Chris Pons
( 42 ); The first method didn't give an error it just didn't update the list as I thought. Any idea? On Monday, 2 April 2012 at 06:07:40 UTC, Ali Çehreli wrote: On 04/01/2012 10:45 PM, Chris Pons wrote: I'm trying to add an element to a list with insert but that doesn't seem to do anything at all

Re: Add Element to list not Working

2012-04-02 Thread Chris Pons
Ah, thank you. I didn't realize taht SList is a struct and that it used value semantics. That clears this up. On Monday, 2 April 2012 at 14:22:25 UTC, Ali Çehreli wrote: On 04/01/2012 11:18 PM, Chris Pons wrote: Thanks. I tried doing this and the list didn't update: void AddToList( SList

Length of an SLIst ?

2012-04-02 Thread Chris Pons
I'm trying to find the length of a Slist. I've tried using the built in .length function but it generates this error: Error: no property 'length' for type 'SList!(Node)'. Are there any other built in ways to find the length?

Min-Heap and Hash Table help

2012-04-02 Thread Chris Pons
I'm trying to work with and implement and priority queue( min-heap ) and a hash table. This is the first time I've worked with these data structures so I looked up some information about them to gain an understanding. From what I read, a min-heap is a binary tree that is sorted by a

Re: Min-Heap and Hash Table help

2012-04-02 Thread Chris Pons
Yes, I did see that. How would I set the predicate to sort by fScore? An integer in my struct. On Monday, 2 April 2012 at 22:53:55 UTC, Justin Whear wrote: On Tue, 03 Apr 2012 00:47:56 +0200, Chris Pons wrote: I'm trying to work with and implement and priority queue( min-heap ) and a hash

Re: Min-Heap and Hash Table help

2012-04-02 Thread Chris Pons
On Monday, 2 April 2012 at 23:30:38 UTC, Justin Whear wrote: On Tue, 03 Apr 2012 01:06:54 +0200, Chris Pons wrote: Yes, I did see that. How would I set the predicate to sort by fScore? An integer in my struct. auto myHeap = BinaryHeap!`a.fScore b.fScore`( rangeOfNodes ); Ok, makes sense

Re: Min-Heap and Hash Table help

2012-04-02 Thread Chris Pons
I'm still having troubles with the min-heap. Node[] a; auto b = BinaryHeap!a.fScore b.fScore( a[] ); Error 1 Error: template instance BinaryHeap!(a.fScore b.fScore) BinaryHeap!(a.fScore b.fScore) does not match template declaration BinaryHeap(Store,alias less = a b) if

Add Element to list not Working

2012-04-01 Thread Chris Pons
I'm trying to add an element to a list with insert but that doesn't seem to do anything at all. If I try using ~= it says that Error: cannot append type Node to type SList!(Node). I'm pretty confused about using ~= because it works fine for arrays but apperantly not for lists. How do I add

Initializing multidimentional Array with a struct

2012-03-31 Thread Chris Pons
I'm trying to figure out how to initialize a multi-dimentional array with a struct. I thought it would be straight forward, but i'm running into problems. I'm using nested for loops, and just setting the current index to a blank version of my struct but that gives me this error: Error: no []

Re: Initializing multidimentional Array with a struct

2012-03-31 Thread Chris Pons
I also tried this, which gives an out of range error: void InitializePathGraph() { PathGraph.length = mapWidth; foreach( elem; PathGraph ) { elem.length = mapHeight; }

Re: Initializing multidimentional Array with a struct

2012-03-31 Thread Chris Pons
Yes sorry, I was looking to initialize to the default value of node. Thank you for the help! On Saturday, 31 March 2012 at 21:59:50 UTC, Ali Çehreli wrote: On 03/31/2012 02:34 PM, Chris Pons wrote: I'm trying to figure out how to initialize a multi-dimentional array with a struct. I thought

How to remove element from an SList?

2012-03-27 Thread Chris Pons
Right now i'm struggling with trying to understand how to remove an element from a n SList. I only want to remove one element, not a range of elements. I also don't want to use an Array because I will have to reshuffle elements to take care of the empty spot when I remove it. The only thing

Re: XML Parsing

2012-03-20 Thread Chris Pons
On Tuesday, 20 March 2012 at 04:32:13 UTC, Adam D. Ruppe wrote: I know very little about std.xml (I looked at it and said 'meh' and wrote my own lib), but my lib makes this pretty simple. https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff grab dom.d and

XML Parsing

2012-03-19 Thread Chris Pons
Hey Guys, I am trying to parse an XML document with std.xml. I've looked over the reference of std.xml as well as the example but i'm still stuck. I've also looked over some example code, but it's a bit confusing and doesn't entirely help explain what i'm doing wrong. As far as I understand

Error 42 Symbol Undefined

2012-03-17 Thread Chris Pons
Hello, I'm trying to use the Gl3n (https://bitbucket.org/dav1d/gl3n) but I keep getting error 42 whenever I try this: alias Vector!(float, 2) vect2; vect2 position; position.x = 2.0f; //This is what causes the error I looked into how the struct was implemented and x is an alias for a

Re: DLL's and D

2012-03-15 Thread Chris Pons
Yes, this is a lot more clear, thanks. On Thursday, 15 March 2012 at 05:06:16 UTC, Mike Parker wrote: On 3/15/2012 12:26 PM, Chris Pons wrote: I haven't used DLL's much, especially one I've built on my own, so guidance would be appreciated. I'm trying to figure out how to build a DLL which

Re: DLL's and D

2012-03-15 Thread Chris Pons
Ok, I've actually run into another problem. I've decided to use a static library, since my project is small. I have added the path to the static library's .lib file in my project properties, just like with derelict2. However, I'm not sure how to use import properly. The library in question

Build errors and VS Macros for Build Commands

2012-03-15 Thread Chris Pons
I've been playing around with VS Macros trying to step away from explicit declarations of library locations. I'm using a google repository as I would like to be able to work on projects either at my desktop or laptop without having to worry about specific library path locations. I tried

Re: Proper Use of Assert and Enforce

2012-03-14 Thread Chris Pons
Thank you for the valuable information! The difference between assert and enforce is now clearer in my mind. Also, that's a great trick with enforce. On Thursday, 15 March 2012 at 01:08:02 UTC, Jonathan M Davis wrote: On Wednesday, March 14, 2012 20:15:16 Spacen Jasset wrote: Is enforce then

DLL's and D

2012-03-14 Thread Chris Pons
I haven't used DLL's much, especially one I've built on my own, so guidance would be appreciated. I'm trying to figure out how to build a DLL which was written in D but i'm not sure i'm doing this right. I'm using VS2010 and Visual D. Visual D has a template for Dll's in D, so I used that

Math Libraries (and vectors, matrices, etc)

2012-03-13 Thread Chris Pons
Does D have a math library that defines, points, vectors and matrices including the appropriate functions(addition, dot product, cross product, etc)? I'm starting my next game and I would like to know what my options are. I plan on using SDL, I'm not exactly into OpenGL yet, since I'm new

Re: Math Libraries (and vectors, matrices, etc)

2012-03-13 Thread Chris Pons
Thanks, I'll take a look. I'm new, so I might need some help properly building this. I will post back if I have any problems. On Tuesday, 13 March 2012 at 20:06:13 UTC, Dmitry Olshansky wrote: On 14.03.2012 0:03, H. S. Teoh wrote: On Tue, Mar 13, 2012 at 08:25:49PM +0100, Chris Pons wrote

Re: Math Libraries (and vectors, matrices, etc)

2012-03-13 Thread Chris Pons
SciD looks nice, but it seems to be a bit too complicated for my use. Are there any other alternatives? On Tuesday, 13 March 2012 at 20:14:14 UTC, Chris Pons wrote: Thanks, I'll take a look. I'm new, so I might need some help properly building this. I will post back if I have any problems

Re: Math Libraries (and vectors, matrices, etc)

2012-03-13 Thread Chris Pons
Oops, I didn't see the replies, after my last message. I'll check this out. Thanks! On Tuesday, 13 March 2012 at 20:34:54 UTC, Kiith-Sa wrote: SciD is a scientific math library providing vectors/matrices of arbitrary sizes, but not useful at all for game development. See gl3n for a

Proper Use of Assert and Enforce

2012-03-13 Thread Chris Pons
I'm new, and trying to incorporate assert and enforce into my program properly. My question revolves around, the fact that assert is only evaluated when using the debug switch. I read that assert throws a more serious exception than enforce does, is this correct? I'm trying to use enforce

Re: Assert and the optional Message

2012-03-09 Thread Chris Pons
Ok, thank you for the advice. I will look into it.

Re: Assert and the optional Message

2012-03-09 Thread Chris Pons
Any idea why, system(PAUSE) does work?

Re: Assert and the optional Message

2012-03-09 Thread Chris Pons
You are right, there is also an option to Pause when program finishes. I never saw it until now. Thank you for all the replies. On Friday, 9 March 2012 at 13:39:02 UTC, Dmitry Olshansky wrote: On 09.03.2012 11:42, Chris Pons wrote: I am new to D and have been playing around with Assert. I

Assert and the optional Message

2012-03-08 Thread Chris Pons
I am new to D and have been playing around with Assert. I figured that using a message with assert would be very helpful, but unfortunately when the message is printed to the console, the console closes and my program ends. Is there any way to get a more permanent message? I've tried adding

How to cast a int to a string?

2012-03-06 Thread Chris Pons
I'm trying to update a string easily whenever I change a numeric component of the string. I've tried to do this so far with no result: while( testInt 10 ) string testString = Test ; int testInt = 0; testString ~= toString(testInt) testInt++; or this: testString ~= cast(string)(testInt)

Re: How to cast a int to a string?

2012-03-06 Thread Chris Pons
On Tuesday, 6 March 2012 at 23:19:03 UTC, H. S. Teoh wrote: On Wed, Mar 07, 2012 at 12:13:54AM +0100, Chris Pons wrote: I'm trying to update a string easily whenever I change a numeric component of the string. I've tried to do this so far with no result: [...] Try this: import

How to check type of an object to a class name?

2012-03-05 Thread Chris Pons
Is it possible to check the type of an object to a class name? //Something like this: Class test { //... } assert(is(anonObject == typeof(test))

Char * character and string

2012-03-01 Thread Chris Pons
Hello, I am trying to work with SDL and one of their functions takes a char * file as a function a parameter. However, i'm running into trouble how to actually set this variable in my constructor. I am getting a problem where if I use a pointer to a char and set it as test.bmp I get an error

Re: Char * character and string

2012-03-01 Thread Chris Pons
Thank you for the reply. However, I've run into another problem. I changed: --- char * file; this() { this.filename = test.bmp; } --- To: char * file this() { this.filename = toStringz(test.bmp); } --- I am getting this error:

Re: Char * character and string

2012-03-01 Thread Chris Pons
Ok, got it all sorted. Thank you for the guidance.

Re: D, Derelict2, and OpenGL

2012-02-23 Thread Chris Pons
On Thursday, 23 February 2012 at 19:26:31 UTC, James Miller wrote: I find that when learning a complicated system or library, the best way is to write out the code examples, compile them, then change things until they break, fix it, then make more changes. Eventually you end up with the worst

UnitTest and visual D

2012-02-23 Thread Chris Pons
I am following the book The D Programming Language and am at the portion about functions and unittest. For some reason I cannot get unittest to do anything noticeable. I right clicked on my Project Properties Command Line and under additional options added -unittest (--main gave me an error

Re: UnitTest and visual D

2012-02-23 Thread Chris Pons
Ok, thanks. I haven't run into version(...) yet. Would I be correct if I assumed that this version of void main: void main() {} would only run if -unittest was in the command line? Also, what should be in a unit test? Test cases to make sure certain functions/classes are working as you

Re: UnitTest and visual D

2012-02-23 Thread Chris Pons
Thanks for the response. There are a lot of great features to D that really excites me about using this language. Unittest is definitely one of them. It's hard for me to imagine myself going back to C++ at this point because of the amount of great features in D. :)

D, Derelict2, and OpenGL

2012-02-22 Thread Chris Pons
I have been reading the book The D Programming Language and am really enjoying D. However, my current motivation to use D was specifically for programming through OpenGL, and I was excited when I found out Dereict2 provided support for OpenGL. My current Gfx card can only support up to OpenGL

Re: D, Derelict2, and OpenGL

2012-02-22 Thread Chris Pons
Hey David and Vijay, Thank you for the swift replies. It seems like this foray into D and OpenGL could be a bit overwhelming considering I would be learning D and SDL/OpenGL at the same time. So because of this, i'm going to make sure I have a solid base in D to start with. I am an

Re: D, Derelict2, and OpenGL

2012-02-22 Thread Chris Pons
, but how long does it take to get approved to post on that forum? I read that I had to wait for moderator activation (unless I was mistaken) ? On Thursday, 23 February 2012 at 01:15:17 UTC, David wrote: Am 23.02.2012 01:20, schrieb Chris Pons: Hey David and Vijay, Thank you for the swift replies

Re: D, Derelict2, and OpenGL

2012-02-22 Thread Chris Pons
Ok, well it must be something wrong on my end. I have tried logging in with no result. I'll try to work it. I don't know if you are mistaken or not, but looking at the member list sorted by join date, several new members have registered recently. So if approval *is* required, it probably

Re: D for game Development

2012-02-15 Thread Chris Pons
On Wednesday, 15 February 2012 at 15:41:02 UTC, Kiith-Sa wrote: On Wednesday, 15 February 2012 at 06:51:11 UTC, RedShift wrote: Can I use OpenGL or DirectX with D? If so, where can I find a guide to get everything setup? Derelict provides bindings for OpenGL and SDL (and many other

Re: D for game Development

2012-02-15 Thread Chris Pons
I am sorry about the double post. I am in the middle of trying to install derelict following this tutorial: http://h3.gd/dmedia/?n=Tutorials.SdlGlTutorial1 However, when I get to the third step I get this error: Error 1 Error: module gl is in file 'derelict\opengl\gl.d' which cannot be read

How to get Visual D working with Derelict2?

2012-02-15 Thread Chris Pons
Hey everyone, I am new to D, and interested in using it with Derelict2 for game development. I plan on using Visual D, which I have installed already. I used the visual studio 2008 solution file to build the libraries and the .di files but unfortunately I do not know where to put these files