Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / placing a pawn on a chess board

Author
Message
whipped6
19
Years of Service
User Offline
Joined: 31st Aug 2006
Location:
Posted: 23rd Sep 2006 03:25
hello i found out how to move a sprite now im having troble putting the pawn on the board i tried doing it myself and couldnt figure it out... all help is very very appreciated.

DO
sync on
load image "pawn.bmp",1
sprite 1,0,0,1
if mouseclick()
sprite 1,mousex(),mousey(),1
endif
sync
LOOP

game creator
Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 23rd Sep 2006 18:06 Edited at: 23rd Sep 2006 18:07
I have modified your code. It works now.


The sync on command only needs to be called once, so do that at the top of your code and not inside a loop. Likewise, you only need to load an image once. So, again I have moved that outside you loop.
When I said it works now. What I mean is, you can at least see some kind of result but I don't think it is really what you are trying to do. At the moment the pawn sprite will be positioned at the top left corner of the screen until you press the left mousebutton. At that point the pawn will be positioned a the mouse pointers position and move with it until you release the LMB, at which point it will return to the top left corner.
So, it works because the code is nowdoing what you are asking but is that really what you are trying to do?


Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 28th Sep 2006 17:08
I think it's a half-assed solution for a far more complex problem.

Whipped, if your making a chess game, then you'll need to do a lot more than just position sprites with the mouse, you need to assign these bits to a board array, have the computer able to move them itself, check where each piece is as well as what is on each board square.

Pawn movement with the mouse is a long way down the line in your list of issues when writing a chess game. Personally, I'd go 3D, and use the pick object commands to let you select peices, very neat and professional, but it's nice and easy to make moving piece systems in 3D. When your using sprites, you have issues with z-sorting too, if you move a knight through some pawns, then the knight should be drawn on top, or last - it's not always easy to control that in 2D.

The quickest method I've found is to just try and get the basic AI working, so the computer can check what moves are possible, score them, and select a nice move, having it play itself is the best bet, you don't want to get sick of playing chess (defeats the purpose of writing a chess game!).

''Stick that in your text and scroll it!.''

Login to post a reply

Server time is: 2026-07-08 12:25:06
Your offset time is: 2026-07-08 12:25:06