• What are you working on? V5
    2,005 replies, posted
[QUOTE=NovembrDobby;18964821]failed, are you sure it's automatic?[/QUOTE] It runs a script every 20 minutes and updates.
[QUOTE=flair;18964521]go tell that to all the devs that use mocap.[/QUOTE] Mocap is for 3D, 2D animations are way too different =/ Here's a post I made on gamdev explaining shit : [quote] *text*text*text*blablabal* The good thing about this is that it's perfect for 2D games, skeletal animations are only good for 3D games just because 3D has depth. In 2D games sometimes you have to give an illusion of depth. Also you may have noticed games taht use skeletal animations are usually flat and 2Dish , while other games such as Shank ( link to the video above ) look much nicer and less ugleh. *some more snipped text* [/quote] Almost forgot the link to the Shank gameplay video I used as illustration : [url]http://www.youtube.com/watch?v=KTnYay1je3Q[/url]
Hey guys, where should i learn c++. like simplest ebooks etc. Im getting used to php, now i want another thing to learn. :)
Still reading tutorials and writing simple programs so im still on the noob programming :bandwagon:
Well it took me about 2 months to get comfortable with php and mysql.
[QUOTE=s0ul0r;18948504]I will, let me eat up first :) Ok, so here's the mainclass where the int gold is stored and where it gets passed to the Standardtower class: -snip- the StandardTower class, from there it gets passed to the StandardAmmo class: -snip- And finally, the StandardAmmo class where the gold value is supposed to be increased. -snip- Yeah and with this double reference, it just doesn't modify the gold value in the mainclass....[/QUOTE] Well you're never writing to the referenced value you're getting. "gold = Gold" sets the public field "gold" to the value of "Gold", hence "Gold" is only read, and not modified. "Gold = gold", on the other hand, would modify the value all the way back up. Seems a bit obvious though, so maybe I'm completely missing something :)
Thanks for your reply so far, but isn't the ref Value existent in the constructor only? I mean i'd have to modify it in the constructor to make it work? But well... That obviously is not possible since it's passee again and tuen modified in another function. Or maybe i'm missing something too :D I never had to modify a value that Way
Here's one for you.. say I have these templates.. [cpp]template <typename T> struct NetworkedList { std::list<T> list; }; typedef NetworkedList<int> NetworkedIntList; template <> void WriteVarToBuffer( NetworkedIntList& var, CBuffer& buffer ) { buffer.WriteInt( var.list.size() ); for ( std::list<int>::iterator i = var.list.begin() ; i != var.list.end() ; ++i ) { WriteVarToBuffer( *i, buffer ); } } [/cpp] Can I make WriteVarToBuffer take a NetworkedList<T> instead, so I don't have to re-write and redefine the function for every variable I want to network in a list?
[cpp]template<typename T> void WriteVarToBuffer( NetworkedList<T>& var, CBuffer& buffer ) { buffer.WriteInt( var.list.size() ); for ( std::list<T>::iterator i = var.list.begin() ; i != var.list.end() ; ++i ) { WriteVarToBuffer( *i, buffer ); } }[/cpp] This?
[QUOTE=garry;18967184]Here's one for you.. say I have these templates.. [cpp]template <typename T> struct NetworkedList { std::list<T> list; }; typedef NetworkedList<int> NetworkedIntList; template <> void WriteVarToBuffer( NetworkedIntList& var, CBuffer& buffer ) { buffer.WriteInt( var.list.size() ); for ( std::list<int>::iterator i = var.list.begin() ; i != var.list.end() ; ++i ) { WriteVarToBuffer( *i, buffer ); } } [/cpp] Can I make WriteVarToBuffer take a NetworkedList<T> instead, so I don't have to re-write and redefine the function for every variable I want to network in a list?[/QUOTE] [cpp]template <typename T> struct NetworkedList { std::list<T> list; }; typedef NetworkedList<int> NetworkedIntList; template <typename T> void WriteVarToBuffer( NetworkedList<T>& var, CBuffer& buffer ) { //use var } //Use like this: NetworkedList<int> *list = new NetworkedList<int>; WriteVarToBuffer<int>(*list, buffer); [/cpp] Didn't test, but I'm pretty sure that's how it works. [QUOTE=s0ul0r;18967159]Thanks for your reply so far, but isn't the ref Value existent in the constructor only? I mean i'd have to modify it in the constructor to make it work? But well... That obviously is not possible since it's passee again and tuen modified in another function. Or maybe i'm missing something too :D I never had to modify a value that Way[/QUOTE] [cpp] class A { public static int num; public static void SetNum(ref int n) { num = n; //copies n into num. They're still two separate variables. } public static void ChangeFoo(ref int n) { n = 321; //the variable n is referencing is changed to 321. } public static void main() { int foo = 123; //Creates a new local variable, duh SetNum(ref foo); //Passes a reference to foo to the SetNum function ChangeFoo(ref foo); //Passes a reference to foo to the ChangeFoo function Console.Write(foo); //Prints foo, now changed to 321 } } [/cpp] I'm still not sure what your problem is, but I hope that explains something.
No, I don't think it's possible.. :/ [editline]07:10PM[/editline] WriteVarToBuffer is already a templated function..
This dummy-code works fine: [cpp]#include <iostream> #include <string> template <typename T> struct NetworkedList { NetworkedList(void){} std::string list; T b; }; template<typename T> void WriteVarToBuffer( T& var ) { std::cout << var; } template<typename T> void WriteVarToBuffer( NetworkedList<T>& var ) { std::cout << "Yo!\n"; for ( std::string::iterator i = var.list.begin() ; i != var.list.end() ; ++i ) { std::cout << *i; } } int main() { int a = 5; WriteVarToBuffer( a ); NetworkedList<bool> b; b.list = "Hi"; WriteVarToBuffer( b ); std::cout << std::flush; std::cin.get(); return 0; }[/cpp] output: [code]5Yo! Hi[/code]
Because you're straight defining WriteVarToBuffer, when in reality it's specializing it. Add [cpp]template<typename T> void WriteVarToBuffer( T& var ) { // Default Action } [/cpp] to the top of the file
I just can't find any solution to my double reference problem :/
[QUOTE=garry;18967803]Because you're straight defining WriteVarToBuffer, when in reality it's specializing it. Add [cpp]template<typename T> void WriteVarToBuffer( T& var ) { // Default Action } [/cpp] to the top of the file[/QUOTE] Why do you define a template specialization without taking any template specialization arguments, though? [QUOTE=s0ul0r;18967988]I just can't find any solution to my double reference problem :/[/QUOTE] What do you mean by "double reference"?
[QUOTE=jA_cOp;18968038] What do you mean by "double reference"?[/QUOTE] Yeah basically I passed it through 2 classes, but now I found a solution by breaking it down to a single reference. I just passed the gold value in the move function of the Ammo class, and that's exactly where the enemy kills are triggered and where the gold value is supposed to be increased. Works fine now :)
[QUOTE=garry;18967803]Because you're straight defining WriteVarToBuffer, when in reality it's specializing it. Add [cpp]template<typename T> void WriteVarToBuffer( T& var ) { // Default Action } [/cpp] to the top of the file[/QUOTE] I have a WriteVarToBuffer taking T and a WriteVarToBuffer taking a NetworkedList<T> and it's working fine. I tested it by passing an integer and by passing a NetworkedList<bool> to two functions, which are named the same and the compiler picked the right one for each. I'm quite unsure of what I could do wrong here.
[img]http://i50.tinypic.com/91fdc2.png[/img] Working on my achievement engine, inspired by the other guy here. It is done and now I just need to forward it to a display. Yay. Is not dumb :( </3
[QUOTE=ZeekyHBomb;18968171]I have a WriteVarToBuffer taking T and a WriteVarToBuffer taking a NetworkedList<T> and it's working fine. I tested it by passing an integer and by passing a NetworkedList<bool> to two functions, which are named the same and the compiler picked the right one for each. I'm quite unsure of what I could do wrong here.[/QUOTE] Your second one isn't specializing the first one, it's making a new one. I.E, put your first one on a class, then try to specialize it without editing the class..
Hmm, is it possible to change a function of a class while runtime? I have a simple Button class, but I have like 5 different types of buttons and the only thing I'd have to change would be the OnClick function... So f.e. I create a button: [cpp] Button1 = new Button(); [/cpp] and directly below that: [cpp] Button1.OnClick = override OnClick(int bla) { blabla; } [/cpp] ?
[QUOTE=s0ul0r;18970134]Hmm, is it possible to change a function of a class while runtime? I have a simple Button class, but I have like 5 different types of buttons and the only thing I'd have to change would be the OnClick function... So f.e. I create a button: [cpp] Button1 = new Button(); [/cpp] and directly below that: [cpp] Button1.OnClick = override OnClick(int bla) { blabla; } [/cpp] ?[/QUOTE] You'd use event handlers for that in conjunction with delegates, both in-built parts of C#. If you're not familiar with function pointers, the C# way is a bit overwhelming, so you should read a tutorial on it.
[QUOTE=jA_cOp;18970323]You'd use event handlers for that in conjunction with delegates, both in-built parts of C#. If you're not familiar with function pointers, the C# way is a bit overwhelming, so you should read a tutorial on it.[/QUOTE] Got some links? Since I really am not familiar with that kind of programming :D But for a button class I'd probably have to have a look on it.
Sweet, learned some more about the subject I am doing. Apparently they call it "Frame Pointer"(push EBP, mov ebp, esp). And unless specified otherwise, it will be omitted when built in release mode. [img]http://i49.tinypic.com/2qa4u9u.jpg[/img] Just need image bounds checking(So like in the image, the last call doesn't get wrongly found) and support for external modules which I am going to do by parsing a map file if it exists and if not it checks the exports.
[QUOTE=garry;18969167]Your second one isn't specializing the first one, it's making a new one. I.E, put your first one on a class, then try to specialize it without editing the class..[/QUOTE] You end up with two functions regardless of whether you specialize or not. Why do you need to specialize the first (single-variable) template? Just keep that how it is, and add your second template for lists of variables. AFAIK, the compiler should pick the right function/template. i.e. [cpp] template<typename T> void addVar(const T &t) { /* single var */ } template<typename T> void addVar(const std::vector<T> &t) { /* list of vars */ BOOST_FOREACH(const T &i, t) addVar(i); } [/cpp] <edit> oh, you want to specialize it without changing the class itself. I'm pretty sure you can't.
[QUOTE=nullsquared;18970788]You end up with two functions regardless of whether you specialize or not. Why do you need to specialize the first (single-variable) template? Just keep that how it is, and add your second template for lists of variables. AFAIK, the compiler should pick the right function/template. i.e. [cpp] template<typename T> void addVar(const T &t) { /* single var */ } template<typename T> void addVar(const std::vector<T> &t) { /* list of vars */ BOOST_FOREACH(const T &i, t) addVar(i); } [/cpp][/QUOTE] I didn't know C++ let you instanciate a template without specifying its template arguments, wouldn't you need: [cpp] addVar<T>(i); [/cpp] instead? (Line 11)
Trying to make the smallest possible scripting language I can, in C.
I just made a macro to make typedefs and define the functions for them. It sucks but it works. More editor work today. Grid, entity selection. Except entity selection doesn't show anything right now so you're completely unaware that it's working. [img]http://filesmelt.com/downloader/15Dec2009_003.png[/img]
[QUOTE=jA_cOp;18970929]I didn't know C++ let you instanciate a template without specifying its template arguments, wouldn't you need: [cpp] addVar<T>(i); [/cpp] instead? (Line 11)[/QUOTE] No, compilers can automatically deduce the template type from the function arguments. [editline]05:10PM[/editline] In fact that's the whole idea that lets everything in <algorithm> work the way it does.
[QUOTE=nullsquared;18972002]No, compilers can automatically deduce the template type from the function arguments. [editline]05:10PM[/editline] In fact that's the whole idea that lets everything in <algorithm> work the way it does.[/QUOTE] Wow, for some reason I never used it. I use it all the time in D, but I was sure C++ wouldn't let me.
[b]Posting on behalf of vladh[/b] [url=http://vladh.net/canvas.php] http://vladh.net/canvas.php [img]http://imgkk.com/i/0xNx9N.png[/img] [/url]
Sorry, you need to Log In to post a reply to this thread.