GameWorkshop Pres 2
Transcript of GameWorkshop Pres 2
![Page 1: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/1.jpg)
Object Oriented Programming and Games
![Page 2: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/2.jpg)
Building a ProjectThe building blocks of your game.
Variables Functions Conditions
These store data. These do actions.These perform checks and comparisons between variables and facilitate actions.
![Page 3: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/3.jpg)
An Actionscript game is made up of several files with code in them.
These individual files in a program are called Classes. Classes make up the basic structure of every unique item in a game.
Building a ProjectClasses in code are a big deal.
Classes are made up of variables, functions, and conditions which are all put together to provide a purpose.
Classes are like mini programs.
We create classes to define unique objects in our code.
![Page 4: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/4.jpg)
PackagesIn Actionscript 3 we use something called a Package.A package is a collection of classes.A game can be made from multiple or one package
Building a ProjectThe building blocks of your game.
![Page 5: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/5.jpg)
Building a ProjectThe building blocks of your game.
![Page 6: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/6.jpg)
This is Object Oriented ProgrammingObject oriented is how you will create your games.
![Page 7: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/7.jpg)
• You have modular code that you can reuse.
• Because we kept our code in different classes, its modular and reusable.
This is Object Oriented ProgrammingWhat’s the benefit?
![Page 8: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/8.jpg)
A game is made of:- Variables- Functions- Conditions- Classes- Package(s)
Lets apply this to a game model.
Building a gameUsing code structures to make something cool.
![Page 9: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/9.jpg)
Applying the conceptsHow these coding terms fit into a game.
BrickBreaker - Classic and a good place to start
![Page 10: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/10.jpg)
Applying the conceptsHow these coding terms fit into a game.
“We create classes for every unique object in our code.”
What are the unique objects in BrickBreaker?
What would the classes be?
![Page 11: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/11.jpg)
Applying the conceptsHow these coding terms fit into a game.
What are the unique objects?
- Ball
- Paddle (Player)
- Bricks
- The stage we play on
All of these will need to be built as separate classes.
![Page 12: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/12.jpg)
What attributes and actions do each class have?
Ball Stage- Graphics - Collision Detection- Speed - Keeping track of objects on stage- Bounce - Updating movement
Paddle Bricks- Graphics - Graphics- Speed - Knowing when they are hit
Applying the conceptsHow these coding terms fit into a game.
![Page 13: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/13.jpg)
• The attributes will be comes the variables in each class, and the actions will become the functions.
Applying the conceptsHow these coding terms fit into a game.
![Page 14: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/14.jpg)
• It was mentioned before that object oriented programming is reusable.
• If we built the classes to make brickbreaker, we could easily use those same classes to make Pong without rewriting an entire program.
• What would we change?- The ball class would be the same- The orientation of the paddles
would change- The bounds of the stage would be
different
Modular code = happinessThe benefit of Object Oriented.
![Page 15: GameWorkshop Pres 2](https://reader036.fdocuments.in/reader036/viewer/2022083000/5565a8b6d8b42a4c6f8b466d/html5/thumbnails/15.jpg)
BrickBreaker!
So lets make a game.