Tratto da: Treasure – Written by Mark Overmars – Graphics by Matt Sandford – Sounds and music by Jacob Habgood.
Un clone di PACMAN presente nella cartella Examples di GameMaker 8.
Sviluppato ulteriormente nel libro ufficiale.
Se sei un principiante studia prima il tutorial DIAMONDS.
Se hai già un po’ d’esperienza crea le risorse elencate di seguito con le caratteristiche specificate
TIPO |
NOME |
FILE |
|
Sprites |
spr_wall |
wall_strip2.png |
 |
spr_treasure |
treasure.png |
 |
spr_expl_left |
expl_left_strip4.png |
 |
spr_expl_left |
expl_right_strip4.png |
 |
spr_expl_left |
expl_up_strip4.png |
 |
spr_expl_down |
expl_down_strip4.png |
 |
spr_monster |
monster_strip4.png |
 |
spr_scared |
afraid_strip4.png |
 |
spr_special |
special.png |
 |
spr_bonus |
bonus.png |
 |
Sounds |
snd_beep |
beep.wav |
|
snd_dead |
dead.wav |
|
snd_bonus |
bonus.wav |
|
snd_won |
won.wav |
|
snd_catch |
catch.wav |
|
snd_music |
music.mid |
|
Backgrounds |
back_game |
background.png |
vedi dopo |
Scripts |
script_direction |
… |
|
Objects |
obj_wall |
spr_wall |
 |
obj_point |
spr_treasure |
 |
obj_explorer |
spr_expl_up |
 |
obj_monster |
spr_monster |
 |
obj_scared |
spr_scared |
 |
obj_pil |
spr_special |
 |
obj_bonus |
spr_bonus |
 |
Room |
room_0
room_1
… |
|
|
Imposta le proprietà dei livelli
Snap X / Snap Y: 32
Width / Height: 480
Speed: 20

obj_point
obj_pil
obj_wall
Create

Change sprite into
spr_wall (
subimage:
0)

With chance 1 out of 20 perform next (
sides:
20)

Start of block

Change sprite into
spr_wall (
subimage:
1)

End of block
obj_explorer
Create

Change sprite into
spr_expl_up (
sprite:
spr_expl_up,
subimage: 0,
speed:
0)
Game Start

Set lives to
3 (
new lives:
3)

Set the score to
0 (
new score:
0)

Set the score caption info (
show score:
show,
show lives:
show)

Play sound
snd_music (
sound:
snd_music,
loop:
true)
<Left>

If a position is collision free (
x:
-4,
y:
0,
Relative:
on,
objects:
Only solid)

Start of block

Start moving in a direction (
speed:
4)

Change sprite into
spr_expl_left (
sprite:
spr_expl_left,
subimage:
-1,
speed:
0.5)

End of block
<Up>
…
(x: 0, y: -4, sprite: spr_expl_up)
<Right>
…
(x: 4, y: 0, sprite: spr_expl_right)
<Down>
…
(x: 0, y: 4, sprite: spr_expl_down)
obj_wall

Start moving in a direction (
Speed:
0,
Relative:
off)

Set variable
image_speed to
0 (
variable:
image_speed,
value:
0)
Outside Room

Wrap in both directions when outside (
directions:
in both directions)
obj_point

Destroy the instance (
Applies to:
Other)

Play sound
snd_beep (
sound:
snd_beep,
loop:
false)

Set the score
relative to
10 (
new score:
10,
Relative:
true)
Step

If the number of instances is a value (
object:
point,
number:
0,
operation:
Equal to)

Start of block

Play sound
snd_won (
sound:
snd_won,
loop:
false)

Sleep
2000 milliseconds (
milliseconds:
2000,
redraw:
true)

If next room exists

Start of block

Go to next room

End of block
Else

Start of block

Show the highscore table

Restart the game

End of block
End of block
obj_monster

Play sound
snd_dead; loop: false

Sleep
1500 milliseconds (
milliseconds:
1500,
redraw:
true)

Jump to the start position (
Object:
obj_monster)

Jump to the start position (
Object:
obj_scared)

Start moving in a direction (
speed:
0,
Relative:
off)

Set variable
image_speed to
0 (
variable:
image_speed,
value:
0)

Jump to the start position (
Self:
on)

Set lives relative to
-1 (
new lives:
-1,
Relative:
true)
No More Lives

Show the highscore table

Restart the game
obj_pil

Play sound
snd_bonus (
sound:
snd_bonus,
loop:
false)

Destroy the instance (
Applies to:
Other)

Change instance into
obj_monster (
Object:
obj_scared,
change into:
obj_monster,
perform events:
not)

Change instance into
obj_scared (
Object:
obj_monster,
change into:
obj_scared,
perform events:
not)

Set Alarm
0 to
160 (
Object:
obj_scared,
number of steps:
160,
in alarm no:
Alarm 0)
obj_scared

Play sound
snd_catch (
sound:
snd_catch,
loop:
false)

Jump to the start position (
Other:
on)

Change instance into
obj_monster (
Other:
on,
change into:
obj_monster,
perform events:
not)

Set the score
relative to
100 (
new score:
100,
Relative:
on)
obj_monster
Create

Change sprite into
spr_monster (
Self:
on,
sprite:
spr_monster,
subimage:
0,
speed:
0)

Start moving in a direction (
speed:
4)
Step

If instance is aligned with grid

Start of block

Execute script
script_direction: (
script:
script_direction)

End of block
End Step

If direction is equal to 0

Start of block

Set variable image_index to 2

End of block
Else
If direction is equal to 90

Start of block

Set variable image_index to 3

End of block
Else
If direction is equal to 180

Start of block

Set variable image_index to 0

End of block
Else
If direction is equal to 270

Start of block

Set variable image_index to 1

End of block
obj_wall

Reverse horizontal direction

Reverse vertical direction

Execute script
script_direction: (
script:
script_direction)
Outside Room

Wrap in both directions when outside (
Self:
on,
directions:
in both directions)
obj_scared
Alarm 0

Change instance into
obj_monster (
Self:
on,
change into:
monster,
perform events:
not)

Start moving in a direction (
Directions:
N-E-S-O,
Speed:
4,
Relative:
off)
obj_bonus
Create

Jump to position
(-1000,0) (
x:
-1000,
y:
0)

Set Alarm
0 to
500 (
Self:
on,
number of steps:
500,
in alarm no:
Alarm 0)
Alarm 0

Jump to the start position (
Self:
on)

Set Alarm
1 to
200 (
Self:
on,
number of steps:
200,
in alarm no:
Alarm 1)
Alarm 1

Jump to position
(-1000,0) (
x:
-1000,
y:
0)

Set Alarm
0 to
500 (
Self:
on,
number of steps:
500,
in alarm no:
Alarm 0)
explorer

Play sound
snd_bonus (
Sound:
snd_bonus,
loop:
false)

Set the score
relative to
200 (
new score:
200,
Relative:
on)

Jump to position
(-1000,0) (
x:
-1000,
y:
0)

Set Alarm
0 to
500 (
Self:
on,
number of steps:
500,
in alarm no:
Alarm 0)
script_direction
// This script adapts the direction of the monster
// when it comes at a possible crossing
{
if (hspeed == 0)
{
if (random(3)<1 && place_free(x-4,y)) { hspeed = -4; vspeed = 0;}
if (random(3)<1 && place_free(x+4,y)) { hspeed = 4; vspeed = 0;}
}
else
{
if (random(3)<1 && place_free(x,y-4)) { hspeed = 0; vspeed = -4;}
if (random(3)<1 && place_free(x,y+4)) { hspeed = 0; vspeed = 4;}
}
}