All your not-thread-worthy questions here!
Well? What do you need help with?
All your not-thread-worthy questions here!
Well? What do you need help with?
Is the .0 necessary
I like the .0
Repostin' from old thread
I'm going to work on my first XNA game, but first I need some good XNA tutorials. Anybody know of any good ones?
It makes the OP look smarter
http://www.riemers.net/
If i have a get method in C++, what would be the best way to use it
As in how would i return a reference and not a copy?
would it be like:
Class myClass; public Class getMyClass() { return &myClass; }
Class &getMyClass() { return myClass; }
He was making sure the compiler knew it was a double.
-snip-
Could someone give me some pseudocode (or C# if you're feeling generous) that would rotate point at x,y around point at a,b n degrees? I've been hacking at this for a while and any implementation I try wigs out at anything other than 180 degrees.
By rotate around {a,b} you mean simply circle around it?
Yep.
Where does XNA redistributable install to?
Just a little trig.
Simple example with SFML
Code:using System; using SFML; using SFML.Graphics; using SFML.Window; namespace XYABRotation { class Program { static void Main(string[] args) { Program pgm = new Program(); } RenderWindow rw; /// <param name="v">Value in degrees</param> /// <returns>Returns Sin of the degree</returns> static float sind(float v) { return (float)Math.Sin(v / 180d * Math.PI); //Math.Sin uses radians... convert from degrees } /// <param name="v">Value in degrees</param> /// <returns>Returns Cos of the degree</returns> static float cosd(float v) { return (float)Math.Cos(v / 180d * Math.PI); //convert from degrees like Sin() } public Program() { rw = new RenderWindow(new VideoMode(640, 480), "Rotate", Styles.Close, new ContextSettings(24, 8)); rw.Closed += new EventHandler(rw_Closed); Vector2 AB = new Vector2(rw.Width/2, rw.Height/2); Vector2 XY = new Vector2(); //this point will rotate around AB float degrees = 0.0f; float distance = 40.0f; //XY will be 40 pixels in distance from AB while (rw.IsOpened()) { rw.DispatchEvents(); XY.X = sind(degrees) * distance + AB.X; XY.Y = cosd(degrees) * distance + AB.Y; degrees += 0.05f; rw.Clear(); rw.Draw(Shape.Circle(AB, 5f, Color.Red)); rw.Draw(Shape.Circle(XY, 5f, Color.Green)); rw.Display(); } } void rw_Closed(object sender, EventArgs e) { rw.Close(); } } }
Edit
I just realized it should be "//Math.Sin uses radians... convert from degrees", not "to"
Thanks! That worked.
C:\Program Files (x86)\Microsoft XNA
?
Im very new to C# and have a quick question.
Why would you use a random class (rand thingie) when you can use randomizer.Next
I really don't understand the whole random class thing truthfully.
Example?
Random class lets you use a specific seed, so you can have a repeatable sequence of numbers.
For instance, if you were randomly generating terrain, you could save the seed and regenerate the terrain each time it is loaded, saving tons of space for the save file.
Thanks both of ya, ended up figuring it out and now have a new quick question.
I have a really simple console program I'm working with here. I wanted to it randomly generated numbers until it hit 119 at which point it would output a message.
However upon going to A: it waits for the user to input something/ press enter. Anyway to make it automatically continue?Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int chance; Random rand; rand = new Random(); A:chance = rand.Next(5, 200); Console.WriteLine(chance); Console.ReadLine(); if (chance == 119) { Console.WriteLine("Boom, 119 oh yah"); Console.ReadLine(); } else { goto A; } } } }
Don't use Console.ReadLine()? Lol.
What did you think it would do?
don't use goto
Oh fuck. You are right. This all makes sense now. I was confused about Console.ReadLine from the start. Now it makes sense, its reading the user input line becuase it is blank?
Haha set the program to the same odds of winning the jackpot of the mega millions lottery. This should be fun.
Indeed. ReadLine just waits until you type something and press enter.
Goto isn't just pure evil, you know. I mean it clearly isn't the best option in this case, but it annoys me when people go "Language construct X, Y and Z should never, ever be used just because."
I have a problem with my python script, any idea why this isn't printing the last line?
the last line, you kept the creation, doesn't print in any situation.Code:print("hello and welcome to my test game") print("defining food... Done") fruit = 'apple ' meat = 'beef ' cheese = 'cheddar ' vegetable = 'asparagus' print ('Combining Foods...') print fruit + meat print fruit + cheese print fruit + vegetable print fruit + fruit print('Done!') creation = raw_input('What do you want to create? ') print "creating", creation print "would you like to store the", creation, "?" print "to store the pie, type one. to throw away the", creation, "type 2." decision = input("What do you want to do? ") if decision == 1: creation = "you have created nothing." else: print "you kept the", creation
in most cases, goto is not necessary and makes the code hard to follow
I'm not big on Python, but hopefully this will help.
The input() method is used for taking in python expressions, not flat user input. Even with raw_input(), though, you're not going to get a numeric value for what the user types in; raw_input() only returns a string. You'll either have to convert whatever the result is into a number with int() and check that, or compare the string directly, i.e. use 'if decision == "1"'
I want to make a jumping system for my game, and I have basic gravity, a force pushing down the player. But, I want it, so if you press spacebar, it does a full jump, and not if you hold spacebar, it just keeps going up.
if player is on floor
can jump = true
else
can jump = false
I have a question related to Box2D. I'm trying to make the current object follow the mouse while the mouse button is held down such that it is unaffected by gravity but can still collide with other things. My b2World's gravity vector is set to (0.f, -9.81f). If I do this:
b2Vec2 magnitude(0.f, 9.81f); object->ApplyForce(magnitude, object->GetWorldCenter());
Then it gradually floats upward relative to the mouse cursor and when I release the mousebutton it flies up. If I manually set the position of the object each tick but don't apply an upward force, the same phenomenon happens but downward (it gradually sinks and then when I let go it flies into the ground). How can I effectively cancel out the gravity acting on a single object (b2Body) while still being able to set the position of the object to follow the mouse?
Edit: What happened to the cpp tags?
Edit: Never mind
I'm working on a todo-list application (C++ on C::B with SFML2) and I have a question: what's the best way to save the name of the task? Right now I have a "Task" class that has all of it's properties + a string named "name", however, to draw text on the screen with SFML it has to be a sf::string.
So, should I keep a unique sf::string that I change everytime I'm gonna draw a task or should each task object have a sf::string of it's own?
Just make each task have a string of its own
Edited:
Dont know if anyone has used mogre but im trying to load a plain sphere
when ever i do this tho i get
using Mogre; using Mogre.TutorialFramework; using System; namespace Mogre.Tutorials { class Tutorial : BaseApplication { public static void Main() { new Tutorial().Go(); } protected override void CreateScene() { mSceneMgr.AmbientLight = new ColourValue(1, 1, 1); Entity ent = mSceneMgr.CreateEntity("sphere", "SphereCus.mesh"); SceneNode node = mSceneMgr.RootSceneNode.CreateChildSceneNode("HeadNode"); node.AttachObject(ent); } } }
I have tried both my own meshes (simple sphere exported with blender) and te spheres that come with Mogre
Alright. But now I get an error when trying to load the font from a file :saddowns:
sf::Font fnt_task_name; if (!fnt_task_name.LoadFromFile("arial.ttf", 20)) { return 1; }error: no matching function for call to 'sf::Font::LoadFromFile(const char [10], int)
Edited:
Oh. The new LoadFromFile function is not supposed to get a second argument now.
C#
What's the best way to store a list of unicode characters in human readable format? I have my characters in a string delimited by semicolons, but that doesn't really work with invisible and control characters (their effects still take place), so I want to store them in a good format (ideally stored as \u, \x, etc).
Not really sure what you mean, but cant you just use a list of chars?
List<char> myCharList;
or a char array?
I feel like WDYNHW is unsuccessful because a large # of good programmers only visit WAYWO, anyone agree
like i think questions should just go in WAYWO, not only is it relevant but there is a higher chance of it being answered
I agree with most people only check the WAYWO thread, but i dont think everything should go in it