• What do you need help with? V. 3.0
    4,884 replies, posted
  • All your not-thread-worthy questions here! Well? What do you need help with?
  • Repostin' from old thread [QUOTE]Could somebody explain to me how I would use pygame.sprite.RenderPlain when working with multiple instances of the same class? I know renderplain is just like a group but that's all I know. I don't really know what groups are either. Multiple instances of the same class being like: [CODE] i = 0 while i < difficulty * 10: #difficulty is set by the user as either 1 2 or 3 food = Food(blah) #Just see this part as "create a new instance of Food class named food" #Renderplain stuff here? [/CODE] This has been a massive hurdle in my game developing for a while now and it would really be awesome if someone could get this out of my way.[/QUOTE]
  • I'm going to work on my first XNA game, but first I need some good XNA tutorials. Anybody know of any good ones?
  • [QUOTE=Tangara;30126375]Is the .0 necessary[/QUOTE] It makes the OP look smarter
  • [QUOTE=Xion12;30126963]I'm going to work on my first XNA game, but first I need some good XNA tutorials. Anybody know of any good ones?[/QUOTE] [url]http://www.riemers.net/[/url] 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: [cpp] Class myClass; public Class getMyClass() { return &myClass; } [/cpp]
  • [QUOTE=Richy19;30127740]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?[/QUOTE] [cpp] Class &getMyClass() { return myClass; } [/cpp]
  • [QUOTE=Tangara;30126375]Is the .0 necessary[/QUOTE] He was making sure the compiler knew it was a double.
  • 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.
  • [QUOTE=Phyxius;30131947]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.[/QUOTE] By rotate around {a,b} you mean simply circle around it?
  • [QUOTE=Phyxius;30131988]Yep.[/QUOTE] 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(); } } } [/code] Edit I just realized it should be "//Math.Sin uses radians... convert [b]from[/b] degrees", not "to"
  • [QUOTE=Map in a box;30132003]Where does XNA redistributable install to?[/QUOTE] 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.
  • [QUOTE=MadPro119;30132665]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.[/QUOTE] Example?
  • [QUOTE=MadPro119;30132665]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.[/QUOTE] 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. [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; } } } } [/code] However upon going to A: it waits for the user to input something/ press enter. Anyway to make it automatically continue?
  • [QUOTE=MadPro119;30133467]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. [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; } } } } [/code] However upon going to A: it waits for the user to input something/ press enter. Anyway to make it automatically continue?[/QUOTE] don't use goto
  • [QUOTE=Darwin226;30133566]Don't use Console.ReadLine()? Lol. What did you think it would do?[/QUOTE] 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.
  • [QUOTE=Tangara;30133797]don't use goto[/QUOTE] 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? [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 [/code] the last line, you kept the creation, doesn't print in any situation.
  • [QUOTE=Icedshot;30134938]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."[/QUOTE] in most cases, goto is not necessary and makes the code hard to follow
  • [QUOTE=Joxstrap;30135167]I have a problem with my python script, any idea why this isn't printing the last line? -snippity- the last line, you kept the creation, doesn't print in any situation.[/QUOTE] 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"'