1 / 22

Programming Games in Visual Basic

Programming Games in Visual Basic. Introductions Origin of Book & Course overview Administration Assignment: CourseInfo survey. Start reading textbook. Introductions. Jeanine Meyer Associate professor, Math/Computer Science & New Media formerly at Pace University

kendra
Télécharger la présentation

Programming Games in Visual Basic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Games in Visual Basic Introductions Origin of Book & Course overview Administration Assignment: CourseInfo survey. Start reading textbook. MAT 1420.45 Meyer Week 1

  2. Introductions • Jeanine Meyer • Associate professor, Math/Computer Science & New Media • formerly at Pace University • IBM (research, manufacturing staff, education, grants) • Staff development for New York City schools • Also teaching: Creating Web Documents • Son in Cornell graduate school, daughter just started at American Health Foundation • Hobbies/interests: origami, flute, cooking and eating, aerobics, reading novels, travel and… programming • Zach Wolliner, teaching assistant • You? MAT 1420.45 Meyer Week 1

  3. Origin of book • Several years ago, at Pace, I programmed minesweeper (programmed the computer action for minesweeper) as a way of getting more familiar with Visual Basic. • Observations: • Fun! Also, did the job. • Most of our CIS 101 students, many CS/IS students • Don’t like programming • Don’t understand how features can be used • Aren’t very good at it • So…I recruited a friend, we wrote, some said it wasn’t serious enough, some said the games were too difficult, we re-wrote, piloted chapters, got a publisher, re-wrote and the textbook is the result! MAT 1420.45 Meyer Week 1

  4. Course topics • Features of Visual Basic common to all programming languages • Logic, statements, compound statements • Variables, subroutines & functions • Features of Visual Basic common or similar to ‘modern’ programming systems • Design of graphical user interface • Event handling • Objects • Some devotees of OO would argue here. • Topics in Paint Shop Pro (Photo Shop is fine). You may also acquire images from Web, scanning, etc. MAT 1420.45 Meyer Week 1

  5. Brief introduction to a few terms • A variable holds values (numbers, strings of characters, Booleans (true or false)) • Statement types include • Assignment statements • Calls to procedures • Compound statements IF/Then/Else; For/Next; Select • An event is something that can happen that Visual Basic can detect (e.g., player clicking a button). • A control object is something that can be placed on a VB form (user interface) that has events and properties. MAT 1420.45 Meyer Week 1

  6. Course administration • Web site: courseinfo.purchase.edu • You will be enrolled in this course. Take survey. • Course schedule. Announcements. Grading. • Discussion forums for problems & comments • Lecture/demonstration & work on games in class. You need to work inside and outside of class. Repetition of concepts! • Presentations in class. You may learn from anyone, including each other, but you are responsible & must be able to explain everything in your projects. • Two quizzes. Turn in projects. • Some choices, including final project can be your own game or enhancement of text game. MAT 1420.45 Meyer Week 1

  7. Rock-paper-scissors Mix & match cartoons Chance dice game Memory Hangman Quiz I Spring Vacation Cannonball Files/best scores feature Final project: enhanced version of text projects (e.g., adding scoring & best scores) advanced text project (quiz show, minesweeper, tic tac toe) your own choice of game, including original game Quiz II (Final) Schedule MAT 1420.45 Meyer Week 1

  8. What is programming? MAT 1420.45 Meyer Week 1

  9. Computers must be programmed • Some one, generally a collection of people, have specified the actions of ‘the computer’. • ‘Actions’ can include • Performing a calculation • Moving data around • Accepting input or producing output • Testing something and doing different things depending on the results MAT 1420.45 Meyer Week 1

  10. Programming involves • Problem solving (more or less independent of the programming language) • Specifying solution in terms of the programming language & environment • Program = sequence of statements (certain statements can change the flow of control, e.g., conditionals & loops) • Additional issue(s) involve the user interface: input (information & directives from the user) & output (information presented & actions taken) MAT 1420.45 Meyer Week 1

  11. Sample statements • Assignment Note: equal sign doesn’t mean equal! • count = 0 • count = count + 1 • studentScores(current) = (project1 + project2 + 2* project3)/4 • If…Then…Else…End If IF class = ‘Visual Basic’ then schedule = ‘Monday/Wednesday’ Else schedule = ‘Tuesday/Thursday’ End IF • Select Case Select Case month Case ‘Sept’, ‘Apr’, ‘Jun’, ‘Nov’ days = 30 Case ‘Feb’ days = 28 Case Else days = 31 End Select MAT 1420.45 Meyer Week 1

  12. If actions must be specified completely…. • How do we put randomness into a program • For example, throw of dice, layout of mines in minesweeper • Answer: VB (and other programming languages) have built in features to produce pseudo-random sequences of numbers. • They appear random, but they are calculated. MAT 1420.45 Meyer Week 1

  13. Pseudo-random functions • VB has Randomize and Rnd • Typical use: Randomize … dice1Value = 1 + Int(Rnd * 6) dice2Value = 1 + Int(Rnd * 6) MAT 1420.45 Meyer Week 1

  14. How to specify the actions for shoe tying • Typical situation: easy to do but more difficult to articulate how to do it. • Atypical: physical actions and not just data/information. • Issues of deciding level of specification. • Get in small groups and write down instructions as you would teach a child. MAT 1420.45 Meyer Week 1

  15. Complete cards • Name • E-mail • Phone number (for emergencies) • Experience / courses in programming • Major (interest/career ideas) MAT 1420.45 Meyer Week 1

  16. Assignment • Start reading text. • After CourseInfo orientation session: Go to http://courseinfo.purchase.edu and sign on to this course. • Take survey • Review schedule, grading allocation. • I teach Tuesdays from noon to 2:20, and will be on campus before & after class. I will be in my office (3003) before class Mon. & Wed. Send e-mail to fix a time to meet. MAT 1420.45 Meyer Week 1

  17. Visual Basic • Design time • Design interface (place controls on the Form) • Program the event handlers (type in code into the specific event procedures one at a time). More advanced projects involve programming user-defined procedures & incorporating other code such as Active X controls. • Run time = execution time • Test program. Turn over to users = players. MAT 1420.45 Meyer Week 1

  18. Controls • A Visual Basic project contains at least one Form (the user interface) and code. • Visual Basic has different things = controls that can be placed on a form. • Textbox, label, command button, more… • Each control (including the form itself) has properties & events. You may choose to write code for the event handlers = event procedures for some of these events. • Properties can be set at design time and read & changed during run time. • You will ignore most of the properties and most of the events. MAT 1420.45 Meyer Week 1

  19. Examples • Form has properties: caption, size, background color, etc. and event Form_Load executed when project is started.. • Textbox has properties: initial text, size, position, color, font, etc. Users can enter text and a program can read and write text. • Label has properties: caption, size, position, color, font. Label captions can be changed by code. • Command button: caption, size, color, etc. One event is the Click event. • Other properties & other events MAT 1420.45 Meyer Week 1

  20. Hello, world • Refers to the typical first program in many introductory texts. • By the end of class today, you will produce a more complex program than you could produce at the end of most introductory classes in other languages. Why? • VB provides built-in controls for the interface & VB runtime handles ‘listening’ for events. • VB programming environment (WYSIWYG) helps in programming and debugging. MAT 1420.45 Meyer Week 1

  21. WARNING on reading/using text • Read the text, especially the first sections. Do not jump to later sections and copy code. • The text is 'in English'. You need to translate into Visual Basic. For example, "…make die1 plus die2 to be the total…" translates to total = die1 + die2 MAT 1420.45 Meyer Week 1

  22. Rock-paper-scissors • Computer does (your programming will make the ‘computer’ do) • Handling of player move • Computer move • Determining who wins • Start work tonight. Read text. Start and see how far you can get. MAT 1420.45 Meyer Week 1

More Related