100% found this document useful (1 vote)
201 views30 pages

Simple Game in Alice

This document provides instructions for creating a simple click-the-zombie game in Alice. It describes setting up the world, adding objects like buildings and a zombie, and creating methods to hide and randomly pop up the zombie. It also covers using properties to track the number of hits, incrementing this using a method, and notifying the player after 5 hits. The game uses a while loop to continuously hide and pop up the zombie until won. Additional ideas like sounds, counts, and losing conditions are also suggested.

Uploaded by

snezana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
201 views30 pages

Simple Game in Alice

This document provides instructions for creating a simple click-the-zombie game in Alice. It describes setting up the world, adding objects like buildings and a zombie, and creating methods to hide and randomly pop up the zombie. It also covers using properties to track the number of hits, incrementing this using a method, and notifying the player after 5 hits. The game uses a while loop to continuously hide and pop up the zombie until won. Additional ideas like sounds, counts, and losing conditions are also suggested.

Uploaded by

snezana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Creating a Simple Game in Alice

Barb Ericson
Georgia Institute of Technology
June 2008

SimpleGameInAlice

Objectives
Show how to create a simple game in
Alice
Creating methods in Alice
Creating a field or property of an object
Creating a variable
Using a while loop
Creating a Boolean function
Creating a comment

SimpleGameInAlice

Things to Consider
All objects in an Alice movie or game must
be created before the game starts
you can make them invisible to start
click on properties and set the opacity to 0

you can also hide objects by moving them


under the ground
move down some amount

You can update a field (property) in an


object to track if it has been clicked on
SimpleGameInAlice

Click the Zombie Game


While the user hasn't won hide
the zombie and after some
random amount of time
between 1-3 seconds have it
pop up in a random place.
If the user clicks on the zombie
increment the number of hits
and when it reaches 5 let the
user know s/he won
If the user doesn't click on the
zombie within 1 second hide it
again
Add instructions at the
beginning to let the user know
how to play
and then make them invisible
after some amount of time

SimpleGameInAlice

Set-up the World


Click on File -> New
World
Select the Template
tab
Click on the grass
world
click on open

SimpleGameInAlice

Add Objects to the World


Click the add objects
button at the bottom
of the scene
Scroll to the City
category and click on
City
Add some Buildings
by dragging out some
building clusters

SimpleGameInAlice

Add the Zombie


Click on Local Gallery to get back to the
list of categories
Open the People category
Scroll over to Zombie and add one to the
world

SimpleGameInAlice

Hide the Zombie


Create a method to
hide the zombie
Click on zombie in the
object tree
Click on methods in
the details window
Click the create new
method button
name the method hide

SimpleGameInAlice

The hide method


Click on properties
in the detail window
Drag out opacity = 1
(100%)
Put it in the hide
method
Change the opacity to
0 (0%)
Click on methods
Pull out zombie move
down 2 meters
SimpleGameInAlice

Create the pop up method


Click on methods
Click the create new
method button
name the method
popUp
move the zombie
randomly
move the zombie up
above the ground
make the zombie
visible
SimpleGameInAlice

10

Move the zombie randomly


Start by dragging out
zombie move tiles
one for each of left, right,
forward, and backward

Click on world in the


object tree to select it
Click on functions in the
details window
Drag out random number
and drop it on the 1 meter
select 0 for min and 2 for
the maximum
SimpleGameInAlice

11

Add a comment
You can add a comment to explain what
you are doing in English
Drag a // tile from the bottom of the
method editing window to where you wish
to place the comment
Click on the down arrow
Select other
Type in the comment

SimpleGameInAlice

12

Showing the zombie


Click on zombie in the
object tree to select it
Click on methods in
the details window
Drag out a zombie
move tile
select up 2 meters

Click on properties in
the details window
Drag out opacity = 0
change to 1 (100%)
SimpleGameInAlice

13

Adding a property (field)


We need to store the
number of hits on this
zombie
Click on the
properties tab
Click the create new
variable button
name the variable
numHits
set the value to 0
SimpleGameInAlice

14

Increment the number of hits


If the user clicks on the zombie we want to add
1 to the number of hits so far
Create a method that does this
It should be a new zombie method

SimpleGameInAlice

15

Respond to mouse click on zombie


In the events window
click the create new
event button
select When the
mouse is clicked on
something

Change the anything


to the zombie (the
entire zombie)
Change the nothing to
zombie incrementHits
SimpleGameInAlice

16

Method to run the game


Click on world in the
object tree
Select methods
Pull up a while tile
from the bottom of the
editor window
select true

Click on functions
drag out a < b and
drop it on true
select 1 and 1

SimpleGameInAlice

17

While number of hits < 5


Click on zombie in the
object tree
Click on properties
drag out numHits = 0
and drop on the first 1

Change the second 1


to 5
click on other and
enter 5

SimpleGameInAlice

18

Hide and wait a random amount of time


Click on methods
Drag out hide
Drag up a wait tile
from the bottom of the
editor window
select 1 second

Click on world in the


object tree
click on functions
drag out random
number and drop on
the 1 second
SimpleGameInAlice

19

pop up and wait for 1 second


Drag out a zombie
popUp
Drag up a wait tile
and select 1 second
Try it out!
What happens after
you click on the
zombie 5 times?

SimpleGameInAlice

20

Tell the user s/he won


Add some 3D text that
tells the user she or he
won
Click on File and then on
Add 3D Text
Type in the text
you can change the font

Place it where you want it


to appear
Click on add objects to get
to the mouse controls
Click on done when done

SimpleGameInAlice

21

Make the text invisible to start


Click on the text in the
object tree
Click on properties
Modify opacity to 0

SimpleGameInAlice

22

When the user wins show the text


Drag out opacity = 0
to the method
change to 1 (100%)

Play the game!

SimpleGameInAlice

23

Speeding things up
All animation takes 1
second by default
you can change this
using the more

Make the zombie


move up or down and
become visible and
invisible at the same
time
use a do together from
the bottom of the
editor window
SimpleGameInAlice

24

Add instructions
Create 3D text that
tells the user what to
do in the game
When the game starts
wait for 1 second
then make the text
invisible
can set isShowing to
false

SimpleGameInAlice

25

Show the number of hits


Create 3D text that says
Hits and one that says 0
Click on the 0 in the
object tree
Click on properties
Drag out text = 0
select default string

Use the mouse controls


to position the text
Click on Add Objects to see
the mouse controls
when done click on done

SimpleGameInAlice

26

World incrementHits method


Add an incrementHits
method to the world
call the zombie
incrementHits method
click on 0 then properties
drag out text = 0
select default string

replace the default string


with the what as string
function in the world to
convert the number to a
string
choose expressions and
pick zombie numHits as
what to convert
SimpleGameInAlice

27

Change when mouse clicked


Modify then when
mouse is clicked on
the zombie to call the
world's incrementHits
method
Try it!

SimpleGameInAlice

28

Other Ideas
Have the zombie play a sound when hit
modify zombie incrementHits method
use play sound in methods
you can also record your own sounds
click on properties for the zombie
click on the + next to Sounds
and record a sound and name it

Count the number of times the zombie has appeared


Add a way to lose
maybe it will only run till it appears 10 times
maybe add a timer and a time limit
maybe add other objects that if you click on these you lose

Make the amount of time you give the user to click on


the zombie a random amount from 0.5 to 1 second
SimpleGameInAlice

29

Summary
Alice can be used to create simple 3D
games
Concepts covered
creating methods
creating a property (field)
creating a variable
using a while loop
creating a comment

SimpleGameInAlice

30

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy