CSE 142: More Critters! - PowerPoint PPT Presentation

About This Presentation
Title:

CSE 142: More Critters!

Description:

CSE 142: More Critters! Weds, Nov. 26th Reading: Section Handout Today s Agenda Review ideas behind Critter assignment, answer questions Practice writing Critters ... – PowerPoint PPT presentation

Number of Views:498
Avg rating:3.0/5.0
Slides: 13
Provided by: tim109
Category:
Tags: cse | critters | more | tick

less

Transcript and Presenter's Notes

Title: CSE 142: More Critters!


1
CSE 142 More Critters!
  • Weds, Nov. 26th
  • Reading Section Handout

2
Todays Agenda
  • Review ideas behind Critter assignment, answer
    questions
  • Practice writing Critters
  • Critters will also be on the final!

3
Role of CritterMain
  • Think of CritterMain as Game Master
  • Does the behind the scenes work to administer the
    game
  • Constructs your Critters, places them in the
    world for you
  • What the Game Master does you do NOT have to
    implement!!
  • You create the Critter classes, which are like
    players in the game

CritterMain the Game Master
4
Review of CritterMain
CritterMain
5
Role of CritterMain, 2
  • Game Master also runs each move of the game
  • Every Critters move is executed during a tick
  • Game Sequence of ticks
  • Moves the critters, runs battles, figures out
    whos napping/mating/eating, etc
  • Must prompt each Critter
  • Tell me what you look like (toString(),
    getColor()), Tell me where you want to go to next
    (getMove())
  • If on a food, calls eat()
  • If in a fight, calls fight()

6
Whats your next move?
L
7
(No Transcript)
8
Programming a Critter
  • Our job is to program Critters we decide how a
    Critter behaves when CritterMain calls its
    methods
  • How it moves, how it eats, etc.
  • Behavior often dependent on things the Critter
    has to remember so we also give Critters state

9
A Simple Critter Rabbit
Method Behavior
Constructor public Rabbit()
Color dark gray (Color.DARK_GRAY)
Eating alternates between true and false(true, false, true, ...)
Fighting if opponent is a Lion, then scratch otherwise, roar
Movement 2 N, 2 S, 2 E, repeat
toString "V"
10
Rabbit movement
11
Rabbit movement
3
2
4
5
1
6
12
A complex Critter Snake
Method Behavior
Constructor public Snake()
Color (red20, green50, blue128)
Eating Never eats
Fighting Randomly choose to roar or pounce
Movement 1 E, 1 S 2 W, 1 S 3 E, 1 S 4 W, 1 S 5 E, ...
toString Always returns "S"
Write a Comment
User Comments (0)
About PowerShow.com