• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=Cam00;38778515]I'm getting an error while using if statements; [code] if (x>=z); { if (x>=y); { count1++; } else { count2++; } } [/code] it says: error C2181: illegal else without matching if[/QUOTE] Remove the semi colons at the end of the lines with the if statement.
[QUOTE=Cam00;38778515]I'm getting an error while using if statements; [code] if (x>=z); { if (x>=y); { count1++; } else { count2++; } } [/code] it says: error C2181: illegal else without matching if[/QUOTE] Not sure what language you are using but in c# and java it's this: [code] if (x>=z) { if (x>=y) { count1++; } else { count2++; } } [/code] Don't put a ';' after the if statement. ... Damm ninjas
Now I've ran into another issue, getting an error at this line [code] while (arr[count] != "/0") [/code] error C2446: '!=' : no conversion from 'const char *' to 'int' How do I get around this? The loop needs to continue until the end of the array is reached, and /0 is the final char.
[QUOTE=Cam00;38778732]Now I've ran into another issue, getting an error at this line [code] while (arr[count] != "/0") [/code] error C2446: '!=' : no conversion from 'const char *' to 'int' How do I get around this? The loop needs to continue until the end of the array is reached, and /0 is the final char.[/QUOTE] /0 is a number, \0 is the escaped NUL character.
Also "/0" is a string literal, You want '\0' (notice the single quotes instead of double quotes).
[QUOTE=MakeR;38778827]Also "/0" is a string literal, You want '\0' (notice the single quotes instead of double quotes).[/QUOTE] What's the difference? This is basic C btw, forgot to mention that.
[QUOTE=Cam00;38778843]What's the difference? This is basic C btw, forgot to mention that.[/QUOTE] In C, 'a' is a single character and "a" is a string of characters (an array containing 'a' and '\0').
Sorted
[QUOTE=ThePuska;38774021]Well besides being scaled by two compared to the original integers the world axes may be different from what you're using so you shouldn't expect them to match. The distance function should work regardless. edit: No it doesn't actually work, sorry about that. But the idea is solid: Using your transformation, convert the grid coordinates to basically screen coordinates. Then project the coordinates onto the world axes, and calculate the distance along those axes[/QUOTE] Can you explain the math behind this? At least the U and V (the dotu and dotv are dot products right?) And is there any way to make the values all be positive apart from getting the min and adding it to all y values? I also got it to work, thanks for the help. From my understanding U and V are both vectors, U point down and right and V pointing up and right, and they signify the change of the tiles. This is done with a dot product of the tile.
[QUOTE=Funley;38763764]With C#'s XmlNode, how can i retrieve the values of "type" and "position" thingies in the following? [code] <Entity type="tree" position="10;10"></Entity> [/code] [editline]asd[/editline] Got it! XmlNode.Attributes contain all the thingies of the node.[/QUOTE] That's because the "thingies" are called attributes
-fixed it-
I don't know if I should make a thread on this (It will probably start a programmers fan-boy war, perhaps) I am having mixed feelings so please help me out. A lot of people are suggesting that C# is somewhat better than C++, I am currently teaching myself C++, but with all these people on forums, in real life etc I don't know if I should continue C++ or switch over before its too late. To be honest I'll be making pretty basic games, simple calculators and randomized environments. Physics engines. So option A is to continue C++ Option B is to switch to C# Option C is to continue C++ but switch over later to C# if I (personally) feel it'd be a better option, Id rather not waste my time going down the road of C++ only to find it is an inadequet, insuperior programming language and have to roll back all those (somewhat but not entirely) wasted weeks/months learning the language. Now this of course opens discussion that C++ and C# go together like peanut butter and jam so it does not matter which I learn, they are more or less the same (I'm not that much of a programmer so I don't really know) If anyone actually cared to read any of this I'd appreciate any and all responses :) Cheers
Can anyone recommend me a 3D drawing framework using either Python, Lua or Javascript that works with the Raspberry Pi?
[QUOTE=Darkwater124;38788023]Can anyone recommend me a 3D drawing framework using either Python, Lua or Javascript that works with the Raspberry Pi?[/QUOTE] Python -> [url]http://www.pygame.org/[/url] Javascript -> [url]http://unity3d.com/[/url]
[QUOTE=Mega1mpact;38788474]Javascript -> [url]http://unity3d.com/[/url][/QUOTE] [img]http://puu.sh/1zMH1[/img] ? And can you give me a good PyGame tutorial for 3d then? AFAIK it's meant for 2d and not 3d.
For some reason the blinking cursor that appears when you click text to edit it (What is that thing called, anyway?) isn't appearing in visual studio anymore, even after a system/program restart. Also, I can no longer highlight text. Does anyone know what could cause this? It's making things much more difficult to work with.
[QUOTE=Mettrone;38787099]I don't know if I should make a thread on this (It will probably start a programmers fan-boy war, perhaps) I am having mixed feelings so please help me out. A lot of people are suggesting that C# is somewhat better than C++, I am currently teaching myself C++, but with all these people on forums, in real life etc I don't know if I should continue C++ or switch over before its too late. To be honest I'll be making pretty basic games, simple calculators and randomized environments. Physics engines. So option A is to continue C++ Option B is to switch to C# Option C is to continue C++ but switch over later to C# if I (personally) feel it'd be a better option, Id rather not waste my time going down the road of C++ only to find it is an inadequet, insuperior programming language and have to roll back all those (somewhat but not entirely) wasted weeks/months learning the language. Now this of course opens discussion that C++ and C# go together like peanut butter and jam so it does not matter which I learn, they are more or less the same (I'm not that much of a programmer so I don't really know) If anyone actually cared to read any of this I'd appreciate any and all responses :) Cheers[/QUOTE] Hey, I would Always tell people to use c# for nearly any project. But don't think you won't need the other languages too. I use c# as my main language because you can develop so blazingly fast with it but I also know c++ and (f)asm. In my opinion the knowledge about those low level languages (fasm obviously more than c++ :P) Really helps with c#. You can optimize your code better because you know about stuff like caching and other lower level stuff. Tldr: do not only learn c# and c++ but also a little assembler
[QUOTE=phygon;38790659]For some reason the blinking cursor that appears when you click text to edit it (What is that thing called, anyway?) isn't appearing in visual studio anymore, even after a system/program restart. Also, I can no longer highlight text. Does anyone know what could cause this? It's making things much more difficult to work with.[/QUOTE] The [url=http://en.wikipedia.org/wiki/Caret_browsing]caret[/url]
Which configuration library do you recommed for .net? I need one that can (de)serialize and supports arrays... I'm tired of typing all these xml nowadays.
So, I'm learning basic Javascript on codeacademy and I can't get this to work. [CODE]//Check if the user is ready to play confirm("Are you ready to play?") var age = prompt("What's your age?"); if (var age < 18) { console.log("You are not old enough!") } console.log("Snow White and Batman were hanging out at the bus stop, waiting to go to the shops. There was a sale on and both needed some new threads. You've never really liked Batman. You walk up to him. ") console.log("Batman glares at you.") { var userAnswer = prompt("Are you feeling lucky, punk?") }[/CODE] It tells me that I didn't create the variable "userAnswer"
Remove the "{}" before and after "var userAnswer"
Does anyone know anything about getting HL2MP vanilla mod base to work properly? I have it all compiling, but on loading a map i get a garbage crash and assembler in my face. If anyone thinks they would be able to help, let me know and ill post dumps/call stack and other details.
What values for ux, uy, vx, vy do I need to reverse this operation? [code] int ux = 1; int uy = 1; int vx = 1; int vy = -1; int dotu = ux * xt + uy * yt; int dotv = vx * xt + vy * yt;[/code]
I need to create characters on a tilemap with individual tiles, looking similar to this font: [url]http://www.dafont.com/led-display7.font[/url] What would be the best way to go about this that isn't individually configuring what each character maps to, unless that really is the best way?
When dealing with UV mapping, what is a good way to determine the coordinates of the UV map of a texture? Also, how do I not clutter up my main function with those coordinates?
[QUOTE=Meatpuppet;38794652]When dealing with UV mapping, what is a good way to determine the coordinates of the UV map of a texture? Also, how do I not clutter up my main function with those coordinates?[/QUOTE] Typically bottom left is (0, 0) and top right is (1, 1). Anything beyond those ranges are determined by parameters you set for individual textures (basically just repeat or clamp)
[QUOTE=robmaister12;38795026]Typically bottom left is (0, 0) and top right is (1, 1). Anything beyond those ranges are determined by parameters you set for individual textures (basically just repeat or clamp)[/QUOTE] I realize how UV mapping works, just not how the actual coordinates are printed out. I'm looking here: [url]http://www.opengl-tutorial.org/beginners-tutorials/tutorial-5-a-textured-cube/[/url] At the part where he defines the uv buffer data. How do I determine that?
[QUOTE=Meatpuppet;38795046]I realize how UV mapping works, just not how the actual coordinates are printed out. I'm looking here: [url]http://www.opengl-tutorial.org/beginners-tutorials/tutorial-5-a-textured-cube/[/url] At the part where he defines the uv buffer data. How do I determine that?[/QUOTE] You just map each vertex onto the part of the texture that you want. For example, if you wanted a square to display the top left 1/3 of the texture, your UV coords will be (counter-clockwise starting from the top left): [code] 0, 1, 0, 0.6667, 0.6667, 0.6667, 0.6667, 1 [/code] If you want specific pixel coordinates, the UV coordinate is just scaling the location of the pixel - pixel_x/width, pixel_y/height
Someone helping me in my thread regarding viewports ran this link by me, which turned out to be very helpful: [url]https://github.com/LaurentGomila/SFML/blob/master/src/SFML/Window/Win32/WindowImplWin32.cpp[/url] I noticed another function in there that I was pretty interested in. It looks to be a clean way to set a standard Windows application's icon, changing it from the default IDI_APPLICATION icon or whatever the hell that nasty looking thing is called. Anyways, here's the code: [code] //////////////////////////////////////////////////////////// void WindowImplWin32::setIcon(unsigned int width, unsigned int height, const Uint8* pixels) { // First destroy the previous one if (m_icon) DestroyIcon(m_icon); // Windows wants BGRA pixels: swap red and blue channels std::vector<Uint8> iconPixels(width * height * 4); for (std::size_t i = 0; i < iconPixels.size() / 4; ++i) { iconPixels[i * 4 + 0] = pixels[i * 4 + 2]; iconPixels[i * 4 + 1] = pixels[i * 4 + 1]; iconPixels[i * 4 + 2] = pixels[i * 4 + 0]; iconPixels[i * 4 + 3] = pixels[i * 4 + 3]; } // Create the icon from the pixel array m_icon = CreateIcon(GetModuleHandle(NULL), width, height, 1, 32, NULL, &iconPixels[0]); // Set it as both big and small icon of the window if (m_icon) { SendMessage(m_handle, WM_SETICON, ICON_BIG, (LPARAM)m_icon); SendMessage(m_handle, WM_SETICON, ICON_SMALL, (LPARAM)m_icon); } else { err() << "Failed to set the window's icon" << std::endl; } } [/code] I understand all the ins and outs of this snippet except the 'const Uint8* pixels' parameter. Given that I have a PNG or BMP or GIF or whatever format image ready to go, is there a function for getting its "pixels" to pass to this function? I've been looking for a solution like this for a while.
[QUOTE=thirty9th;38798534]Someone helping me in my thread regarding viewports ran this link by me, which turned out to be very helpful: [url]https://github.com/LaurentGomila/SFML/blob/master/src/SFML/Window/Win32/WindowImplWin32.cpp[/url] I noticed another function in there that I was pretty interested in. It looks to be a clean way to set a standard Windows application's icon, changing it from the default IDI_APPLICATION icon or whatever the hell that nasty looking thing is called. Anyways, here's the code: [code] //////////////////////////////////////////////////////////// void WindowImplWin32::setIcon(unsigned int width, unsigned int height, const Uint8* pixels) { // First destroy the previous one if (m_icon) DestroyIcon(m_icon); // Windows wants BGRA pixels: swap red and blue channels std::vector<Uint8> iconPixels(width * height * 4); for (std::size_t i = 0; i < iconPixels.size() / 4; ++i) { iconPixels[i * 4 + 0] = pixels[i * 4 + 2]; iconPixels[i * 4 + 1] = pixels[i * 4 + 1]; iconPixels[i * 4 + 2] = pixels[i * 4 + 0]; iconPixels[i * 4 + 3] = pixels[i * 4 + 3]; } // Create the icon from the pixel array m_icon = CreateIcon(GetModuleHandle(NULL), width, height, 1, 32, NULL, &iconPixels[0]); // Set it as both big and small icon of the window if (m_icon) { SendMessage(m_handle, WM_SETICON, ICON_BIG, (LPARAM)m_icon); SendMessage(m_handle, WM_SETICON, ICON_SMALL, (LPARAM)m_icon); } else { err() << "Failed to set the window's icon" << std::endl; } } [/code] I understand all the ins and outs of this snippet except the 'const Uint8* pixels' parameter. Given that I have a PNG or BMP or GIF or whatever format image ready to go, is there a function for getting its "pixels" to pass to this function? I've been looking for a solution like this for a while.[/QUOTE] This topic has a solution on getting pixels from DX textures I think. [url]http://www.gamedev.net/topic/487751-create-a-texture-from-pixel-values/[/url] I'm not sure what else you might need to do to format it to work with CreateIcon (if anything). The icon needs to be a max of 16x16 to fit in the Uint8 I'd guess.
Sorry, you need to Log In to post a reply to this thread.