Chapter 10 additional scenario ideas
This presentation is the property of its rightful owner.
Sponsored Links
1 / 43

Chapter 10 - Additional Scenario Ideas PowerPoint PPT Presentation


  • 50 Views
  • Uploaded on
  • Presentation posted in: General

Chapter 10 - Additional Scenario Ideas. Bruce Chittenden. 10.1 Marbles. Marbles (continued). Marbles (continued). Collision Detection.

Download Presentation

Chapter 10 - Additional Scenario Ideas

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Chapter 10 additional scenario ideas

Chapter 10 - Additional Scenario Ideas

Bruce Chittenden


10 1 marbles

10.1 Marbles


Marbles continued

Marbles (continued)


Marbles continued1

Marbles (continued)


Collision detection

Collision Detection

The Marbles scenario does not use any of the built-in Greenfoot collision detection methods, since these all work on the rectangular actor images. The Marbles Scenario on the other hand are round and we need precise collision for this image.


Havehit marble marble

haveHit(Marble marble )

/*

* Check whether we have hit the given marble. We have hit it if its distance from us

* (measured at the centre points) is less then our diameter.

*/

private boolean haveHit(Marble marble)

{

int dx = Math.abs (this.getX() - marble.getX());

int dy = Math.abs (this.getY() - marble.getY());

double distance = Math.sqrt(dx*dx+dy*dy);

return distance < DIAMETER;

}


Collision detection1

Collision Detection

distance = √ (dx2 + dy2)

marble.getY()

distance

dy

dx

this.getY()

this.getX()

marble.getX()


10 2 lifts

10.2 Lifts


Lifts continued

Lifts (continued)


Lifts continued1

Lifts (continued)

The Lifts scenario is a simple elevator simulation. It shows several floors of a multistory building and three elevators moving up and down. People appear on the floors and press the call buttons and enter the elevators when they come. To finish this scenario the movement of people would have to be properly modeled in and out of the elevators.


10 3 boids

10.3 Boids


Boids continued

Boids (continued)


Boids continued1

Boids (continued)


Boids algorithm

Boids Algorithm

  • The term “Boids” comes from a program developed in 1986 by Craig Reynolds that first implemented this flocking algorithm. In it each bird flies according to three rules:

  • Separation: Steer away from other birds if getting too close

  • Alignment: Steer toward the average heading of other birds in the vicinity

  • Cohesion: Steer to move toward the average position of other birds in the vicinity


10 4 circles

10.4 Circles

Click the Mouse to Create a Circle at That Location


Circles continued

Circles (continued)


Circles nice to look at

Circles Nice to Look At

The Circles scenario is a scenario that does not seem to have much of a purpose but is interesting to play with and nice to look at.


10 5 explosion

10.5 Explosion


Explosion continued

Explosion (continued)


Explosion continued1

Explosion (continued)


Explosion continued2

Explosion (continued)


Explosion continued3

Explosion (continued)


Explosion continued4

Explosion (continued)


Explosion continued5

Explosion (continued)


Explosion continued6

Explosion (continued)


Explosion continued7

Explosion (continued)


Explosion continued8

Explosion (continued)


Explosion continued9

Explosion (continued)


Explosion continued10

Explosion (continued)


More spectacular explosion

More Spectacular Explosion

The Explosion scenario demonstrates how we can implement a more spectacular looking explosion effect. To achieve this effect, we have a Debris class that represents a part of the rock. When the rock explodes, we remove it from the world and place 40 pieces of debris in its place.

See the tutorial video at

http://www.greenfoot.org/doc/videos.html


10 6 breakout

10.6 Breakout


Breakout continued

Breakout (continued)


Act method paddle

act Method Paddle

/*

* Act - do whatever the Paddle wants to do. This method is called whenever

* the 'Act' or 'Run' button gets pressed in the environment.

*/

public void act()

{

if (Greenfoot.isKeyDown ("left")) {

move(-9);

}

if (Greenfoot.isKeyDown ("right")) {

move(9);

}

if (haveBall() && Greenfoot.isKeyDown ("space")) {

releaseBall();

}

}


10 7 platform jumper

10.7 Platform Jumper


Platform jumper continued

Platform Jumper (continued)


Platform jumper continued1

Platform Jumper (continued)


Act method pengu

act Method Pengu

private void checkKeys()

{

if (Greenfoot.isKeyDown("left") )

{

setImage("pengu-left.png");

moveLeft();

}

if (Greenfoot.isKeyDown("right") )

{

setImage("pengu-right.png");

moveRight();

}

if (Greenfoot.isKeyDown("space") )

{

if (onGround())

jump();

}

}


Platform jumper

Platform Jumper

A very common style game is a “platform” game. The player typically controls a game character that has to move from one are on the screen to another, while over coming various obstacles. This scenario demonstrates how an actor can move along the top of another actor (the penguin on top of the ground), and how jumping and falling might be implemented.

See the tutorial video at

http://www.greenfoot.org/doc/videos.html


10 8 wave

10.8 Wave


Wave continued

Wave (continued)


Wave continued1

Wave (continued)


Chapter 10 additional scenario ideas

Wave

One of the fascinating aspects of this scenario is how a fairly simple implementation achieves a quite sophisticated simulation of various aspects of wave propagation. In each act round, each bead simply moves toward the middle of its two neighbors.


10 9 summary

10.9 Summary

When you program in other environments, outside of Greenfoot, you will have to learn new skills and techniques, but everything you have learned using Greenfoot will be useful and applicable.


  • Login