• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.


  • Content count

  • Joined

  • Last visited

Community Reputation

108 Neutral

About avelle

  • Rank
  1. Hi Scrap, I just wanted to mention something that would hopefully make your life easier in the future. When comparing characters such as y, Y, n, and N, you can force the comparison to be either all lower case or all upper case which would be useful in this instance. You could turn the following: [code]if (again1 == "n" || again1 == "N")[/code] into: [code]if (again.ToUpper() == "N")[/code] and it would take whatever was in the variable 'again' and capitalize it for the comparison. It's important to note that it wouldn't save it as upper case beyond this statement. For that you would need to do [code]again = again.ToUpper()[/code] I hope that's helpful.
  2. The PC(s) you intend to execute the program on need to have the .NET framework version (1.1, 2.0, 3.5, etc) you used to compile the program.
  3. [quote name='GraySnakeGenocide' timestamp='1302805935' post='4798501'] [quote name='Khaiy' timestamp='1302804769' post='4798493'] You need the methods to be static because you aren't instantiating any objects. A static method operates from the class itself, while a non-static method is called from a specific object of the class that has already been created. Your project has a single class (Program), and you don't actually create an object of type Program (which is fine for what this program does). But that means that any method you call will need to be static. Does that make sense? Also, do you feel like you've got a better grasp on return types and parameters now? If not, I'd be happy to try to explain them. [/quote] I'm still shakey on how the parameters work, as well as the return types. As Avelle mentioned: "Also you're returning an integer when your method return type is a string." I try having the return types as ints, and it caused the "cannot convert errors. So I have a long way to go. But yeah, if you could help me understand the parameters/return type stuff better i'd appreciate it. [/quote] The reason it threw that conversion error when you changed the return type of the function to an int is because in Main the variable temp is a string and it won't allow you to assign an int as a string. I'm sure someone else can better explain this but I'll make an attempt as well. Parameters are just want you want to pass to your function, it can be any kind of data type or object. In your earliest example of code: [code] Console.WriteLine("Fahrenheit it is!, Please enter a temperature to convert: "); int temp; temp = int.Parse(Console.ReadLine(); [/code] you defined temp as an integer. In general you would have wanted your ToFahrenheit method to accept an integer parameter instead of a string. Frankly I'm dumbfounded that it let you return an integer in a function that had a string return type without screaming bloody murder. I'm not sure if this is a C# thing, but I was always under the impression that what you returned HAD to match the return type. Anyways, as far as I know, it's best practice to match what you return with the declared return type of the function, but I'm sure there are much more experienced programmers on here that can tell you for sure.
  4. [quote name='jtagge75' timestamp='1302804314' post='4798489'] [quote name='avelle' timestamp='1302800594' post='4798467'] [quote name='GraySnakeGenocide' timestamp='1302798010' post='4798448'] When removing static from both methods, I get the following error: "An object reference is required for the non-static field, method or property "ConsoleApplication1.Program.ToFahrenheit(string); [/quote] My fault, I don't write console applications so ignore what I said there and keep them static. "static void ToFahrenheit(string fTemp)" and the same for Celsius should work though. [/quote] Its not that its a console app, its that Main() is a static function. Unless the conversion functions are put into a class and that class is created in Main or the functions are declared as static then Main will never be able to find them. [/quote] Aha, I forgot all about that. I thought it probably had something to do with Main() but couldn't remember what it was exactly. Thanks for clearing that up.
  5. [quote name='GraySnakeGenocide' timestamp='1302798010' post='4798448'] When removing static from both methods, I get the following error: "An object reference is required for the non-static field, method or property "ConsoleApplication1.Program.ToFahrenheit(string); [/quote] My fault, I don't write console applications so ignore what I said there and keep them static. "static void ToFahrenheit(string fTemp)" and the same for Celsius should work though.
  6. [quote name='GraySnakeGenocide' timestamp='1302795812' post='4798438'] [quote name='rip-off' timestamp='1302794968' post='4798433'] You are doing "integer division". Using integer division, 9 / 5 is 1, any fractional value is truncated. This is despite the fact that you later store the result of the expression as a float. The compiler uses the immediate types of the constants to determine the kind of operation it is. Use floating point constants, e.g. 9.0f / 5.0f. I would recommend using parentheses or extra variables, because it clarifies your intent. I would write: [code] float conversionRatio = 9.0f / 5.0f; farenheit = (conversionRation * farenheit) + 32; [/code] [/quote] Thank you sir. I'm SLOWLY starting to get this. I'll need to work on the whole static returnvalue Method(parameter) parts. The whole returning a variable thing is still a bit confusion to me, as well as the parameter bits. I'm not 100% on how either of these work. [/quote] [code] static string ToFahrenheit(string fTemp) { float fahrenheit; fahrenheit = float.Parse(fTemp); fahrenheit = 9 / 5 * fahrenheit + 32; Console.WriteLine(fahrenheit); return fTemp; } [/code] For a function like this, if you don't need to do anything with the converted temperature, a return type isn't needed here. If you want to manipulate the temperature back in your main method then you would want to keep the return type. The code like this: [code] static void ToFahrenheit(string fTemp) { float fahrenheit; fahrenheit = float.Parse(fTemp); fahrenheit = 9 / 5 * fahrenheit + 32; Console.WriteLine(fahrenheit); } [/code] should do exactly the same thing. The only exception is that when you call a function with no return type like this, you won't use "temp = ToFahrenheit(temp)", you'd simply just call it like "ToFarhrenheit(temp)". Additionally, I don't think static is necessary in either of these functions, but I don't do a lot of console programming so not sure if that's different somehow. You could probably just use "void ToFahrenheit(string fTemp)" and be fine. Hope that makes sense/helps.
  7. [quote name='GraySnakeGenocide' timestamp='1302764035' post='4798289'] I feel like I have made alot of progress between now and yesterday, even though this is not very much. The issues I am working on trying to solve: Taking the input from the "temp" int variables, sending it to the proper conversion method, and having the converted temperature sent back to the screen. Not having the "Invalid type, please type Celsius or Fahrenheit" line execute when I type exit. There are probably some rookie mistakes/obvious mistakes that I am too tired to notice right now, as in I think the Console.Writline(celsius/fahenheit) lines will not work as the value is returned afterwards, or w/e. But help would be appreciated. [/quote] In addition to Rip's advice, I'd probably move this line: [code]Console.WriteLine("Please enter a conversion type: ");[/code] into your loop so that when you're done with your conversion it reprints the instructions on the screen each iteration. That said, in order to get your conversions working, changing what you currently have to: [code] Console.WriteLine("Fahrenheit it is!, Please enter a temperature to convert: "); string temp = Console.ReadLine(); temp = ToFahrenheit(temp); [/code] should fix your issue. If you would rather parse your integer before the method call, you could change your method parameter to an integer so you didn't have to parse it to an int again after you did in your original "if" statement. A word of caution though, whenever you try to parse data types you run the risk of throwing an exception which you aren't dealing with here. If the user enters "banana" when you're expecting a temperature, you're going to crash out of your program so it's generally a good idea to wrap your parses in a try/catch block. Also you're returning an integer when your method return type is a string. C# apparently doesn't care about that (at least visual studio didn't seem to yell at me about it) but that may be an issue in other languages.
  8. [quote name='Huwtrosky' timestamp='1301854736' post='4793891'] Well set it to loop but now I'm having a problem with the File.WriteAllText line. The problem is that when debugging I get the NotSupportedException pop up. I can't see what I'm doing wrong [img]http://public.gamedev.net/public/style_emoticons/default/sad.gif[/img] Here's the new code Fixed now [/quote] I think there's a few things you can improve on here. [code] for (int i = 0; i < 5; i++) { SheetWriter = contents[i] + "\r\n"; } [/code] For this loop, SheetWriter is just a string right? If you want to keep appending contents[i] with the carriage return, you need to use += or you'll just keep rewriting the data every iteration. Though it's not super important in this example, you can also use contents.Length for your loop and if you ever need to change the size of your array someday you won't have to worry about hardcoding the iterations. Lastly for writing the data to file, you can just use a string array, but I believe you need to use File.WriteAllLines. It takes the same arguments as WriteAllText but it should write the contents of an array. [code] File.WriteAllLines( file_name, contents ); [/code] Here's the example on msdn: [url="http://msdn.microsoft.com/en-us/library/92e05ft3.aspx"]http://msdn.microsof...y/92e05ft3.aspx[/url] That should work, but I'm going off memory right now so my syntax might be off. Hope that helps.