home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GameStar 2006 April
/
Gamestar_83_2006-04_dvd.iso
/
Dema
/
keepsake_demo_en.exe
/
res
/
puzzles
/
gardenWatch.puzzle.tcl
< prev
next >
Wrap
Text File
|
2006-01-25
|
13KB
|
428 lines
class Maze {
set (OX) 0.343750
set (OY) 0.097656
set (TW) 0.073242
set (TH) 0.097656
proc Maze {this wall} {set ($this,wall) $wall}
proc WallUp? {this x y} {lindex $($this,wall) [expr $x + $y * 17]}
proc WallDown? {this x y} {lindex $($this,wall) [expr $x + $y * 17 + 17]}
proc WallLeft? {this x y} {lindex $($this,wall) [expr $x + $y * 17 + 8]}
proc WallRight? {this x y} {lindex $($this,wall) [expr $x + $y * 17 + 9]}
}
class Peon {
proc Peon {this peon maze} oz'widget {Peon} {
set ($this,x) 0
set ($this,y) 0
set ($this,maze) $maze
set ($this,peon) [new oz'sprite $peon]
oz'widget::child $this $($this,peon) 0.5
set ($this,wo) [expr ($Maze::(TW) - [oz'sprite::width $($this,peon)]) / 2]
set ($this,ho) [expr ($Maze::(TH) - [oz'sprite::height $($this,peon)])]
oz'widget::property $this -alpha 0
}
proc ~Peon {this} {
delete $($this,peon)
}
proc qShow {this} {
oz'event {
oz'widget::fadeto $this 1
}
}
proc qHide {this} {
oz'event {
oz'widget::fadeto $this 0
}
}
proc X {this} {
return [expr $Maze::(OX) + $($this,x) * $Maze::(TW) + $($this,wo)]
}
proc Y {this} {
return [expr $Maze::(OY) + $($this,y) * $Maze::(TH) + $($this,ho)]
}
proc Move {this} {
oz'widget::moveto $this [X $this] [Y $this]
}
proc qSetPosition {this x y} {
set ($this,x) $x
set ($this,y) $y
oz'widget::property $this -pos [Peon::X $this] [Peon::Y $this]
}
proc qMoveUp {this} {
oz'event {
incr Peon::($this,y) -1
Peon::Move $this
delay 900
}
}
proc qMoveDown {this} {
oz'event {
incr Peon::($this,y)
Peon::Move $this
delay 900
}
}
proc qMoveLeft {this} {
oz'event {
incr Peon::($this,x) -1
Peon::Move $this
delay 900
}
}
proc qMoveRight {this} {
oz'event {
incr Peon::($this,x)
Peon::Move $this
delay 900
}
}
proc WallUp? {this} {
Maze::WallUp? $($this,maze) $($this,x) $($this,y)
}
proc WallDown? {this} {
Maze::WallDown? $($this,maze) $($this,x) $($this,y)
}
proc WallLeft? {this} {
Maze::WallLeft? $($this,maze) $($this,x) $($this,y)
}
proc WallRight? {this} {
Maze::WallRight? $($this,maze) $($this,x) $($this,y)
}
}
class Goblin {
proc Goblin {this maze p_logic} Peon {"goblin" $maze} {
set ($this,p_logic) $p_logic
set ($this,arrow.up) [new oz'button "U"]
set ($this,arrow.down) [new oz'button "D"]
set ($this,arrow.left) [new oz'button "L"]
set ($this,arrow.right) [new oz'button "R"]
oz'widget::property $($this,arrow.up) -pos -$Peon::($this,wo) [expr -$Maze::(TH) - $Peon::($this,ho)]
oz'widget::property $($this,arrow.down) -pos -$Peon::($this,wo) [expr $Maze::(TH) - $Peon::($this,ho)]
oz'widget::property $($this,arrow.left) -pos [expr -$Maze::(TW) - $Peon::($this,wo)] -$Peon::($this,ho)
oz'widget::property $($this,arrow.right) -pos [expr $Maze::(TW) - $Peon::($this,wo)] -$Peon::($this,ho)
oz'button::property $($this,arrow.up) -click Goblin::qMoveUp $this \
-sclick "sound/puzzles/puzzleMinotaurMaze/goblinArrowClick.ogg" \
-sover "sound/puzzles/puzzleMinotaurMaze/goblinArrow.ogg"
oz'button::property $($this,arrow.down) -click Goblin::qMoveDown $this \
-sclick "sound/puzzles/puzzleMinotaurMaze/goblinArrowClick.ogg" \
-sover "sound/puzzles/puzzleMinotaurMaze/goblinArrow.ogg"
oz'button::property $($this,arrow.left) -click Goblin::qMoveLeft $this \
-sclick "sound/puzzles/puzzleMinotaurMaze/goblinArrowClick.ogg" \
-sover "sound/puzzles/puzzleMinotaurMaze/goblinArrow.ogg"
oz'button::property $($this,arrow.right) -click Goblin::qMoveRight $this \
-sclick "sound/puzzles/puzzleMinotaurMaze/goblinArrowClick.ogg" \
-sover "sound/puzzles/puzzleMinotaurMaze/goblinArrow.ogg"
oz'widget::child $this $($this,arrow.up) 1
oz'widget::child $this $($this,arrow.down) 1
oz'widget::child $this $($this,arrow.left) 1
oz'widget::child $this $($this,arrow.right) 1
}
proc ~Goblin {this} {
delete $($this,arrow.up)
delete $($this,arrow.down)
delete $($this,arrow.left)
delete $($this,arrow.right)
}
proc qEnableArrows {this} {
oz'event {
if [Peon::WallUp? $this ] {
oz'widget::fadeto $($this,arrow.up) 0
} else {
oz'widget::fadeto $($this,arrow.up) 1
}
if [Peon::WallDown? $this] {
oz'widget::fadeto $($this,arrow.down) 0
} else {
oz'widget::fadeto $($this,arrow.down) 1
}
if [Peon::WallLeft? $this] {
oz'widget::fadeto $($this,arrow.left) 0
} else {
oz'widget::fadeto $($this,arrow.left) 1
}
if [Peon::WallRight? $this] {
oz'widget::fadeto $($this,arrow.right) 0
} else {
oz'widget::fadeto $($this,arrow.right) 1
}
}
}
proc qDisableArrows {this} {
oz'event {
oz'widget::fadeto $($this,arrow.up) 0
oz'widget::fadeto $($this,arrow.down) 0
oz'widget::fadeto $($this,arrow.left) 0
oz'widget::fadeto $($this,arrow.right) 0
}
}
proc qMoveUp {this} {
wizDisableMouse
qDisableArrows $this
oz'event {
ozqSound::NewFX "sound/puzzles/puzzleMinotaurMaze/goblinMove.ogg"
}
Peon::qMoveUp $this
oz'event {$($this,p_logic)}
}
proc qMoveDown {this} {
wizDisableMouse
qDisableArrows $this
oz'event {
ozqSound::NewFX "sound/puzzles/puzzleMinotaurMaze/goblinMove.ogg"
}
Peon::qMoveDown $this
oz'event {$($this,p_logic)}
}
proc qMoveLeft {this} {
wizDisableMouse
qDisableArrows $this
oz'event {
ozqSound::NewFX "sound/puzzles/puzzleMinotaurMaze/goblinMove.ogg"
}
Peon::qMoveLeft $this
oz'event {$($this,p_logic)}
}
proc qMoveRight {this} {
wizDisableMouse
qDisableArrows $this
oz'event {
ozqSound::NewFX "sound/puzzles/puzzleMinotaurMaze/goblinMove.ogg"
}
Peon::qMoveRight $this
oz'event {$($this,p_logic)}
}
}
class Minotaur {
proc Minotaur {this maze} Peon {"minotaur" $maze} {}
proc ~Minotaur {this} {}
proc qMoveToward {this peon} {
oz'event {
if {\$Peon::($peon,x) < \$Peon::($this,x)} {
if ![Peon::WallLeft? $this] {
oz'event {
ozqSound::NewFX "sound/puzzles/puzzleMinotaurMaze/minoMove.ogg"
}
Peon::qMoveLeft $this
return
}
} elseif {\$Peon::($peon,x) > \$Peon::($this,x)} {
if ![Peon::WallRight? $this] {
oz'event {
ozqSound::NewFX "sound/puzzles/puzzleMinotaurMaze/minoMove.ogg"
}
Peon::qMoveRight $this
return
}
}
if {\$Peon::($peon,y) < \$Peon::($this,y)} {
if ![Peon::WallUp? $this] {
oz'event {
ozqSound::NewFX "sound/puzzles/puzzleMinotaurMaze/minoMove.ogg"
}
Peon::qMoveUp $this
return
}
} elseif {\$Peon::($peon,y) > \$Peon::($this,y)} {
if ![Peon::WallDown? $this] {
oz'event {
ozqSound::NewFX "sound/puzzles/puzzleMinotaurMaze/minoMove.ogg"
}
Peon::qMoveDown $this
return
}
}
}
}
}
namespace eval pzlmm {}
proc pzlmm::qInit {} {
if {[ozGet "minotaurMazeFigurines"] == ""} return
variable {}
set (maze) [new Maze " 1 1 1 1 1 1 1 1 \
0 0 0 0 0 0 0 0 1 \
1 0 0 0 1 0 0 0 \
1 0 0 0 0 0 0 0 1 \
0 0 0 0 0 0 1 0 \
1 0 0 0 0 0 1 0 1 \
0 0 0 0 0 0 0 0 \
1 0 0 0 0 0 0 0 1 \
0 0 0 0 1 0 0 0 \
1 1 0 0 0 0 1 1 1 \
0 0 0 0 0 0 0 1 \
1 0 0 1 0 0 0 0 1 \
0 0 1 0 0 0 0 0 \
1 0 0 0 0 0 1 0 1 \
0 0 0 0 0 1 0 0 \
1 0 0 0 0 0 0 0 1 \
1 1 1 1 1 1 1 1"]
set (goblin) [new Goblin $(maze) pzlmm::logic]
set (minotaur) [new Minotaur $(maze)]
oz'widget::child [FOREGROUNDWIDGET] $(goblin) 1
oz'widget::child [FOREGROUNDWIDGET] $(minotaur) 0
Peon::qSetPosition $(goblin) 0 5
Peon::qSetPosition $(minotaur) 6 4
Goblin::qEnableArrows $(goblin)
Peon::qShow $(goblin)
Peon::qShow $(minotaur)
}
proc pzlmm::qQuit {} {
if {[ozGet "minotaurMazeFigurines"] == ""} return
variable {}
oz'event {
Peon::qHide $(goblin)
Peon::qHide $(minotaur)
}
oz'event {delay 900}
oz'event {
delete $(goblin)
delete $(minotaur)
}
}
proc pzlmm::logic {} {
variable {}
Minotaur::qMoveToward $(minotaur) $(goblin)
Minotaur::qMoveToward $(minotaur) $(goblin)
oz'event {
if {\$Peon::($(goblin),x) == \$Peon::($(minotaur),x) &&
\$Peon::($(goblin),y) == \$Peon::($(minotaur),y)} {
oz'event {
ozqSound::NewFX "sound/puzzles/puzzleMinotaurMaze/goblinLose.ogg"
}
oz'event {
Peon::qHide $(goblin)
Peon::qHide $(minotaur)
}
oz'event {
delay 900
}
oz'event {
Peon::qSetPosition $(goblin) 0 5
Peon::qSetPosition $(minotaur) 6 4
Peon::qShow $(goblin)
Peon::qShow $(minotaur)
}
} else {
if {$Peon::($(goblin),x) == 0 && $Peon::($(goblin),y) == 0} {
oz'event {
ozqSound::NewFX "sound/puzzles/puzzleMinotaurMaze/goblinWin.ogg"
}
oz'event {
Peon::qHide $(goblin)
Peon::qHide $(minotaur)
playMusic silence
}
oz'event {
delay 900
}
oz'event {
setCrossfadeCamera "minotaurMazeCloseUpOff"
delay 1000
}
PlayMovieSound minotaurMazeCloseUp nigilisBean "puzzles/puzzleMinotaurMaze/seedMaterialize"
oz'event {
setCamera "minotaurMazeCloseUpComplete"
wizhCameraChange
callEvent "gardenWatch.mMazeWin"
}
return
}
}
}
Goblin::qEnableArrows $(goblin)
wizqEnableMouse
}
proc useMinotaurMazeResetProc {} {
PlayMovieSound minotaurMazeCloseUp reset "/puzzles/common/reset"
if {[ozGet "minotaurMazeFigurines"] == ""} return
oz'event {Goblin::qDisableArrows $pzlmm::(goblin)}
oz'event {
Peon::qHide $pzlmm::(goblin)
Peon::qHide $pzlmm::(minotaur)
}
oz'event {
delay 900
}
oz'event {
Peon::qSetPosition $pzlmm::(goblin) 0 5
Peon::qSetPosition $pzlmm::(minotaur) 6 4
}
oz'event {Goblin::qEnableArrows $pzlmm::(goblin)}
oz'event {
Peon::qShow $pzlmm::(goblin)
Peon::qShow $pzlmm::(minotaur)
}
}
event "useMinotaurMazeReset" {
useMinotaurMazeResetProc
}