Defining Squares for a chess board puzzle.

Started by Superman95, Wed 15/10/2003 03:30:34

Previous topic - Next topic

Superman95

I'm working on a puzzle based off a chess board.  It's a standard 8x8 board (64 squares).  The board is a perspective view render of a 3d view.  I had planned to mask off each square as a hotspot.  But I quickly realized I could only have 16 hotspots.
So, I'm planning on alternating the hotspots and when it's clicked, check the mouse's x,y cordinate for it's location.  This will work, but will require 4 "IF" statements for each hotspot.
I'm brand new to AGS, so I thought there might be something I'm missing.

MillsJROSS

What kind of puzzle is this, might I ask, because there might be a more simple solution if it's just say a mate in one scenario versus maybe 8 queens on a board puzzle.

-MillsJROSS

Ishmael

Make each vertical line one hotspot, then just check the mouse y cordinate to see on which horizontal line the mouse was clicked.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Superman95

Quote from: MillsJROSS on Wed 15/10/2003 04:51:41
What kind of puzzle is this, might I ask, because there might be a more simple solution if it's just say a mate in one scenario versus maybe 8 queens on a board puzzle.

-MillsJROSS

There's actually going to be 3 puzzles.  The largest is actually the 8 queens.  One of the other puzzles uses a 4x5 and the last one uses at 5x5.  For all 3 puzzles I need all the regions clickable.

Superman95

 ;D I figured out a really simple way to do it.

First, make a hotspot out of each row.  Then, make regions out of each column.  Then, when the player clicks the hotspot, just check to see which region the mouse.x & mouse.y are in.  Ta Da.  You have both the row and column of the square with basically no work.  Of course, this will only working if you're not planning on using regions..and for this room, i'm not.

After

#5
I would expect a bigger challenge to be that of ensuring that squares behind pieces remain (easily) accessible, and that both player and game agree on which is being clicked.
Players will want to grab the pieces themselves, not the squares they stand on, in order to move them.

Gilbert

#6
Actually if you want that (ensuring that squares behind pieces remain (easily) accessible) can be even more easy, you can even make it without using hotspots or regions or whatever. Just do something like this in the on_mouse_click() function (of course you should do the usual variable initiations (for checkx, checky, checkclk):

if (character[GetPlayerCharacter()].room==10){
//say the checkerboard room is room 10, and you wont want the following codes to be triggered in other room, you may add more stuffs to check other things yourselves.
//Now say the squares are located at x-coordinates (100-259), y-coordinates (20-179), which each square is 20x20 pixels.

if ((mouse.x>99)&&(mouse.x<260)&&(mouse.y>19)&&(mouse.y<180)){
checkclk=1;// clicked within checker board.
checkx=(mouse.x-100)/20; //ranges from 0-7
checky=(mouse.y-20)/20; //ranges from 0-7
} else {checkclk=0;}

blah bla bla
}

Ishmael

#7
QuoteThe board is a perspective view render of a 3d view

This, I think, means the bottom row is wider than the top row...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Kweepa

#8
Gilbot - he said it was a perspective view. <edit - like TK said :) >
Superman95 - presumably, you're going to have an array of x positions and an array of y positions for the pieces?
Still waiting for Purity of the Surf II

Superman95

Yeah, it's in perspective view.  Which means the squares in the back are smaller than the squares in the front.  I was hoping I could just project the piece using vectors to the right location.  But that doesn't work because of the scale (the board is not evenly spaced across the screen).  I could scale the vector project as well, but without floating point numbers, it gets harder.  So, yeah, I'm going to create an array of x and y for each square.  I feel a little confined with the scripting language, and I've looked at the plug stuff.  So, I'm going to impliment the logic of the puzzle with a plugin.  The plugin will store all the information about the board and where to put the pieces.  Then, I'll just have the script pass everything to the puzzle.  So far, everything is coming together really well.  The most time consuming part is going to be figuring out the points for the squares.

And you're right.   With perspective mode, you have make sure all the pieces are visible.   The image I have now was more to make sure I could do it.  Now that I know I can.  I'll go back and change the angle of the camera to a more arial view.  This should make it easier and still give that "cool" 3D look.

If anyone would like the source files once it's finished, let me know.  I'd be more than glad to share both the game files and the plugin source.  I'm hoping to have it finish in a couple weeks.

Superman95

Quote from: After on Thu 16/10/2003 07:01:35
I would expect a bigger challenge to be that of ensuring that squares behind pieces remain (easily) accessible, and that both player and game agree on which is being clicked.
Players will want to grab the pieces themselves, not the squares they stand on, in order to move them.

For this puzzle, the interface is completely in the board.  The chess pieces have no interaction.  The pieces are added to the board with click on the squares.  The pieces can not be moved, only added or removed.  I may add an interaction to the piece to let you remove it, but I think the way I will handle it is anytime a new piece is added, I will have it kill (remove) all the pieces in it's line of attack automatically.  I hope this makes sense.

SMF spam blocked by CleanTalk