[URL="http://www.facepunch.com/threads/1146474?p=33638755"]This[/URL]. Is this real life?
[QUOTE=Map in a box;33635934]What IDE are you using?[/QUOTE]
I tried using eclipse. I have NetBeans but I've never used it so I have no idea how to import jars into it.
[QUOTE=Blueridge;33640312]I tried using eclipse. I have NetBeans but I've never used it so I have no idea how to import jars into it.[/QUOTE]
Create a new project in eclipse and import the .java files.
When dealing with linked lists or other data structures with pointers to another structure, is there an easy way to start at the Head or Root?
My usual method (a workaround really) is to do this, for example with linked lists:
[code]
void LinkedList::printList() {
// Prints the contents of the current linked list
printListUtil(head);
}
void LinkedList::printListUtil(Node *conductor) {
// Private method for recursing through the list
if (conductor->data != EMPTY)
std::cout << conductor->data;
if (conductor->next != NULL)
printListUtil(conductor->next);
}
[/code]
Having printList() and printListUtl() allows me to reliably start at the head of the linked list every time by passing head (a pointer to the head node) to printListUtil().
However, for the assignment I am currently working on, we are given a SET header file for the Node and LinkedList classes, meaning I cannot add my printListUtil() method.
Am I missing a really easy way to start at the head of a list?
[editline]FUCK[/editline]
I found a way to do it iteratively instead of recursively, just in case anyone needs this information in the future.
[code]
void LinkedList::printList() {
Node *current = head; // Set this iterator called current to the head node
while (current->next != NULL) {
std::cout << current->data << " ";
current = current->next;
}
}
[/code]
I didn't find a way to do it recursively with only one function, but this seems to be easier.
Of course you'll have to modify it to always print the head data in the case that the head is the only node.
Anyone know why SFML 2.0 fonts would do this?
[img]http://i.imgur.com/cp4m2.jpg[/img][img]http://i.imgur.com/mo5Yi.jpg[/img][img]http://i.imgur.com/OoByP.jpg[/img]
[img]http://i.imgur.com/BbGpC.jpg[/img][img]http://i.imgur.com/yARuu.jpg[/img]
(filled in with blue so you can see the corruption)
It's different every time but normally they come out something like this:
[img]http://i.imgur.com/oSPaN.png[/img]
I found something about it being fixed by building with release config, but it still happens.
[editline]9th December 2011[/editline]
just noticed it says 'debug' in that one up there, do they only add letters when they're used?
Probably for the same reason my textures don't seem to get filled even though they should.
[editline]10th December 2011[/editline]
I'll make sure to tell you if I find a solution to my issue in case they're related phenomena
Okay, I am absolutely stunned by these 2 linker errors:
[cpp]
1>game.obj : error LNK2001: unresolved external symbol "public: unsigned int __thiscall shadermanager::LinkProgram(unsigned int)" (?LinkProgram@shadermanager@@QAEII@Z)1>game.obj : error LNK2001: unresolved external symbol "public: unsigned int __thiscall shadermanager::LoadFromFileUL(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?LoadFromFileUL@shadermanager@@QAEIAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z)1>C:\Users\Capsup\Documents\Visual Studio 2010\Projects\UpEngine\Release\UpEngine.exe : fatal error LNK1120: 2 unresolved externals
[/cpp]
I just added these 2 functions to the shadermanager object like always and have checked that all variables are the correct types etc ... What the hell can cause these 2 linker errors all of a sudden?
This is the code in question:
[cpp]
GLuint shadermanager::LoadFromFileUL( std::string& fpPath, std::string& vpPath )
{
glShader fpShader;
glShader vpShader;
fpShader.Load( fpPath );
vpShader.Load( vpPath );
GLuint program = glCreateProgram();
glAttachShader( program, fpShader.GetObject() );
glAttachShader( program, vpShader.GetObject() );
return program;
}
[/cpp]
[cpp]
GLuint shadermanager::LinkProgram( GLuint program )
{
glLinkProgram( program );
GLint success;
glGetProgramiv( program, GL_LINK_STATUS, &success );
if( !success )
{
GLint blen = 0;
GLsizei slen = 0;
glGetProgramiv( program, GL_INFO_LOG_LENGTH, &blen );
if( blen > 1 )
{
char* log = (char*) malloc( blen );
char* log2 = "Linker error: ";
glGetInfoLogARB( program, blen, &slen, log );
char* log3 = tools::AppendChar( log2, log );
//FatalAppExit( NULL, tools::DCharToError( log2, log ) );
FatalAppExit( NULL, log3 );
free( log );
}
}
return program;
}
[/cpp]The rest of the functions in shadermanager works fine, just not these 2 that I just added.
Nevermind, I figured it out. I had forgotten the shadermanager:: before the function name. Stupid me.
You should be returning ret, you're not doing any manipulation of x but you're returning it for some reason.
[QUOTE=Octave;33648515]You should be returning ret, you're not doing any manipulation of x but you're returning it for some reason.[/QUOTE]
Now i feel dumb. Its still returning "??????????????????????????"
Shouldn't the condition in the if() be (x[i] > '\x0002') && (x[i] < '\a') instead of (x[i] > '\x0002') & (x[i] < '\a')? Usually a single '&' is bitwise and.
[QUOTE=Octave;33651308]Shouldn't the condition in the if() be (x[i] > '\x0002') && (x[i] < '\a') instead of (x[i] > '\x0002') & (x[i] < '\a')? Usually a single '&' is bitwise and.[/QUOTE]
Technically & works the same way as &&, because you are applying that operation to bools (result of comparison). Although && is short-circuiting so it doesn't evaluate the right side if the left side is false, because the entire expression can't be true in neither case.
A question about C#, So if I'd want to make lets say, a text box say a certain line from a text line like:
textbox.Text = Readstuff.line(4)
[CODE]Stuff
Not stuff
Medium stuff
Boring stuff
Less stuff[/CODE]
would output Boring stuff and so on.
Thanks in advance.
[QUOTE=DestWa;33653571]A question about C#, So if I'd want to make lets say, a text box say a certain line from a text line like:
textbox.Text = Readstuff.line(4)
[CODE]Stuff
Not stuff
Medium stuff
Boring stuff
Less stuff[/CODE]
would output Boring stuff and so on.
Thanks in advance.[/QUOTE]
I'm not too sure what you mean, but you could put each line of Readstuff into an array or List.
You put all the lines into an array, then do textbox.Text = arrayname[3] (to get line number 4. Arrays use zeroth numbering, so the first line would be 0, the second would be 1, etc.)
I need help with my HL2 beta MDL decompiler. Anybody has studio.h and optimize.h of Source MDL version 37? The leaked sources have only v36 specifications.
[QUOTE=SiPlus;33653845]I need help with my HL2 beta MDL decompiler. Anybody has studio.h and optimize.h of Source MDL version 37? The leaked sources have only v36 specifications.[/QUOTE]
I'm pretty sure those don't exist in the wild. That's why the gaben guys and the other guys wrote their own.
-snip-
[QUOTE=Tukimoshi;33637798]-Snip-
I got some help from my teacher and figured out the solution. Here's my code.
The program takes two inputs in 24-hour format (e.g 2230, 0415) with the second one being later. It then finds the difference.
[code]#Lab 5 Part 4
#09/12/2011
import utils
time1 = utils.get_int("Please enter a time in 24-hour format (####): ")
time2 = utils.get_int("Please enter a second time in 24-hour format (####): ")
#We are lazy so we use Deryk's convenient utility to grab our inputs.
hours1 = time1 / 100 ##e.g: 2230 / 100 = 22
hours2 = time2 / 100 ##e.g: 0415
#Separate hours to break this question down.
minutes1 = time1%100 ##e.g 2230 %100 = 30
minutes2 = time2%100
#Same for minutes
hours = hours2 - hours1 + 24
if hours > 24:
hours -= 24
#If we go over a day, we can just convert 24 hours into a day. We don't need to calculate the days (Example: 2230 on Tuesday and 0415 on Wednesday)
minutes = minutes2 - minutes1
if minutes < 0:
minutes += 60
hours -= 1
#In calculating the minutes, we may get negative. So we borrow an hour.
print 'The difference was', hours, 'hours and', minutes, 'minutes.'
[/code][/QUOTE]
I found my answer guys. So if anyone's interested, it's included in the post now.
I now have a bunch of (e.g: 30-40+) python programs that do various simple functions from calculating e (base of natural logarithms using a set # of terms) to converting celsius to fahrenheit.
If anyone's interested, I can throw em in a zip on my dropbox or something.
Anyone know of a good resource for (don't need to be free) android tutorials?
I'm creating a menuscreen for my XNA game,
Can anyone give me a good way to make a changing background?
-I have a 640 x 1280 background texture,
-My windows is 640 x 640,
First screen shows the most left of the background texture, as you press enter you continue to the next screen, a vector x's coördinate moves 640, and you should see the middle of the background texture.
If you select one of the few options (now just play game, options and exit) you move to the most right of the background texture.
I've tried to let the vector2.X go until he reaches 640 but somehow he never does and the texture goes until it's offscreen.
[CODE]
public void SetBackgroundPosition(int number)
{
switch (number)
{
case 0:
moveToBackgroundPosition = 0;
break;
case 1:
moveToBackgroundPosition = 1;
break;
case 2:
moveToBackgroundPosition = 2;
break;
}
}
public void Update(GameTime gameTime)
{
switch (moveToBackgroundPosition)
{
case 0:
if (backgroundPosition.X < 0)
{
backgroundPosition.X += 5;
}
break;
case 1:
if (backgroundPosition.X > 640)
{
backgroundPosition.X += 5;
}
if (backgroundPosition.X < 640)
{
backgroundPosition.X -= 5;
}
break;
case 2:
if (backgroundPosition.X > 1280)
{
backgroundPosition.X -= 5;
}
break;
}
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(currentBackgroundTexture, backgroundPosition, Color.White);
}
[/CODE]
[QUOTE=FlashStock;33660831]Anyone know of a good resource for (don't need to be free) android tutorials?[/QUOTE]
[url]http://developer.android.com/guide/index.html[/url]
[url]http://hackaday.com/2010/07/12/android-development-101-%E2%80%93-a-tutorial-series/[/url]
[url]http://www.ibm.com/developerworks/opensource/library/os-android-devel/[/url]
Google is your friend.
[QUOTE=ToXiCsoldier;33660900]I'm creating a menuscreen for my XNA game,
Can anyone give me a good way to make a changing background?
-I have a 640 x 1280 background texture,
-My windows is 640 x 640,
First screen shows the most left of the background texture, as you press enter you continue to the next screen, a vector x's coördinate moves 640, and you should see the middle of the background texture.
If you select one of the few options (now just play game, options and exit) you move to the most right of the background texture.
I've tried to let the vector2.X go until he reaches 640 but somehow he never does and the texture goes until it's offscreen.[/quote]
I think these signs are backwards:
[code]
case 1:
if (backgroundPosition.X > 640)
{
backgroundPosition.X += 5;
}
if (backgroundPosition.X < 640)
{
backgroundPosition.X -= 5;
}
[/code]
try swapping the -= and the += around.
[editline]10th December 2011[/editline]
Or better, replace everything with this:
[code]
public void SetBackgroundPosition(int number)
{
moveToBackgroundPosition = number;
}
public float approach(float curVal, float newVal, float step)
{
if(curVal < newVal)
{
if(newVal - curVal < step)
curVal = newVal;
else
curVal += step;
}
else if(curVal > newVal)
{
if(curVal - newVal < step)
curVal = newVal;
else
curVal -= step;
}
return curVal;
}
public void Update(GameTime gameTime)
{
backgroundPosition.x = approach(backgroundPosition.x,
moveToBackgroundPosition * 640, 5);
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(currentBackgroundTexture, backgroundPosition, Color.White);
}
[/code]
It replaces those switch/if statements with a nice function to do it.
[editline]10th December 2011[/editline]
You could also add some nice MathHelper.SmoothStep() stuff to make it change smoothly between the three states.
I know Batch might not be considered a programming language, however I hope there is someone here who can help me.
I'm just trying to make a very simple batch file that will take a file you drag onto it and send that and its creation date as arguments to a lua script I have already made. My problem is that I simply can't figure out how to get the creation date.
This is what I have so far. It works fine, but only sends the file, not the file's creation date.
[code]
cd C:/
set file=%1
lua Users/Nick/Desktop/ExcelLua/AddFile.lua %file%
[/code]
I pretty much have no experience with batch so I'm sorry if this is a dumb question... also, sorry if this does not belong in this sub-forum, I didn't know where else to post it.
[QUOTE=Sparky-Z;33665054]...
I'm just trying to make a very simple batch file that will take a file you drag onto it and send that and its creation date as arguments to a lua script I have already made. My problem is that I simply can't figure out how to get the creation date.
...
[/QUOTE]
I don't know much batch either, but this might help.
[url]http://stackoverflow.com/questions/2111333/how-to-get-files-modifed-date-on-windows-dos-command[/url]
[QUOTE=arleitiss;33619889]Apparently my shite headded lecturer requires us to "comment a lot" so there i give her, nearly every line commented.[/QUOTE]
Once I put "//this is a comment explaining the line immediately before it." after all of the normal comments. (which were already on every line.)
She gave me extra credit.
[QUOTE=Sparky-Z;33665054]I know Batch might not be considered a programming language, however I hope there is someone here who can help me.I'm just trying to make a very simple batch file that will take a file you drag onto it and send that and its creation date as arguments to a lua script I have already made. My problem is that I simply can't figure out how to get the creation date.This is what I have so far. It works fine, but only sends the file, not the file's creation date.[code]cd C:/set file=%1lua Users/Nick/Desktop/ExcelLua/AddFile.lua %file%[/code]I pretty much have no experience with batch so I'm sorry if this is a dumb question... also, sorry if this does not belong in this sub-forum, I didn't know where else to post it.[/QUOTE] [code]set file=%1dir /tc /o-d %file%PAUSE[/code]This?Why won't it take my newlines. Javascript being off prevents it apparently.
[QUOTE=Mr. Smartass;33638680]What's a good, well-explained guide to XNA?[/QUOTE]
Have you seen this? It covers 2D, 3D, Shaders and other stuff.
[url]http://rbwhitaker.wikidot.com/xna-tutorials[/url]
Whats the best version of SFML to get and how would I get it working with Visual C++ 2010 Express?
[editline]when[/editline]
Got it to work with 1.6 using this video.
[url]http://www.youtube.com/watch?v=VpHG_ENSgsQ[/url]
[QUOTE=Jacen;33667332]Have you seen this? It covers 2D, 3D, Shaders and other stuff.
[url]http://rbwhitaker.wikidot.com/xna-tutorials[/url]
Whats the best version of SFML to get and how would I get it working with Visual C++ 2010 Express?[/QUOTE]
Thanks a bunch.
I want to simulate a double pendulum using my program, but I can't find any math online that would help me do required calculations. I don't feel like using a full physics engine. Can anybody here give me something that would help me simulate a double pendulum?
[QUOTE=sim642;33668227]I want to simulate a double pendulum using my program, but I can't find any math online that would help me do required calculations. I don't feel like using a full physics engine. Can anybody here give me something that would help me simulate a double pendulum?[/QUOTE]
I have a feeling that you're going to get some mess of unruly differential equations.
Is it a lost cause for me to want to code in C++ for OS X, and should I just move to Windows?
[url=http://pastebin.com/JdmGi7HJ]This is a fare calculator I'm working on at the moment[/url], don't attempt to compile it because it's a mess at the moment. The general idea of where I'm at is there though.
I spent around two hours today with C (admittedly not very long), during that time I was thinking about how confusing it is in comparison to C++, like the differences between cin and scanf.
I'm partial to C++, but I really like Xcode/the OS in general even though making applications is based around Objective C. With toolkits like wxWidgets it looks like my concerns aren't anything I should be worrying about, but I just want to run it by you guys first.
I don't really have a platform in mind that I want to code for (Windows, OS X, Linux), I just like C++ and I like OS X but they don't play well together.
Sorry, you need to Log In to post a reply to this thread.