# xstreme2000

Member

329

152 Neutral

• Rank
Member
1. ## Matrix rotation problem in 2d

Got it, was a case of being a total idiot (as I suspected) this is wrong because it changes the value of y before which causes the second calculation to be incorrect [code] Vector.transform = function(matrix) { this.x = (this.x * matrix.data[0][0] + this.y * matrix.data[1][0] + matrix.data[2][0]); this.y = (this.x * matrix.data[0][1] + this.y * matrix.data[1][1] + matrix.data[2][1]); return this; }[/code] changed it to [code] Vector.transform = function(matrix) { x = (this.x * matrix.data[0][0] + this.y * matrix.data[1][0] + matrix.data[2][0]); y = (this.x * matrix.data[0][1] + this.y * matrix.data[1][1] + matrix.data[2][1]); this.x = x; this.y = y; return this; }[/code]
2. ## Matrix rotation problem in 2d

I'm sure this is something really stupid but I'm drawing a blank on it. I'm just playing about with some basic 2d transformations in javascript. Translations and scaling are working perfectly but rotation has gone a bit weird. I'm sure many of you will probably be able to tell what's wrong just by seeing the rotation movement so I have uploaded a demo to here: [url="http://x2k.co.uk/canvastest/2d.html"]http://x2k.co.uk/canvastest/2d.html[/url] All the code is obviously visible via view src but here are the relevant bits: [code] Matrix.init = function() { this.data = [ [1, 0, 0], [0, 1, 0], [0, 0, 1] ]; }[/code] [code] Matrix.setRotate = function(r) { this.init(); this.data[0][0] = Math.cos(r); this.data[0][1] = Math.sin(r); this.data[1][0] = -Math.sin(r); this.data[1][1] = Math.cos(r); return this; }[/code] [code] Vector.transform = function(matrix) { this.x = (this.x * matrix.data[0][0] + this.y * matrix.data[1][0] + matrix.data[2][0]); this.y = (this.x * matrix.data[0][1] + this.y * matrix.data[1][1] + matrix.data[2][1]); return this; }[/code] Like I said I'm sure it's something really simple but I've been trying to work it out and failing so I'd very much appreciate it if one of you guys could point me in the right direction. Many thanks!!!
3. ## How many dimensions can you have in a game?

Quote:Original post by templewulf On another note, the fading in-out is a good idea. I imagine they wouldn't fade so much as shrink. Sort of like how people "shrink" as they become more distant. Interesting, that would also make targetting harder as they are getting away from you...I like it. Quote:Original post by templewulf What I don't want to attempt, though, is to describe a level that changes in mathematical terms. At best, you could have 2 level layouts at each extreme of the fifth dimension and interpolate between them depending on where you are on that dimension. The problem is whether or not you could stop shifting in the middle. I mean, depth isn't a binary state, you can stop between point A and point B. I just don't think it's possible for humans to visualize it coherently, much less represent it in concrete terms a computer can show you. I certainly think you could stop anywhere between (I did try to say that in my original post but I make have failed). Also I'm not entirely convinced that it would hard to visualize/control/represent...only problem for me would be actually coding the thing as I'm far too lazy. Quote:Original post by spartanx I like this! Thanks, I like it to :-P I've not read that book you mentioned, sounds interesting though. Quote:Original post by spartanx One issue on the rendering side is how to accomplish the popping and distortion - especially if areas have a huge difference (wooded vs. urbanized). But I suspect with clever shaders doing scaling, shearing, blending, blurring, and refracting it's doable [cool]. Yes, there would be some interesting problems to over come here but I think it would be very doable and could work really well...on that note if anyone wants to do it then be my guest, I'm certainly to lazy/busy to complete anything like this :(
4. ## How many dimensions can you have in a game?

I was recently talking to a collegue about the possibility of extra dimension in game play, one idea I had was that you'd have a 3 dimentional game displayed on the screen but by 'sliding' through dimentions you the layout and look would change. Let me explain...imagine you had an FPS but and you have 2 maps which map to each other (these would be 2 parrallel dimentions, in theory you could map 4, 5, 6, etc. levels together but for explaination sake I'll stick to 2), so essentially the maps would probably be the same shape & have similar pathways and obsticals which would match and be in the same places in both maps. Obviously the maps should look quite different, maybe one a built up area them the other in a forrest or something Anyway, on to the controls, the idea is that you have a control which would allow you to move between dimensions/maps, I've been thinking the mouse wheel would be ideal. However rather than just switch from one map to the other, one map would kind of warp/morph into the other so as you turn the mouse wheel texture and geometary starts to morph to the other map. So now you have a set of controls something like WASD for movement, Mouse look and Mouse Wheel to move you through the added dimension of gameplay. Now say for example you are chasing an opponent, you could have it so that they start to fade out as the move out of the current dimension space...you could also have them fade out lighter or darker depending which way they are going, so if you are chasing them and the start going light and fading you have to scroll the mouse wheel upwards to keep following them. Other clever ideas could also be implemented, like if you destroy matter in one dimention it appears in another or also destroys it in another...so you might his a wall in one dimension then shift to another one and destroy then go back to the original one to continue through the map. I don't know how well I've explained it but I think my concept is sound and the controls should be manageable & fun. Anyone have any oppions or ideas on this idea?
5. ## [web] Problem with some CSS in IE

Ok thanks. Sadly I've not got the option to individually class each item as the html is generated by some other software which I'm not going to start modifying. I'll just pick a nice style for the default list item and let IE display that. Thanks again.
6. ## [web] Problem with some CSS in IE

I'm having a bit of trouble with some CSS, it works in Opera & Firefox but not in IE (surprise surprise, althought I've not tried IE7). This CSS code looks something like this... /* -----------------------*/ li { background-color: black; /* All list elements in IE have this style */ } ul > li { background-color: red; } ul > li + li { background-color: orange; } ul > li + li + li { background-color: yellow; } /* etc... */ /* -----------------------*/ So I'm trying to change the style of each list item. Any ideas on getting this to work in IE?
7. ## [C++] Why is the predefined index operator commutative?

That makes sense, thanks.
8. ## [C++] Why is the predefined index operator commutative?

I was looking at the page about the book C++ Gotchas by Stephen C. Dewhurst on Amazon when I noticed in one of the reviews someone states that this book talks about why the predefined index operator is commutative, e.g. referring to MyArray[24] is the same as referring to 24[MyArray]. Now I've not read the book so I don't know what the book say about it (I do intend to buy it & read it one day but not yet) but it's got me wandering, I've never seen that before and to refer to an element by index[array] seems backwards to me but I'm thinking there must be a good reason for this...does someone care to enlighten me? Many thanks, Tom
9. ## [C++] Gibberish in std::string? [Solved]

if pMeshContainer->pTextureName type is std::string then what is the dw doing in... pMeshContainer->pTextureName[dw] = nameStr; ??? Maybe it should be... pMeshContainer->pTextureName = nameStr; or pMeshContainer[dw]->pTextureName = nameStr; or maybe pTextureName is actually an array/vector of std::string but you didn't say????? ;)
10. ## Meals

I could be wrong but I believe there is some scientific evidence which suggests the healthiest way to eat is by eating small amounts of food frequently, rather than large meals with long gaps between them, because processing a massive meal put quite alot of strain on the digestion system...I'm probably wrong though ;)
11. ## Adding a feature to CPP

Personally I don't feel this should be a feature added to C++, I think the way you did it in your example is fine, at least you can see what's going you when you read it. The other thing I'd say is that in you're example I'd ague that inheritence would be a better way to go but I do understand it's just an example to highlight your point.
12. ## Train robots to take over the world!

I had a play with this a while back, but didn't go into too much because my ancient machine could only just run it. Anyway, what I had kinda hoped was that you'd get the ability to train different units in different ways, so for example you'd train them in the same way as you do in NERO but once you are satified with the way you units are behaving you could add 10 to youe team, then train some more units in another way and have 10 of them one your team and so one until you are read then take your team into battle. Just an idea.
13. ## Filling an array of pointers.

Quote:Original post by Brocketino I was thinking that perhaps your GetName function was returning a pointer to a variable that just will be filled with new data at each call. Hehe, that's what I was saying, just I said it very badly :p
14. ## Filling an array of pointers.

sorry, that ^^^ was a really bad reply, I hope you get what I mean
15. ## Filling an array of pointers.

Fair enough, I could be wrong because I'm not really sure what some of those variables are but at a guess I'd say that each call to GetName() is returning a pointer to the same block of memory which is being overwritten each time by the latest line read. So something along the line of this is happening char buf[256]; // global var char *GetName() { readFromFileIntoBuffer(buf); return buf; } // in main()... char *p1 = GetName(); // p1 = &buf[0], buf = first name char *p2 = GetName(); // p2 = &buf[0], buf = second name therefore p1 also = second name since it also points to buf.