I repaired the board table and the pieces go straight to the left as I plan but it still don't turn and go out of the game board...
I will follow searching what is wrong... Greetings. --- In svg-developers@yahoogroups.com, "jucabapa79" <[EMAIL PROTECTED]> wrote: > Good afternoon. > > I review the code made by Mr. Holger and this is working properly in > a 3 X 3 board, but I have troubles to make it run properly in a 6 X > 6 board what I mean? > > First I made that my game pieces run in the down right corner, but > when the pieces began to run using the throw button, they are > running first one space to the left and then one space down, and > they never go straight in one direction and also they go out of the > board. > > Would someone explain me what is going on? What do you suggest to > correct this bug and made it run properly? > > Greetings. > > Travsam > > --- In svg-developers@yahoogroups.com, "jucabapa79" > <[EMAIL PROTECTED]> wrote: > > Mr. Holger, I will check the code made by you and study all the > > properties, so I can adapt it to my game board, and also to learn > > more about scripting because for me it this the most difficult > thing > > in SVG. > > > > I will do my best. > > > > Travsam > > > > --- In svg-developers@yahoogroups.com, Holger Will <[EMAIL PROTECTED]> > > wrote: > > > jucabapa79 schrieb: > > > > > > > Me again... > > > > > > > > As I told in some of the messages my dice will have two > > functions, > > > > the first one it was solved, but I still have troubles with the > > > > second one. > > > > > > > > The objective is to move a piece in the sides of a square > board > > of > > > > 700*700 and I tried using the script down below. > > > > > > > > But any moment I try to load the SVG the javascript reader > gives > > an > > > > exception because is expecting an object, but all SVG is loaded > > > > properly, anyway anytime that I click on the "Throw" button > gets > > the > > > > same mistake. > > > > > > > > Any suggestion? > > > > > > hi > > > ive written two small examples, > > > the first is a simple game framework. showing a simple gameloop. > > > http://www.treebuilder.de/svg/monopoly01.svg > > > the second is a basic monopoly framework, > > > http://www.treebuilder.de/svg/monopoly02.svg > > > study both examples, if you have any questions concerning this > > code, > > > just ask. > > > cheers > > > Holger > > > > > > > > > > > Travsam > > > > > > > > <script type="text/ecmasscript"> > > > > <![CDATA[ > > > > /** The dice should move a piece in a board, the piece > is > > > > in the right down corner, the piece has first to > > > > move to the left, when it gets the corner will move up, > and > > > > so on, moving in the trayectory of the clock, the > > > > movement will be controled by a random number between 1 > and > > > > 6. > > > > */ > > > > > > > > // svg variables > > > > var svgdoc; > > > > var svgroot; > > > > > > > > // game area variables > > > > var xMax = 700; > > > > var yMax = 700; > > > > var xMin = 100; > > > > var yMin = 100; > > > > > > > > // game variables > > > > var piece; > > > > var pieceX = 700; > > > > var pieceY = 700; > > > > > > > > function init (evt) { > > > > > > > > svgdoc = evt.getTarget().getOwnerDocument(); > > > > svgroot = svgdoc.documentElement; > > > > piece = svgdoc.getElementbyId("piece"); > > > > > > > > } > > > > > > > > // function throwDice, it will choose a number between 1 > > and > > > > 6 and set it as value "dice" > > > > > > > > function throwDice(){ > > > > > > > > var randomDice=Math.round(Math.random()*5) + 1; > > > > dice = randomDice; > > > > > > > > > > > > } > > > > // function movePiece, first it will move the piece to > the > > > > left, then it > > > > have to check when the piece arribes to the left corner > > then > > > > it moves up and so > > > > on, also it will use the counter "dice" that comes from > the > > > > throwDice function. > > > > > > > > function movePiece() > > > > { > > > > > > > > Do > > > > { > > > > pieceX = pieceX - 100; > > > > if pieceX = xMin and pieceY = yMax > > > > { > > > > pieceY = pieceY - 100; > > > > } > > > > else if pieceX = xMin AND pieceY = yMin > > > > { > > > > pieceX = pieceX + 100; > > > > } > > > > else if pieceX = xMax AND pieceY = yMin > > > > { > > > > pieceY = pieceY + 100; > > > > } > > > > Dice = Dice-1; > > > > piece.setAttribute("cx",pieceX); > > > > piece.setAttribute("cy",pieceY); > > > > } > > > > While Dice > 0; > > > > > > > > } > > > > > > > > > > > > // ]]> > > > > > > > > </script> > > > > ----- To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click "edit my membership" ---- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/