• What do you need help with? Version 1
    5,001 replies, posted
[QUOTE=Matthew0505;25738745]This'll seem like a strange question, but what's the fastest way to divide unsigned 8-bit numbers? Assuming that add/subtract, multiply, shifts and inequality (<, >, != etc) are already defined.[/QUOTE] Integer or floating-point division?
This looks like a pretty good algorithm, but I'm not sure: [url]http://www.convict.lu/Jeunes/Math/Fast_operations2.htm[/url]
I am at a loss of what to make this weekend, I have already made a basic web-server and synced command running app.
[QUOTE=Matthew0505;25738745]This'll seem like a strange question, but what's the fastest way to divide unsigned 8-bit numbers? Assuming that add/subtract, multiply, shifts and inequality (<, >, != etc) are already defined.[/QUOTE] If the divisor (D) is a power of two, the fastest way is N >> log(2, D)
[QUOTE=Matthew0505;25739147]Does that example apply to any division of integers, or just those 2 numbers?[/QUOTE] are you serious
[QUOTE=Matthew0505;25740149] There seems to be some kind of iteration in the example, but it doesn't specify the conditions [/QUOTE] The conditions are specified. It's a simple algorithm, although there are some mistakes and confusing grammar. rotate divisor and base_index until the most significant bit of numerator equals the most significant bit of divisor A: subtract divisor from numerator --if difference is negative, rotate divisor and base_index one digit to the right --if difference is positive, goto B goto A B: let numerator = difference C: add base_index to result rotate divisor and base_index one digit to the right subtract divisor from numerator --if difference is negative, END --if difference is positive, goto C
Ignore this, I am late do to thinking an old page was the current one
I believe the question is about doing integer division without a division operator available only only the named operators - also only available for integer arithmetics. Besides, the multiplying by the inverse still requires the division operator (x * (1 / y)).
I'm looking for a way to have a console window be created along with my usual DirectX Screen, to be used as a debug console. Any ideas? [editline]1st November 2010[/editline] In C++ [editline]1st November 2010[/editline] In C++
[QUOTE=wolfalt;25790225]I'm looking for a way to have a console window be created along with my usual DirectX Screen, to be used as a debug console. Any ideas? [editline]1st November 2010[/editline] In C++ [editline]1st November 2010[/editline] In C++[/QUOTE] I'm pretty sure one will be created if you try to std::cout something? [editline]1st November 2010[/editline] Okay. So I have a Game class: [code] #ifndef _CGAME_H_INC #define _CGAME_H_INC #include "globals.h" #include "cCharacter.h" #include "cRoom.h" class cEmote; class cGame { public: int init(); int run(); int halt(); // OTHER IRRELEVANT STUFF HERE std::vector<cRoom> rooms; std::vector<cEmote> emotes; cCharacter *pCurrent_Character; private: protected: }; #endif //_CGAME_H_INC [/code] And in run() I try to do this: [code] testzone.set_Name("Lair of the Debugger"); testzone.set_Desc("All you'd ever need to find and kill bugs is in this room."); testzone.add_Item(flyswat); testzone.add_Item(mosquitonet); testzone.add_Item(bugspray); testzone.add_NPC(character); testzone.add_NPC(debugger); testzone.add_NPC(magictable); try { rooms.push_back(testzone); } catch (std::length_error& le) { std::cerr << "Length error: " << le.what() << std::endl; std::stringstream temp; temp << "rooms.size() = " << rooms.size() << std::endl << "rooms.max_size() = " << rooms.max_size() << "rooms.capacity() = " << rooms.capacity(); mainLog.log(temp.str()); } [/code] That catch block is called every time and mainLog.log gives this: [code] rooms.size() = 4294949122 rooms.max_size() = 17318416 rooms.capacity() = 4294949122 [/code] ...Yeah. This causes it to crash as soon as it tries to access rooms[0]. But if I try to push_back an emote to the emotes vector, that works fine. Halp? :v: Edit: cRoom.h is this, by the way: [code] #ifndef _CROOM_H_INC #define _CROOM_H_INC #include "globals.h" #include "cItem.h" #include "cCharacter.h" class cCharacter; class cRoom : public cEntity { public: cRoom(); std::string tele_password; std::vector<cItem> items; std::vector<cCharacter> npcs; void add_Item(cItem toAdd); void add_NPC(cCharacter toAdd); bool echo; bool dark; private: protected: }; #endif //_CROOM_H_INC [/code] Edit 2: It's probably important to note that this only happens in release builds. Debug builds run this code perfectly. :psyduck:
This might help: [url]http://msdn.microsoft.com/en-us/library/fsk896zz.aspx[/url] If you're using GCC, just add "-g -O2" to your compiler and linker flags :)
[QUOTE=wolfalt;25790225]I'm looking for a way to have a console window be created along with my usual DirectX Screen, to be used as a debug console. Any ideas? [editline]1st November 2010[/editline] In C++ [editline]1st November 2010[/editline] In C++[/QUOTE] [url=http://msdn.microsoft.com/en-us/library/ms681944(VS.85).aspx]AllocConsole[/url]
Or make a console project and create a window.
Hey, stupid c++ newbie question incoming, I am just starting to learn c++, I don't quite understand how to set up classes with header files and the like, say I have 3 files, the main program, the header file for a class and the cpp file with the class methods defined. for example: main.cpp [code] #include <iostream> int main() { //stuff } [/code] foo.h [code] class Foo { public: Foo(void); ~Foo(void); void DoStuff(void); }; [/code] Foo.cpp [code] Foo::Foo(void) { //stuff } Foo::~Foo(void) { //stuff } void Foo::DoStff(void) { //stuff } [/code] were do the #include "foo.h" and "foo.cpp" go in each of these files so that I can use the foo class in the main.cpp?
You have to include foo.h in Foo.cpp and main.cpp, that's all. You never include a .cpp file.
[QUOTE=Overv;25805250]You have to include foo.h in Foo.cpp and main.cpp, that's all. You never include a .cpp file.[/QUOTE] Ah, that's were I was going wrong, cheers.
[QUOTE=Liquid Helium;25805276]Ah, that's were I was going wrong, cheers.[/QUOTE] If you want more info as to why, it's because every .cpp file is its own "translation unit", which means they are all compiled separately and then linked together.
[QUOTE=ZeekyHBomb;25791867][url=http://msdn.microsoft.com/en-us/library/ms681944(VS.85).aspx]AllocConsole[/url][/QUOTE] Thanks.
In actionscript 3, how would I go about making it that when I click a picture, it gets bigger and centered on the screen, and when i click it again, it goes back to normal
Ok, so let's say I have a simple tile-based map going on, stored in a 2D array. Drawing it would be something like [code]For each tile in X dimension of map For each tile in Y dimension of map Draw square at X * TileSize, Y * TileSize, taking the graphics from Map[X, Y][/code] Now say I add a camera system like so: [code]Declare CamX and CamY For each tile in X dimension of map For each tile in Y dimension of map Draw square at X * TileSize, Y * TileSize, taking the graphics from Map[X + CamX, Y CamY][/code] Of course, that results in scrolling by one whole tile per increment/decrement of CamX and CamY. How best would I go about implementing smooth scrolling?
I have a feeling this is a really dumb question but I'm going to ask it anyway. I have this code, [code] D3DXMATRIX Scale, Rotation, Matrix, Position; D3DXMatrixRotationY(&Rotation, 0); D3DXMatrixRotationX(&Rotation, 0); D3DXMatrixRotationZ(&Rotation, 0); D3DXMatrixScaling( &Scale, 1.0f, 1.0f, 1.0f ); Matrix = Scale * Rotation; d3ddev->SetTransform(D3DTS_WORLD, &(Matrix)); // set the world transform [/code] I'm confused as to how I apply these matrices to one single model or object. At the moment they just appear to effect everything on the screen.
You set the world matrix, then render a model with that. Then for the next model you set a different world matrix before rendering that.
[QUOTE=yngndrw;25834250]You set the world matrix, then render a model with that. Then for the next model you set a different world matrix before rendering that.[/QUOTE] I shall give it a try now, thanks very much.
I'm not sure if this is where I should post this but a few of us hosting Minecraft servers need help with a batch file to increase the available memory for Java. According to the Minecraft forums, the following command should increase the range of available memory to a minimum of 1GB available with a max of 4GB available. [code]java -Xms1024M -Xmx4096M -jar minecraft_server.jar[/code] When we run a batch file with that command though, we get an error like this: [IMG]http://img837.imageshack.us/img837/6607/minecraftserverbatch.png[/IMG] Does anyone know what we need to differently? Any help would be extremely appreciated.
[QUOTE=Onyx3173;25835505]I'm not sure if this is where I should post this but a few of us hosting Minecraft servers need help with a batch file to increase the available memory for Java. According to the Minecraft forums, the following command should increase the range of available memory to a minimum of 1GB available with a max of 4GB available. [code]java -Xms1024M -Xmx4096M -jar minecraft_server.jar[/code] When we run a batch file with that command though, we get an error like this: [img_thumb]http://img837.imageshack.us/img837/6607/minecraftserverbatch.png[/img_thumb] Does anyone know what we need to differently? Any help would be extremely appreciated.[/QUOTE] Looks like you haven't installed the Java SDK. [url]http://www.oracle.com/technetwork/java/index.html[/url]
[QUOTE=Veid;25835775]Looks like you haven't installed the Java SDK. [URL]http://www.oracle.com/technetwork/java/index.html[/URL][/QUOTE] So after installing the SDK, the batch file should work fine then? [editline]a[/editline] That seems to have worked just fine actually. Thank you from all of us Minecraft server hosters!
[QUOTE=Chris220;25833455]Ok, so let's say I have a simple tile-based map going on, stored in a 2D array. Drawing it would be something like [code]For each tile in X dimension of map For each tile in Y dimension of map Draw square at X * TileSize, Y * TileSize, taking the graphics from Map[X, Y][/code] Now say I add a camera system like so: [code]Declare CamX and CamY For each tile in X dimension of map For each tile in Y dimension of map Draw square at X * TileSize, Y * TileSize, taking the graphics from Map[X + CamX, Y CamY][/code] Of course, that results in scrolling by one whole tile per increment/decrement of CamX and CamY. How best would I go about implementing smooth scrolling?[/QUOTE] I also am interested in this.
Hey guys, I am working on my Computing project for my A-Level. It is basically a program made in VB.net which gives a slideshow on recursion and then goes on to a multiple choice quiz of which the users result is stored in a database alongside there account details. I have been having a nightmare trying to get a fading animation on the panel which holds the slide so I can have cool transitions between slides, but I just can't seem to figure out a way to do it and really my programming knowledge is limited to VB.net. Here is the current sub-procedure code I have for the 'wiping' slide animation I have at the moment. [code] If HeightReached = False Then TutorialPanel.Height = TutorialPanel.Height - 8 If TutorialPanel.Height = 0 Then HeightReached = True End If End If If HeightReached = True Then If TutorialPanel.Height >= 488 Then SlideWiper.Dispose() TutorialPanel.Height = TutorialPanel.Height + 4 Else TutorialPanel.Height = TutorialPanel.Height + 8 If SlideCheckerValidated = False Then Call SlideChecker() SlideCheckerValidated = True End If End If End If Label1.Text = TutorialPanel.Height [/code] As you can see it basically just reduces and increase the height of TutorialPanel to give a wiping effect, this is sub is triggered on the ticking of my timer, I really want a fade in and out transition however, any idea how I would go about doing this? I have tried overlaying a form and using opacity property already however it produced really glitchy and generally ugly results so that is pretty much out of the question.
[QUOTE=Onyx3173;25835914]So after installing the SDK, the batch file should work fine then? [editline]a[/editline] That seems to have worked just fine actually. Thank you from all of us Minecraft server hosters![/QUOTE] You'll need to install the SDK and then you'll probably have to set up the PATH variable if you want the command to run globally. You can go here: [url]http://www.apl.jhu.edu/~hall/java/beginner/settingup.html[/url] and check out the portion on setting your PATH. Edit: Didn't notice your edit, no problem.
[QUOTE=Chris220;25833455]Ok, so let's say I have a simple tile-based map going on, stored in a 2D array. Drawing it would be something like [code]For each tile in X dimension of map For each tile in Y dimension of map Draw square at X * TileSize, Y * TileSize, taking the graphics from Map[X, Y][/code] Now say I add a camera system like so: [code]Declare CamX and CamY For each tile in X dimension of map For each tile in Y dimension of map Draw square at X * TileSize, Y * TileSize, taking the graphics from Map[X + CamX, Y CamY][/code] Of course, that results in scrolling by one whole tile per increment/decrement of CamX and CamY. How best would I go about implementing smooth scrolling?[/QUOTE] [code]If CamX > OldCamX OldCamX += StepSize Else If CamX < OldCamX OldCamX -= StepSize Else OldCamX = CamX (same with Y) ... Draw square at x * TileSize + (CamX - OldCamX), Y * TileSize + (CamY - OldCamY), taking the graphics from Map[X + CamX, Y + CamY][/code] Something like this I think. [QUOTE=Veid;25835775]Looks like you haven't installed the Java SDK. [url]http://www.oracle.com/technetwork/java/index.html[/url][/QUOTE] Shouldn't installing the Java Runtime Environment not be enough?
Sorry, you need to Log In to post a reply to this thread.