[bknr-cvs] r2284 - in branches/trunk-reorg/projects/scrabble: src website website/images/de website/images/en
bknr at bknr.net
bknr at bknr.net
Sat Nov 17 10:29:00 UTC 2007
Author: hhubner
Date: 2007-11-17 05:28:57 -0500 (Sat, 17 Nov 2007)
New Revision: 2284
Added:
branches/trunk-reorg/projects/scrabble/website/images/de/cursor.png
branches/trunk-reorg/projects/scrabble/website/images/de/mask.png
branches/trunk-reorg/projects/scrabble/website/images/en/cursor.png
branches/trunk-reorg/projects/scrabble/website/images/en/mask.png
Modified:
branches/trunk-reorg/projects/scrabble/src/make-letters.lisp
branches/trunk-reorg/projects/scrabble/website/scrabble.js
Log:
Cursor image, mask image for placed tiles, don't consider placed tiles
for move legality determination.
Modified: branches/trunk-reorg/projects/scrabble/src/make-letters.lisp
===================================================================
--- branches/trunk-reorg/projects/scrabble/src/make-letters.lisp 2007-11-15 14:10:11 UTC (rev 2283)
+++ branches/trunk-reorg/projects/scrabble/src/make-letters.lisp 2007-11-17 10:28:57 UTC (rev 2284)
@@ -1,43 +1,44 @@
-
(in-package :scrabble.graphics)
-(defparameter *special-tile-texts* (make-hash-table))
+(defparameter *special-field-texts* (make-hash-table))
-(setf (gethash :de *special-tile-texts*)
+(setf (gethash :de *special-field-texts*)
'(:double-letter "DOPPELTER
BUCHSTABEN
WERT"
- :double-word "DOPPELTER
+ :double-word "DOPPELTER
WORT
WERT"
- :triple-letter "DREIFACHER
+ :triple-letter "DREIFACHER
BUCHSTABEN
WERT"
- :triple-word "DREIFACHER
+ :triple-word "DREIFACHER
WORT
WERT"))
-(setf (gethash :en *special-tile-texts*)
+(setf (gethash :en *special-field-texts*)
'(:double-letter "DOUBLE
LETTER
SCORE"
- :double-word "DOUBLE
+ :double-word "DOUBLE
WORD
SCORE"
- :triple-letter "TRIPLE
+ :triple-letter "TRIPLE
LETTER
SCORE"
- :triple-word "TRIPLE
+ :triple-word "TRIPLE
WORD
SCORE"))
-(defparameter *special-tile-colors*
+(defparameter *special-field-colors*
'(:double-letter (0.53 0.8 0.94)
:double-word (0.97 0.67 0.6)
:triple-letter (0.0 0.62 0.87)
:triple-word (0.93 0.11 0.18)
:standard (0.0 0.59 0.57)))
+(defparameter *tile-color* '(1.0 0.98 0.8))
+
(defparameter *bold-font* #.(merge-pathnames #p"../fonts/DIN/DINMd___.ttf" *default-pathname-defaults*))
(defparameter *regular-font* #.(merge-pathnames #p"../fonts/DIN/DINRg___.ttf" *default-pathname-defaults*))
@@ -50,7 +51,7 @@
(char-name char)
char-string)
:type "png")))
- (set-rgb-fill 1.0 0.98 0.8)
+ (apply #'set-rgb-fill *tile-color*)
(rounded-rectangle 0 0 34 34 4 4)
(fill-path)
(when char
@@ -62,6 +63,13 @@
(save-png pathname)
pathname)))
+(defun make-mask-tile ()
+ (with-canvas (:width 34 :height 34)
+ (apply #'set-rgba-fill (append *tile-color* (list 0.5)))
+ (rounded-rectangle 0 0 34 34 4 4)
+ (fill-path)
+ (save-png #P"mask.png")))
+
(defun make-letter-tile-set (language)
(with-open-file (letter-map-file "charmap.xml"
:direction :output
@@ -76,7 +84,15 @@
(cxml:attribute "filename" (namestring (make-letter-tile letter score)))
(cxml:text (princ-to-string letter)))))))))
-(defun make-special-tile (name color &key text star)
+(defun make-cursor ()
+ (with-canvas (:width 46 :height 46)
+ (apply #'set-rgb-stroke *tile-color*)
+ (set-line-width 5)
+ (rounded-rectangle 4 4 38 38 5 5)
+ (stroke)
+ (save-png #P"cursor.png")))
+
+(defun make-special-field (name color &key text star)
(with-canvas (:width 40 :height 40)
(let ((regular-font (get-font *regular-font*)))
(apply #'set-rgb-fill color)
@@ -84,26 +100,25 @@
(fill-path)
(set-rgb-fill 0 0 0)
(cond
- (text
- (set-font regular-font 6)
+ (text
+ (set-font regular-font 6)
(let* ((lines (cl-ppcre:split "\\n" text))
(position (+ 20 (* 6 (/ 2 (length lines))))))
(dolist (line lines)
(draw-centered-string 20 position line)
(decf position 6))))
- (star
- ))
+ (star
+ ))
(save-png (make-pathname :name (string-downcase (symbol-name name)) :type "png")))))
-(defun make-special-tile-set (language)
+(defun make-special-field-set (language)
(dolist (tile-name '(:double-letter :double-word :triple-letter :triple-word))
- (make-special-tile tile-name
- (getf *special-tile-colors* tile-name)
- :text (getf (gethash language *special-tile-texts*) tile-name)))
- (make-special-tile :standard (getf *special-tile-colors* :standard) :star nil)
- (make-special-tile :standard (getf *special-tile-colors* :double-word) :star t))
+ (make-special-field tile-name
+ (getf *special-field-colors* tile-name)
+ :text (getf (gethash language *special-field-texts*) tile-name)))
+ (make-special-field :standard (getf *special-field-colors* :standard) :star nil)
+ (make-special-field :standard (getf *special-field-colors* :double-word) :star t))
-
(defun make-tile-set (directory language)
(let ((*default-pathname-defaults*
(merge-pathnames (merge-pathnames (make-pathname
@@ -111,5 +126,5 @@
directory))))
(ensure-directories-exist *default-pathname-defaults*)
(make-letter-tile-set language)
- (make-special-tile-set language)))
-
+ (make-special-field-set language)
+ (make-cursor)))
Added: branches/trunk-reorg/projects/scrabble/website/images/de/cursor.png
===================================================================
(Binary files differ)
Property changes on: branches/trunk-reorg/projects/scrabble/website/images/de/cursor.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/trunk-reorg/projects/scrabble/website/images/de/mask.png
===================================================================
(Binary files differ)
Property changes on: branches/trunk-reorg/projects/scrabble/website/images/de/mask.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/trunk-reorg/projects/scrabble/website/images/en/cursor.png
===================================================================
(Binary files differ)
Property changes on: branches/trunk-reorg/projects/scrabble/website/images/en/cursor.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/trunk-reorg/projects/scrabble/website/images/en/mask.png
===================================================================
(Binary files differ)
Property changes on: branches/trunk-reorg/projects/scrabble/website/images/en/mask.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/trunk-reorg/projects/scrabble/website/scrabble.js
===================================================================
--- branches/trunk-reorg/projects/scrabble/website/scrabble.js 2007-11-15 14:10:11 UTC (rev 2283)
+++ branches/trunk-reorg/projects/scrabble/website/scrabble.js 2007-11-17 10:28:57 UTC (rev 2284)
@@ -74,8 +74,8 @@
}
}
}
-
-
+
+
//
function getFieldScore(x, y) {
@@ -138,27 +138,35 @@
// appendChildNodes(container, clearButton);
}
-function setLetter(x, y, letter) {
+function setLetter(x, y, letter, justPlaced) {
var image = IMG({ src: 'images/' + letter + '.png'});
image.style.position = 'absolute';
image.style.top = '3px';
image.style.left = '3px';
replaceChildNodes(board[x][y], image);
+ if (justPlaced) {
+ var mask = IMG({ src: 'images/mask.png'});
+ mask.style.position = 'absolute';
+ mask.style.top = '3px';
+ mask.style.left = '3px';
+ appendChildNodes(board[x][y], mask);
+ }
board[x][y].letterNode = image;
board[x][y].letter = letter;
+ board[x][y].justPlaced = justPlaced;
YAHOO.util.Event.purgeElement(board[x][y], false, 'click');
}
function letterAt(x, y) {
- return board[x][y].letter;
+ return board[x][y].letter && !board[x][y].justPlaced;
}
function Cursor()
{
- var image = new IMG({ src: 'images/NIL.png' });
+ var image = new IMG({ src: 'images/cursor.png' });
image.style.position = 'absolute';
- image.style.top = '3px';
- image.style.left = '3px';
+ image.style.top = '-3px';
+ image.style.left = '-3px';
this.image = image;
this.x = -1;
@@ -233,12 +241,13 @@
function makeMove(x, y, letter) {
move[move.length] = [x, y, letter];
- $('move').onclick = submitMove;
- $('move').innerHTML = move.toString();
try {
checkMoveLegality(move);
+ $('move').onclick = submitMove;
+ $('move').innerHTML = move.toString();
}
catch (e) {
+ $('move').onclick = undefined;
$('move').innerHTML = e.toString();
}
}
@@ -291,7 +300,7 @@
var x = cursor.x;
var y = cursor.y;
cursor.advance();
- setLetter(x, y, letter);
+ setLetter(x, y, letter, true);
makeMove(x, y, letter);
}
@@ -304,7 +313,7 @@
function functionKeyPressed(type, args, obj) {
var x = cursor.x;
var y = cursor.y;
-
+
switch (args[0]) {
case rightKey:
while (x < 14)
More information about the Bknr-cvs
mailing list