• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=KmartSqrl;37832804]I'd take area out of the equation entirely. If you are subtracting a small area from the circle it might not change the radius enough to make them not overlap. Figure out a way to do it by only checking the distance between the circles and the radii to see how much they are overlapping and adjust the radii accordingly. As soon as they are touching start adding the amount of overlap to the radius of the bigger circle and subtracting it from the radius of the smaller circle. I think you're overcomplicating it :P[/QUOTE] Using the radius for the smaller and bigger circle is too fast. I'm now calculating the new radius for the smaller circle. After that I get the area before and after collision from the smaller circle, subtract them and add the difference area it to the bigger circles area. Now it works like expected :D thanks [vid]http://dl.dropbox.com/u/28034726/circleNew.webm[/vid]
[QUOTE=Electroholic;37834039]Java[/QUOTE] Include whatever exceptions that are needed. For example: [code]import NullArrayException; import IntegerOverflowException;[/code] And use code tags please.
[QUOTE=ThePuska;37833535]Both methods are encoding the URI correctly. The difference is that C# is encoding it as UTF-8 and PHP is encoding it as extended ASCII. I find it likely that they both have methods to do it in either encoding. In order to support full UTF-8 I'd suggest you try fixing the PHP implementation, though I can't tell you how[/QUOTE] Then I suppose it's a configuration issue on my server? Any idea where to look?
So, I'm trying to design a modularly usable collision component for handling all the types of collision in a game I'm working on. I know for certain that there will be AABB, OBB, Circle, and Pixel perfect collisions, I also know how to do each of these tests against another of the same type. But how would I go about designing a collision class that can do collisions between any of them? Right now my collision setup looks something like: [cpp] enum CollisionType { AABB, OBB, Circle, PixelPerfect }; class Collision { public: virtual ~Collision() { } virtual bool couldCollide(const Collision& other) = 0; // Fastest check virtual bool willCollide(const Collision& other) { return couldCollide(other); } // More in-depth check, for the computationally heavier collision types protected: CollisionType mType; } class AABBCollision : public Collision { public: AABBCollision(const sf::FloatRect& rectangle) : mRect(rectangle), mType(AABB) { } bool couldCollide(const Collision& other) { if (other.mType == AABB) return mRect.intersects((const AABBCollision&)other.mRect) else return false; } private: sf::FloatRect mRect; } // And similar classes for the other collision types [/cpp]
[QUOTE=AlienCat;37834799]Include whatever exceptions that are needed. For example: [code]import NullArrayException; import IntegerOverflowException;[/code] And use code tags please.[/QUOTE] says those don't exist. After some reasearch, they aren't even included in Java. I have no idea why we are instructed to use (and apparently write) those exceptions when NullPointerException and IllegalArgumentException (instead of InvalidInputException) already exist for the same purpose.
[QUOTE=horsedrowner;37832713]I've made a screenshot uploader called Superscrot.[/QUOTE] I'm sorry... what? Super scrote? Like a man's... scrotum?
[QUOTE=ShaunOfTheLive;37837398]I'm sorry... what? Super scrote? Like a man's... scrotum?[/QUOTE] Like the scrot screenshot utility, but this one is a superset of its abilities because it also uploads.
Any way to make Java use local database? I mean not online, because my college has blocked ports which I cannot access now therefore I can't run program correctly as queries are not made.
[QUOTE=arleitiss;37837515]Any way to make Java use local database? I mean not online, because my college has blocked ports which I cannot access now therefore I can't run program correctly as queries are not made.[/QUOTE] SQLite
[QUOTE=Eudoxia;37837494]Like the scrot screenshot utility, but this one is a superset of its abilities because it also uploads.[/QUOTE] Yeah, it was just a joke. Scrot sounds silly to begin with. I'll try to be more helpful if I have time.
[QUOTE=arleitiss;37837515]Any way to make Java use local database? I mean not online, because my college has blocked ports which I cannot access now therefore I can't run program correctly as queries are not made.[/QUOTE] Depends what database you use, but all you'd have to do is install it on your machine and then point your application to localhost:<databaseporthere>
[QUOTE=Eudoxia;37837494]Like the scrot screenshot utility, but this one is a superset of its abilities because it also uploads.[/QUOTE] Pretty much. There weren't any screenshot programs on Windows that I like, so I wrote my own. Linux users have scrot, so I decided to name it after that.
Anybody else had to do that Bumpkins of Bumpus assignment? I specified a function to calculate the door to the heights (after I converted to centimeters). After converting the values for the second bumpkin, it returns "Stilts" for them, no matter what. The height (b) is 170.942 cm, and the doorway (d) is 204.5 cm. Tracing that: b = 170.942c, d = 204.5c, and therefore 204.5 > 213.6775 ("Stilts"). [code]string calcDoor(float b, float d) { if (d > b * 1.25) return "Stilts\n"; if (b * 1.25 >= d && d > b * 1.05) return "Walk\n"; if (b * 1.05 >= d && d > b * 0.65) return "Duck\n"; if (b * 0.65 >= d && d > b * 0.40) return "Crawl\n"; if (b * 0.40 >= d && d > b * 0.25) return "Limbo if you can!\n"; if (b * 0.25 >= d) return "Blocked! No way in.\n"; }[/code] What the crap am I doing verily wrong?
The problem is not with the code you gave.
[QUOTE=ThePuska;37845977]The problem is not with the code you gave.[/QUOTE] Alright, whole deal coming up. The purpose of the assignment is to have us whip something up that can get the height of someone, the height of their doorway, and determine how they have to enter it (on stilts, walking, ducking, crawling, limboing, or not at all). Not everyone's measurements are in the same unit, so I converted what isn't in centimeters into centimeters and compared through that. The calcDoor function works universally through each unit. Problem: Bumpkin #1's travels come out as expected, but Bumpkin #2's doesn't (it's supposed to be "Walk"). bumpkin.cpp [code]/* BUMPKIN.CPP Input: BUMPKIN.IN Times to compute [Name - Doorways Encountered - Height [Doorway heights]] */ #include <iostream> #include <fstream> #include <string> using namespace std; string calcDoor(float b, float d); float conv2cm(float value, char unit); int main() { int populate; // Bumpkins to check for ifstream census; census.open("bumpkin.in"); census >> populate; for (int i = 0; i < populate; i++) { string name; // Bumpkin's name int doorways; // Doorways bumpkin will enter float b; // Bumpkin's height float d; // Doorway's height char unit; // Unit of measurement // Name, doorways, height, unit // Doorway heights census >> name >> doorways >> b >> unit; cout << "Bumpkin #" << i + 1 << ": " << name << " "; cout << "entering " << doorways << " doors.\n"; cout << name << " has a height of " << b << unit << endl << endl; if (unit != 'c') { cout << name << "\'s height is converted to " << conv2cm(b, unit) << "c" << endl << endl; } for (int j = 0; j < doorways; j++) { cout << name << " in doorway #" << j + 1 << ": "; census >> d >> unit; cout << calcDoor(b, conv2cm(d, unit)); } cout << "----------------------------------------" << endl; } system("pause"); return 0; } string calcDoor(float b, float d) { if (d > b * 1.25) return "Stilts\n"; if (b * 1.25 >= d && d > b * 1.05) return "Walk\n"; if (b * 1.05 >= d && d > b * 0.65) return "Duck\n"; if (b * 0.65 >= d && d > b * 0.40) return "Crawl\n"; if (b * 0.40 >= d && d > b * 0.25) return "Limbo if you can!\n"; if (b * 0.25 >= d) return "Blocked! No way in.\n"; } float conv2cm (float value, char unit) { // Convert values to centimeters for main computing // Why can't we still go metric yet? Oh right. Bumpkins. if (unit == 'i') return value * 2.54; // http://www.wolframalpha.com/input/?i=1in+to+cm else if (unit == 'f') return value * 30.48; else if (unit == 'y') return value * 91.44; else if (unit == 'm') return value * 100; else if (unit == 'c') return value; }[/code] bumpkin.in [code]2 Mookin 3 150.4 c 75 i 2 f 151 c Kimkin 1 67.3 i 204.5 c[/code] Output: [IMG]http://i.imgur.com/vAxLU.gif[/IMG] [editline]Whoa![/editline] Actually, I just fixed it. In that check "unit != 'c'", I forgot to actually convert the Bumpkin's height to centimeters with the line: [code]b = conv2cm(b, unit);[/code] Disregard, it's done.
So for my 3rd year project I have been thinking of what I want to do and the one thing that genuinely excites me is doing something AI related. I had the idea of doing like, a top down view of a house, and you choose up to 6 AI's, select if male or female, and then you give them attributes and personalities. In the house they can interact with different things, fight etc, depending on their personality's. Like on of them gets drunk and pees on the floor in the bathroom and another AI slips and dies because it hits his head on the toilet. I think the hardest part of this would be the graphics. Having the AI move to areas they want to go to. I'm not even sure if this is possible with the amount of programming knowledge I have, but that's why I'm asking here. Would this project be too hard for a 3rd level student? Any recommended places to look for tutorials or whichever on AI? Any help would be appreciated.
[QUOTE=Over-Run;37848173]So for my 3rd year project I have been thinking of what I want to do and the one thing that genuinely excites me is doing something AI related. I had the idea of doing like, a top down view of a house, and you choose up to 6 AI's, select if male or female, and then you give them attributes and personalities. In the house they can interact with different things, fight etc, depending on their personality's. Like on of them gets drunk and pees on the floor in the bathroom and another AI slips and dies because it hits his head on the toilet. I think the hardest part of this would be the graphics. Having the AI move to areas they want to go to. I'm not even sure if this is possible with the amount of programming knowledge I have, but that's why I'm asking here. Would this project be too hard for a 3rd level student? Any recommended places to look for tutorials or whichever on AI? Any help would be appreciated.[/QUOTE] If thats what you want to do then you are probably better of taking something like the sims and building an AI controller for it
How would one make a proper textbox input in XNA, I've tried making my own but its so horrible to type in, is there some documentation on how to make a userfriendly textbox, or have I missed some object?
Can someone tell me if this is correct? I want to create a triangle class that can subdivide its self. So the way i do this is by taking the 3 original verticies, call these 1,2,3 [code] 1 2 ---------- | / | / | / | / |/ 3 [/code] and make a point in the middle of these, now here is the problem. I want to do this irelevantly of the axis or direction that the triangle is facing So would this be the way to find that middle point: Take 2 verticies a & b center point is: (b.xyz - a.xyz)/0.5
snip never mind i fixed it
[QUOTE=Richy19;37849811]Can someone tell me if this is correct? I want to create a triangle class that can subdivide its self. So the way i do this is by taking the 3 original verticies, call these 1,2,3 [code] 1 2 ---------- | / | / | / | / |/ 3 [/code] and make a point in the middle of these, now here is the problem. I want to do this irelevantly of the axis or direction that the triangle is facing So would this be the way to find that middle point: Take 2 verticies a & b center point is: (b.xyz - a.xyz)/0.5[/QUOTE] I'm not sure exactly what you are asking, but I think you want: [code]p = (a.xyz + b.xyz) / 2[/code] This finds the point in the middle of a and b.
How do motion events work exactly on android? Does a single motion event contain ALL the information of pointers, or is one issued every time a pointer is changed? If so, then why can there be multiple pointer per motion event?
Should these coordinates not create a cube? [cpp] Vertice a,b,c,d, e,f,g,h; a.z = 5; b.z = 5; c.z = 5; d.z = 5; e.z = -5; f.z = -5; g.z = -5; h.z = -5; a.x = -5; b.x = -5; g.x = -5; h.x = -5; c.x = 5; d.x = 5; e.x = 5; f.x = 5; a.y = 5; d.y= 5; e.y= 5; h.y= 5; b.y = -5; c.y= -5; f.y= -5; g.y= -5; man.AddTriangle(Triangle(a,b,d,l)); man.AddTriangle(Triangle(d,b,c,l)); man.AddTriangle(Triangle(d,c,e,l)); man.AddTriangle(Triangle(e,c,f,l)); man.AddTriangle(Triangle(e,f,h,l)); man.AddTriangle(Triangle(h,f,g,l)); man.AddTriangle(Triangle(h,g,a,l)); man.AddTriangle(Triangle(a,g,b,l)); man.AddTriangle(Triangle(h,a,e,l)); man.AddTriangle(Triangle(e,a,d,l)); man.AddTriangle(Triangle(b,g,c,l)); man.AddTriangle(Triangle(c,g,f,l));[/cpp]
[QUOTE=gparent;37839320]Depends what database you use, but all you'd have to do is install it on your machine and then point your application to localhost:<databaseporthere>[/QUOTE] Well my college blocked ports to access database online. What can I do?
I'm using Ruby and I was wondering something. I've got a script that's going to load external ruby scripts up, and execute a function in them. The function is called [file]::main() Is there any way to do this?
I need my compiler to support Unicode, preferably different character sets, so I started thinking: How? Well, a string is just an array of characters, and a character is just an integer, so what I thought I'd do like this: [CPP] Input -> LLVM IR u8"ABC" -> @str0 = global constant [i8 x 4] [i8 'A', i8 'B', i8 'C', i8 '\0'] //i8 is an eight-bit integer u16"ABC" -> @str1 = global constant [i16 x4] [i16 'A', i16 'B', i16 'C', i16 '\0'] u32"ABC" -> @str1 = global constant [i32 x4] [i32 'A', i32 'B', i32 'C', i32 '\0'] [/CPP] (Here I have replaced the character codes for '[I]x[/I]', where [I]x[/I] is the character, because I'm too lazy to look up character codes) Basically, I need to be able to take in a Unicode string (From the console, or a file, or whatever, so I need a library with multiple input facilities) and print out the string as an array of numbers. How should I do this?
If you need to print out the string as an array of numbers, you don't really need Unicode support. Just print out the bytes.
[QUOTE=Jookia;37857193]If you need to print out the string as an array of numbers, you don't really need Unicode support. Just print out the bytes.[/QUOTE] But the strings have to come from somewhere. How do I read the string from a file, specifically from a FILE* which is what my compiler uses for IO right now? Now, getc() doesn't return a char but an int, does that mean I can read UTF-32 input through it?
[QUOTE=Eudoxia;37857222]But the strings have to come from somewhere. How do I read the string from a file, specifically from a FILE* which is what my compiler uses for IO right now?[/QUOTE] Read in the binary. Then convert it from whatever encoding the file is (there's no easy way to detect it) to UTF-8, use UTF-8. [QUOTE=Eudoxia;37857222]Now, getc() doesn't return a char but an int, does that mean I can read UTF-32 input through it?[/QUOTE] getc() can return whatever it wants, but the only way to truly return a Unicode character is a string. Unicode characters can be multiple code points.
[QUOTE=Jookia;37857237]getc() can return whatever it wants, but the only way to truly return a Unicode character is a string. Unicode characters can be multiple code points.[/QUOTE] I know about the printable glyph != code point thing, but since I am just looking to output the string as an array of numbers, I should just output the array of codepoints, no?
Sorry, you need to Log In to post a reply to this thread.