CIS125GA_03 Things that help

Slides:



Advertisements
Similar presentations
Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Advertisements

Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
COMPUTER PROGRAMMING I Understand Problem Solving Tools to Design Programming Solutions.
Intro to Java while loops pseudocode. 1 A “Loop” A simple but powerful mechanism for “making lots of things happen!” Performs a statement (or block) over.
Information Technology Center Hany Abdelwahab Computer Specialist.
Wizard Game: Class-Level Variables in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July
1 The First Step Learning objectives write Java programs that display text on the screen. distinguish between the eight built-in scalar types of Java;
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Making a Timer in Alice.
Microsoft Visual Basic 2008: Reloaded Fourth Edition
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Python Programming Using Variables and input. Objectives We’re learning to make use of if statements to enable code to ask questions. Outcomes Build an.
Alice Learning to program: Part Three Camera Control, Invisibility, and 3-D Text By Ruthie Tucker and Jenna Hayes, Under the direction of Professor Rodger.
Using Visual Basic for Applications (VBA) – Project 8.
Introduction to Arrays. definitions and things to consider… This presentation is designed to give a simple demonstration of array and object visualizations.
Chapter 12: How Long Can This Go On?
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Alice Pong Recreating Pong in Alice By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June 2010.
Variables Tutorial 3c variable A variable is any symbol that can be replaced with a number to solve a math problem. An open sentence has at least one.
Chapter 1 - Getting to know Greenfoot
By the end of this session you should be able to...
Making Decisions uCode: October Review What are the differences between: o BlueJ o Java Computer objects represent some thing or idea in the real.
Introduction to Computer Application (IC) MH Room 517 Time : 7:00-9:30pm.
7 1 User-Defined Functions CGI/Perl Programming By Diane Zak.
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
Applications Development
1 ball, 2 ball, red ball, blue ball By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Slide 1 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Task 2 Briefing The Design of a Computer.
CHAPTER 3 Getting Player Input XNA Game Studio 4.0.
Lesson 2: Reading a program. Remember: from yesterday We learned about… Precise language is needed to program Actors and Classes Methods – step by step.
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
Using the Eclipse Debugger Extra Help Session (Christina Aiello)
Slide 1 Chapter 4 The If…Then Statement  Conditional control structure, also called a decision structure  Executes a set of statements when a condition.
1 Quiz Show Programming Terms. 2 Alice - 3D Virtual Programming Vocabulary Quiz Board Chapter 1 Chapter 2a Chapter 2b Chapter 3 Chapter 4 $100 $200 $300.
© 2006 Lawrenceville Press Slide 1 Chapter 5 The If…Then Statement (One-Way)  Conditional control structure, also called a decision structure  Executes.
By Melissa Dalis Professor Susan Rodger Duke University June 2011
Understand Problem Solving Tools to Design Programming Solutions
Complex Conditionals Human languages are ambiguous
Content Programming Overview The JVM A brief look at Structure
Alice Learning to program: Part Three Camera Control, Invisibility, and 3-D Text By Ruthie Tucker and Jenna Hayes, Under the direction of Professor Rodger.
Chapter 4 The If…Then Statement
A basic tutorial for fundamental concepts
Variables.
Python Let’s get started!.
IF statements.
Understand Problem Solving Tools to Design Programming Solutions
Diamond Hunt Mock Programming Project.
Let's Race! Typing on the Home Row
Introduction to Events
User-Defined Functions
Microsoft Visual Basic 2005 BASICS
Alice Learning to program: Part Three By Ruthie Tucker and Jenna Hayes, Under the direction of Professor Rodger Duke University, 2008.
Boolean Bingo!.
Use of Mathematics using Technology (Maltlab)
CIS16 Application Development and Programming using Visual Basic.net
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
1) C program development 2) Selection structure
Introduction to TouchDevelop
Introduction to Problem Solving and Control Statements
While Loops and If-Else Structures
Microsoft Visual Basic 2005: Reloaded Second Edition
Week 6: Time and triggers!
ICT Gaming Lesson 3.
Chapter 3: Selection Structures: Making Decisions
ICT Gaming Lesson 2.
Chapter 3: Selection Structures: Making Decisions
CIS125GA Week 4 Logical Beginnings
Restricting Events Creating Conditional Events in Alice By Henry Qin
Presentation transcript:

CIS125GA_03 Things that help

Methods Planning Code Flowcharts Comments Pseudocode Contents: 13 Slides Methods Planning Code Flowcharts Comments Pseudocode

Methods Dissected A Method / Function can do several things: Ask a Question about the state Do some Math Modify the Values of an Object’s properties Update and Start are both Methods. ReturnType NameOfMethod (Parameters) { Instructions; }

Methods Dissected Cont. Think of a Method as a little factory. Parameters / Arguments are Raw Materials going in. The Method processes it. Return – ed values are your final Product. Int DamageTaken (HP, FireBallPoints) { HP -= FireballPoints Return HP }

Methods Dissected Further There are 3 Questions you should ask yourself when designing a Method. What do I want to achieve? (Method Instructions) What information does it need to run? (Parameters) What do I need to get back from it? (Return)

Planning your Code Code for games involves asking a lot of questions about the State, then selecting a branch to modify the state in response. The questions you ask will be Booleans (True or False Questions) or Mathematical Operations. The more Branches you have, the more complicated the game. Common Questions include: Is the Hero’s HP above 0? Did the Sword Hit the enemies weak spot? Is the Mob facing the player? Is the Timer below 1 minute? Is the Player Colliding with the power up? Did the player Collide with the trigger?

PseudoCode PSUEDOCODE Is writing down your code in plain Human Language, as part of your planning process. Similar to Human Languages, if you can articulate what you want to do in words, you can “translate” it to Programming languages. Each Written Line should be equivalent to a Line of code. You may write, In EXAMPLE: IF Lancelot enters the Forest, THEN Turn on the grail shaped beacon.

Visual Programming See if you can figure out what the code is doing. Answer is a click away! Once the trigger is touched, the door becomes open-able by the character. Once the trigger (which is an area in space) is exited by the player, the door is closeable.

FlowChart Example: Has the 1 button been pressed? No Yes Do Nothing Does the Hero have more than 0 HP AND does the Enemy have more than 0 HP? No Yes Debug Log Game Over Turn Off Level Light Assign a random number to HitDamage Debug Log HitDamage Is HitDamage Greater than or Equal to 5? No Yes Debug Log "Hit!" Enable Hero Light Disable Enemy Light Subtract HitDamage from EnemyHP, then re-assign it to the variable Debug Log EnemyHP (the new value) Debug Log "Miss!" Disable Hero Light Enable Enemy Light

Comments A // COMMENT is text placed into your code that computer ignores, but maintains the sanity of you and other programmers! A special symbol tells the computer what text is comment, and what is code. You can Comment out large blocks of code with a /* at the beginning, and a */ at the end. In MonoDevelop, you can also R-CLICK several lines of code and Toggle line comments on and off. This is helpful for troubleshooting!

Pseudocode & Comments Cont. Your Comments will likely look like your Pseudocode, but recognize the difference: Pseudocode is what you just write out somewhere for planning. Comments are text you insert In Your Code, that the computer ignores, but people read.

EXAMPLE: Let’s take our Pseudocode, and make it into some comments in our code: // This is a block of code that turns on the Beacon. Void TurnOnGrailShapedBeacon () { // If Lancelot is in the forest AND if the Beacon isn’t currently on: if ( lancelotInForest = true && beaconOn = false) // Then we tell the computer that it is on and we make it visible in the game {beaconOn = true; beaconOpacity = 100; }

Example: In Alice, it may look like this: (Assuming Lancelot is the crispy knight, and the forest is all apple trees..) See the comment line? You will need to LIBERALLY comment your code from now on!