• What do you need help with? Version 1
    5,001 replies, posted
snip I've spent WAY to much time away from c++, holy shit.
Mr noob needs help again! :) I've started creating get and set methods for most of the variables in my classes but I have come across a problem. No matter how i pass the information into my D3DXVECTOR3 position variable the position of it will never change. Here is my code, [code] #include "GuiObject.h" guiObject::guiObject(void) { } guiObject::guiObject(LPDIRECT3DDEVICE9 d3ddev, const std::string &modelname, D3DXVECTOR3 newPosition) { position = newPosition; D3DXCreateSprite(d3ddev, &d3dspt); // create the Direct3D Sprite object D3DXCreateTextureFromFile(d3ddev, modelname.c_str(), &sprite); } void guiObject::Render() { d3dspt->Begin(NULL); // // begin sprite drawing with transparency d3dspt->Draw(sprite, NULL, &center, &position, D3DCOLOR_XRGB(255, 255, 255)); d3dspt->End(); } D3DXVECTOR3 guiObject::getPosition(void){return position;} D3DXVECTOR3 guiObject::getCenter(void){return center;} void guiObject::setPosition(D3DXVECTOR3 newPosition) { position = newPosition; } D3DXVECTOR3 guiObject::setCenter(D3DXVECTOR3 newCenter){return center = newCenter;} guiObject::~guiObject(void) { } [/code] As you can see the newposition is being passed in by the parameters and then its being copied over to position.
Repeating mah question : Could anyone pre compile the luainteface source for me for .net 4.0 ? Source code : [url]http://code.google.com/p/luainterface/[/url]
[QUOTE=bootv2;25873914]I'm programming four in a row in c++. and I can't think of a algorythm that'll check If you've won or not which doesnt involve hard-coding all possible cases of four in a row. Anyone got a suggestion?(I'd like a suggestion on how to do it and not just the code, since I'm really trying to learn this.). Right now it's console based. but when I finished the game engine I'll port it to SFML.[/QUOTE] Store the game as a 2 dimensional array if you aren't already. Then, iterate over each piece and check if it makes a line horizontally, vertically, or angled. If it does, the owner of the piece wins.
is it possible to interpret c++ code in an external file from within c++ at runtime?
[QUOTE=Icedshot;25875078]is it possible to interpret c++ code in an external file from within c++ at runtime?[/QUOTE] [I]Technically[/I] yes and in practise yes – but if and only if you have a suitable runtime library that does this for you. Eg. One [B]can[/B] do it, but you can't do it that easily.
Anyone know how I could go about drawing a four quadrant Cartesian plane? I have the drawing itself down, it's just the math and such i'm not sure on.
[QUOTE=esalaka;25876013][I]Technically[/I] yes and in practise yes – but if and only if you have a suitable runtime library that does this for you. Eg. One [B]can[/B] do it, but you can't do it that easily.[/QUOTE] Thats pretty much what i thought, and seeing as there doesnt seem to be any libs around (that i can find), id have to do it myself. Which is a no
[QUOTE=Icedshot;25877551]Thats pretty much what i thought, and seeing as there doesnt seem to be any libs around (that i can find), id have to do it myself. Which is a no[/QUOTE] There's Ch and I think it's possible via clang and llvm. At least there's a [url=http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/main.cpp?view=markup]c-interpreter example[/url].
[QUOTE=quincy18;25872796]Repeating mah question : Could anyone pre compile the luainteface source for me for .net 4.0 ? Source code : [url]http://code.google.com/p/luainterface/[/url][/QUOTE] [url]http://luaforge.net/frs/download.php/3968/LuaInterface_2.0.3.7z[/url]
[QUOTE=Dj-J3;25878604][url]http://luaforge.net/frs/download.php/3968/LuaInterface_2.0.3.7z[/url][/QUOTE] Yea thats the older version, its not build for net 4.0 getting this error : Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. looked it up and they said just rebuild it against net 4.0 but I have no idea how, really need this for a old game I retrieved from my old hard disk want to continue it.
Anyone got some references on embedding a layout engine in C++ (Win32)? I've looked at Webkit, Gecko, Trident and the documentation/examples for them are horrible.
[QUOTE=ichiman94;25850025]Cosmos MS4 - Visual Studio 2008 System.exception: plug needed. System.Void System.Threading.Thread.Monitor.Enter(System object) god, where do i need to change the code?! [url]http://www.2shared.com/file/bov9pjVt/NOS.html[/url][/QUOTE] please help :smith:
How do i add smooth jumping in LOVE i tried using [code]applyForce(0, -100)[/code] inste ad of the example which makes the player jump to half the screens height in one tick. Please help
What the hell is a "syntax error: identifier *classname*" and what the hell is going on here? [media]http://i.imgur.com/vLGf3.png[/media]
[QUOTE=toaster468;25901106]How do i add smooth jumping in LOVE i tried using [code]applyForce(0, -100)[/code] inste ad of the example which makes the player jump to half the screens height in one tick. Please help[/QUOTE] What Actually Happens when you try that? [QUOTE=Liquid Helium;25904708]What the hell is a "syntax error: identifier *classname*" and what the hell is going on here? [media]http://i.imgur.com/vLGf3.png[/media][/QUOTE] What does the definition of GameObject look like
[QUOTE=Vbits;25904786]What Actually Happens when you try that? What does the definition of GameObject look like[/QUOTE] Actually I think I found the problem, ball.h imports aibat.h and aibat.h imports ball.h. Is there any way around this? edit: other than to just not have one refer to the other.
Well you could use a class prototype, as i recall you can just reopen a class to add more stuff in the header.
[QUOTE=Vbits;25904994]Well you could use a class prototype, as i recall you can just reopen a class to add more stuff in the header.[/QUOTE] I don't understand, your saying have 2 prototypes for one class? and the second just have the method that refers to the other class?
You're creating a "PlayerBat" object, yet you're looking in the "AIBat" source file in the screen shot. Make sure the PlayerBat class has the correct Update parameters.
[QUOTE=yngndrw;25905087]You're creating a "PlayerBat" object, yet you're looking in the "AIBat" source file in the screen shot. Make sure the PlayerBat class has the correct Update parameters.[/QUOTE] What? The error has nothing to do with PlayerBat, it's to do with AIBat.
[QUOTE=Liquid Helium;25904955]Actually I think I found the problem, ball.h imports aibat.h and aibat.h imports ball.h. Is there any way around this?[/QUOTE] Why do they need to refer to each other?
[QUOTE=Liquid Helium;25905033]I don't understand, your saying have 2 prototypes for one class? and the second just have the method that refers to the other class?[/QUOTE] No, you just need to have a empty class definition such as "class Ball;"
[QUOTE=Wyzard;25905161]Why do they need to refer to each other?[/QUOTE] AIBat needs to know what ball is because its update method needs to know were the ball is so it can follow it. Ball needs to know what AIBat is so it can know were that it can detect collisions with it. Of course this is easy to get around, I can just pass in an int for the position and a rect to check for collisions so they don't need to refer to each other, or I could just pass them in as gameobjects. So it really isn't a problem any more, just the error messages threw me off, but it would still be useful to know if there was a way around 2 objects needing to know what each other are for the future I guess. Also sorry if my messages are irreadable, I have been up far too long.
[QUOTE=Liquid Helium;25905147]What? The error has nothing to do with PlayerBat, it's to do with AIBat.[/QUOTE] Sorry, read the wrong line. :( [b]Edit:[/b] [i]AIBat.h[/i] [code]class Ball; class AIBat : public GameObject { void Update( Ball*, /* ...etc */ ); //...etc };[/code] [i]Ball.h[/i] [code]class AIBat; class Ball : public GameObject { void Update( AIBat*, /* ...etc */ ); //...etc };[/code] Don't include the other's header file in the header files, do include the other's header file in the source file. The reason for your odd error message is that you're reading them in the wrong order - Start from the first error in the list and work downwards.
[QUOTE=Liquid Helium;25905255]AIBat needs to know what ball is because its update method needs to know were the ball is so it can follow it. Ball needs to know what AIBat is so it can know were that it can detect collisions with it.[/QUOTE] OK, so you're including ball.h in aibat.h so that the AIBat class can declare its Update() method as taking a Ball parameter? Makes sense. The trick here is to use a forward declaration (as yngndrw posted) and to understand the difference between a class declaration and a class definition. [cpp]class Foo;[/cpp] is a class declaration. Since it doesn't provide any information about the contents of the class, you can't create instances or refer to fields of a class that's only been declared, but you [i]can[/i] form pointers and references to it, because those only need to know that the class exists, not how it's structured. [cpp]class Foo { /*... */ };[/cpp] is a class definition, which you're already familiar with. It implicitly declares the class if it hasn't been declared already, and provides information about its contents so that you can create instances and access fields in it. There's nothing wrong with including one header from another if it's actually needed: if you want class A to actually contain an instance of class B as a member variable, for example, B's definition has to be visibile within A's header. But if all you need are pointers or references to a type, it's a good idea to just declare it rather than including its header: it avoids the risk of unintentional circular dependencies like the one you encountered, and also helps the program compile faster because there's les code to be parsed.
[QUOTE=Sharpshooter;25837006]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] Re-posting to see if anyone has any tips :downs:.
I'm trying to rotate the camera around a specific point in Love2D, but it isn't working as I expected it would. Can anyone shed some insight? [editline]7th November 2010[/editline] Oh and sorry sharpshooter for posting right after you.
You're doing very strange things there. Is there any reason you're not doing this? [cpp]for ( int i = 0; i < 8; i++ ) { for ( int x = 0; x < 6; x++ ) { placeholder[i][x] = 0; } }[/cpp]
[QUOTE=Wyzard;25905665]OK, so you're including ball.h in aibat.h so that the AIBat class can declare its Update() method as taking a Ball parameter? Makes sense. The trick here is to use a forward declaration (as yngndrw posted) and to understand the difference between a class declaration and a class definition. [cpp]class Foo;[/cpp] is a class declaration. Since it doesn't provide any information about the contents of the class, you can't create instances or refer to fields of a class that's only been declared, but you [i]can[/i] form pointers and references to it, because those only need to know that the class exists, not how it's structured. [cpp]class Foo { /*... */ };[/cpp] is a class definition, which you're already familiar with. It implicitly declares the class if it hasn't been declared already, and provides information about its contents so that you can create instances and access fields in it. There's nothing wrong with including one header from another if it's actually needed: if you want class A to actually contain an instance of class B as a member variable, for example, B's definition has to be visibile within A's header. But if all you need are pointers or references to a type, it's a good idea to just declare it rather than including its header: it avoids the risk of unintentional circular dependencies like the one you encountered, and also helps the program compile faster because there's les code to be parsed.[/QUOTE] Ah, Thanks for the help, it's really appreciated.
Sorry, you need to Log In to post a reply to this thread.