250 likes | 401 Views
Intel Ultimate Engineering Experience Build an App. Team. Ashish Amresh Asst. Professor, College of Technology and Innovation, ASU Game Design Software Design Ryan Scott Senior Computer Science, ASU Game Development, App Development Glenn Craver Senior Computer Science, ASU
E N D
Team • Ashish Amresh • Asst. Professor, College of Technology and Innovation, ASU • Game Design • Software Design • Ryan Scott • Senior Computer Science, ASU • Game Development, App Development • Glenn Craver • Senior Computer Science, ASU • Game Development, App Development
Introduction • Objectives • Learn programming with C# • Learn to use XNA platform • Learn how to develop simple Apps • What should you know • How to use a computer • Ability and open mind to learn new tools and technologies • What do you need (working at home) • http://creators.xna.com/Resources/Essentials.aspx • You'll need XNA Game Studio Express(GSE), Visual C# Express Edition, and DirectX Software Development Kit(DirectX SDK). • A simple paint program: http://www.getpaint.net/index.html
Learning C# • What programming language is the best? • Python, C#, Java, C++ • Language differences • Native vs. Managed • Why C# • Managed code • Easy to learn • Object-oriented • Technical Requirements • 32 or 64 bit • Single or multi-core
How does a Computer Work Hard Drive • Data Storage / shelf • Read and write • Memory (RAM) • Shopping cart • Temporary storage for all our actions • CPU • Checkout machine • Faster the processor the more it can crunch out • Motherboard • Floor / store layout • Good motherboard is necessary to maintain good flow between all components • Output/Graphics Card/Input • Peripherals or accessories, access data and display it
Visual Studio: Hello world • First open Visual Studio 2008 and you will see a start page • Go to File -> New Project -> Visual C# ->"Console application“ • Name it Tutorial1
Visual Studio: Hello World • Learning the basics of a program • using System; • usingSystem.Collections.Generic; • usingSystem.Text; • namespace Tutorial1 • { • classProgram • { • staticvoid Main(string[] args) • { • } • } • } • The first thing you might notice is the different colors. Dark blue signifies a code/command that C# recognizes. Light blue indicates a class, while the regular text is for user defined names.
Visual Studio: Hello World • Program Components • Namespace • Synonymous with a windows folder, a collection of classes used for grouping • Class • Class is a more specific collection than namespace, it holds methods and variables. In C# everything we deal with resides in some class • Methods and Main • Methods are the work horses that do all the crunching of data for your class. The main is a specialized method that is run as soon as a program starts. • Scope • The scope of a namespace, class or method is defined by the { }. It is important to know while programming which scope you are dealing with • Using Statements • Using statements are useful to call other namespaces, so you can bring in additional features that you need into your program.
Visual Studio: Hello World namespace Tutorial1 { classProgram { staticvoid Main(string[] args) { Console.WriteLine("Hello World!"); Console.ReadLine(); } } } • Our first program: • type this inside of the Main() scope • Console.WriteLine("Hello World!"); • Console.ReadLine();
Learning C#: Variables namespace Tutorial1 { class Program { static void Main(string[] args) { intherohitpoints; string myname; boolisalive; } } } • Types • Numbers • Int • Float • Double • Char • Unicode • String • Set of unicodes • Bool • True or false • Void
Learning C#: Variables • Declaration and Assignment
Learning C#: Variables String yourName BoolisBlack BoolisActive Int DNA Int _hitPoints Intmax_number • Naming Conventions • Use nouns • Bools can have verbs • Do not capitalize the first letter • Be descriptive • Do not abbreviate • Do not use prefixes or suffixes
Learning C#: Operations namespace Tutorial1 { class Program { static void Main(string[] args) { double x, y; x = 30.0; y = 3.5; Console.WriteLine(x % y); Console.ReadLine(); } } } • Operators • + • - • * • / • % (modulus) 5%2 =1 or 30 % 3.5 = 2
Learning C#: Operations • Operator shorthand • X += Y is equal to X = X+Y • X -= Y is equal to X = X - Y • X *= Y is equal to X = X * Y • X /= Y is equal to X = X / Y • X++ is equal to X = X +1 • X- -is equal to X = X -1 • Debugging • Use the short hand, and use the Debugger to step in to the code by setting break points. • Runtime vs. buildtime errors
Learning C#: Conditionals • Operators • < is less than • > is greater than • <= is less than or equal to • >= is greater than or equal to • == is equal to • != is not equal to • && logical “and” • ||logical “or” Example: ((X>3)&&(X<6)) hitPoints == 3
Learning c#: Loops • do/while loop
Learning c#: Conditionals • The "if" Statement • static void Main(string[] args) • { • int x; • x=20; • if (x > 0) • { • x -= 1; • Console.WriteLine(x); • } • }
Learning c#: Conditionals • The "if" Statement
Learning C#: conditionals Console.WriteLine("Your favorite color is blue"); break; case "Red": case "red": Console.WriteLine("Your favorite color is red"); break; case "purple": case "Purple": Console.WriteLine("Your favorite color is purple"); break; case "1": Console.WriteLine("You were supposed to pick a color"); break; default: Console.WriteLine("Your favorite color isn't on my list."); break; } Console.ReadLine(); } • Switch Statement • static void Main(string[] args) • { • string favoriteColor; • Console.WriteLine("What if your favorite color?"); • //Incase you were wondering the next statement is reading whatever • //is typed and assigning it to favorite color when enter is pressed • favoritecolor = Console.ReadLine(); • //Just so you know I always type my cases and breaks prior to typing code. • //It just seems easier to me. Do whatever you like though • switch (favoriteColor) • { • case "blue": • case "Blue":
Learning C#: Loops • For Loop • namespace Tutorial1 • { • class Program • { • static void Main(string[] args) • { • for (inti = 0; i < 10; i++) • { • Console.WriteLine(i); • } • Console.ReadLine(); • } • } • }
Learning C#: Simple Calculator • Task: • Using loops and conditional statements create a simple calculator application that will take command line inputs and operations (+ - * / %) and process the output. • The flow of the calculator will be as follows: • Enter the first number • Enter the operation • Enter the second number • Write the answer • Ask if you would like to calculate another set of numbers
Learning c#: Simple calculator • { • case"+": • Console.WriteLine(number1 + number2); • break; • case"-": • Console.WriteLine(number1 - number2); • break; • case"*": • Console.WriteLine(number1 * number2); • break; • case"/": • Console.WriteLine(number1 / number2); • break; • case"%": • Console.WriteLine(number1 % number2); • break; • default: • Console.WriteLine("I'm sorry, that wasn't a valid choice"); • break; • } • Console.WriteLine("Do you want to calculate another set of numbers?"); • choice = Console.ReadLine(); • } • while (choice != "n" && choice != "N"); • } • staticvoid Main(string[] args) • { • int number1, number2; • string numb1,numb2,operrand; • string choice; • do • { • Console.WriteLine("Enter a Number"); • numb1= Console.ReadLine(); • Console.WriteLine("Enter an operator, ie +,-,*,/"); • operrand = Console.ReadLine(); • Console.WriteLine("Enter a second number"); • numb2 = Console.ReadLine(); • Console.WriteLine("The answer is: "); • number1 = int.Parse(numb1); • number2 = int.Parse(numb2); • switch (operrand)