• What do you need help with? V4 (January 2012)
    966 replies, posted
  • In a 2D sidescroller with gravity, what would I multiply with dt for lag compensation?
  • [QUOTE=Darkwater124;34818539]In a 2D sidescroller with gravity, what would I multiply with dt for lag compensation?[/QUOTE] Everything
  • Do something fun? Whatever interests you, really. I'm pretty sure the first recommendation from anyone here is going to be games, but you've got plenty of choices. You could do web development with any language and FCGI, which involves writing a handler that spits out some HTML for a given URL (or other HTTP header info, like GET/POST, etc.). The simplest "hello world" doesn't have to be more than like 10 lines. You could start working on an interpreter for mathematical expressions, which involves parsing plaintext into tokens and building an expression tree (or code for a stack machine). This is more involved, but the advantage here is that you can practice programming without having to worry about external libraries. Everything can be done with primitive types and basic I/O. You could make a simple visual demo with Lua+LOVE or Processing, or you could build a robot with an Arduino and program it to follow lines or avoid obstacles.
  • [QUOTE=ROBO_DONUT;34818169]Don't start with UI? Nobody likes UI work. It's tedious and stupid, and most of the time you have your face buried in the API reference for your widget toolkit.[/QUOTE] I just dumped a GUI project for sleep pattern analysis considering the bulk of it was screwing with wxWidgets and whatnot to add/remove/edit entries, while I already have a human readable and editable file format used to store patterns. In fact, one that resembles my sleep diary.
  • [QUOTE=Darkwater124;34818539]In a 2D sidescroller with gravity, what would I multiply with dt for lag compensation?[/QUOTE] You're actually doing integration, so it helps to know a little bit of calculus to work with the classical mechanics. Velocity is the derivative of position, and acceleration is the derivative of velocity (second derivative of position). Using the most basic approximation (Euler integration): [i][b]v(t) = a(t) * Δt[/b] [b]x(t) = v(t) * Δt[/b] = a(t) * (Δt)[sup]2[/sup] / 2[/i] There are, of course, multiple methods of integration, each with their own advantages and disadvantages. Two other popular methods are RK4 and Verlet.
  • [QUOTE=ROBO_DONUT;34818650]Do something fun? Whatever interests you, really. I'm pretty sure the first recommendation from anyone here is going to be games, but you've got plenty of choices. You could do web development with any language and FCGI, which involves writing a handler that spits out some HTML for a given URL (or other HTTP header info, like GET/POST, etc.). The simplest "hello world" doesn't have to be more than like 10 lines. You could start working on an interpreter for mathematical expressions, which involves parsing plaintext into tokens and building an expression tree (or code for a stack machine). You could make a simple visual demo with Lua+LOVE or Processing, or you could build a robot with an Arduino and program it to follow lines or avoid obstacles.[/QUOTE] Where would be the best place to start learning that stuff? Any recommended tutorials or anything? I was looking at LOVE earlier on and it looks pretty cool. Mainly what I will want to be doing when I finish college will be trying to make games, so I will have to try get good at it. I just don't know where I should be starting with it all, since my college course isn't about making games.
  • The [url=https://love2d.org/wiki/Main_Page]Wiki[/url] seems to have a lot of good information. I've never used LOVE2D before, but it seems to be your typical framework, where you fill in a few callback functions that run when specific events occur. They've got a 'love.load', which, I'm guessing is your run-once initialization routine, 'love.update', which appears to be where you'd put your logic for whenever a game frame 'ticks', and 'love.draw', which would be called when the display wants a new image. They have a bunch of tutorials there, which seem to be arranged alphabetically rather than by complexity. [url=https://love2d.org/wiki/Tutorial:Hamster_Ball]This one[/url] seems to be the simplest.
  • See all this framework stuff confuses me. I'm not too sure what they are. Like I always hear about XNA and all this sort of framework stuff but I don't know what or how to use them. We haven't been shown it in college so I'm sort of at a loss for what they are. Thanks for the link I'll have a look over the stuff
  • [QUOTE=Over-Run;34818953]See all this framework stuff confuses me. I'm not too sure what they are. Like I always hear about XNA and all this sort of framework stuff but I don't know what or how to use them. We haven't been shown it in college so I'm sort of at a loss for what they are. Thanks for the link I'll have a look over the stuff[/QUOTE] Frameworks and libraries are similar in that they are both collections of reusable code, but the difference is that a framework dictates structure to some degree, whereas a library merely provides you with some routines for you to use however you wish. A framework will typically override the usual entry-point (if there is one, like "int main()" in C) and, instead, gives the programmer some callback functions or handlers to fill-in to specify behavior. The framework does what it needs to do (all the simple boilerplate stuff), but references your code in places where any major decisions are to be made.
  • Oh right I see, cheers. I just downloaded LOVE. Trying it now, not too sure how to actually run the program. I just copied the Hamster game code to see if I could work it, no luck yet EDIT Never mind, just got it there. going to play around in it now. Thanks. EDIT Man, even though it's so simple, LOVE is so fucking cool. I'm in love. I just tried that Hamster program, but how would I get it so I can have 2 hamsters controlled by different keys? I have gotten 2 hamsters to print on in different areas on the screen, but I'm not sure how to make the second one move by different keys. I copied the function to make the first move and changed the variables to the corresponding ones for the second hamster but I can't get it working.
  • This is supposed to print the largest string in the vector, but it seems to be printing random strings in the vector instead: [cpp]#include <iostream> #include <iomanip> #include <ios> #include <vector> #include <string> #include <algorithm> using std::cin; using std::cout; using std::endl; using std::sort; using std::streamsize; using std::string; using std::vector; int main() { cout << "Enter followed by ctrlz"; vector<string> vec; string x; while (cin >> x) vec.push_back(x); cout << endl; typedef vector<string>::size_type vec_sz; vec_sz size = vec.size(); sort(vec.begin(), vec.end()); cout << vec[size-1]; system("pause"); return 0; }[/cpp]
  • [QUOTE=Protocol7;34820025]It's working for me. What values are you testing with?[/QUOTE] awefawef awef awefawefawefwaef awefawefawef
  • When I use those values, newline delimited, awefawefawefwaef is the return value of the cout. Even on a single line it works: [IMG]http://puu.sh/hWKT[/IMG]
  • How can I save a struct data in a file ? Like: [code] typedef struct student { char name[40+1]; int idade; unsigned int n_reg; /* Number of register */ } STUDENT;[/code] I tried 100000000... times and didn't work. I know that I need use fwrite() and fread().
  • to write structure: [code]fwrite(pointer_to_struct,sizeof(your_struct),1,file)[/code] to read it in again: [code]fread(pointer_to_struct,sizeof(your_struct),1,file)[/code] if you have an array, replace pointer_to_struct with the array and replace 1 with the size of the array in both examples.
  • Okay...Will work this ? [code] typedef struct student { char name[40+1]; int idade; unsigned int n_reg; /* Number of register */ } STUDENT; fwrite(&STUDENT, sizeof(STUDENT), 1, file); while ((fread(&STUDENT, sizeof(STUDENT), 1, file) == 1) fprintf(stdout, "Name: %s\nAge: %d\nNº reg.: %u\n", student->name, student->age, student->n_reg);[/code]
  • [QUOTE=Cesar Augusto;34821333]Okay...Will work this ? [code] typedef struct student { char name[40+1]; int idade; unsigned int n_reg; /* Number of register */ } STUDENT; fwrite(&STUDENT, sizeof(STUDENT), 1, file); while ((fread(&STUDENT, sizeof(STUDENT), 1, file) == 1) fprintf(stdout, "Name: %s\nAge: %d\nNº reg.: %u\n", student->name, student->age, student->n_reg);[/code][/QUOTE] You have to populate the struct first: [code]STUDENT john; john.name = "John Fuck"; john.idade = 400; john.n_reg = 1234567; fwrite(&john, sizeof(STUDENT), 1, file); [/code]
  • Flub, I think it'll be easier if you just used std::cout rather than typing using std::cout. I might be wrong on this though, but I find it cleaner to just type std::cout rather than what you're doing.
  • [QUOTE=Cesar Augusto;34821333]Okay...Will work this ? [code] typedef struct student { char name[40+1]; int idade; unsigned int n_reg; /* Number of register */ } STUDENT; fwrite(&STUDENT, sizeof(STUDENT), 1, file); while ((fread(&STUDENT, sizeof(STUDENT), 1, file) == 1) fprintf(stdout, "Name: %s\nAge: %d\nNº reg.: %u\n", student->name, student->age, student->n_reg);[/code][/QUOTE] Just look at "while" Damn...wrong button.... :´(
  • This it the code for my Save As button that iv made on my project. private void saveAsToolMenu_Click(object sender, EventArgs e) { saveFD.InitialDirectory = "C:"; saveFD.Title = "save a text file"; saveFD.FileName = ""; saveFD.Filter = "Text Files|*.txt|All Files|*.*"; if (saveFD.ShowDialog() != DialogResult.Cancel) Its works fine but i don't know what the code would be for the Save button where you don't actually choose a place to save it to it just updates the last save you made and saves it to that with out having to scroll through your files and folders. Can any one help?
  • Look at this part of my program [code] void Salvar(USUARIO *x) { fseek(fp, 0L, SEEK_END); if (fwrite(&x, sizeof(x), 1, fp) != 1) { fprintf(stderr, "Erro ao salvar o registro"); exit(1); } fprintf(stdout, "Registro salvo com sucesso!"); } void ProcessOpen() { if ((fp = fopen("Registros.dat", "wb")) == NULL) { fprintf(stderr, "Erro ao abrir o registro"); exit(1); } } void Ler(USUARIO *x) { rewind(fp); while (fread(&x, sizeof(USUARIO), 1, fp)) fprintf(stdout, "Nome: %s\nSexo: %s\nIdade: %d\nTelefone: %d\nSalário: %.2f\nRegistrado: %d/%d/%d\n", x->nome, x->sexo, x->idade, x->telefone, x->salario, x->registrado.dia, x->registrado.mes, x->registrado.ano); } [/code] Works, but I want show each information of x person. Don't appears... Obs.: Some parts are in portuguese (dun worry)
  • I got a problem. I want to make a broadcast, that sends a String to every connected client. but when I execute the command, then I get the following error, at this point: Error: A disposed object can not be accessed. Object: "System.Net.Sockets.Socket". Code: [code]sent += socket.Send(buffer, offset + sent, size - sent, SocketFlags.None);[/code] The error probably only happens, when it tries to send the message to "127.0.0.1" Whole Network code: [url]http://pastebin.com/D01U4GTy[/url] Execution code: [code] private void btn_send_01_Click(object sender, EventArgs e) { string str = "Teststring"; //String that gets send to the client foreach(ServerThread th in cNetListener.threads) { Socket sck = th.connection.Client; th.Send(sck, Encoding.UTF8.GetBytes(str), 0, str.Length, 1000); } }[/code] Also, can someone take a look at my network code, and tell me if the network shit I coded is bullshit?
  • In C# how could i have a texture manager hold all the images and then have the classes point to the image they need? (while using safe code) In C+ I would do something like. MyClassImagePointer = TextureManager.GetImage(blah); But from what i can remember c# would create a copy of the image not a pointer to it
  • I've tried taking a look at my webgl project once again, and I just seem unable to find the problem... I'm sure I'm missing something really obvious but I just can't quite pinpoint it. Would anybody care to take a look at it and see if they can spot my mistake? The textured quads doesn't show up at all while the lines works fine. I'm also very certain that the texture is right as it works in my c++ opengl engine, but just not with webgl. Here's a link to it: [url]http://dl.dropbox.com/u/40398697/WebGLProject/WebGLProject.rar[/url] Any help is appreciated!
  • [QUOTE=Richy19;34833041]In C# how could i have a texture manager hold all the images and then have the classes point to the image they need? (while using safe code) In C+ I would do something like. MyClassImagePointer = TextureManager.GetImage(blah); But from what i can remember c# would create a copy of the image not a pointer to it[/QUOTE] C# is more likely to create a reference to it than a copy. You normally don't need to explicitly use pointers and ref objects.
  • [QUOTE=NovembrDobby;34833227]C# is more likely to create a reference to it than a copy. You normally don't need to explicitly use pointers and ref objects.[/QUOTE] More specifically, all class objects in C# are reference types, not value types, just like in Java. Only value types (primitives and structs) get copied.