Click to See Complete Forum and Search --> : chess program
elemental850
11-03-2004, 02:37 PM
I'd like to create a web page with html and javascript that would allow my father and I to play chess while he is away in Sacremento.
I can't figure out a way to input a move from him or myself and have it change on the page. The board is the page but I can't change the position of a piece on the page beyond the time a single user is logged on. I'm extremely new and getting back in to the whole programming thing but would like to resurect this old idea and make it happen. Any thoughts or sound advice would be helpful.
David in Tally
7stud
11-03-2004, 03:29 PM
Start out displaying "hello world" to the screen. Then work your way up. :)
First, some inspiration:
http://www.codingforums.com/showthread.php?t=42994
Then, start with some javascript tutorials:
http://jennifermadden.com/index.html
http://www.jsmadeeasy.com/about.htm
After you get familiar with the basics, you might want to study the "DOM":
http://www.sitepoint.com/article/rough-guide-dom
css positioning:
http://www.sitepoint.com/forums/showthread.php?t=171943
cookies:
http://www.elated.com/tutorials/programming/javascript/cookies/
http://www.quirksmode.org/js/cookies.html
Nevermore
11-03-2004, 03:43 PM
I know it doesn't help in the programming sense, but why not use one of the many free services to play?
Exuro
11-03-2004, 10:29 PM
You're going to have to use a server-side language of some sort, like PHP or ASP.Net, if you're wanting to be able to play against someone else online...
7stud
11-04-2004, 07:46 AM
I can't figure out a way to input a move from him or myself and have it change on the page.
You're going to have to use a server-side language of some sort, like PHP or ASP.Net, if you're wanting to be able to play against someone else online...
Inputing data and then changing the appearance of a page based on the data is done all the time with javascript.
scragar
11-04-2004, 08:00 AM
there's a one player version on the javascript source somewhere...
http://javascript.internet.com/games/javascript-chess-with-cpu-oppo.html
Juuitchan
11-04-2004, 10:31 AM
7stud:
"THE" appearance of the page? This is not an uncommon error in programming JavaScript.
With JavaScript, it often does not make sense to speak of "THE" appearance of the page, because the changes on the page appear on your screen only. Like a JavaScript clock that shows me MY local time, and a friend in Japan HER local time. Why the difference?
You are confusing the APPEARANCE of a Web page in your browser with the actual Web page FILE, which could be on a server absolutely anywhere on earth.
For your chess program to work, you would have to somehow get the Web page FILE to be modified. (Actually, there's more to it than this. Some Web page files are actually computer programs which put together the web page from your input and stored data and/or mathematical calculations and then send it to you. So if the Web page file does not change but the stored data changed, the appearance of the page you get will be different. I wouldn't swear to it, but I think this is exactly how graphical hit counters work: they are images which get redrawn every time somebody requests them from the server.)
Exuro
11-04-2004, 05:29 PM
Originally posted by 7stud
Inputing data and then changing the appearance of a page based on the data is done all the time with javascript.
As Juuitchan so aptly put it, you obviously don't know what you're talking about... JavaScript can change data on your page, but in order for your partner's screen to be updated as well you're going to need a way for the data to be communicated over there. JavaScript, being a client-side scriping language, has no control over anything but what pops up on your screen, and has no way of communicating data to the server. If this chess game idea were to work, it would need the server to be used as an in-between for the two computers, relaying the data back and forth...
Exuro
11-04-2004, 05:31 PM
Originally posted by scragar
there's a one player version on the javascript source somewhere...
It may be benificial to reference that source, but I would really recommend writing yours yourself. The AI for the one-player version is going to add an insane jumble of code that you're not going to want to try and deal with and clip out... Maybe you could go ahead and steal their images though ;)!
7stud
11-04-2004, 06:39 PM
:p
Juuitchan
11-04-2004, 08:52 PM
Originally posted by Exuro
JavaScript, being a client-side scriping language, has no control over anything but what pops up on your screen, and has no way of communicating data to the server.
JavaScript can communicate data to the server, but I don't know all the ways it can do this. However, for this chess program, server-side scripting, or the like, will be necessary.
Exuro
11-05-2004, 12:32 AM
Originally posted by Juuitchan
JavaScript can communicate data to the server, but I don't know all the ways it can do this. However, for this chess program, server-side scripting, or the like, will be necessary.
Sorry, but JavaScript really can't handle the server-side stuff you'd need for this... JS could submit a form, or pass data to the server via a query string, but as for actually processing the data and sending it to the other player you'd need something like CGI/Perl, PHP, or ASP.Net.