• What do you need help with? V. 3.0
    4,884 replies, posted
[code] protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); device = graphics.GraphicsDevice; backgroundTexture = Content.Load<Texture2D>("background"); foregroundTexture = Content.Load<Texture2D>("foreground"); screenWidth = device.PresentationParameters.BackBufferWidth; screenHeight = device.PresentationParameters.BackBufferHeight; } [/code] That's the loadContent code the tutorial tells you to use by the end of this section. Obviously this code won't work with whatever content project was given to me.
-snip- Fixed it by using this: [code]System.Diagnostics.Process.Start("http://googe.com");[/code]
[QUOTE=HyyperVyyper;30992744][code] protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); device = graphics.GraphicsDevice; backgroundTexture = Content.Load<Texture2D>("background"); foregroundTexture = Content.Load<Texture2D>("foreground"); screenWidth = device.PresentationParameters.BackBufferWidth; screenHeight = device.PresentationParameters.BackBufferHeight; } [/code] That's the loadContent code the tutorial tells you to use by the end of this section. Obviously this code won't work with whatever content project was given to me.[/QUOTE] What error do you get?
[QUOTE=Dj-J3;30993193]What error do you get?[/QUOTE] On the first Content.Load I get: ContentLoadException unhandled. Error loading "background". File not found. I'm not sure but I think I have a vague memory of having a "Content" project under a XML solution, but I'm not sure. Something tells me my IDE's settings might have changed to mess this all up, but I can't find any options anywhere to fix this, or add a content project to my IDE. Having no knowledge of XNA isn't helping either.
[QUOTE=HyyperVyyper;30993400]On the first Content.Load I get: ContentLoadException unhandled. Error loading "background." File not found. I'm not sure but I think I have a vague memory of having a "Content" project under a XML solution, but I'm not sure. Something tells me my IDE's settings might have changed to mess this all up, but I can't find any options anywhere to fix this, or add a content project to my IDE. Having no knowledge of XNA isn't helping either.[/QUOTE] Make sure Content.Root = "Content" and is that error a direct copy paste? Because that '.' shouldn't be in "background."
Can anybody explain what is wrong with my program? [cpp]#include <iostream> #include <cstdlib> class CYear { int x, y; public: void age2(int a,int b); int answer () { return (x-y); }; } void age2(int a,int b) { int x,y; x = a; y = b; } int main() { int year,year2; CYear person; std::cout << "Enter the current year:____\b\b\b\b"; std::cin >> year; std::cout << "Enter the year you were born:____\b\b\b\b"; std::cin >> year2; person.age2 (year, year2); std::cout << "You are approxx. " << person.answer() << " years old."; std::cin.ignore(); std::cin.get(); } [/cpp] I keep getting the errors: 21|error: new types may not be defined in a return type| 21|error: two or more data types in declaration of `age2'|
age2 needs to be within the declaration of CYear (because its a function that is part of the class, accessing its member variables), and the semicolon needs to be at the end of the class declaration, not at the end of answer
[QUOTE=Icedshot;30993776]age2 needs to be within the declaration of CYear (because its a function that is part of the class, accessing its member variables), and the semicolon needs to be at the end of the class declaration, not at the end of answer[/QUOTE] Thanks, bro.
[QUOTE=NorthernGate;30993599]Make sure Content.Root = "Content" and is that error a direct copy paste? Because that '.' shouldn't be in "background."[/QUOTE] Well I tried including a Content.RootDirectory = "Content" line under the game initialization, but it didn't do anything.
Herm. Have you tried reapplying the code to a new XNA project, just to double check your IDE settings?
-balls-
What is the C library for linked lists? It's hard to google for it because I keep finding unrelated topics. Alternatively, I just need some sort of simple library for working with dynamics arrays. Adding and deleting entries from arbitrary indices, sorting, etc.
C itself doesn't provide things like that, but [url=http://developer.gnome.org/glib/stable/]GLib[/url] is quite useful in that regard. (Note, it's on the GNOME site because it's a foundation layer of GTK, but it doesn't actually depend on GTK or GNOME. I've used it to write a daemon, which has no UI at all.)
[QUOTE=NorthernGate;30994941]Herm. Have you tried reapplying the code to a new XNA project, just to double check your IDE settings?[/QUOTE] Suppose I'll give this a shot. But seriously does anybody know why I don't get the same content project as the tutorial?
How would I go about writing a preprocesser for C#. Something like one used for C and C++
[QUOTE=Vbits;31002606]How would I go about writing a preprocesser for C#. Something like one used for C and C++[/QUOTE] You can't make macros in C#, but you can make simple defines: #define Something #if Something //code #else //other code #endif
[QUOTE=ief014;31002715]You can't make macros in C#, but you can make simple defines: #define Something #if Something //code #else //other code #endif[/QUOTE] Yes i know, I have used that before, what I am wanting to write is a custom one based on # directives
[cpp]#include <iostream> #include <cstdlib> class CYear { int x, y; public: void age2(int a,int b); int answer () { return (x-y); } void age2(int a,int b) { int x,y; x = a; y = b; } }; int main() { int year,year2; CYear person; std::cout << "Enter the current year:____\b\b\b\b"; std::cin >> year; std::cout << "Enter the year you were born:____\b\b\b\b"; std::cin >> year2; person.age2(year, year2); std::cout << "You are approxx. " << person.answer() << " years old."; std::cin.ignore(); std::cin.get(); } [/cpp] Okay I need someone to explain something else, at line 20 its gives me the error 20|error: `void CYear::age2(int, int)' and `void CYear::age2(int, int)' cannot be overloaded|.
[QUOTE=Vbits;31003126]Yes i know, I have used that before, what I am wanting to write is a custom one based on # directives[/QUOTE] I'm not even sure if that's supported under the default msbuild... you could write a program that launches as a pre-build event and applies the preprocessor changes to the files you want to compile (you'll have to also tell it to compile in a different way). This is the closest thing I could find via Google, hope it helps: [url]http://msdn.microsoft.com/en-us/library/ee265439(v=bts.10).aspx[/url]
[QUOTE=robmaister12;31003524]I'm not even sure if that's supported under the default msbuild... you could write a program that launches as a pre-build event and applies the preprocessor changes to the files you want to compile (you'll have to also tell it to compile in a different way). This is the closest thing I could find via Google, hope it helps: [URL="http://msdn.microsoft.com/en-us/library/ee265439%28v=bts.10%29.aspx"]http://msdn.microsoft.com/en-us/library/ee265439(v=bts.10).aspx[/URL][/QUOTE] Firstly the restrictions of msbuild are unimportant here, the project this is for is to inline build directives like other libarys and a couple other things. Also that page is for Biztalk
[QUOTE=Vbits;31002606]How would I go about writing a preprocesser for C#. Something like one used for C and C++[/QUOTE] You could use [url=http://en.nothingisreal.com/wiki/GPP]gpp[/url] and do it like gpp -ofile.cs file.cspp and then compile file.cs like you're used to. If you really want to create your own, just read the file, write it straight back out until you find one of your commands, in which case to something special.
[QUOTE=Vbits;31003927]Firstly the restrictions of msbuild are unimportant here, the project this is for is to inline build directives like other libarys and a couple other things. Also that page is for Biztalk[/QUOTE] [url=http://msdn.microsoft.com/en-us/library/ed8yd1ha(v=VS.100).aspx]"Although the compiler does not have a separate preprocessor, the directives described in this section are processed as if there were one."[/url] So either go with my first idea (which ZeekyHBomb seems to have explained a lot better), or hack a separate preprocessor into csc.exe or something like that.
[QUOTE=Exosel;31003162] Okay I need someone to explain something else, at line 20 its gives me the error 20|error: `void CYear::age2(int, int)' and `void CYear::age2(int, int)' cannot be overloaded|.[/QUOTE] Maybe try changing the void to something else? I do not know much of function types, but I though void didn't return values. Or put void(int a, int b); after void(int a, int b) { //code }
[QUOTE=Exosel;31003162][cpp]#include <iostream> #include <cstdlib> class CYear { int x, y; public: void age2(int a,int b); int answer () { return (x-y); } void age2(int a,int b) { int x,y; x = a; y = b; } }; int main() { int year,year2; CYear person; std::cout << "Enter the current year:____\b\b\b\b"; std::cin >> year; std::cout << "Enter the year you were born:____\b\b\b\b"; std::cin >> year2; person.age2(year, year2); std::cout << "You are approxx. " << person.answer() << " years old."; std::cin.ignore(); std::cin.get(); } [/cpp] Okay I need someone to explain something else, at line 20 its gives me the error 20|error: `void CYear::age2(int, int)' and `void CYear::age2(int, int)' cannot be overloaded|.[/QUOTE] The forward declaration "void age2(int a,int b);" is unnecessary and seems like it could be causing that error. You also declare ints x and y inside the other age2 function. They're not needed and they probably override the class members x and y inside the function scope. [editline]9th July 2011[/editline] Also your indentation is a fucking mess. [editline]9th July 2011[/editline] Also "approximately" is never spelled with two x's.
It's the kind of coding style you'd use if you thought the Illuminati were reading your brainwaves.
Is it better to do: [code] class Class { int mem1, mem2; int function(int a, int b) { blaaaarghh... } } [/code] or [code] class Class { int mem1, mem2; } int Class::function(int a, int b) { blaaaarghh.. } [/code] [editline]9th July 2011[/editline] Shit.. nevermind
[QUOTE=Armandur;31010662]Is it better to do: [code] class Class { int mem1, mem2; int function(int a, int b) { blaaaarghh... } } [/code] or [code] class Class { int mem1, mem2; } int Class::function(int a, int b) { blaaaarghh.. } [/code] [editline]9th July 2011[/editline] Shit.. nevermind[/QUOTE] If you want it to be in one file, I suggest the first. But classes are often split up so definition and declaration are in separate files.
[QUOTE=sim642;31011419]If you want it to be in one file, I suggest the first. But classes are often split up so definition and declaration are in separate files.[/QUOTE] It's worth noting that doing this can give you quite a few advantages, some notable ones being it's generally an easier way to manage everything, you can quite easily see the interface of a class just by looking at the forward declarations and it also can help to increase compile times. The second method is definitely promoted and preferred.
I have a tile map. I can draw it on the screen based on an X and Y on the actual screen. Then I have the player X and Y. I want to draw the tile map clamped to the bounds of the screen(so you see no void, so to speak) I want the player to be at the center of the screen, but when the bounds are hit, I want the player to be able to "roam around" in the area from the center to the edge of the tile map. I keep trying to get this but I keep failing V:v:V This is what I'm doing and failing: [code] double mapx=MathUtil.clamp(plyx,0,mapw); double mapy=MathUtil.clamp(plyy,0,maph); [/code] just to give you a sense of the variables I'm using [editline]10th July 2011[/editline] Let me rephrase that kinda: I want to be able to translate local coordinates(based off the maps position) and transfer them to physical screen coordinates. That part won't be that hard I presume, only a few subtracts.
This is a more mathematical question, but how would I calculate the rotation of a player so that it is always pointing at where the mouse is?
Sorry, you need to Log In to post a reply to this thread.