• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=LtKyle2;42194583]Quick question: I'm currently at the Beehive Managing part of Headfirst C#, but when I do this; [code] public bool AssignWork(string job, int numberOfShifts) { for (int i = 0; i < workers.Length; i++); if (workers[i].DoThisJob(job, numberOfShifts)) return true; else return false; }[/code] the 'i' in the if statement doesn't exist in the current context, so I'm not sure what the book is doing with this. Further along it says I need a get or set accessor for a private int they use in another method, but adding in a get or set accessor and then using the public version still says I need a get or set accessor. If someone has read this book before how did you fix this?[/QUOTE] The semicolon after the for statement shouldn't be there.
[QUOTE=LtKyle2;42194583] -snipsnap- [/QUOTE] If you have Steam, [URL="http://steamcommunity.com/id/cartman300"]add me[/URL], i'm most of the time online and willing to help doing C# [editline]14th September 2013[/editline] (That is meant for everybody, not just LtKyle2)
Has anyone used Protobuf-net and had issues with looping through a contracted class? I am trying to loop through 15 objects like so, but it only loops through two and then skips the rest. [img]http://puu.sh/4rJpy.png[/img] Here is the saveObject class.. [code] [ProtoContract] class saveObject { [ProtoMember(1)] public int UID = 0; [ProtoMember(2)] public string type = "NoDraw"; [ProtoMember(3)] public int x = 0; [ProtoMember(4)] public int y = 0; [ProtoMember(5)] public string texture = "Base.png"; //Optional and type specific below. [ProtoMember(6)] public string Dialogue { get; set; } [ProtoMember(7)] public string NPCName { get; set; } } [/code]
[QUOTE=reevezy67;42198733]-Protobuf-net problem-[/QUOTE] I've been using Protobuf-net for quite a while in a heavy traffic production environment, but I've never encountered something like this (though I use protogen in combination with .proto definitions for declaring messages). Does using the corresponding LINQ query produce the same problem? [code] pair.Value.ForEach(so => { BaseEntity tempEntity = new BaseEntity(); tempEntity.UID = so.UID; // ... }); [/code]
[QUOTE=NoFaTe;42198850]I've been using Protobuf-net for quite a while in a heavy traffic production environment, but I've never encountered something like this (though I use protogen in combination with .proto definitions for declaring messages). Does using the corresponding LINQ query produce the same problem? [code] pair.Value.ForEach(so => { BaseEntity tempEntity = new BaseEntity(); tempEntity.UID = so.UID; // ... }); [/code][/QUOTE] Yeah unfortunately, I may have to find another way of doing it.
[QUOTE=reevezy67;42198876]Yeah unfortunately, I may have to find another way of doing it.[/QUOTE] Just a random note. When targeting x64 (and especially in C++ projects) I usually don't trust the debugger with watching variable values (it has given me quite a few nightmares by providing invalid information). Now, with that being said (and if you are targeting x64/AnyCPU), does printing pair.Value.Count() result in 15?
Yeah it does.
[QUOTE=jamesrupert;42188783]I need help setting up Codeblocks, the compiler isn't working apparently. I've installed it though, C/C++ Intel Compiler.[/QUOTE] What's the error you get? [QUOTE=Erasus;42189089]Does anybody know where I can get GWEN for Ubuntu?[/QUOTE] [url]https://github.com/garrynewman/GWEN.git[/url] ?
[QUOTE=ZeekyHBomb;42199249]What's the error you get? [url]https://github.com/garrynewman/GWEN.git[/url] ?[/QUOTE] Not really an error, the "Hello World" I ran just does not show up in the console, anything.
Hm. Try this: [code]#include <fstream> int main() { std::ofstream("file.txt") << "Hello World" << std::endl; }[/code] And see if it leaves a file.txt.
[QUOTE=ZeekyHBomb;42200081]*writing to a temporary ofstream object*[/QUOTE] Wow, I haven't ever thought of that. Thanks for the "tip" :v:
Is there any way to apply projection mapping to the vga output on my laptop? So the desktop would be projection mapped? There must be :/
[QUOTE=jaooe;42200599]Is there any way to apply projection mapping to the vga output on my laptop? So the desktop would be projection mapped? There must be :/[/QUOTE] If you have multiple monitors you may be able to use streaming software to capture one of them and show the transformed image on the other output somehow, but otherwise no, not in in Windows. [editline]edit[/editline] Unless you run a single fullscreen application with OpenGL or Direct3D. In that case it's possible to rebind the buffer and swap function to transform the image when it's presented.
[QUOTE=ZeekyHBomb;42200081]Hm. Try this: [code]#include <fstream> int main() { std::ofstream("file.txt") << "Hello World" << std::endl; }[/code] And see if it leaves a file.txt.[/QUOTE] You just blew my fuckin' mind, man. I never thought of writing to a file in one line like that.
What the heck is this? I installed Qt4 I tried doing the example code [url=http://www.zetcode.com/gui/qt4/introduction/]on this website[/url], but I can't even compile it using make because it says that QApplication doesn't exist. [code][20:53:15|supervoltage build1]$ qmake -project [20:53:19|supervoltage build1]$ qmake [20:53:20|supervoltage build1]$ make g++ -c -pipe -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt/mkspecs/linux-g++ -I. -I. -I/usr/include/qt -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I. -o main.o main.cpp main.cpp:1:24: fatal error: QApplication: No such file or directory #include <QApplication> ^ compilation terminated. make: *** [main.o] Error 1[/code] why are you not working
Do I have to: [code]glEnable(GL_WHAT); glEnable(GL_IS); glEnable(GL_THIS);[/code] or is this valid: [code]glEnable(GL_WHAT | GL_IS | GL_THIS);[/code] I'm unsure if this is a driver issue or if I just suck at OpenGL.
[QUOTE=supervoltage;42202982]What the heck is this? I installed Qt4 I tried doing the example code [url=http://www.zetcode.com/gui/qt4/introduction/]on this website[/url], but I can't even compile it using make because it says that QApplication doesn't exist. [code][20:53:15|supervoltage build1]$ qmake -project [20:53:19|supervoltage build1]$ qmake [20:53:20|supervoltage build1]$ make g++ -c -pipe -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt/mkspecs/linux-g++ -I. -I. -I/usr/include/qt -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I. -o main.o main.cpp main.cpp:1:24: fatal error: QApplication: No such file or directory #include <QApplication> ^ compilation terminated. make: *** [main.o] Error 1[/code] why are you not working[/QUOTE] [code]find /usr/include/qt -name QApplication[/code]? [QUOTE=JohnnyOnFlame;42203345]Do I have to: [code]glEnable(GL_WHAT); glEnable(GL_IS); glEnable(GL_THIS);[/code] or is this valid: [code]glEnable(GL_WHAT | GL_IS | GL_THIS);[/code] I'm unsure if this is a driver issue or if I just suck at OpenGL.[/QUOTE] glEnable takes a constant, not bit-flags, so you have to do the first one. [editline]15th September 2013[/editline] Also, why does std::fstream("blah") << "stuff"; blow peoples minds? Sure, it's kinda nice, but when do you really create a file to write one thing and immediately forget about it?
I posted these questions in the "I want to learn programming!" thread, but I figured I'd post them here as well. (Also I'm sorry if this kind of question doesn't fit into help here). Anyway, some back story would be that last year I took a basic Computer Science class, and we basically learned the beginning of C#. At the end of year we were able to make the classic game "Frogger". The only bad thing is, I basically retained no information from that class, and I basically remember nothing from last year. :suicide: The questions I have are: -What are some good starting languages (for someone with basically no programming experience)? -Should I start with an easier, or a more difficult language? -What programs should I use for the recommended languages? -What are good resources where I could learn more about the recommended languages? Sorry if I sound like an idiot, it's just I am honestly interested in learning more about this particular subject. Thanks for any help in advance.
[QUOTE=xExigent;42204522]I posted these questions in the "I want to learn programming!" thread, but I figured I'd post them here as well. (Also I'm sorry if this kind of question doesn't fit into help here). Anyway, some back story would be that last year I took a basic Computer Science class, and we basically learned the beginning of C#. At the end of year we were able to make the classic game "Frogger". The only bad thing is, I basically retained no information from that class, and I basically remember nothing from last year. :suicide: The questions I have are: -What are some good starting languages (for someone with basically no programming experience)? -Should I start with an easier, or a more difficult language? -What programs should I use for the recommended languages? -What are good resources where I could learn more about the recommended languages? Sorry if I sound like an idiot, it's just I am honestly interested in learning more about this particular subject. Thanks for any help in advance.[/QUOTE] [url]http://facepunch.com/showthread.php?t=1305793&p=42120522&viewfull=1#post42120522[/url] ;)
Hey guys I'm back with newbie questions. So my assignment is: 1. Asks the user to enter two integers. Store the user entries in variables. Be sure the variables are of type int. 2. Calculate the sum, product, and average of the two variables. Declare and use variables to store the results of those calculations. 3. Output the values of the sum, product, and average variables. Use a printf statement for the output, and be sure the product and average are displayed with 3 decimal places. This is what I have[CODE]import java.util.Scanner; public class HW2 { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.printf("Input an interger! "); int Num1 = in.nextInt(); System.out.printf("Input another interger! "); int Num2 = in.nextInt(); int SumTotal = Num1 + Num2; System.out.printf( "The sum total is " + SumTotal); System.out.println(); int ProductTotal = Num1 * Num2; System.out.printf( "The product total is " + ProductTotal); System.out.println(); double Average = (Num1 + Num2) / 2; System.out.printf("The average is " + Average); } } [/CODE] Now I can't for the life of me get it to print with 3 decimal places. How do I have it return with decimal places? What am I doing wrong?
See [url=http://docs.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax]Format string syntax[/url], specifically the precision stuff.
Okay, so i've got 2 rectangles like this [thumb]http://puu.sh/4slfG.png[/thumb] each of them are a separate vertex array, going clockwise starting in upper left corner. How would i connect them both into a single vertex array creating a shape like this? [thumb]http://puu.sh/4smcl.png[/thumb] The big rectangle rotates based on player position. Also how would i determine what points on a rectangle are visible from X,Y position?
[QUOTE=ZeekyHBomb;42206382]See [url=http://docs.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax]Format string syntax[/url], specifically the precision stuff.[/QUOTE] I'm screwing this up hardcore. How do I format it correctly? I'm confusing myself now.
[QUOTE=cartman300;42206460]Okay, so i've got 2 rectangles like this [thumb]http://puu.sh/4slfG.png[/thumb] each of them are a separate vertex array, going clockwise starting in upper left corner. How would i connect them both into a single vertex array creating a shape like this? [thumb]http://puu.sh/4smcl.png[/thumb] The big rectangle rotates based on player position. Also how would i determine what points on a rectangle are visible from X,Y position?[/QUOTE] Hey! Finally a use for the tutorial I made a while back. You can make your own algorithm but here is mine: [url]http://farmpolice.com/tutorial/[/url] [editline]asfp[/editline] re-reading it, the tutorial is actually pretty horrible at explaining the specifics. I made it for a project in highschool for a teacher that didn't know anything. Feel free to add me on steam and ask questions, I can then reveal to you what I meant by [I][quote]--eliminate faces that are facing the light, this can be done by getting the direction from one point of the face to the other. Then comparing it to the direction that the light makes from its origin to the center of the face.[/quote][/I] among other things.
[QUOTE=blacksam;42206905]I'm screwing this up hardcore. How do I format it correctly? I'm confusing myself now.[/QUOTE] You're using string concatenation in a formatted print method call, which is almost certainly not what you want. When you call printf, it will read its first argument (a string) and look for format specifiers (short codes starting with a % i.e. %f for floats or %.3f for floats rounded to 3 decimals, etc, etc.). Whenever it encounters a specifier it looks in its arguments for a corresponding parameter; if the type matches it will do the specified formatting and move on to the next specifier. Basically, you need to modify your printf statements to actually use the printf facilities: [code] System.out.printf( "The sum total is " + SumTotal); [/code] might become [code] System.out.printf( "The sum total is %d", SumTotal); [/code] Since this is homework I will leave the rest as an exercise. Zeeky already linked to the documentation you need to form your own specifiers. Godspeed!
I have another question regarding [B]AS3[/B]. So, I have this ball, okay... And this ball... Is moving, okay.. And I want to hae a particle-effect-ish thing after it. - How can I achieve that?
[QUOTE=Rayjingstorm;42208746]You're using string concatenation in a formatted print method call, which is almost certainly not what you want. When you call printf, it will read its first argument (a string) and look for format specifiers (short codes starting with a % i.e. %f for floats or %.3f for floats rounded to 3 decimals, etc, etc.). Whenever it encounters a specifier it looks in its arguments for a corresponding parameter; if the type matches it will do the specified formatting and move on to the next specifier. Basically, you need to modify your printf statements to actually use the printf facilities: [code] System.out.printf( "The sum total is " + SumTotal); [/code] might become [code] System.out.printf( "The sum total is %d", SumTotal); [/code] Since this is homework I will leave the rest as an exercise. Zeeky already linked to the documentation you need to form your own specifiers. Godspeed![/QUOTE] Thanks to the both of you! Definitely got some clarity from my terrible tunnel vision.
Ok for any C enthusiasts I need help understanding what this function does exactly.. [code] #define ONEGB 1073741824 #define ONEMB 1048576 #define ONEKB 1024 char *addr(unsigned long a) { unsigned long r; // remainder r = (unsigned long) a; int gb = (int) ( r / ONEGB ); r -= gb * ONEGB; int mb = (int) ( r / ONEMB ); r -= mb * ONEMB; int kb = (int) ( r / ONEKB ); r -= kb * ONEKB; int b = (int) ( r ); char *p = malloc(64); sprintf(p, "%4dGB, %4dMB, %4dKB, %4d", gb, mb, kb, b); return p; } [/code]
[QUOTE=z0mbify;42213756]Ok for any C enthusiasts I need help understanding what this function does exactly.. [code] #define ONEGB 1073741824 #define ONEMB 1048576 #define ONEKB 1024 char *addr(unsigned long a) { unsigned long r; // remainder r = (unsigned long) a; int gb = (int) ( r / ONEGB ); r -= gb * ONEGB; int mb = (int) ( r / ONEMB ); r -= mb * ONEMB; int kb = (int) ( r / ONEKB ); r -= kb * ONEKB; int b = (int) ( r ); char *p = malloc(64); sprintf(p, "%4dGB, %4dMB, %4dKB, %4d", gb, mb, kb, b); return p; } [/code][/QUOTE] It interprets its argument as a byte count and then returns a string where of the format "xGB xMB xKB x" which specifies how many GB, MB, kB and B it represents, respectively. For example, if I input 1100, it will output "0GB 0MB 1KB 76" because 1 kB and 76 B together is 1100 B.
[QUOTE=cartman300;42206460]Okay, so i've got 2 rectangles like this [thumb]http://puu.sh/4slfG.png[/thumb] each of them are a separate vertex array, going clockwise starting in upper left corner. How would i connect them both into a single vertex array creating a shape like this? [thumb]http://puu.sh/4smcl.png[/thumb] The big rectangle rotates based on player position. Also how would i determine what points on a rectangle are visible from X,Y position?[/QUOTE] Smells like convex hulls, theres a wikipedia article that explains : [url]http://en.wikipedia.org/wiki/Convex_hull_algorithms[/url], For this specific scenario, it's overkill, but usefull for wapping multiple shapes [editline]16th September 2013[/editline] Looks like your doing a line-of-sight lighting thingy? try casting rays out in 360 degrees around the player, for a certain distance (view distance). Check for intersection with any shapes, can be done in a grid-environment with DDA (for efficiency). Collect the points at the end of each ray (either from a collision, or reached view distance) and from the bounded shape make an alpha mask. Links; DDA for raycasting covered here : [url]http://lodev.org/cgtutor/raycasting.html#The_Basic_Idea_[/url] Dynamic-light (AS3) : [url]http://www.emanueleferonato.com/2007/09/26/create-a-survival-horror-game-in-flash-tutorial-part-1/[/url] [editline]16th September 2013[/editline] NB. Obvisously the tighter packed (greater ammount of) rays, the better looking the effect (reduces clipping) but the more processor intensive.
Sorry, you need to Log In to post a reply to this thread.