Treasure

TREASURETratto 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 image
spr_treasure treasure.png image
spr_expl_left expl_left_strip4.png image
spr_expl_left expl_right_strip4.png image
spr_expl_left expl_up_strip4.png image
spr_expl_down expl_down_strip4.png image
spr_monster monster_strip4.png image
spr_scared afraid_strip4.png image
spr_special special.png image
spr_bonus bonus.png image
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 image
obj_point spr_treasure image
obj_explorer spr_expl_up image
obj_monster spr_monster image
obj_scared spr_scared image
obj_pil spr_special image
obj_bonus spr_bonus image
Room room_0
room_1

Imposta le proprietà dei livelli

Snap X / Snap Y32
Width / Height480
Speed20

image

 

 

imageobj_point

imageobj_pil

imageobj_wall

  • Solidon

image Create

Sprite Action Change sprite into spr_wall (subimage0)
Dice Action With chance 1 out of 20 perform next (sides20)

Begin Start of block
Sprite Action Change sprite into spr_wall (subimage1)
End End of block

 

imageobj_explorer

  • Depth-1

image Create

Sprite Action Change sprite into spr_expl_up (spritespr_expl_upsubimage: 0, speed0)

Other Event Game Start

Set Lives Set lives to 3 (new lives3)
Set Score Set the score to 0 (new score0)
Set Caption Set the score caption info (show scoreshowshow livesshow)
Play Sound Play sound snd_music (soundsnd_musiclooptrue)

<Left>

If Free If a position is collision free (x-4y0RelativeonobjectsOnly solid)

Begin Start of block
Move Action 1 Start moving in a direction (speed4)
Sprite Action Change sprite into spr_expl_left (spritespr_expl_leftsubimage-1speed0.5)
End End of block

<Up>


(x0y-4spritespr_expl_up)

<Right>


(x4y0spritespr_expl_right)

<Down>


(x0y4spritespr_expl_down)

Collision Event obj_wall

Move Action 1 Start moving in a direction (Speed0Relativeoff)
Set Variable Set variable image_speed to 0 (variableimage_speedvalue0)

Other Event Outside Room

Wrap Action Wrap in both directions when outside (directionsin both directions)

Collision Event obj_point

Destroy Action Destroy the instance (Applies toOther)
Play Sound Play sound snd_beep (soundsnd_beeploopfalse)
Set Score Set the score relative to 10 (new score10Relativetrue)

Step Event Step

If Number If the number of instances is a value (objectpointnumber0operationEqual to)

Begin Start of block
Play Sound Play sound snd_won (soundsnd_wonloopfalse)
Sleep Action Sleep 2000 milliseconds (milliseconds2000redrawtrue)
If Next Room If next room exists

Begin Start of block
Next Room Go to next room
End End of block

Else Action Else

Begin Start of block
Highscore Action Show the highscore table
Restart Game Restart the game
End End of block

End End of block

Collision Event obj_monster

Play Sound Play sound snd_dead; loop: false
Sleep Action Sleep 1500 milliseconds (milliseconds1500redrawtrue)
image Jump to the start position (Objectobj_monster)
image Jump to the start position (Objectobj_scared)
Move Action 1 Start moving in a direction (speed0Relativeoff)
Set Variable Set variable image_speed to 0 (variableimage_speedvalue0)
image Jump to the start position (Selfon)
Set Lives Set lives relative to -1 (new lives-1Relativetrue)

Other Event No More Lives

Highscore Action Show the highscore table
Restart Game Restart the game

Collision Event obj_pil

Play Sound Play sound snd_bonus (soundsnd_bonusloopfalse)
Destroy Action Destroy the instance (Applies toOther)
image Change instance into obj_monster (Objectobj_scaredchange intoobj_monsterperform events:not)
image Change instance into obj_scared (Objectobj_monsterchange intoobj_scaredperform eventsnot)
image Set Alarm 0 to 160 (Objectobj_scarednumber of steps160in alarm noAlarm 0)

Collision Event obj_scared

Play Sound Play sound snd_catch (soundsnd_catchloopfalse)
image Jump to the start position (Otheron)
image Change instance into obj_monster (Otheronchange intoobj_monsterperform eventsnot)
Set Score Set the score relative to 100 (new score100Relativeon)

 

imageobj_monster

  • Depth-2

image Create

Sprite Action Change sprite into spr_monster (Selfonspritespr_monstersubimage0speed0)
Move Action 1 Start moving in a direction (speed4)

Step Event Step

If Grid If instance is aligned with grid

Begin Start of block
image Execute script script_direction: (scriptscript_direction)
End End of block

Step Event End Step

If Variable If direction is equal to 0

Begin Start of block
image Set variable image_index to 2
End End of block

Else Action Else
If Variable If direction is equal to 90

Begin Start of block
image Set variable image_index to 3
End End of block

Else Action Else
If Variable If direction is equal to 180

Begin Start of block
image Set variable image_index to 0
End End of block

Else Action Else
If Variable If direction is equal to 270

Begin Start of block
image Set variable image_index to 1
End End of block

Collision Event obj_wall

Hor. Reverse Reverse horizontal direction
Ver. Reverse Reverse vertical direction
image Execute script script_direction: (scriptscript_direction)

Other Event Outside Room

Wrap Action Wrap in both directions when outside (Selfondirectionsin both directions)

 

imageobj_scared

  • Parentobj_monster

image Alarm 0

image Change instance into obj_monster (Selfonchange intomonsterperform eventsnot)
Move Action 1 Start moving in a direction (DirectionsN-E-S-OSpeed4Relativeoff)

 

imageobj_bonus

image Create

image Jump to position (-1000,0) (x-1000y0)
image Set Alarm 0 to 500 (Selfonnumber of steps500in alarm noAlarm 0)

image Alarm 0

image Jump to the start position (Selfon)
image Set Alarm 1 to 200 (Selfonnumber of steps200in alarm noAlarm 1)

image Alarm 1

image Jump to position (-1000,0) (x-1000y0)
image Set Alarm 0 to 500 (Selfonnumber of steps500in alarm noAlarm 0)

Collision Event explorer

Play Sound Play sound snd_bonus (Soundsnd_bonusloopfalse)
Set Score Set the score relative to 200 (new score200Relativeon)
image Jump to position (-1000,0) (x-1000y0)
image Set Alarm 0 to 500 (Selfonnumber of steps500in alarm noAlarm 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;}
  }
}