Programming games Reprise on dice game and alternative dice game Homework: [Catch up.]. Finish dice game.

Slides:



Advertisements
Similar presentations
Lesson Objective Be able to calculate probabilities for Binomial situations Begin to recognise the conditions necessary for a Random variable to have a.
Advertisements

Introduction to Programming Lesson 1. Objectives Skills/ConceptsMTA Exam Objectives Understanding Computer Programming Understand computer storage and.
Tonight’s JavaScript Topics 1 Conditional Statements: if and switch The Array Object Looping Statements: for, while and do-while.
Overview Reference parameters Documenting functions A game of craps. Design, code, test and document.
Programming games More drawing. Text. Radian measure. Faces. Homework: Do your own drawings. Create index.html file. Upload work.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 16 – Craps Game Application Introducing Random-Number.
Page 1 of 26 Javascript/Jscript Ch 7,8,9,10 Vadim Parizher Computer Science Department California State University, Northridge Spring 2003 Slides from.
Matlab tutorial course Exercises 4:. Exercises – for loops Download the scripts loops_example.m and if_else_example.m, run the code Download the function,
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 5 - Functions Outline 5.1Introduction 5.2Program.
Information Technology Center Hany Abdelwahab Computer Specialist.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
Main task -write me a program
CIS101 Introduction to Computing Week 12 Spring 2004.
Programming Games Computer science big ideas. Computer Science jargon. Show virtual dog Homework: [Catch up: dice game, credit card or other form.] Plan.
Line up By Melissa Dalis Professor Susan Rodger Duke University June 2011.
The game of Craps Rules of play: 1. Played with two dice (six faces to a die – numbers 1-6 per face) 2. Sequence of betting rounds (or just rounds) 3.
JS Arrays, Functions, Events Week 5 INFM 603. Agenda Arrays Functions Event-Driven Programming.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Programming games Recap. Upload work (Filezilla, index.html). Drawing lines. Drawing stars. Homework: Drawing exercises.
Homework: Finish dice game.
MOM! Phineas and Ferb are … Aims:
Visual Basic Games: Week 3 Global variables, parameters, Select, KeyDown Enable, Visible, Focus State of Game Read chapter 3.
11 Finding Winners Using Arrays Session 8.2. Session Overview  Find out how the C# language makes it easy to create an array that contains multiple values.
Programming games Reprise: coin toss on canvas. Dice game rules. Global and local variables. Homework: [Catch up. Upload projects, including index.html.]
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
Homework: New coin toss. [Start dice game.]
Bug Session Four. Session description Objectives Session activities summary Resources Prior knowledge of sequencing instructions using Bug Bug website.
By the end of this session you should be able to...
VB Games: Preparing for Memory Brainstorm controls & events Parallel structures (again), Visibility, LoadPicture, User-defined procedures, Do While/Loop,busy.
Programming Games Preview Video & Audio. Work on cannonball. Homework: finish cannonball!
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Creating Databases Local storage. join & split Classwork: show 1 table application. Share designs for oscars application. Adaptive select. Homework: [Catch.
Logic and Control. 4-2 Decision (selection) structure: if (condition) { statement etc. } Example: if (age == 15) { document.write(“ you are a fifteen”);
Programming games Show shaking screen, quiz show. Calculations Homework: (Finish basic Javascript Projects) Make proposal. Work on project.
Visual Basic Games: Week 4 Recap Parallel structures Initialization Prepare for Memory Scoring Shuffling Homework: when ready, move on to next game/chapter.
Programming games HTML/JavaScript basics Functions, events, forms Classwork: [Show favorite sites.] Coin toss. Homework: GET WEB SPACE. Complete coin toss.
XP Tutorial 8 Adding Interactivity with ActionScript.
Programming Games Credit cards. Forms. Homework: Catch up: dice game. Produce your own credit card application or something else making use of a form with.
Select (drop-down list) Inputs. Insert/Form/List Menu.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
WOULD YOU PLAY THIS GAME? Roll a dice, and win $1000 dollars if you roll a 6.
Programming games Context of what we are doing. Drawing on canvas. Homework: [Complete coin toss examples.] Do your own drawings. Upload files to website.
CSD 340 (Blum)1 Starting JavaScript Homage to the Homage to the Square.
Programming Games Logic. Slide show. Range input. Storage. Datatypes. Binary numbers. Homework: Catch up. This includes uploading projects to your server.
Creating Databases for Web applications Server side vs client side PHP basics Homework: Get your own versions of sending working: both html and Flash!
Computer Science I Recap: variables & functions. Images. Pseudo-random processing.
Programming games Review concepts. Crooked coin toss. Drawing on canvas. Homework: Complete [static] drawings. Upload files to website.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Craps Game Application Introducing Random-Number Generation and Enum.
More Sequences. Review: String Sequences  Strings are sequences of characters so we can: Use an index to refer to an individual character: Use slices.
Computer Science I Share plans for virtual something. Text. Show my virtual dog. Classwork: Plans for your virtual something. Homework: start implementation.
Creating Web Documents: JavaScript Ftp / file management: review Introduction to JavaScript Sources Homework: start review for midterm, work on Project.
Methods Chapter 6. 2 Program Modules in Java What we call "functions" in C++ are called "___________________" in Java Purpose –Reuse code –Modularize.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 16 – Craps Game Application Introducing Random-Number.
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
World of Wokcraft The very best in Single pan cooking themed fantasy gaming!
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Programming Games Reprise Credit Cards! Reprise Binary. Overall time limit, setTimeout Homework: [Show virtual something.] Make proposal as reply to my.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
Programming games Show work on site. Work on slide show. Timed event for bouncing ball. Homework: [Finish slide show and upload to site.] Acquire a short.
Creating Databases Local storage. join & split
Programming Games Work / finish and show dice game. Extras. Timed events. ftp. index file. Homework: Catch up and do slide show.
Programming Games Computer science big ideas and Computer Science jargon: review of things we have used in examples. Show virtual dog Homework: [Catch.
Chapter 5 - Functions Outline 5.1 Introduction
Chapter 10 Algorithms.
Programming games Share your plans for your virtual something.
Catchup. Work on project.
Copyright  1997 Oxford University Press All Rights Reserved
Programming games Reprise on dice game and alternative dice game
Presentation transcript:

Programming games Reprise on dice game and alternative dice game Homework: [Catch up.]. Finish dice game.

Staged implementation Throw 1 die Throw 2 dice Throw 2 dice and get sum –Show sum Do rules of craps NOTE: you will be adding code into the dthrow function (inside the brackets)

Incremental development Do practice writing outlines as just shown. Get small parts of project working –Follow suggestions in the tutorials and –Follow this practice for your own projects. You may divide tasks differently.

Faces examples First example, faces is a list of character strings representing names of image files. Second example, faces is a list of image elements. To get the name of the image file, the code needs to be document.dicea.src = faces[choice].src; TWO EXAMPLES IN TUTORIAL ARE DIFFERENT…. TO SHOW YOU DIFFERENT WAYS OF DOING THINGS….

Testing You test the program to see if it works correctly! This means you as the player win and lose! Because of the pseudo-random feature (aka stochastic processing), testing takes time…many cases.

Work session Catch up and show us: sites, coin toss, biased coin, drawings, alternative coin toss Work on dice game If you have completed dice game, do alternative dice game OR add feature(s) –Add (more) graphics –Display different message depending on situation –Keep score and show it using an alert statement or form variable –(May take knowledge/research): add field for entering value of bet.

Extra credit posting opportunity What are the chances of winning on a first move? What are the chances of losing? What are the chances of needing followup moves? For each possible point value, what are the chances of winning, losing, needing to continue?

Recap: Dice game Game logic implemented using if statement and switch statements Game rules require global variables to hold state information: information persisting between throws Arrays: sequences of things (names of files or img elements) –Indexing starts at 0

Reflection on dice game Logic: switch statements in clauses of if/else statements Global variables holding state of the game –first move or follow-up –point value (only has significance if follow-up) Display using graphics and text Implement in stages!!!! Need to test all possibilities –not test until you win….

Reflect and Continue Storage of standard things (e.g., numbers) solved but representation of information for specific problems is / will be new challenge Now on to representation of formulas and logic. –Closed form – mathematical formula – easy to represent in code –Algorithm, logic, may require use of conditionals, more… Models: build computer model = representation of something, some phenomenon. NOT simple (closed form) formula, but involving programs…

Alternative dice game Remove the need for image files by drawing the die faces. html5/craps.htmlhttp://faculty.purchase.edu/jeanine.meyer/ html5/craps.html –examine code

Calling pattern throwdice function sets up dx and dy for each die and calls –drawface(n) uses a switch statement to determine what to do, namely single or combination from a set of functions.

switch(n) { case 1: draw1();break; case 2: draw2();break; case 3: draw2();draw1();break; case 4: draw4();break; case 5: draw4();draw1();break; case 6: draw4();draw2mid();break; }

draw2 function draw2() { var dotx; var doty; ctx.beginPath(); dotx = dx + 3*dotrad; doty = dy + 3*dotrad; ctx.arc(dotx,doty,dotrad,0,Math.PI*2,true); dotx = dx+dicewidth-3*dotrad; doty = dy+diceheight-3*dotrad; ctx.arc(dotx,doty,dotrad,0,Math.PI*2,true); ctx.closePath(); ctx.fill();}

Exercise Take one of the choices for the switch statement and be able to explain how it works. Choose different colors and make it do what you want!

How many files…. original coin toss alternative coin toss original dice game new dice game (draw the faces)

Comparison of two dice games? Using image files means…you can use fancy image files. Not using image files means that this application is just the one html file. Speed? Downloading of image files versus drawing. The downloading time is not repeated. ?

Enhancements Adding other images. Adding a bankroll feature. –start with a certain amount, say 100 and –at each game (first throw), decrease this by 10. –at each win, increase by 20. –Display this amount in a new input field in the form. –Comment: this is appropriate method of scoring for this type of game! How to score varies and can be subjective.

Homework [catch up] Complete dice game. –You can do html5 drawing on canvas version for extra credit. –You can enhance the game Keep up with uploading applications and updating your index file. –Choose / invent appealing names