mIRC Puzzle Oyunu – Pic Puzzle Game
menu status,channel,query {
Pic-Puzzle : pic-puzzle
}
alias pic-puzzle { dialog $iif($dialog(dia.pic-puzzle),-v,-ma dia.pic-puzzle) dia.pic-puzzle }
dialog dia.pic-puzzle {
title "Pic Puzzle"
icon $mircexe, 0
size $iif($readini($scriptdirPic-Puzzle.ini,Settings,lastpos.d),$v1,-1 -1) 211 141
option dbu
box "New Game", 1, 8 5 195 130
text "Click here to choose a pic", 12, 15 65 110 8, center
icon 2, 15 15 110 110
text "Image size:", 3, 135 15 60 8, center
combo 4, 135 25 60 165, size drop
text "Cubes:", 5, 135 40 60 8, center
combo 6, 135 50 60 140, size drop
text "Border width:", 9, 135 65 60 8, center
combo 10, 135 75 60 90, size drop
text "© by Flobse", 7, 135 100 60 8, center
button "Start Game", 11, 135 110 60 15
}
on *:dialog:dia.pic-puzzle:*:*: {
var %ini $qt($scriptdirPic-Puzzle.ini)
if ($devent == init) {
var %x 200
while (%x < = 1200) { did -a $dname 4 %x x %x | inc %x 200 }
did -c $dname 4 $iif($readini(%ini,Settings,size),$v1,3)
var %x 3
while (%x <= 10) { did -a $dname 6 %x x %x | inc %x }
did -c $dname 6 $iif($readini(%ini,Settings,quads),$v1,1)
var %x 0
while (%x <= 100) { did -a $dname 10 %x Pixel | inc %x 5 }
did -c $dname 10 $iif($readini(%ini,Settings,border),$v1,7)
if ($isfile($scriptdirpreview.jpg)) {
did -g $dname 2 0 $qt($scriptdirpreview.jpg)
did -h $dname 12
} }
elseif ($devent == sclick) {
if ($did == 2) || ($did == 12) {
if ($sfile($iif($readini(%ini,Settings,lastpath),$v1,C:\) $+ *.jpg;*.bmp,OK)) {
var %file $v1, %w @Pic-Puzzle.strech
if ($window(%w)) { window -c %w }
window -dphw0f @pic-puzzle.strech -1 -1 500 500
drawpic -s @pic-puzzle.strech 1 1 500 500 $qt(%file)
drawsave @pic-puzzle.strech $qt($scriptdirpreview.jpg)
window -c @pic-puzzle.strech
did -g $dname 2 0 $qt($scriptdirpreview.jpg)
did -h $dname 12
writeini %ini Settings lastpic %file
writeini %ini Settings lastpath $nofile(%file)
} }
elseif ($did == 11) {
writeini %ini Settings size $did(4).sel
writeini %ini Settings border $did(10).sel
writeini %ini Settings quads $did(6).sel
pic.puzzle.start $readini(%ini,Settings,lastpic)
dialog -c $dname
} }
elseif ($devent == close) { writeini %ini Settings lastpos.d $dialog($dname).x $dialog($dname).y }
}
on *:close:@Pic-Puzzle: {
writeini $qt($scriptdirPic-Puzzle.ini) Settings lastpos $window($target).x $window($target).y
.timer 1 0 pic-puzzle
}
menu @Pic-Puzzle {
sclick : pic.puzzle.move $mouse.x $mouse.y
dclick : pic.puzzle.move $mouse.x $mouse.y
}
alias pic.puzzle.start {
if ($isfile($1-)) {
var %winh @Pic-Puzzle.temp, %win @Pic-Puzzle, %h Pic-Puzzle, %hs Pic-Puzzle-Settings, %ini $qt($scriptdirPic-Puzzle.ini)
if ($window(%winh)) { window -c $v1 }
if ($window(%win)) { window -c $v1 }
hfree -w Pic-Puzzle*
hadd -m %hs ps $iif($readini(%ini,Settings,size),$calc($v1 *200),600)
hadd -m %hs pr $iif($readini(%ini,Settings,border),$calc(($v1 -1) *5),30)
hadd -m %hs wr 30
hadd -m %hs bc $rgb(0,0,0)
hadd -m %hs bce $rgb(255,255,255)
hadd -m %hs quads $iif($readini(%ini,Settings,quads),$calc($v1 +2),3)
hadd -m %hs ql $round($calc(($hget(%hs,ps) - ($hget(%hs,pr) *2)) / $hget(%hs,quads)),0)
hadd -m %hs pic $1-
window -dpafBw0k0uh %winh -1 -1 $calc($hget(%hs,ps) + ($hget(%hs,wr) *2)) $calc($hget(%hs,ps) + ($hget(%hs,wr) *2))
window -dpafBw0k0u +t %win $iif($readini(%ini,Settings,lastpos),$v1,-1 -1) $calc($hget(%hs,ps) + ($hget(%hs,wr) *2)) $calc($hget(%hs,ps) + ($hget(%hs,wr) *2)) $mircexe 0
drawfill -r %win $hget(%hs,bc) $hget(%hs,bc) 1 1
drawpic -s %winh $hget(%hs,wr) $hget(%hs,wr) $hget(%hs,ps) $hget(%hs,ps) $qt($hget(%hs,pic))
drawpic -s %win $hget(%hs,wr) $hget(%hs,wr) $hget(%hs,ps) $hget(%hs,ps) $qt($hget(%hs,pic))
var %x $calc($hget(%hs,quads) * $hget(%hs,quads)), %r
while (%x) { var %r $instok(%r,%x,$rand(1,$numtok(%r,32)),32) | dec %x }
var %x $calc($hget(%hs,quads) * $hget(%hs,quads) -1)
while (%x) { hadd -m %h %x $gettok(%r,%x,32) | dec %x }
var %i 1, %qx $calc($hget(%hs,pr) + $hget(%hs,wr)), %qy %qx
drawrect -rf %win $hget(%hs,bc) 1 $calc(%qx -1) $calc(%qy -1) $calc($hget(%hs,ql) * $hget(%hs,quads) +1) $calc($hget(%hs,ql) * $hget(%hs,quads) +1)
while (%i <= $calc($hget(%hs,quads) * $hget(%hs,quads) -1)) {
var %i2 1, %qx2 $calc($hget(%hs,pr) + $hget(%hs,wr)), %qy2 %qx2
while (%i2 <= $calc($hget(%hs,quads) * $hget(%hs,quads) -1)) {
if (%i2 == $hget(%h,%i)) { drawcopy %winh %qx %qy $hget(%hs,ql) $hget(%hs,ql) %win %qx2 %qy2 $calc($hget(%hs,ql) -1) $calc($hget(%hs,ql) -1) }
if ($hget(%hs,quads) // %i2) { var %qx2 $calc($hget(%hs,pr) + $hget(%hs,wr)) | inc %qy2 $hget(%hs,ql) }
else { inc %qx2 $hget(%hs,ql) }
inc %i2
}
if ($hget(%hs,quads) // %i) { var %qx $calc($hget(%hs,pr) + $hget(%hs,wr)) | inc %qy $hget(%hs,ql) }
else { inc %qx $hget(%hs,ql) }
inc %i
}
var %sx $calc($hget(%hs,wr) + $hget(%hs,pr) + ($hget(%hs,ql) * ($hget(%hs,quads) -1)))
var %sy $calc($hget(%hs,wr) + $hget(%hs,pr) + ($hget(%hs,ql) * ($hget(%hs,quads) -1)))
drawrect -rf %win $hget(%hs,bce) 1 %sx %sy $hget(%hs,ql) $hget(%hs,ql)
window -c %winh
} }
alias pic.puzzle.move {
var %h Pic-Puzzle, %hs Pic-Puzzle-Settings, %win @Pic-Puzzle, %mx $calc($1 - $hget(%hs,wr) - $hget(%hs,pr)), %my $calc($2 - $hget(%hs,wr) - $hget(%hs,pr))
if (%mx isnum 1- $+ $calc($hget(%hs,ql) * $hget(%hs,quads))) && (%my isnum $v2) {
if ($hget(pic-puzzle-settings,quads)) {
var %qx $ceil($calc(%mx / $hget(%hs,ql))), %qy $ceil($calc(%my / $hget(%hs,ql))), %q $calc(%qx + (%qy * $hget(%hs,quads)) - $hget(%hs,quads))
var %sx $calc($hget(%hs,wr) + $hget(%hs,pr) + ($hget(%hs,ql) * (%qx -1)))
var %sy $calc($hget(%hs,wr) + $hget(%hs,pr) + ($hget(%hs,ql) * (%qy -1)))
if (%qx isnum 1- $+ $calc($hget(%hs,quads) -1)) && (!$hfind(%h,$calc(%q +1),1,n).data) {
drawcopy %win %sx %sy $hget(%hs,ql) $hget(%hs,ql) %win $calc(%sx + $hget(%hs,ql)) %sy $hget(%hs,ql) $hget(%hs,ql)
drawrect -rf %win $hget(%hs,bce) 1 %sx %sy $hget(%hs,ql) $hget(%hs,ql)
hinc %hs Moves
hinc -m %h $hfind(%h,%q,1,n).data
}
elseif (%qx isnum 2-) && (!$hfind(%h,$calc(%q -1),1,n).data) {
drawcopy %win %sx %sy $hget(%hs,ql) $hget(%hs,ql) %win $calc(%sx - $hget(%hs,ql)) %sy $hget(%hs,ql) $hget(%hs,ql)
drawrect -rf %win $hget(%hs,bce) 1 %sx %sy $hget(%hs,ql) $hget(%hs,ql)
hinc %hs Moves
hdec -m %h $hfind(%h,%q,1,n).data
}
elseif (%qy isnum 1- $+ $calc($hget(%hs,quads) -1)) && (!$hfind(%h,$calc(%q + $hget(%hs,quads)),1,n).data) {
drawcopy %win %sx %sy $hget(%hs,ql) $hget(%hs,ql) %win %sx $calc(%sy + $hget(%hs,ql)) $hget(%hs,ql) $hget(%hs,ql)
drawrect -rf %win $hget(%hs,bce) 1 %sx %sy $hget(%hs,ql) $hget(%hs,ql)
hinc %hs Moves
hinc -m %h $hfind(%h,%q,1,n).data $hget(%hs,quads)
}
elseif (%qy isnum 2-) && (!$hfind(%h,$calc(%q - $hget(%hs,quads)),1,n).data) {
drawcopy %win %sx %sy $hget(%hs,ql) $hget(%hs,ql) %win %sx $calc(%sy - $hget(%hs,ql)) $hget(%hs,ql) $hget(%hs,ql)
drawrect -rf %win $hget(%hs,bce) 1 %sx %sy $hget(%hs,ql) $hget(%hs,ql)
hinc %hs Moves
hdec -m %h $hfind(%h,%q,1,n).data $hget(%hs,quads)
}
if ($hget(%hs,moves)) { drawtext -rob %win $rgb(120,120,120) $hget(%hs,bc) Tahoma 16 $hget(%hs,wr) $calc($hget(%hs,wr) /4) $hget(%hs,moves) $iif($hget(%hs,moves) == 1,Move $chr(160),Moves) }
var %x 1
while ($hget(%h,%x)) {
if ($v1 != %x) { return }
inc %x
}
var %pw $calc(($hget(%hs,pr) *2) + ($hget(%hs,quads) * $hget(%hs,ql)))
drawpic -s %win $hget(%hs,wr) $hget(%hs,wr) %pw %pw $qt($hget(%hs,pic))
drawtext -rob %win $rgb(120,120,120) $hget(%hs,bc) Tahoma 16 $hget(%hs,wr) $calc($hget(%hs,wr) /4) Done in $hget(%hs,moves) $iif($hget(%hs,moves) == 1,Move $chr(160),Moves)
hdel %hs quads
} } }